<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[170174] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/170174">170174</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-06-19 23:44:16 -0700 (Thu, 19 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] webkit_dom_document_create_tree_walker impossible to use due to WebKitDOMNodeFilter
https://bugs.webkit.org/show_bug.cgi?id=93002
Reviewed by Gustavo Noronha Silva.
Source/WebCore:
Add custom implementation of WebKitDOMNodeFilter to expose it as
an interface instead of a class.
* PlatformGTK.cmake: Add new files to compilation.
* bindings/gobject/GObjectNodeFilterCondition.cpp: Added.
(WebCore::GObjectNodeFilterCondition::~GObjectNodeFilterCondition):
Reset the NodeFilter WebCore object associated to the
WebKitDOMNodeFilter object.
(WebCore::GObjectNodeFilterCondition::acceptNode): Call webkit_dom_node_filter_accept_node().
* bindings/gobject/GObjectNodeFilterCondition.h: Added.
(WebCore::GObjectNodeFilterCondition::create): Create a new
GObjectNodeFilterCondition for the given WebKitDOMNodeFilter.
(WebCore::GObjectNodeFilterCondition::GObjectNodeFilterCondition):
* bindings/gobject/WebKitDOMNodeFilter.cpp: Added.
(webkit_dom_node_filter_default_init):
(webkit_dom_node_filter_accept_node):
(WebKit::nodeFilterMap): Map NodeFilter WebCore objects to
WebKitDOMNodeFilter objects.
(WebKit::nodeFilterObjectDestroyedCallback): Remove the node
filter form the map when the WebKitDOMNodeFilter objecrt is destroyed.
(WebKit::kit): Return the WebKitDOMNodeFilter object for the given
NodeFilter WebCore object.
(WebKit::core): Get or create a NodeFilter WebCore object
associated to the given WebKitDOMNodeFilter.
* bindings/gobject/WebKitDOMNodeFilter.h: Added.
* bindings/gobject/WebKitDOMNodeFilter.symbols: Added.
* bindings/gobject/WebKitDOMNodeFilterPrivate.h: Added.
* bindings/scripts/CodeGeneratorGObject.pm:
(GenerateFunction): Add exceptions for NodeFilter parameters since
the core method returns a PassRefPtr.
Tools:
Add unit tests to check WebKitDOMNodefilter API used from both
TreeWalker and NodeIterator.
* Scripts/webkitpy/style/checker.py: Add exceptions for GTK+
public headers and add WebKitDOMNodeFilter to the list of exceptions.
* TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt: Add new files to compilation.
* TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp: Added.
(webkitNodeFilterAcceptNode):
(webkitNodeFilterDOMNodeFilterIfaceInit):
(webkit_node_filter_init):
(webkit_node_filter_class_init):
(WebKitDOMNodeFilterTest::create):
(WebKitDOMNodeFilterTest::webPageFromArgs):
(WebKitDOMNodeFilterTest::testTreeWalker):
(WebKitDOMNodeFilterTest::testNodeIterator):
(WebKitDOMNodeFilterTest::runTest):
(registerTests):
* TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp: Added.
(runTest):
(testWebKitDOMNodeFilterTreeWalker):
(testWebKitDOMNodeFilterNodeIterator):
(beforeAll):
(afterAll):
* gtk/webkitdom.py:
(WebKitDOMDocGeneratorSections.__init__):
(WebKitDOMDocGeneratorSections._symbol_list):
(WebKitDOMDocGeneratorSections.write_section):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorGObjectpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerpy">trunk/Tools/Scripts/webkitpy/style/checker.py</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt</a></li>
<li><a href="#trunkToolsgtkwebkitdompy">trunk/Tools/gtk/webkitdom.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorebindingsgobjectGObjectNodeFilterConditioncpp">trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsgobjectGObjectNodeFilterConditionh">trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.h</a></li>
<li><a href="#trunkSourceWebCorebindingsgobjectWebKitDOMNodeFiltercpp">trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsgobjectWebKitDOMNodeFilterh">trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.h</a></li>
<li><a href="#trunkSourceWebCorebindingsgobjectWebKitDOMNodeFiltersymbols">trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.symbols</a></li>
<li><a href="#trunkSourceWebCorebindingsgobjectWebKitDOMNodeFilterPrivateh">trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilterPrivate.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkDOMNodeFilterTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMNodeFiltercpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Source/WebCore/ChangeLog        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -1,5 +1,43 @@
</span><span class="cx"> 2014-06-19 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><ins>+ [GTK] webkit_dom_document_create_tree_walker impossible to use due to WebKitDOMNodeFilter
+ https://bugs.webkit.org/show_bug.cgi?id=93002
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Add custom implementation of WebKitDOMNodeFilter to expose it as
+ an interface instead of a class.
+
+ * PlatformGTK.cmake: Add new files to compilation.
+ * bindings/gobject/GObjectNodeFilterCondition.cpp: Added.
+ (WebCore::GObjectNodeFilterCondition::~GObjectNodeFilterCondition):
+ Reset the NodeFilter WebCore object associated to the
+ WebKitDOMNodeFilter object.
+ (WebCore::GObjectNodeFilterCondition::acceptNode): Call webkit_dom_node_filter_accept_node().
+ * bindings/gobject/GObjectNodeFilterCondition.h: Added.
+ (WebCore::GObjectNodeFilterCondition::create): Create a new
+ GObjectNodeFilterCondition for the given WebKitDOMNodeFilter.
+ (WebCore::GObjectNodeFilterCondition::GObjectNodeFilterCondition):
+ * bindings/gobject/WebKitDOMNodeFilter.cpp: Added.
+ (webkit_dom_node_filter_default_init):
+ (webkit_dom_node_filter_accept_node):
+ (WebKit::nodeFilterMap): Map NodeFilter WebCore objects to
+ WebKitDOMNodeFilter objects.
+ (WebKit::nodeFilterObjectDestroyedCallback): Remove the node
+ filter form the map when the WebKitDOMNodeFilter objecrt is destroyed.
+ (WebKit::kit): Return the WebKitDOMNodeFilter object for the given
+ NodeFilter WebCore object.
+ (WebKit::core): Get or create a NodeFilter WebCore object
+ associated to the given WebKitDOMNodeFilter.
+ * bindings/gobject/WebKitDOMNodeFilter.h: Added.
+ * bindings/gobject/WebKitDOMNodeFilter.symbols: Added.
+ * bindings/gobject/WebKitDOMNodeFilterPrivate.h: Added.
+ * bindings/scripts/CodeGeneratorGObject.pm:
+ (GenerateFunction): Add exceptions for NodeFilter parameters since
+ the core method returns a PassRefPtr.
+
+2014-06-19 Carlos Garcia Campos <cgarcia@igalia.com>
+
</ins><span class="cx"> [GTK] Limit the amount of API exposed to GObject DOM bindings API
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=133726
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -435,9 +435,11 @@
</span><span class="cx"> bindings/gobject/ConvertToUTF8String.cpp
</span><span class="cx"> bindings/gobject/DOMObjectCache.cpp
</span><span class="cx"> bindings/gobject/GObjectEventListener.cpp
</span><ins>+ bindings/gobject/GObjectNodeFilterCondition.cpp
</ins><span class="cx"> bindings/gobject/WebKitDOMCustom.cpp
</span><span class="cx"> bindings/gobject/WebKitDOMEventTarget.cpp
</span><span class="cx"> bindings/gobject/WebKitDOMHTMLPrivate.cpp
</span><ins>+ bindings/gobject/WebKitDOMNodeFilter.cpp
</ins><span class="cx"> bindings/gobject/WebKitDOMObject.cpp
</span><span class="cx"> bindings/gobject/WebKitDOMPrivate.cpp
</span><span class="cx"> ${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdomdefines.h
</span><span class="lines">@@ -470,7 +472,6 @@
</span><span class="cx"> dom/MouseEvent.idl
</span><span class="cx"> dom/NamedNodeMap.idl
</span><span class="cx"> dom/Node.idl
</span><del>- dom/NodeFilter.idl
</del><span class="cx"> dom/NodeIterator.idl
</span><span class="cx"> dom/NodeList.idl
</span><span class="cx"> dom/ProcessingInstruction.idl
</span><span class="lines">@@ -629,12 +630,13 @@
</span><span class="cx"> )
</span><span class="cx"> endif ()
</span><span class="cx">
</span><del>-set(GObjectDOMBindingsStable_CLASS_LIST Custom EventTarget Object)
</del><ins>+set(GObjectDOMBindingsStable_CLASS_LIST Custom EventTarget NodeFilter Object)
</ins><span class="cx"> set(GObjectDOMBindingsStable_INSTALLED_HEADERS
</span><span class="cx"> ${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdomdefines.h
</span><span class="cx"> ${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}/webkitdom.h
</span><span class="cx"> ${WEBCORE_DIR}/bindings/gobject/WebKitDOMCustom.h
</span><span class="cx"> ${WEBCORE_DIR}/bindings/gobject/WebKitDOMEventTarget.h
</span><ins>+ ${WEBCORE_DIR}/bindings/gobject/WebKitDOMNodeFilter.h
</ins><span class="cx"> ${WEBCORE_DIR}/bindings/gobject/WebKitDOMObject.h
</span><span class="cx"> )
</span><span class="cx">
</span><span class="lines">@@ -732,6 +734,7 @@
</span><span class="cx"> set(GObjectDOMBindings_GIR_HEADERS ${GObjectDOMBindings_INSTALLED_HEADERS})
</span><span class="cx"> list(REMOVE_ITEM GObjectDOMBindings_GIR_HEADERS
</span><span class="cx"> bindings/gobject/WebKitDOMEventTarget.h
</span><ins>+ bindings/gobject/WebKitDOMNodeFilter.h
</ins><span class="cx"> bindings/gobject/WebKitDOMObject.h
</span><span class="cx"> )
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsgobjectGObjectNodeFilterConditioncpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.cpp (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.cpp         (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.cpp        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * 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 "GObjectNodeFilterCondition.h"
+
+#include "NodeFilter.h"
+#include "WebKitDOMNodePrivate.h"
+
+namespace WebCore {
+
+GObjectNodeFilterCondition::~GObjectNodeFilterCondition()
+{
+ g_object_set_data(G_OBJECT(m_filter.get()), "webkit-core-node-filter", nullptr);
+}
+
+short GObjectNodeFilterCondition::acceptNode(JSC::ExecState*, Node* node) const
+{
+ if (!node)
+ return NodeFilter::FILTER_REJECT;
+ return webkit_dom_node_filter_accept_node(m_filter.get(), WebKit::kit(node));
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsgobjectGObjectNodeFilterConditionh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.h (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.h         (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/GObjectNodeFilterCondition.h        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * 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 GObjectNodeFilterCondition_h
+#define GObjectNodeFilterCondition_h
+
+#include "NodeFilterCondition.h"
+
+#include "WebKitDOMNodeFilter.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+
+namespace WebCore {
+class Node;
+
+class GObjectNodeFilterCondition : public NodeFilterCondition {
+public:
+
+ static PassRefPtr<GObjectNodeFilterCondition> create(WebKitDOMNodeFilter* filter)
+ {
+ return adoptRef(new GObjectNodeFilterCondition(filter));
+ }
+
+ virtual short acceptNode(JSC::ExecState*, Node*) const;
+
+private:
+ GObjectNodeFilterCondition(WebKitDOMNodeFilter* filter)
+ : m_filter(filter)
+ {
+ }
+ ~GObjectNodeFilterCondition();
+
+ GRefPtr<WebKitDOMNodeFilter> m_filter;
+};
+
+} // namespace WebCore
+
+#endif // GObjectNodeFilterCondition_h
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsgobjectWebKitDOMNodeFiltercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.cpp (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.cpp         (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.cpp        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+/*
+ * 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 "WebKitDOMNodeFilter.h"
+
+#include "GObjectNodeFilterCondition.h"
+#include "NodeFilter.h"
+#include "WebKitDOMNode.h"
+#include "WebKitDOMNodeFilterPrivate.h"
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+
+typedef WebKitDOMNodeFilterIface WebKitDOMNodeFilterInterface;
+
+G_DEFINE_INTERFACE(WebKitDOMNodeFilter, webkit_dom_node_filter, G_TYPE_OBJECT)
+
+static void webkit_dom_node_filter_default_init(WebKitDOMNodeFilterIface*)
+{
+}
+
+gshort webkit_dom_node_filter_accept_node(WebKitDOMNodeFilter* filter, WebKitDOMNode* node)
+{
+ g_return_val_if_fail(WEBKIT_DOM_IS_NODE_FILTER(filter), WEBKIT_DOM_NODE_FILTER_REJECT);
+ g_return_val_if_fail(WEBKIT_DOM_IS_NODE(node), WEBKIT_DOM_NODE_FILTER_REJECT);
+
+ return WEBKIT_DOM_NODE_FILTER_GET_IFACE(filter)->accept_node(filter, node);
+}
+
+namespace WebKit {
+
+static HashMap<WebCore::NodeFilter*, WebKitDOMNodeFilter*>& nodeFilterMap()
+{
+ static NeverDestroyed<HashMap<WebCore::NodeFilter*, WebKitDOMNodeFilter*>> nodeFilterMap;
+ return nodeFilterMap;
+}
+
+static void nodeFilterObjectDestroyedCallback(gpointer coreNodeFilter, GObject* nodeFilter)
+{
+ WebKitDOMNodeFilter* filter = nodeFilterMap().take(static_cast<WebCore::NodeFilter*>(coreNodeFilter));
+ UNUSED_PARAM(nodeFilter);
+ ASSERT_UNUSED(filter, filter == nodeFilter);
+}
+
+WebKitDOMNodeFilter* kit(WebCore::NodeFilter* coreNodeFilter)
+{
+ if (!coreNodeFilter)
+ return nullptr;
+
+ return nodeFilterMap().get(coreNodeFilter);
+}
+
+PassRefPtr<WebCore::NodeFilter> core(WebKitDOMNodeFilter* nodeFilter)
+{
+ if (!nodeFilter)
+ return nullptr;
+
+ RefPtr<WebCore::NodeFilter> coreNodeFilter = static_cast<WebCore::NodeFilter*>(g_object_get_data(G_OBJECT(nodeFilter), "webkit-core-node-filter"));
+ if (!coreNodeFilter) {
+ coreNodeFilter = WebCore::NodeFilter::create(WebCore::GObjectNodeFilterCondition::create(nodeFilter));
+ nodeFilterMap().add(coreNodeFilter.get(), nodeFilter);
+ g_object_weak_ref(G_OBJECT(nodeFilter), nodeFilterObjectDestroyedCallback, coreNodeFilter.get());
+ g_object_set_data(G_OBJECT(nodeFilter), "webkit-core-node-filter", coreNodeFilter.get());
+ }
+ return coreNodeFilter.release();
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsgobjectWebKitDOMNodeFilterh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.h (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.h         (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.h        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,212 @@
</span><ins>+/*
+ * 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 WebKitDOMNodeFilter_h
+#define WebKitDOMNodeFilter_h
+
+#include <glib-object.h>
+#include <webkitdom/webkitdomdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_DOM_NODE_FILTER (webkit_dom_node_filter_get_type ())
+#define WEBKIT_DOM_NODE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WEBKIT_TYPE_DOM_NODE_FILTER, WebKitDOMNodeFilter))
+#define WEBKIT_DOM_NODE_FILTER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), WEBKIT_TYPE_DOM_NODE_FILTER, WebKitDOMNodeFilterIface))
+#define WEBKIT_DOM_IS_NODE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WEBKIT_TYPE_DOM_NODE_FILTER))
+#define WEBKIT_DOM_NODE_FILTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), WEBKIT_TYPE_DOM_NODE_FILTER, WebKitDOMNodeFilterIface))
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_ACCEPT:
+ *
+ * Accept the node. Use this macro as return value of webkit_dom_node_filter_accept_node()
+ * implementation to accept the given #WebKitDOMNode
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_ACCEPT 1
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_REJECT:
+ *
+ * Reject the node. Use this macro as return value of webkit_dom_node_filter_accept_node()
+ * implementation to reject the given #WebKitDOMNode. The children of the given node will
+ * be rejected too.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_REJECT 2
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SKIP:
+ *
+ * Skip the node. Use this macro as return value of webkit_dom_node_filter_accept_node()
+ * implementation to skip the given #WebKitDOMNode. The children of the given node will
+ * not be skipped.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SKIP 3
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_ALL:
+ *
+ * Show all nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_ALL 0xFFFFFFFF
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_ELEMENT:
+ *
+ * Show #WebKitDOMElement nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_ELEMENT 0x00000001
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_ATTRIBUTE:
+ *
+ * Show #WebKitDOMAttr nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_ATTRIBUTE 0x00000002
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_TEXT:
+ *
+ * Show #WebKitDOMText nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_TEXT 0x00000004
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_CDATA_SECTION:
+ *
+ * Show #WebKitDOMCDataSection nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_CDATA_SECTION 0x00000008
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY_REFERENCE:
+ *
+ * Show #WebKitDOMEntityReference nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY_REFERENCE 0x00000010
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY:
+ *
+ * Show #WebKitDOMEntity nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY 0x00000020
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_PROCESSING_INSTRUCTION:
+ *
+ * Show #WebKitDOMProcessingInstruction nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_PROCESSING_INSTRUCTION 0x00000040
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_COMMENT:
+ *
+ * Show #WebKitDOMComment nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_COMMENT 0x00000080
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT:
+ *
+ * Show #WebKitDOMDocument nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT 0x00000100
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_TYPE:
+ *
+ * Show #WebKitDOMDocumentType nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_TYPE 0x00000200
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_FRAGMENT:
+ *
+ * Show #WebKitDOMDocumentFragment nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_FRAGMENT 0x00000400
+
+/**
+ * WEBKIT_DOM_NODE_FILTER_SHOW_NOTATION:
+ *
+ * Show #WebKitDOMNotation nodes.
+ *
+ * Since: 2.6
+ */
+#define WEBKIT_DOM_NODE_FILTER_SHOW_NOTATION 0x00000800
+
+typedef struct _WebKitDOMNodeFilterIface WebKitDOMNodeFilterIface;
+
+struct _WebKitDOMNodeFilterIface {
+ GTypeInterface gIface;
+
+ /* virtual table */
+ gshort (* accept_node)(WebKitDOMNodeFilter *filter,
+ WebKitDOMNode *node);
+
+ void (*_webkitdom_reserved0) (void);
+ void (*_webkitdom_reserved1) (void);
+ void (*_webkitdom_reserved2) (void);
+ void (*_webkitdom_reserved3) (void);
+};
+
+
+WEBKIT_API GType webkit_dom_node_filter_get_type(void) G_GNUC_CONST;
+
+/**
+ * webkit_dom_node_filter_accept_node:
+ * @filter: A #WebKitDOMNodeFilter
+ * @node: A #WebKitDOMNode
+ *
+ * Returns: a #gshort
+ */
+WEBKIT_API gshort webkit_dom_node_filter_accept_node(WebKitDOMNodeFilter *filter,
+ WebKitDOMNode *node);
+
+G_END_DECLS
+
+#endif /* WebKitDOMNodeFilter_h */
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsgobjectWebKitDOMNodeFiltersymbols"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.symbols (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.symbols         (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.symbols        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+GType webkit_dom_node_filter_get_type(void)
+WEBKIT_DOM_NODE_FILTER_ACCEPT
+WEBKIT_DOM_NODE_FILTER_REJECT
+WEBKIT_DOM_NODE_FILTER_SHOW_ALL
+WEBKIT_DOM_NODE_FILTER_SHOW_ATTRIBUTE
+WEBKIT_DOM_NODE_FILTER_SHOW_CDATA_SECTION
+WEBKIT_DOM_NODE_FILTER_SHOW_COMMENT
+WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT
+WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_FRAGMENT
+WEBKIT_DOM_NODE_FILTER_SHOW_DOCUMENT_TYPE
+WEBKIT_DOM_NODE_FILTER_SHOW_ELEMENT
+WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY
+WEBKIT_DOM_NODE_FILTER_SHOW_ENTITY_REFERENCE
+WEBKIT_DOM_NODE_FILTER_SHOW_NOTATION
+WEBKIT_DOM_NODE_FILTER_SHOW_PROCESSING_INSTRUCTION
+WEBKIT_DOM_NODE_FILTER_SHOW_TEXT
+WEBKIT_DOM_NODE_FILTER_SKIP
+gshort webkit_dom_node_filter_accept_node(WebKitDOMNodeFilter*, WebKitDOMNode*)
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsgobjectWebKitDOMNodeFilterPrivateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilterPrivate.h (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilterPrivate.h         (rev 0)
+++ trunk/Source/WebCore/bindings/gobject/WebKitDOMNodeFilterPrivate.h        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+/*
+ * 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.
+ */
+
+#ifndef WebKitDOMNodeFilterPrivate_h
+#define WebKitDOMNodeFiltertPrivate_h
+
+#include <webkitdom/WebKitDOMNodeFilter.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+class NodeFilter;
+}
+
+namespace WebKit {
+WebKitDOMNodeFilter* kit(WebCore::NodeFilter*);
+PassRefPtr<WebCore::NodeFilter> core(WebKitDOMNodeFilter*);
+} // namespace WebKit
+
+#endif /* WebKitDOMNodeFilterPrivate_h */
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorGObjectpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -54,6 +54,8 @@
</span><span class="cx"> 'webkit_dom_document_create_attribute_ns' => ['namespaceURI'],
</span><span class="cx"> 'webkit_dom_document_create_element_ns' => ['namespaceURI'],
</span><span class="cx"> 'webkit_dom_document_create_entity_reference' => ['name'],
</span><ins>+ 'webkit_dom_document_create_node_iterator' => ['filter'],
+ 'webkit_dom_document_create_tree_walker' => ['filter'],
</ins><span class="cx"> 'webkit_dom_document_evaluate' => ['inResult', 'resolver'],
</span><span class="cx"> 'webkit_dom_document_get_override_style' => ['pseudoElement'],
</span><span class="cx"> 'webkit_dom_dom_implementation_create_document' => ['namespaceURI', 'doctype'],
</span><span class="lines">@@ -956,6 +958,9 @@
</span><span class="cx"> if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) {
</span><span class="cx"> $paramName = "converted" . $codeGenerator->WK_ucfirst($paramName);
</span><span class="cx"> }
</span><ins>+ if ($paramIDLType eq "NodeFilter") {
+ $paramName = "WTF::getPtr(" . $paramName . ")";
+ }
</ins><span class="cx"> push(@callImplParams, $paramName);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1057,6 +1062,8 @@
</span><span class="cx"> push(@cBody, " WTF::String ${convertedParamName} = WTF::String::fromUTF8($paramName);\n");
</span><span class="cx"> } elsif ($paramIDLType eq "CompareHow") {
</span><span class="cx"> push(@cBody, " WebCore::Range::CompareHow ${convertedParamName} = static_cast<WebCore::Range::CompareHow>($paramName);\n");
</span><ins>+ } elsif ($paramIDLType eq "NodeFilter") {
+ push(@cBody, " RefPtr<WebCore::$paramIDLType> ${convertedParamName} = WebKit::core($paramName);\n");
</ins><span class="cx"> } elsif ($paramIsGDOMType) {
</span><span class="cx"> push(@cBody, " WebCore::${paramIDLType}* ${convertedParamName} = WebKit::core($paramName);\n");
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Tools/ChangeLog        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2014-06-19 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><ins>+ [GTK] webkit_dom_document_create_tree_walker impossible to use due to WebKitDOMNodeFilter
+ https://bugs.webkit.org/show_bug.cgi?id=93002
+
+ Reviewed by Gustavo Noronha Silva.
+
+ Add unit tests to check WebKitDOMNodefilter API used from both
+ TreeWalker and NodeIterator.
+
+ * Scripts/webkitpy/style/checker.py: Add exceptions for GTK+
+ public headers and add WebKitDOMNodeFilter to the list of exceptions.
+ * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt: Add new files to compilation.
+ * TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp: Added.
+ (webkitNodeFilterAcceptNode):
+ (webkitNodeFilterDOMNodeFilterIfaceInit):
+ (webkit_node_filter_init):
+ (webkit_node_filter_class_init):
+ (WebKitDOMNodeFilterTest::create):
+ (WebKitDOMNodeFilterTest::webPageFromArgs):
+ (WebKitDOMNodeFilterTest::testTreeWalker):
+ (WebKitDOMNodeFilterTest::testNodeIterator):
+ (WebKitDOMNodeFilterTest::runTest):
+ (registerTests):
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp: Added.
+ (runTest):
+ (testWebKitDOMNodeFilterTreeWalker):
+ (testWebKitDOMNodeFilterNodeIterator):
+ (beforeAll):
+ (afterAll):
+ * gtk/webkitdom.py:
+ (WebKitDOMDocGeneratorSections.__init__):
+ (WebKitDOMDocGeneratorSections._symbol_list):
+ (WebKitDOMDocGeneratorSections.write_section):
+
+2014-06-19 Carlos Garcia Campos <cgarcia@igalia.com>
+
</ins><span class="cx"> [GTK] Limit the amount of API exposed to GObject DOM bindings API
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=133726
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker.py        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -153,6 +153,7 @@
</span><span class="cx"> "Source/WebCore/bindings/gobject/WebKitDOMCustom.h",
</span><span class="cx"> "Source/WebCore/bindings/gobject/WebKitDOMDeprecated.h",
</span><span class="cx"> "Source/WebCore/bindings/gobject/WebKitDOMEventTarget.h",
</span><ins>+ "Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.h",
</ins><span class="cx"> "Source/WebCore/bindings/scripts/test/GObject",
</span><span class="cx"> "Source/WebKit/gtk/webkit/",
</span><span class="cx"> "Tools/DumpRenderTree/gtk/"],
</span><span class="lines">@@ -160,6 +161,8 @@
</span><span class="cx"> "-readability/parameter_name",
</span><span class="cx"> "-readability/null",
</span><span class="cx"> "-readability/enum_casing",
</span><ins>+ "-whitespace/declaration",
+ "-whitespace/indent",
</ins><span class="cx"> "-whitespace/parens"]),
</span><span class="cx">
</span><span class="cx"> ([# The GTK+ API use upper case, underscore separated, words in
</span><span class="lines">@@ -221,6 +224,7 @@
</span><span class="cx"> "Source/WebCore/bindings/gobject/WebKitDOMCustom.cpp",
</span><span class="cx"> "Source/WebCore/bindings/gobject/WebKitDOMDeprecated.cpp",
</span><span class="cx"> "Source/WebCore/bindings/gobject/WebKitDOMEventTarget.cpp",
</span><ins>+ "Source/WebCore/bindings/gobject/WebKitDOMNodeFilter.cpp",
</ins><span class="cx"> "Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer1.cpp",
</span><span class="cx"> "Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp",
</span><span class="cx"> "Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp",
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx"> endmacro()
</span><span class="cx">
</span><span class="cx"> ADD_WK2_TEST_WEB_EXTENSION(WebExtensionTest WebExtensionTest.cpp)
</span><del>-ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp FrameTest.cpp WebProcessTest.cpp)
</del><ins>+ADD_WK2_TEST_WEB_EXTENSION(WebProcessTest DOMNodeTest.cpp DOMNodeFilterTest.cpp FrameTest.cpp WebProcessTest.cpp)
</ins><span class="cx">
</span><span class="cx"> ADD_WK2_TEST(InspectorTestServer InspectorTestServer.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestAuthentication TestAuthentication.cpp)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx"> ADD_WK2_TEST(TestContextMenu TestContextMenu.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestCookieManager TestCookieManager.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestDOMNode TestDOMNode.cpp)
</span><ins>+ADD_WK2_TEST(TestDOMNodeFilter TestDOMNodeFilter.cpp)
</ins><span class="cx"> ADD_WK2_TEST(TestDownloads TestDownloads.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestWebKitFaviconDatabase TestWebKitFaviconDatabase.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestWebKitFindController TestWebKitFindController.cpp)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkDOMNodeFilterTestcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/DOMNodeFilterTest.cpp        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,208 @@
</span><ins>+/*
+ * Copyright (C) 2013 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 _WebKitNodeFilter {
+ GObject parent;
+} WebKitNodeFilter;
+
+typedef struct _WebKitNodeFilterClass {
+ GObjectClass parentClass;
+} WebKitNodeFilterClass;
+
+static short webkitNodeFilterAcceptNode(WebKitDOMNodeFilter*, WebKitDOMNode* node)
+{
+ // Filter out input elements.
+ return WEBKIT_DOM_IS_HTML_INPUT_ELEMENT(node) ? WEBKIT_DOM_NODE_FILTER_REJECT : WEBKIT_DOM_NODE_FILTER_ACCEPT;
+}
+
+static void webkitNodeFilterDOMNodeFilterIfaceInit(WebKitDOMNodeFilterIface* iface)
+{
+ iface->accept_node = webkitNodeFilterAcceptNode;
+}
+
+G_DEFINE_TYPE_WITH_CODE(WebKitNodeFilter, webkit_node_filter, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_DOM_NODE_FILTER, webkitNodeFilterDOMNodeFilterIfaceInit))
+
+static void webkit_node_filter_init(WebKitNodeFilter*)
+{
+}
+
+static void webkit_node_filter_class_init(WebKitNodeFilterClass*)
+{
+}
+
+static const char* expectedNodesAll[] = { "HTML", "HEAD", "TITLE", "#text", "BODY", "INPUT", "INPUT", "BR" };
+static const char* expectedNodesNoInput[] = { "HTML", "HEAD", "TITLE", "#text", "BODY", "BR" };
+static const char* expectedElementsNoInput[] = { "HTML", "HEAD", "TITLE", "BODY", "BR" };
+
+class WebKitDOMNodeFilterTest : public WebProcessTest {
+public:
+ static PassOwnPtr<WebProcessTest> create() { return adoptPtr(new WebKitDOMNodeFilterTest()); }
+
+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;
+ }
+
+ bool testTreeWalker(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));
+
+ WebKitDOMElement* root = webkit_dom_document_get_element_by_id(document, "root");
+ g_assert(WEBKIT_DOM_IS_NODE(root));
+
+ // No filter.
+ WebKitDOMTreeWalker* walker = webkit_dom_document_create_tree_walker(document, WEBKIT_DOM_NODE(root), WEBKIT_DOM_NODE_FILTER_SHOW_ALL, nullptr, FALSE, nullptr);
+ g_assert(WEBKIT_DOM_IS_TREE_WALKER(walker));
+ g_assert(!webkit_dom_tree_walker_get_filter(walker));
+
+ unsigned i = 0;
+ for (WebKitDOMNode* node = WEBKIT_DOM_NODE(root); node; node = webkit_dom_tree_walker_next_node(walker), ++i) {
+ g_assert_cmpuint(i, <, G_N_ELEMENTS(expectedNodesAll));
+ GUniquePtr<char> nodeName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(nodeName.get(), ==, expectedNodesAll[i]);
+ }
+ g_assert_cmpuint(i, ==, G_N_ELEMENTS(expectedNodesAll));
+
+ // Input elements filter.
+ GRefPtr<WebKitDOMNodeFilter> filter = adoptGRef(static_cast<WebKitDOMNodeFilter*>(g_object_new(webkit_node_filter_get_type(), nullptr)));
+ walker = webkit_dom_document_create_tree_walker(document, WEBKIT_DOM_NODE(root), WEBKIT_DOM_NODE_FILTER_SHOW_ALL, filter.get(), FALSE, nullptr);
+ g_assert(WEBKIT_DOM_IS_TREE_WALKER(walker));
+ g_assert(webkit_dom_tree_walker_get_filter(walker) == filter.get());
+
+ i = 0;
+ for (WebKitDOMNode* node = WEBKIT_DOM_NODE(root); node; node = webkit_dom_tree_walker_next_node(walker), ++i) {
+ g_assert_cmpuint(i, <, G_N_ELEMENTS(expectedNodesNoInput));
+ GUniquePtr<char> nodeName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(nodeName.get(), ==, expectedNodesNoInput[i]);
+ }
+ g_assert_cmpuint(i, ==, G_N_ELEMENTS(expectedNodesNoInput));
+
+ // Show only elements, reusing the input filter.
+ walker = webkit_dom_document_create_tree_walker(document, WEBKIT_DOM_NODE(root), WEBKIT_DOM_NODE_FILTER_SHOW_ELEMENT, filter.get(), FALSE, nullptr);
+ g_assert(WEBKIT_DOM_IS_TREE_WALKER(walker));
+ g_assert(webkit_dom_tree_walker_get_filter(walker) == filter.get());
+
+ i = 0;
+ for (WebKitDOMNode* node = WEBKIT_DOM_NODE(root); node; node = webkit_dom_tree_walker_next_node(walker), ++i) {
+ g_assert_cmpuint(i, <, G_N_ELEMENTS(expectedElementsNoInput));
+ GUniquePtr<char> nodeName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(nodeName.get(), ==, expectedElementsNoInput[i]);
+ }
+ g_assert_cmpuint(i, ==, G_N_ELEMENTS(expectedElementsNoInput));
+
+ return true;
+ }
+
+ bool testNodeIterator(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));
+
+ WebKitDOMElement* root = webkit_dom_document_get_element_by_id(document, "root");
+ g_assert(WEBKIT_DOM_IS_NODE(root));
+
+ // No filter.
+ WebKitDOMNodeIterator* iter = webkit_dom_document_create_node_iterator(document, WEBKIT_DOM_NODE(root), WEBKIT_DOM_NODE_FILTER_SHOW_ALL, nullptr, FALSE, nullptr);
+ g_assert(WEBKIT_DOM_IS_NODE_ITERATOR(iter));
+ g_assert(!webkit_dom_node_iterator_get_filter(iter));
+
+ unsigned i = 0;
+ while (WebKitDOMNode* node = webkit_dom_node_iterator_next_node(iter, nullptr)) {
+ g_assert_cmpuint(i, <, G_N_ELEMENTS(expectedNodesAll));
+ GUniquePtr<char> nodeName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(nodeName.get(), ==, expectedNodesAll[i]);
+ i++;
+ }
+ g_assert_cmpuint(i, ==, G_N_ELEMENTS(expectedNodesAll));
+
+ // Input elements filter.
+ GRefPtr<WebKitDOMNodeFilter> filter = adoptGRef(static_cast<WebKitDOMNodeFilter*>(g_object_new(webkit_node_filter_get_type(), nullptr)));
+ iter = webkit_dom_document_create_node_iterator(document, WEBKIT_DOM_NODE(root), WEBKIT_DOM_NODE_FILTER_SHOW_ALL, filter.get(), FALSE, nullptr);
+ g_assert(WEBKIT_DOM_IS_NODE_ITERATOR(iter));
+ g_assert(webkit_dom_node_iterator_get_filter(iter) == filter.get());
+
+ i = 0;
+ while (WebKitDOMNode* node = webkit_dom_node_iterator_next_node(iter, nullptr)) {
+ g_assert_cmpuint(i, <, G_N_ELEMENTS(expectedNodesNoInput));
+ GUniquePtr<char> nodeName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(nodeName.get(), ==, expectedNodesNoInput[i]);
+ i++;
+ }
+ g_assert_cmpuint(i, ==, G_N_ELEMENTS(expectedNodesNoInput));
+
+ // Show only elements, reusing the input filter.
+ iter = webkit_dom_document_create_node_iterator(document, WEBKIT_DOM_NODE(root), WEBKIT_DOM_NODE_FILTER_SHOW_ELEMENT, filter.get(), FALSE, nullptr);
+ g_assert(WEBKIT_DOM_IS_NODE_ITERATOR(iter));
+ g_assert(webkit_dom_node_iterator_get_filter(iter) == filter.get());
+
+ i = 0;
+ while (WebKitDOMNode* node = webkit_dom_node_iterator_next_node(iter, nullptr)) {
+ g_assert_cmpuint(i, <, G_N_ELEMENTS(expectedElementsNoInput));
+ GUniquePtr<char> nodeName(webkit_dom_node_get_node_name(node));
+ g_assert_cmpstr(nodeName.get(), ==, expectedElementsNoInput[i]);
+ i++;
+ }
+ g_assert_cmpuint(i, ==, G_N_ELEMENTS(expectedElementsNoInput));
+
+ return true;
+ }
+
+ virtual bool runTest(const char* testName, WebKitWebExtension* extension, GVariant* args)
+ {
+ if (!strcmp(testName, "tree-walker"))
+ return testTreeWalker(extension, args);
+ if (!strcmp(testName, "node-iterator"))
+ return testNodeIterator(extension, args);
+
+ g_assert_not_reached();
+ return false;
+ }
+};
+
+static void __attribute__((constructor)) registerTests()
+{
+ REGISTER_TEST(WebKitDOMNodeFilterTest, "WebKitDOMNodeFilter/tree-walker");
+ REGISTER_TEST(WebKitDOMNodeFilterTest, "WebKitDOMNodeFilter/node-iterator");
+}
+
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestDOMNodeFiltercpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp (0 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestDOMNodeFilter.cpp        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+/*
+ * 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 "WebProcessTestRunner.h"
+#include "WebViewTest.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static WebProcessTestRunner* testRunner;
+
+static const char* testHTML = "<html id='root'><head><title>DOMNodeTreeWalker</title></head>"
+ "<body><input type='button' name='push' value='push'><input type='button' name='clear' value='clear'><br></body></html>";
+
+static void runTest(WebViewTest* test, const char* name)
+{
+ test->loadHtml(testHTML, nullptr);
+ test->waitUntilLoadFinished();
+
+ 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("WebKitDOMNodeFilter", name, g_variant_builder_end(&builder)));
+}
+
+static void testWebKitDOMNodeFilterTreeWalker(WebViewTest* test, gconstpointer)
+{
+ runTest(test, "tree-walker");
+}
+
+static void testWebKitDOMNodeFilterNodeIterator(WebViewTest* test, gconstpointer)
+{
+ runTest(test, "node-iterator");
+}
+
+void beforeAll()
+{
+ testRunner = new WebProcessTestRunner();
+ webkit_web_context_set_web_extensions_directory(webkit_web_context_get_default(), WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+
+ WebViewTest::add("WebKitDOMNodeFilter", "tree-walker", testWebKitDOMNodeFilterTreeWalker);
+ WebViewTest::add("WebKitDOMNodeFilter", "node-iterator", testWebKitDOMNodeFilterNodeIterator);
+}
+
+void afterAll()
+{
+ delete testRunner;
+}
</ins></span></pre></div>
<a id="trunkToolsgtkwebkitdompy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/gtk/webkitdom.py (170173 => 170174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/gtk/webkitdom.py        2014-06-20 06:24:06 UTC (rev 170173)
+++ trunk/Tools/gtk/webkitdom.py        2014-06-20 06:44:16 UTC (rev 170174)
</span><span class="lines">@@ -92,6 +92,7 @@
</span><span class="cx"> self._second_decamelize_re = re.compile('([a-z0-9])([A-Z])')
</span><span class="cx"> self._dom_class_re = re.compile('(^WebKitDOM)(.+)$')
</span><span class="cx"> self._function_re = re.compile('^.+ (.+)\((.+)\)$')
</span><ins>+ self._constant_re = re.compile('^[A-Z_]+$')
</ins><span class="cx">
</span><span class="cx"> def _dom_class(self, class_name):
</span><span class="cx"> return self._dom_class_re.sub(r'\2', class_name)
</span><span class="lines">@@ -111,6 +112,11 @@
</span><span class="cx"> retval = []
</span><span class="cx"> f = open(symbol_file, 'r')
</span><span class="cx"> for line in f.readlines():
</span><ins>+ match = self._constant_re.match(line)
+ if match:
+ retval.append(line.strip('\n'))
+ continue
+
</ins><span class="cx"> match = self._function_re.match(line)
</span><span class="cx"> if not match or match.group(1).endswith('get_type'):
</span><span class="cx"> continue
</span><span class="lines">@@ -121,7 +127,7 @@
</span><span class="cx"> def write_section(self, symbol_file):
</span><span class="cx"> class_name = os.path.basename(symbol_file).replace(".symbols", "")
</span><span class="cx"> is_custom = class_name == 'WebKitDOMCustom'
</span><del>- is_interface = class_name == 'WebKitDOMEventTarget'
</del><ins>+ is_interface = class_name in ['WebKitDOMEventTarget', 'WebKitDOMNodeFilter']
</ins><span class="cx"> is_object = class_name == 'WebKitDOMObject'
</span><span class="cx"> self.write('<SECTION>\n')
</span><span class="cx"> self.write('<FILE>%s</FILE>\n<TITLE>%s</TITLE>\n' % (class_name, class_name))
</span></span></pre>
</div>
</div>
</body>
</html>