Title: [249779] trunk
Revision
249779
Author
cdu...@apple.com
Date
2019-09-11 15:27:34 -0700 (Wed, 11 Sep 2019)

Log Message

Align our XPath API with the specification and other browsers
https://bugs.webkit.org/show_bug.cgi?id=201660

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/dom/interfaces-expected.txt:

Source/WebCore:

Align our XPath API with the specification and other browsers:
- Document/XPathEvaluator.createExpression()'s first parameter should be mandatory
- Document/XPathEvaluator.evaluate()'s first 2 parameters should be mandatory
- XPathExpression.evaluate()'s first parameter should be mandatory

I have confirmed in the latest Chrome and Firefox that they match the specification.

No new tests, rebaselined existing test.

* dom/Document.cpp:
(WebCore::Document::evaluate):
* dom/Document.h:
* dom/Document.idl:
* inspector/InspectorNodeFinder.cpp:
(WebCore::InspectorNodeFinder::searchUsingXPath):
* xml/XPathEvaluator.cpp:
(WebCore::XPathEvaluator::evaluate):
* xml/XPathEvaluator.h:
* xml/XPathEvaluator.idl:
* xml/XPathExpression.cpp:
(WebCore::XPathExpression::evaluate):
* xml/XPathExpression.h:
* xml/XPathExpression.idl:
* xml/XPathUtil.cpp:
(WebCore::XPath::isValidContextNode):
* xml/XPathUtil.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (249778 => 249779)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-09-11 22:27:34 UTC (rev 249779)
@@ -1,3 +1,14 @@
+2019-09-11  Chris Dumez  <cdu...@apple.com>
+
+        Align our XPath API with the specification and other browsers
+        https://bugs.webkit.org/show_bug.cgi?id=201660
+
+        Reviewed by Geoffrey Garen.
+
+        Rebaseline WPT tests now that more checks are passing.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+
 2019-09-11  Frederic Wang  <fw...@igalia.com>
 
         Bug 201603 - Synchronize MathML WPT tests against upstream

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt (249778 => 249779)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2019-09-11 22:27:34 UTC (rev 249779)
@@ -341,9 +341,9 @@
 PASS Document interface: operation append([object Object],[object Object]) 
 PASS Document interface: operation querySelector(DOMString) 
 PASS Document interface: operation querySelectorAll(DOMString) 
-FAIL Document interface: operation createExpression(DOMString, XPathNSResolver) assert_equals: property has wrong .length expected 1 but got 0
+PASS Document interface: operation createExpression(DOMString, XPathNSResolver) 
 PASS Document interface: operation createNSResolver(Node) 
-FAIL Document interface: operation evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) assert_equals: property has wrong .length expected 2 but got 0
+PASS Document interface: operation evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) 
 PASS Document must be primary interface of new Document() 
 PASS Stringification of new Document() 
 PASS Document interface: new Document() must inherit property "implementation" with the proper type 
@@ -406,15 +406,11 @@
 PASS Document interface: new Document() must inherit property "querySelectorAll(DOMString)" with the proper type 
 PASS Document interface: calling querySelectorAll(DOMString) on new Document() with too few arguments must throw TypeError 
 PASS Document interface: new Document() must inherit property "createExpression(DOMString, XPathNSResolver)" with the proper type 
-FAIL Document interface: calling createExpression(DOMString, XPathNSResolver) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS Document interface: calling createExpression(DOMString, XPathNSResolver) on new Document() with too few arguments must throw TypeError 
 PASS Document interface: new Document() must inherit property "createNSResolver(Node)" with the proper type 
 PASS Document interface: calling createNSResolver(Node) on new Document() with too few arguments must throw TypeError 
 PASS Document interface: new Document() must inherit property "evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult)" with the proper type 
-FAIL Document interface: calling evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) on new Document() with too few arguments must throw TypeError 
 PASS Node interface: new Document() must inherit property "ELEMENT_NODE" with the proper type 
 PASS Node interface: new Document() must inherit property "ATTRIBUTE_NODE" with the proper type 
 PASS Node interface: new Document() must inherit property "TEXT_NODE" with the proper type 
@@ -549,15 +545,11 @@
 PASS Document interface: xmlDoc must inherit property "querySelectorAll(DOMString)" with the proper type 
 PASS Document interface: calling querySelectorAll(DOMString) on xmlDoc with too few arguments must throw TypeError 
 PASS Document interface: xmlDoc must inherit property "createExpression(DOMString, XPathNSResolver)" with the proper type 
