Diff
Modified: trunk/Source/WebCore/ChangeLog (170699 => 170700)
--- trunk/Source/WebCore/ChangeLog 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Source/WebCore/ChangeLog 2014-07-02 07:04:23 UTC (rev 170700)
@@ -1,3 +1,43 @@
+2014-07-01 Carlos Garcia Campos <[email protected]>
+
+ [GTK] XPathNSResolver should be exposed as an interface instead of as a class
+ https://bugs.webkit.org/show_bug.cgi?id=134028
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Add custom implementation of WebKitDOMXPathNSResolver to expose it
+ as an interface instead of a class. It also includes an internal
+ default implementation of the interface to support methods that
+ create a XPathNSResolver using the native implementation.
+
+ * PlatformGTK.cmake: Add new files to compilation.
+ * bindings/gobject/GObjectXPathNSResolver.cpp: Added.
+ (WebCore::GObjectXPathNSResolver::~GObjectXPathNSResolver):
+ (WebCore::GObjectXPathNSResolver::lookupNamespaceURI): Call
+ webkit_dom_xpath_ns_resolver_lookup_namespace_uri().
+ * bindings/gobject/GObjectXPathNSResolver.h: Added.
+ (WebCore::GObjectXPathNSResolver::create):
+ (WebCore::GObjectXPathNSResolver::GObjectXPathNSResolver): Create
+ a new GObjectXPathNSResolver for the given WebKitDOMXPathNSResolver.
+ * bindings/gobject/WebKitDOMXPathNSResolver.cpp: Added.
+ (webkit_dom_xpath_ns_resolver_default_init):
+ (webkit_dom_xpath_ns_resolver_lookup_namespace_uri):
+ (webkitDOMNativeXPathNSResolverFinalize):
+ (webkitDOMNativeXPathNSResolverConstructor):
+ (webkit_dom_native_xpath_ns_resolver_init):
+ (webkit_dom_native_xpath_ns_resolver_class_init):
+ (webkitDOMNativeXPathNSResolverLookupNamespaceURI):
+ (webkitDOMXPathNSResolverIfaceInit):
+ (WebKit::core): Return the native XPathNSResolver when using the
+ internal implementation or create a custom XPathNSResolver when
+ using a user provided WebKitDOMXPathNSResolver.
+ (WebKit::kit):
+ * bindings/gobject/WebKitDOMXPathNSResolver.h: Added.
+ * bindings/gobject/WebKitDOMXPathNSResolverPrivate.h: Added.
+ * bindings/scripts/CodeGeneratorGObject.pm:
+ (GenerateFunction): Add exceptions for XPathNSResolver since
+ the core method returns a PassRefPtr.
+
2014-07-01 Frédéric Wang <[email protected]>
The OpenType MATH table is not read on Mac
Modified: trunk/Source/WebCore/PlatformGTK.cmake (170699 => 170700)
--- trunk/Source/WebCore/PlatformGTK.cmake 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2014-07-02 07:04:23 UTC (rev 170700)
@@ -436,12 +436,14 @@
bindings/gobject/DOMObjectCache.cpp
bindings/gobject/GObjectEventListener.cpp
bindings/gobject/GObjectNodeFilterCondition.cpp
+ bindings/gobject/GObjectXPathNSResolver.cpp
bindings/gobject/WebKitDOMCustom.cpp
bindings/gobject/WebKitDOMEventTarget.cpp
bindings/gobject/WebKitDOMHTMLPrivate.cpp
bindings/gobject/WebKitDOMNodeFilter.cpp
bindings/gobject/WebKitDOMObject.cpp
bindings/gobject/WebKitDOMPrivate.cpp
+ bindings/gobject/WebKitDOMXPathNSResolver.cpp
${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdomdefines.h
${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdomdefines-unstable.h
${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdom.h
@@ -547,7 +549,6 @@
page/DOMWindow.idl
xml/XPathExpression.idl
- xml/XPathNSResolver.idl
xml/XPathResult.idl
)
@@ -649,7 +650,7 @@
)
endif ()
-set(GObjectDOMBindingsStable_CLASS_LIST Custom EventTarget NodeFilter Object)
+set(GObjectDOMBindingsStable_CLASS_LIST Custom EventTarget NodeFilter Object XPathNSResolver)
set(GObjectDOMBindingsStable_INSTALLED_HEADERS
${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdomdefines.h
${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdom.h
@@ -657,6 +658,7 @@
${WEBCORE_DIR}/bindings/gobject/WebKitDOMEventTarget.h
${WEBCORE_DIR}/bindings/gobject/WebKitDOMNodeFilter.h
${WEBCORE_DIR}/bindings/gobject/WebKitDOMObject.h
+ ${WEBCORE_DIR}/bindings/gobject/WebKitDOMXPathNSResolver.h
)
set(GObjectDOMBindingsUnstable_INSTALLED_HEADERS
@@ -755,6 +757,7 @@
bindings/gobject/WebKitDOMEventTarget.h
bindings/gobject/WebKitDOMNodeFilter.h
bindings/gobject/WebKitDOMObject.h
+ bindings/gobject/WebKitDOMXPathNSResolver.h
)
# Propagate this variable to the parent scope, so that it can be used in other parts of the build.
Added: trunk/Source/WebCore/bindings/gobject/GObjectXPathNSResolver.cpp (0 => 170700)
--- trunk/Source/WebCore/bindings/gobject/GObjectXPathNSResolver.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/GObjectXPathNSResolver.cpp 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "GObjectXPathNSResolver.h"
+
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+GObjectXPathNSResolver::~GObjectXPathNSResolver()
+{
+}
+
+String GObjectXPathNSResolver::lookupNamespaceURI(const String& prefix)
+{
+ return String::fromUTF8(webkit_dom_xpath_ns_resolver_lookup_namespace_uri(m_resolver.get(), prefix.utf8().data()));
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/bindings/gobject/GObjectXPathNSResolver.h (0 => 170700)
--- trunk/Source/WebCore/bindings/gobject/GObjectXPathNSResolver.h (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/GObjectXPathNSResolver.h 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef GObjectXPathNSResolver_h
+#define GObjectXPathNSResolver_h
+
+#include "WebKitDOMXPathNSResolver.h"
+#include "XPathNSResolver.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+
+namespace WebCore {
+
+class GObjectXPathNSResolver : public XPathNSResolver {
+public:
+
+ static PassRefPtr<GObjectXPathNSResolver> create(WebKitDOMXPathNSResolver* resolver)
+ {
+ return adoptRef(new GObjectXPathNSResolver(resolver));
+ }
+
+ virtual ~GObjectXPathNSResolver();
+ virtual String lookupNamespaceURI(const String& prefix);
+
+private:
+ GObjectXPathNSResolver(WebKitDOMXPathNSResolver* resolver)
+ : m_resolver(resolver)
+ {
+ }
+
+ GRefPtr<WebKitDOMXPathNSResolver> m_resolver;
+};
+
+} // namespace WebCore
+
+#endif // GObjectXPathNSResolver_h
Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.cpp (0 => 170700)
--- trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.cpp 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "WebKitDOMXPathNSResolver.h"
+
+#include "DOMObjectCache.h"
+#include "GObjectXPathNSResolver.h"
+#include "JSMainThreadExecState.h"
+#include "WebKitDOMObject.h"
+#include "WebKitDOMXPathNSResolverPrivate.h"
+#include "gobject/ConvertToUTF8String.h"
+#include <wtf/GetPtr.h>
+#include <wtf/RefPtr.h>
+
+typedef WebKitDOMXPathNSResolverIface WebKitDOMXPathNSResolverInterface;
+
+G_DEFINE_INTERFACE(WebKitDOMXPathNSResolver, webkit_dom_xpath_ns_resolver, G_TYPE_OBJECT)
+
+static void webkit_dom_xpath_ns_resolver_default_init(WebKitDOMXPathNSResolverIface*)
+{
+}
+
+char* webkit_dom_xpath_ns_resolver_lookup_namespace_uri(WebKitDOMXPathNSResolver* resolver, const char* prefix)
+{
+ g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver), nullptr);
+ g_return_val_if_fail(prefix, nullptr);
+
+ return WEBKIT_DOM_XPATH_NS_RESOLVER_GET_IFACE(resolver)->lookup_namespace_uri(resolver, prefix);
+}
+
+// WebKitDOMNativeXPathNSResolver.
+struct _WebKitDOMNativeXPathNSResolver {
+ WebKitDOMObject parent;
+};
+
+struct _WebKitDOMNativeXPathNSResolverClass {
+ WebKitDOMObjectClass parentClass;
+};
+
+typedef struct _WebKitDOMNativeXPathNSResolverPrivate {
+ RefPtr<WebCore::XPathNSResolver> coreObject;
+} WebKitDOMNativeXPathNSResolverPrivate;
+
+#define WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER, WebKitDOMNativeXPathNSResolverPrivate)
+
+static void webkitDOMXPathNSResolverIfaceInit(WebKitDOMXPathNSResolverIface*);
+
+G_DEFINE_TYPE_WITH_CODE(WebKitDOMNativeXPathNSResolver, webkit_dom_native_xpath_ns_resolver, WEBKIT_DOM_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER, webkitDOMXPathNSResolverIfaceInit))
+
+static void webkitDOMNativeXPathNSResolverFinalize(GObject* object)
+{
+ WebKitDOMNativeXPathNSResolverPrivate* priv = WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER_GET_PRIVATE(object);
+ priv->~WebKitDOMNativeXPathNSResolverPrivate();
+ G_OBJECT_CLASS(webkit_dom_native_xpath_ns_resolver_parent_class)->finalize(object);
+}
+
+static GObject* webkitDOMNativeXPathNSResolverConstructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties)
+{
+ GObject* object = G_OBJECT_CLASS(webkit_dom_native_xpath_ns_resolver_parent_class)->constructor(type, constructPropertiesCount, constructProperties);
+ WebKitDOMNativeXPathNSResolverPrivate* priv = WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER_GET_PRIVATE(object);
+ priv->coreObject = static_cast<WebCore::XPathNSResolver*>(WEBKIT_DOM_OBJECT(object)->coreObject);
+ WebKit::DOMObjectCache::put(priv->coreObject.get(), object);
+ return object;
+}
+
+static void webkit_dom_native_xpath_ns_resolver_init(WebKitDOMNativeXPathNSResolver* resolver)
+{
+ WebKitDOMNativeXPathNSResolverPrivate* priv = WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER_GET_PRIVATE(resolver);
+ new (priv) WebKitDOMNativeXPathNSResolverPrivate();
+}
+
+static void webkit_dom_native_xpath_ns_resolver_class_init(WebKitDOMNativeXPathNSResolverClass* klass)
+{
+ GObjectClass* gobjectClass = G_OBJECT_CLASS(klass);
+ g_type_class_add_private(gobjectClass, sizeof(WebKitDOMNativeXPathNSResolverPrivate));
+ gobjectClass->constructor = webkitDOMNativeXPathNSResolverConstructor;
+ gobjectClass->finalize = webkitDOMNativeXPathNSResolverFinalize;
+}
+
+static char* webkitDOMNativeXPathNSResolverLookupNamespaceURI(WebKitDOMXPathNSResolver* resolver, const char* prefix)
+{
+ WebCore::JSMainThreadNullState state;
+ g_return_val_if_fail(WEBKIT_DOM_IS_NATIVE_XPATH_NS_RESOLVER(resolver), nullptr);
+
+ return convertToUTF8String(WebKit::core(resolver)->lookupNamespaceURI(WTF::String::fromUTF8(prefix)));
+}
+
+static void webkitDOMXPathNSResolverIfaceInit(WebKitDOMXPathNSResolverIface* iface)
+{
+ iface->lookup_namespace_uri = webkitDOMNativeXPathNSResolverLookupNamespaceURI;
+}
+
+namespace WebKit {
+
+PassRefPtr<WebCore::XPathNSResolver> core(WebKitDOMXPathNSResolver* xPathNSResolver)
+{
+ if (!xPathNSResolver)
+ return nullptr;
+
+ RefPtr<WebCore::XPathNSResolver> coreResolver;
+ if (WEBKIT_DOM_IS_NATIVE_XPATH_NS_RESOLVER(xPathNSResolver))
+ coreResolver = core(WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER(xPathNSResolver));
+ else
+ coreResolver = WebCore::GObjectXPathNSResolver::create(xPathNSResolver);
+ return coreResolver.release();
+}
+
+WebKitDOMXPathNSResolver* kit(WebCore::XPathNSResolver* coreXPathNSResolver)
+{
+ if (!coreXPathNSResolver)
+ return nullptr;
+
+ if (gpointer ret = DOMObjectCache::get(coreXPathNSResolver))
+ return WEBKIT_DOM_XPATH_NS_RESOLVER(ret);
+
+ return WEBKIT_DOM_XPATH_NS_RESOLVER(g_object_new(WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER, "core-object", coreXPathNSResolver, nullptr));
+}
+
+WebCore::XPathNSResolver* core(WebKitDOMNativeXPathNSResolver* xPathNSResolver)
+{
+ return xPathNSResolver ? static_cast<WebCore::XPathNSResolver*>(WEBKIT_DOM_OBJECT(xPathNSResolver)->coreObject) : nullptr;
+}
+
+} // namespace WebKit
Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.h (0 => 170700)
--- trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.h (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.h 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef WebKitDOMXPathNSResolver_h
+#define WebKitDOMXPathNSResolver_h
+
+#include <glib-object.h>
+#include <webkitdom/webkitdomdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER (webkit_dom_xpath_ns_resolver_get_type ())
+#define WEBKIT_DOM_XPATH_NS_RESOLVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER, WebKitDOMXPathNSResolver))
+#define WEBKIT_DOM_XPATH_NS_RESOLVER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER, WebKitDOMXPathNSResolverIface))
+#define WEBKIT_DOM_IS_XPATH_NS_RESOLVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER))
+#define WEBKIT_DOM_XPATH_NS_RESOLVER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER, WebKitDOMXPathNSResolverIface))
+
+typedef struct _WebKitDOMXPathNSResolverIface WebKitDOMXPathNSResolverIface;
+
+struct _WebKitDOMXPathNSResolverIface {
+ GTypeInterface gIface;
+
+ /* virtual table */
+ gchar *(* lookup_namespace_uri)(WebKitDOMXPathNSResolver *resolver,
+ const gchar *prefix);
+
+ void (*_webkitdom_reserved0) (void);
+ void (*_webkitdom_reserved1) (void);
+ void (*_webkitdom_reserved2) (void);
+ void (*_webkitdom_reserved3) (void);
+};
+
+
+WEBKIT_API GType webkit_dom_xpath_ns_resolver_get_type(void) G_GNUC_CONST;
+
+/**
+ * webkit_dom_xpath_ns_resolver_lookup_namespace_uri:
+ * @resolver: A #WebKitDOMXPathNSResolver
+ * @prefix: The prefix to lookup
+ *
+ * Returns: (transfer full): a #gchar
+ */
+WEBKIT_API gchar *webkit_dom_xpath_ns_resolver_lookup_namespace_uri(WebKitDOMXPathNSResolver *resolver,
+ const gchar *prefix);
+
+G_END_DECLS
+
+#endif /* WebKitDOMXPathNSResolver_h */
Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolverPrivate.h (0 => 170700)
--- trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolverPrivate.h (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolverPrivate.h 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the WebKit open source project.
+ * This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitDOMXPathNSResolverPrivate_h
+#define WebKitDOMXPathNSResolverPrivate_h
+
+#include "XPathNSResolver.h"
+#include <webkitdom/WebKitDOMXPathNSResolver.h>
+#include <wtf/PassRefPtr.h>
+
+#define WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER (webkit_dom_native_xpath_ns_resolver_get_type())
+#define WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER, WebKitDOMNativeXPathNSResolver))
+#define WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER, WebKitDOMNativeXPathNSResolverClass)
+#define WEBKIT_DOM_IS_NATIVE_XPATH_NS_RESOLVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER))
+#define WEBKIT_DOM_IS_NATIVE_XPATH_NS_RESOLVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER))
+#define WEBKIT_DOM_NATIVE_XPATH_NS_RESOLVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_DOM_TYPE_NATIVE_XPATH_NS_RESOLVER, WebKitDOMNativeXPathNSResolverClass))
+
+typedef struct _WebKitDOMNativeXPathNSResolver WebKitDOMNativeXPathNSResolver;
+typedef struct _WebKitDOMNativeXPathNSResolverClass WebKitDOMNativeXPathNSResolverClass;
+
+namespace WebKit {
+PassRefPtr<WebCore::XPathNSResolver> core(WebKitDOMXPathNSResolver*);
+WebKitDOMXPathNSResolver* kit(WebCore::XPathNSResolver*);
+WebCore::XPathNSResolver* core(WebKitDOMNativeXPathNSResolver*);
+} // namespace WebKit
+
+#endif /* WebKitDOMXPathNSResolverPrivate_h */
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (170699 => 170700)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm 2014-07-02 07:04:23 UTC (rev 170700)
@@ -984,7 +984,7 @@
if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) {
$paramName = "converted" . $codeGenerator->WK_ucfirst($paramName);
}
- if ($paramIDLType eq "NodeFilter") {
+ if ($paramIDLType eq "NodeFilter" || $paramIDLType eq "XPathNSResolver") {
$paramName = "WTF::getPtr(" . $paramName . ")";
}
push(@callImplParams, $paramName);
@@ -1088,7 +1088,7 @@
push(@cBody, " WTF::String ${convertedParamName} = WTF::String::fromUTF8($paramName);\n");
} elsif ($paramIDLType eq "CompareHow") {
push(@cBody, " WebCore::Range::CompareHow ${convertedParamName} = static_cast<WebCore::Range::CompareHow>($paramName);\n");
- } elsif ($paramIDLType eq "NodeFilter") {
+ } elsif ($paramIDLType eq "NodeFilter" || $paramIDLType eq "XPathNSResolver") {
push(@cBody, " RefPtr<WebCore::$paramIDLType> ${convertedParamName} = WebKit::core($paramName);\n");
} elsif ($paramIsGDOMType) {
push(@cBody, " WebCore::${paramIDLType}* ${convertedParamName} = WebKit::core($paramName);\n");
Modified: trunk/Tools/ChangeLog (170699 => 170700)
--- trunk/Tools/ChangeLog 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Tools/ChangeLog 2014-07-02 07:04:23 UTC (rev 170700)
@@ -1,3 +1,39 @@
+2014-07-01 Carlos Garcia Campos <[email protected]>
+
+ [GTK] XPathNSResolver should be exposed as an interface instead of as a class
+ https://bugs.webkit.org/show_bug.cgi?id=134028
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Add unit tests to check WebKitDOMXPathNSResolver API when using the
+ native one and a user provided one.
+
+ * Scripts/webkitpy/style/checker.py: Add WebKitDOMXPathNSResolver
+ to the list of GTK+ public API exceptions.
+ * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt: Add new files to compilation.
+ * TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp: Added.
+ (webkitXPathNSResolverLookupNamespaceURI):
+ (webkitXPathNSResolverDOMXPathNSResolverIfaceInit):
+ (webkit_xpath_ns_resolver_init):
+ (webkit_xpath_ns_resolver_class_init):
+ (WebKitDOMXPathNSResolverTest::create):
+ (WebKitDOMXPathNSResolverTest::webPageFromArgs):
+ (WebKitDOMXPathNSResolverTest::evaluateFooChildTextAndCheckResult):
+ (WebKitDOMXPathNSResolverTest::testXPathNSResolverNative):
+ (WebKitDOMXPathNSResolverTest::testXPathNSResolverCustom):
+ (WebKitDOMXPathNSResolverTest::runTest):
+ (registerTests):
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp: Added.
+ (runTest):
+ (testWebKitDOMXPathNSResolverNative):
+ (testWebKitDOMXPathNSResolverCustom):
+ (serverCallback):
+ (beforeAll):
+ (afterAll):
+ * gtk/webkitdom.py:
+ (WebKitDOMDocGeneratorSections.write_section): Add
+ WebKitDOMXPathNSResolver to the list of interfaces.
+
2014-07-01 Gyuyoung Kim <[email protected]>
Fix build break on EFL and GTK ports since r170683
Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (170699 => 170700)
--- trunk/Tools/Scripts/webkitpy/style/checker.py 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py 2014-07-02 07:04:23 UTC (rev 170700)
@@ -154,6 +154,7 @@
"Source/WebCore/bindings/gobject/WebKitDOMDeprecated.h",
"Source/WebCore/bindings/gobject/WebKitDOMEventTarget.h",
"Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.h",
+ "Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.h",
"Source/WebCore/bindings/scripts/test/GObject",
"Source/WebKit/gtk/webkit/",
"Tools/DumpRenderTree/gtk/"],
@@ -225,6 +226,7 @@
"Source/WebCore/bindings/gobject/WebKitDOMDeprecated.cpp",
"Source/WebCore/bindings/gobject/WebKitDOMEventTarget.cpp",
"Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.cpp",
+ "Source/WebCore/bindings/gobject/WebKitDOMXPathNSResolver.cpp",
"Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer1.cpp",
"Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp",
"Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp",
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (170699 => 170700)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt 2014-07-02 07:04:23 UTC (rev 170700)
@@ -82,7 +82,7 @@
endmacro()
ADD_WK2_TEST_WEB_EXTENSION(WebExtensionTest WebExtensionTest.cpp)
-ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp DOMNodeFilterTest.cpp FrameTest.cpp WebProcessTest.cpp)
+ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp DOMNodeFilterTest.cpp DOMXPathNSResolverTest.cpp FrameTest.cpp WebProcessTest.cpp)
ADD_WK2_TEST(InspectorTestServer InspectorTestServer.cpp)
ADD_WK2_TEST(TestAuthentication TestAuthentication.cpp)
@@ -91,6 +91,7 @@
ADD_WK2_TEST(TestCookieManager TestCookieManager.cpp)
ADD_WK2_TEST(TestDOMNode TestDOMNode.cpp)
ADD_WK2_TEST(TestDOMNodeFilter TestDOMNodeFilter.cpp)
+ADD_WK2_TEST(TestDOMXPathNSResolver TestDOMXPathNSResolver.cpp)
ADD_WK2_TEST(TestDownloads TestDownloads.cpp)
ADD_WK2_TEST(TestWebKitFaviconDatabase TestWebKitFaviconDatabase.cpp)
ADD_WK2_TEST(TestWebKitFindController TestWebKitFindController.cpp)
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp (0 => 170700)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMXPathNSResolverTest.cpp 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "WebProcessTest.h"
+#include <gio/gio.h>
+#include <webkit2/webkit-web-extension.h>
+#include <wtf/gobject/GUniquePtr.h>
+
+typedef struct _WebKitXPathNSResolver {
+ GObject parent;
+} WebKitXPathNSResolver;
+
+typedef struct _WebKitXPathNSResolverClass {
+ GObjectClass parentClass;
+} WebKitXPathNSResolverClass;
+
+static char* webkitXPathNSResolverLookupNamespaceURI(WebKitDOMXPathNSResolver* resolver, const char* prefix)
+{
+ if (!g_strcmp0(prefix, "foo"))
+ return g_strdup("http://www.example.com");
+
+ return nullptr;
+}
+
+static void webkitXPathNSResolverDOMXPathNSResolverIfaceInit(WebKitDOMXPathNSResolverIface* iface)
+{
+ iface->lookup_namespace_uri = webkitXPathNSResolverLookupNamespaceURI;
+}
+
+G_DEFINE_TYPE_WITH_CODE(WebKitXPathNSResolver, webkit_xpath_ns_resolver, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(WEBKIT_DOM_TYPE_XPATH_NS_RESOLVER, webkitXPathNSResolverDOMXPathNSResolverIfaceInit))
+
+static void webkit_xpath_ns_resolver_init(WebKitXPathNSResolver*)
+{
+}
+
+static void webkit_xpath_ns_resolver_class_init(WebKitXPathNSResolverClass*)
+{
+}
+
+class WebKitDOMXPathNSResolverTest : public WebProcessTest {
+public:
+ static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMXPathNSResolverTest()); }
+
+private:
+ guint64 webPageFromArgs(GVariant* args)
+ {
+ GVariantIter iter;
+ g_variant_iter_init(&iter, args);
+
+ const char* key;
+ GVariant* value;
+ while (g_variant_iter_loop(&iter, "{&sv}", &key, &value)) {
+ if (!strcmp(key, "pageID") && g_variant_classify(value) == G_VARIANT_CLASS_UINT64)
+ return g_variant_get_uint64(value);
+ }
+
+ g_assert_not_reached();
+ return 0;
+ }
+
+ void evaluateFooChildTextAndCheckResult(WebKitDOMDocument* document, WebKitDOMXPathNSResolver* resolver)
+ {
+ WebKitDOMElement* documentElement = webkit_dom_document_get_document_element(document);
+ g_assert(WEBKIT_DOM_IS_ELEMENT(documentElement));
+
+ WebKitDOMXPathResult* result = webkit_dom_document_evaluate(document, "foo:child/text()", WEBKIT_DOM_NODE(documentElement), resolver, WEBKIT_DOM_XPATH_RESULT_ORDERED_NODE_ITERATOR_TYPE, nullptr, nullptr);
+ g_assert(WEBKIT_DOM_IS_XPATH_RESULT(result));
+
+ WebKitDOMNode* nodeResult = webkit_dom_xpath_result_iterate_next(result, nullptr);
+ g_assert(WEBKIT_DOM_IS_NODE(nodeResult));
+
+ GUniquePtr<char> nodeValue(webkit_dom_node_get_node_value(nodeResult));
+ g_assert_cmpstr(nodeValue.get(), ==, "SUCCESS");
+ }
+
+ bool testXPathNSResolverNative(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ WebKitDOMXPathNSResolver* resolver = webkit_dom_document_create_ns_resolver(document, WEBKIT_DOM_NODE(webkit_dom_document_get_document_element(document)));
+ g_assert(WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver));
+ evaluateFooChildTextAndCheckResult(document, resolver);
+
+ return true;
+ }
+
+ bool testXPathNSResolverCustom(WebKitWebExtension* extension, GVariant* args)
+ {
+ WebKitWebPage* page = webkit_web_extension_get_page(extension, webPageFromArgs(args));
+ g_assert(WEBKIT_IS_WEB_PAGE(page));
+ WebKitDOMDocument* document = webkit_web_page_get_dom_document(page);
+ g_assert(WEBKIT_DOM_IS_DOCUMENT(document));
+
+ GRefPtr<WebKitDOMXPathNSResolver> resolver = adoptGRef(WEBKIT_DOM_XPATH_NS_RESOLVER(g_object_new(webkit_xpath_ns_resolver_get_type(), nullptr)));
+ evaluateFooChildTextAndCheckResult(document, resolver.get());
+
+ return true;
+ }
+
+ virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+ {
+ if (!strcmp(testName, "native"))
+ return testXPathNSResolverNative(extension, args);
+ if (!strcmp(testName, "custom"))
+ return testXPathNSResolverCustom(extension, args);
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitDOMXPathNSResolverTest, "WebKitDOMXPathNSResolver/native");
+ REGISTER_TEST(WebKitDOMXPathNSResolverTest, "WebKitDOMXPathNSResolver/custom");
+}
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp (0 => 170700)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMXPathNSResolver.cpp 2014-07-02 07:04:23 UTC (rev 170700)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "WebKitTestServer.h"
+#include "WebProcessTestRunner.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static WebProcessTestRunner* testRunner;
+static WebKitTestServer* kServer;
+
+static void runTest(WebViewTest* test, const char* name)
+{
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "pageID", g_variant_new_uint64(webkit_web_view_get_page_id(test->m_webView)));
+ g_assert(testRunner->runTest("WebKitDOMXPathNSResolver", name, g_variant_builder_end(&builder)));
+}
+
+static void testWebKitDOMXPathNSResolverNative(WebViewTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/native").data());
+ test->waitUntilLoadFinished();
+ runTest(test, "native");
+}
+
+static void testWebKitDOMXPathNSResolverCustom(WebViewTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/custom").data());
+ test->waitUntilLoadFinished();
+ runTest(test, "custom");
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ if (g_str_equal(path, "/native")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/xml");
+ static const char* nativeXML = "<root xmlns:foo='http://www.example.org'><foo:child>SUCCESS</foo:child></root>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, nativeXML, strlen(nativeXML));
+ soup_message_body_complete(message->response_body);
+ } else if (g_str_equal(path, "/custom")) {
+ soup_message_set_status(message, SOUP_STATUS_OK);
+ soup_message_headers_append(message->response_headers, "Content-Type", "text/xml");
+ static const char* customXML = "<root xmlns='http://www.example.com'><child>SUCCESS</child></root>";
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, customXML, strlen(customXML));
+ soup_message_body_complete(message->response_body);
+ } else
+ soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ testRunner = new WebProcessTestRunner();
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ WebViewTest::add("WebKitDOMXPathNSResolver", "native", testWebKitDOMXPathNSResolverNative);
+ WebViewTest::add("WebKitDOMXPathNSResolver", "custom", testWebKitDOMXPathNSResolverCustom);
+}
+
+void afterAll()
+{
+ delete testRunner;
+ delete kServer;
+}
Modified: trunk/Tools/gtk/webkitdom.py (170699 => 170700)
--- trunk/Tools/gtk/webkitdom.py 2014-07-02 06:44:05 UTC (rev 170699)
+++ trunk/Tools/gtk/webkitdom.py 2014-07-02 07:04:23 UTC (rev 170700)
@@ -133,7 +133,7 @@
def write_section(self, symbol_file):
class_name = os.path.basename(symbol_file).replace(".symbols", "")
is_custom = class_name == 'WebKitDOMCustom'
- is_interface = class_name in ['WebKitDOMEventTarget', 'WebKitDOMNodeFilter']
+ is_interface = class_name in ['WebKitDOMEventTarget', 'WebKitDOMNodeFilter', 'WebKitDOMXPathNSResolver']
is_object = class_name == 'WebKitDOMObject'
self.write('<SECTION>\n')
self.write('<FILE>%s</FILE>\n<TITLE>%s</TITLE>\n' % (class_name, class_name))