-FAIL Document interface: calling createExpression(DOMString, XPathNSResolver) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS Document interface: calling createExpression(DOMString, XPathNSResolver) on xmlDoc with too few arguments must throw TypeError 
 PASS Document interface: xmlDoc must inherit property "createNSResolver(Node)" with the proper type 
 PASS Document interface: calling createNSResolver(Node) on xmlDoc with too few arguments must throw TypeError 
 PASS Document interface: xmlDoc must inherit property "evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult)" with the proper type 
-FAIL Document interface: calling evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) on xmlDoc with too few arguments must throw TypeError 
 PASS Node interface: xmlDoc must inherit property "ELEMENT_NODE" with the proper type 
 PASS Node interface: xmlDoc must inherit property "ATTRIBUTE_NODE" with the proper type 
 PASS Node interface: xmlDoc must inherit property "TEXT_NODE" with the proper type 
@@ -1779,7 +1771,7 @@
 PASS XPathExpression interface: existence and properties of interface prototype object 
 PASS XPathExpression interface: existence and properties of interface prototype object's "constructor" property 
 PASS XPathExpression interface: existence and properties of interface prototype object's @@unscopables property 
-FAIL XPathExpression interface: operation evaluate(Node, unsigned short, XPathResult) assert_equals: property has wrong .length expected 1 but got 0
+PASS XPathExpression interface: operation evaluate(Node, unsigned short, XPathResult) 
 PASS XPathNSResolver interface: existence and properties of interface object 
 PASS XPathNSResolver interface: existence and properties of interface prototype object 
 PASS XPathNSResolver interface: existence and properties of interface prototype object's "constructor" property 
@@ -1791,8 +1783,8 @@
 PASS XPathEvaluator interface: existence and properties of interface prototype object 
 PASS XPathEvaluator interface: existence and properties of interface prototype object's "constructor" property 
 PASS XPathEvaluator interface: existence and properties of interface prototype object's @@unscopables property 
-FAIL XPathEvaluator interface: operation createExpression(DOMString, XPathNSResolver) assert_equals: property has wrong .length expected 1 but got 0
+PASS XPathEvaluator interface: operation createExpression(DOMString, XPathNSResolver) 
 FAIL XPathEvaluator interface: operation createNSResolver(Node) assert_equals: property has wrong .length expected 1 but got 0
-FAIL XPathEvaluator interface: operation evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) assert_equals: property has wrong .length expected 2 but got 0
+PASS XPathEvaluator interface: operation evaluate(DOMString, Node, XPathNSResolver, unsigned short, XPathResult) 
 PASS Window interface: attribute event 
 

Modified: trunk/Source/WebCore/ChangeLog (249778 => 249779)


--- trunk/Source/WebCore/ChangeLog	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/ChangeLog	2019-09-11 22:27:34 UTC (rev 249779)
@@ -1,3 +1,37 @@
+2019-09-11  Chris Dumez  <cdu...@apple.com>
+
+        Align our XPath API with the specification and other browsers
+        https://bugs.webkit.org/show_bug.cgi?id=201660
+
+        Reviewed by Geoffrey Garen.
+
+        Align our XPath API with the specification and other browsers:
+        - Document/XPathEvaluator.createExpression()'s first parameter should be mandatory
+        - Document/XPathEvaluator.evaluate()'s first 2 parameters should be mandatory
+        - XPathExpression.evaluate()'s first parameter should be mandatory
+
+        I have confirmed in the latest Chrome and Firefox that they match the specification.
+        
+        No new tests, rebaselined existing test.
+
+        * dom/Document.cpp:
+        (WebCore::Document::evaluate):
+        * dom/Document.h:
+        * dom/Document.idl:
+        * inspector/InspectorNodeFinder.cpp:
+        (WebCore::InspectorNodeFinder::searchUsingXPath):
+        * xml/XPathEvaluator.cpp:
+        (WebCore::XPathEvaluator::evaluate):
+        * xml/XPathEvaluator.h:
+        * xml/XPathEvaluator.idl:
+        * xml/XPathExpression.cpp:
+        (WebCore::XPathExpression::evaluate):
+        * xml/XPathExpression.h:
+        * xml/XPathExpression.idl:
+        * xml/XPathUtil.cpp:
+        (WebCore::XPath::isValidContextNode):
+        * xml/XPathUtil.h:
+
 2019-09-11  Truitt Savell  <tsav...@apple.com>
 
         Unreviewed, rolling out r249753.

Modified: trunk/Source/WebCore/dom/Document.cpp (249778 => 249779)


--- trunk/Source/WebCore/dom/Document.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -5765,7 +5765,7 @@
     return m_xpathEvaluator->createNSResolver(nodeResolver);
 }
 
-ExceptionOr<Ref<XPathResult>> Document::evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result)
+ExceptionOr<Ref<XPathResult>> Document::evaluate(const String& _expression_, Node& contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result)
 {
     if (!m_xpathEvaluator)
         m_xpathEvaluator = XPathEvaluator::create();

Modified: trunk/Source/WebCore/dom/Document.h (249778 => 249779)


--- trunk/Source/WebCore/dom/Document.h	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/dom/Document.h	2019-09-11 22:27:34 UTC (rev 249779)
@@ -1039,7 +1039,7 @@
     // XPathEvaluator methods
     WEBCORE_EXPORT ExceptionOr<Ref<XPathExpression>> createExpression(const String& _expression_, RefPtr<XPathNSResolver>&&);
     WEBCORE_EXPORT Ref<XPathNSResolver> createNSResolver(Node* nodeResolver);
-    WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*);
+    WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(const String& _expression_, Node& contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*);
 
     bool hasNodesWithNonFinalStyle() const { return m_hasNodesWithNonFinalStyle; }
     void setHasNodesWithNonFinalStyle() { m_hasNodesWithNonFinalStyle = true; }

Modified: trunk/Source/WebCore/dom/Document.idl (249778 => 249779)


--- trunk/Source/WebCore/dom/Document.idl	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/dom/Document.idl	2019-09-11 22:27:34 UTC (rev 249779)
@@ -136,9 +136,9 @@
     DOMSelection? getSelection();
 
     // XPath extensions (https://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator).
-    [MayThrowException] XPathExpression createExpression(optional DOMString _expression_ = "undefined", optional XPathNSResolver? resolver); // FIXME: Using "undefined" as default parameter value is wrong.
+    [MayThrowException] XPathExpression createExpression(DOMString _expression_, optional XPathNSResolver? resolver);
     XPathNSResolver createNSResolver(Node? nodeResolver);
-    [MayThrowException] XPathResult evaluate(optional DOMString _expression_ = "undefined", optional Node? contextNode, optional XPathNSResolver? resolver, optional unsigned short type = 0, optional XPathResult? inResult); // FIXME: Using "undefined" as default parameter value is wrong.
+    [MayThrowException] XPathResult evaluate(DOMString _expression_, Node contextNode, optional XPathNSResolver? resolver, optional unsigned short type = 0, optional XPathResult? inResult);
 
     // Extensions from Pointer Lock API (https://www.w3.org/TR/pointerlock/#extensions-to-the-document-interface).
     [NotEnumerable, Conditional=POINTER_LOCK] attribute EventHandler onpointerlockchange; // FIXME: Should be enumerable.

Modified: trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp (249778 => 249779)


--- trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -158,7 +158,7 @@
 
 void InspectorNodeFinder::searchUsingXPath(Node& parentNode)
 {
-    auto evaluateResult = parentNode.document().evaluate(m_query, &parentNode, nullptr, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE, nullptr);
+    auto evaluateResult = parentNode.document().evaluate(m_query, parentNode, nullptr, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE, nullptr);
     if (evaluateResult.hasException())
         return;
     auto result = evaluateResult.releaseReturnValue();

Modified: trunk/Source/WebCore/xml/XPathEvaluator.cpp (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathEvaluator.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathEvaluator.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -46,7 +46,7 @@
     return NativeXPathNSResolver::create(nodeResolver);
 }
 
-ExceptionOr<Ref<XPathResult>> XPathEvaluator::evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result)
+ExceptionOr<Ref<XPathResult>> XPathEvaluator::evaluate(const String& _expression_, Node& contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result)
 {
     if (!isValidContextNode(contextNode))
         return Exception { NotSupportedError };

Modified: trunk/Source/WebCore/xml/XPathEvaluator.h (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathEvaluator.h	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathEvaluator.h	2019-09-11 22:27:34 UTC (rev 249779)
@@ -41,7 +41,7 @@
 
     ExceptionOr<Ref<XPathExpression>> createExpression(const String& _expression_, RefPtr<XPathNSResolver>&&);
     Ref<XPathNSResolver> createNSResolver(Node* nodeResolver);
-    ExceptionOr<Ref<XPathResult>> evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*);
+    ExceptionOr<Ref<XPathResult>> evaluate(const String& _expression_, Node& contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*);
 
 private:
     XPathEvaluator() = default;

Modified: trunk/Source/WebCore/xml/XPathEvaluator.idl (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathEvaluator.idl	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathEvaluator.idl	2019-09-11 22:27:34 UTC (rev 249779)
@@ -21,11 +21,9 @@
     Constructor,
     ImplementationLacksVTable,
 ] interface XPathEvaluator {
-    // FIXME: Using "undefined" as default parameter value is wrong.
-    [MayThrowException] XPathExpression createExpression(optional DOMString _expression_ = "undefined", optional XPathNSResolver? resolver);
+    [MayThrowException] XPathExpression createExpression(DOMString _expression_, optional XPathNSResolver? resolver);
 
     XPathNSResolver createNSResolver(optional Node? nodeResolver);
 
-    // FIXME: Using "undefined" as default parameter value is wrong.
-    [MayThrowException] XPathResult evaluate(optional DOMString _expression_ = "undefined", optional Node? contextNode, optional XPathNSResolver? resolver, optional unsigned short type = 0, optional XPathResult? inResult);
+    [MayThrowException] XPathResult evaluate(DOMString _expression_, Node contextNode, optional XPathNSResolver? resolver, optional unsigned short type = 0, optional XPathResult? inResult);
 };

Modified: trunk/Source/WebCore/xml/XPathExpression.cpp (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathExpression.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathExpression.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -54,17 +54,17 @@
 XPathExpression::~XPathExpression() = default;
 
 // FIXME: Why does this take an XPathResult that it ignores?
-ExceptionOr<Ref<XPathResult>> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*)
+ExceptionOr<Ref<XPathResult>> XPathExpression::evaluate(Node& contextNode, unsigned short type, XPathResult*)
 {
     if (!isValidContextNode(contextNode))
         return Exception { NotSupportedError };
 
     EvaluationContext& evaluationContext = _expression_::evaluationContext();
-    evaluationContext.node = contextNode;
+    evaluationContext.node = &contextNode;
     evaluationContext.size = 1;
     evaluationContext.position = 1;
     evaluationContext.hadTypeConversionError = false;
-    auto result = XPathResult::create(contextNode->document(), m_topExpression->evaluate());
+    auto result = XPathResult::create(contextNode.document(), m_topExpression->evaluate());
     evaluationContext.node = nullptr; // Do not hold a reference to the context node, as this may prevent the whole document from being destroyed in time.
 
     if (evaluationContext.hadTypeConversionError)

Modified: trunk/Source/WebCore/xml/XPathExpression.h (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathExpression.h	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathExpression.h	2019-09-11 22:27:34 UTC (rev 249779)
@@ -43,7 +43,7 @@
     static ExceptionOr<Ref<XPathExpression>> createExpression(const String& _expression_, RefPtr<XPathNSResolver>&&);
     WEBCORE_EXPORT ~XPathExpression();
 
-    WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(Node* contextNode, unsigned short type, XPathResult*);
+    WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(Node& contextNode, unsigned short type, XPathResult*);
 
 private:
     explicit XPathExpression(std::unique_ptr<XPath::_expression_>);

Modified: trunk/Source/WebCore/xml/XPathExpression.idl (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathExpression.idl	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathExpression.idl	2019-09-11 22:27:34 UTC (rev 249779)
@@ -22,5 +22,5 @@
     ExportToWrappedFunction,
     ImplementationLacksVTable,
 ] interface XPathExpression {
-    [MayThrowException] XPathResult evaluate(optional Node? contextNode = null, optional unsigned short type = 0, optional XPathResult? inResult = null);
+    [MayThrowException] XPathResult evaluate(Node contextNode, optional unsigned short type = 0, optional XPathResult? inResult = null);
 };

Modified: trunk/Source/WebCore/xml/XPathUtil.cpp (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathUtil.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathUtil.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -54,11 +54,9 @@
     return String();
 }
 
-bool isValidContextNode(Node* node)
+bool isValidContextNode(Node& node)
 {
-    if (!node)
-        return false;
-    switch (node->nodeType()) {
+    switch (node.nodeType()) {
         case Node::ATTRIBUTE_NODE:
         case Node::CDATA_SECTION_NODE:
         case Node::COMMENT_NODE:

Modified: trunk/Source/WebCore/xml/XPathUtil.h (249778 => 249779)


--- trunk/Source/WebCore/xml/XPathUtil.h	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebCore/xml/XPathUtil.h	2019-09-11 22:27:34 UTC (rev 249779)
@@ -41,7 +41,7 @@
         String stringValue(Node*);
 
         /* @return whether the given node is a valid context node */
-        bool isValidContextNode(Node*);
+        bool isValidContextNode(Node&);
 
     } // namespace XPath
 

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp (249778 => 249779)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -1160,7 +1160,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0);
     g_return_val_if_fail(_expression_, 0);
-    g_return_val_if_fail(WEBKIT_DOM_IS_NODE(contextNode), 0);
+    g_return_val_if_fail(contextNode && WEBKIT_DOM_IS_NODE(contextNode), 0);
     g_return_val_if_fail(!resolver || WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver), 0);
     g_return_val_if_fail(!inResult || WEBKIT_DOM_IS_XPATH_RESULT(inResult), 0);
     g_return_val_if_fail(!error || !*error, 0);
@@ -1169,7 +1169,7 @@
     WebCore::Node* convertedContextNode = WebKit::core(contextNode);
     RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
     WebCore::XPathResult* convertedInResult = WebKit::core(inResult);
-    auto result = item->evaluate(convertedExpression, convertedContextNode, WTFMove(convertedResolver), type, convertedInResult);
+    auto result = item->evaluate(convertedExpression, *convertedContextNode, WTFMove(convertedResolver), type, convertedInResult);
     if (result.hasException()) {
         auto description = WebCore::DOMException::description(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp (249778 => 249779)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp	2019-09-11 22:27:34 UTC (rev 249779)
@@ -108,13 +108,13 @@
 {
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_EXPRESSION(self), 0);
-    g_return_val_if_fail(WEBKIT_DOM_IS_NODE(contextNode), 0);
+    g_return_val_if_fail(contextNode && WEBKIT_DOM_IS_NODE(contextNode), 0);
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(inResult), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathExpression* item = WebKit::core(self);
     WebCore::Node* convertedContextNode = WebKit::core(contextNode);
     WebCore::XPathResult* convertedInResult = WebKit::core(inResult);
-    auto result = item->evaluate(convertedContextNode, type, convertedInResult);
+    auto result = item->evaluate(*convertedContextNode, type, convertedInResult);
     if (result.hasException()) {
         auto description = WebCore::DOMException::description(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.legacyCode, description.name);

Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm (249778 => 249779)


--- trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMDocument.mm	2019-09-11 22:27:34 UTC (rev 249779)
@@ -601,8 +601,11 @@
 
 - (DOMXPathResult *)evaluate:(NSString *)_expression_ contextNode:(DOMNode *)contextNode resolver:(id <DOMXPathNSResolver>)resolver type:(unsigned short)type inResult:(DOMXPathResult *)inResult
 {
+    if (!contextNode)
+        return nullptr;
+
     WebCore::JSMainThreadNullState state;
-    return kit(raiseOnDOMError(IMPL->evaluate(_expression_, core(contextNode), wrap(resolver), type, core(inResult))).ptr());
+    return kit(raiseOnDOMError(IMPL->evaluate(_expression_, *core(contextNode), wrap(resolver), type, core(inResult))).ptr());
 }
 
 - (BOOL)execCommand:(NSString *)command userInterface:(BOOL)userInterface value:(NSString *)value

Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMXPathExpression.mm (249778 => 249779)


--- trunk/Source/WebKitLegacy/mac/DOM/DOMXPathExpression.mm	2019-09-11 21:43:53 UTC (rev 249778)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMXPathExpression.mm	2019-09-11 22:27:34 UTC (rev 249779)
@@ -54,8 +54,11 @@
 
 - (DOMXPathResult *)evaluate:(DOMNode *)contextNode type:(unsigned short)type inResult:(DOMXPathResult *)inResult
 {
+    if (!contextNode)
+        return nullptr;
+
     WebCore::JSMainThreadNullState state;
-    return kit(raiseOnDOMError(IMPL->evaluate(core(contextNode), type, core(inResult))).ptr());
+    return kit(raiseOnDOMError(IMPL->evaluate(*core(contextNode), type, core(inResult))).ptr());
 }
 
 @end
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to