Move XPath from ExceptionCode to Exception
https://bugs.webkit.org/show_bug.cgi?id=163656

Reviewed by Chris Dumez.

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::createExpression): Use ExceptionOr.
(WebCore::Document::createNSResolver): Return Ref.
(WebCore::Document::evaluate): Use ExceptionOr.
* dom/Document.h: Updated for above changes.
* dom/Document.idl: Use non-legacy exceptions for the functions above.

* inspector/InspectorNodeFinder.cpp:
(WebCore::InspectorNodeFinder::searchUsingXPath): Call XPath functions
with new interface.

* xml/DOMParser.cpp:
(WebCore::DOMParser::DOMParser): Marked inline.
(WebCore::DOMParser::create): Moved here from header.
(WebCore::DOMParser::parseFromString): Use ExceptionOr.
* xml/DOMParser.h: Updated for above changes.
* xml/DOMParser.idl: Use non-legacy exception.

* xml/XPathEvaluator.cpp:
(WebCore::XPathEvaluator::createExpression): Use ExceptionOr.
(WebCore::XPathEvaluator::evaluate): Ditto.
* xml/XPathEvaluator.h: Updated for above changes.
* xml/XPathEvaluator.idl: Use non-legacy exceptions.

* xml/XPathExpression.cpp:
(WebCore::XPathExpression::createExpression): Use ExceptionOr.
(WebCore::XPathExpression::evaluate): Ditto.
* xml/XPathExpression.h: Updated for above changes.
* xml/XPathExpression.idl: Use non-legacy exceptions.

* xml/XPathGrammar.y: Added include of XPathStep.h.

* xml/XPathParser.cpp:
(WebCore::XPath::Parser::Parser): Initialize three scalar data members
in the class definition rather than here.
(WebCore::XPath::Parser::parseStatement): Use ExceptionOr.
* xml/XPathParser.h: Updated for above changes.

* xml/XPathResult.cpp:
(WebCore::XPathResult::XPathResult): Use a reference rather than a
pointer for the document. Alao initialize two scalar data members
in the class definition rather than here.
(WebCore::XPathResult::convertTo): Use ExceptionOr.
(WebCore::XPathResult::numberValue): Ditto.
(WebCore::XPathResult::stringValue): Ditto.
(WebCore::XPathResult::booleanValue): Ditto.
(WebCore::XPathResult::singleNodeValue): Ditto.
(WebCore::XPathResult::snapshotLength): Ditto.
(WebCore::XPathResult::iterateNext): Ditto.
(WebCore::XPathResult::snapshotItem): Ditto.
* xml/XPathResult.h: Updated for the changes above.
* xml/XPathResult.idl: Use non-legacy exceptions.

Source/WebKit/mac:

* DOM/DOMDocument.mm:
(wrap): Added. Helper function for wrapping a resolver.
(-[DOMDocument createExpression:resolver:]): Use raiseOnDOMError.
(-[DOMDocument evaluate:contextNode:resolver:type:inResult:]): Ditto.
* DOM/DOMXPathExpression.mm:
(-[DOMXPathExpression evaluate:type:inResult:]): Ditto.
* DOM/DOMXPathResult.mm:
(-[DOMXPathResult numberValue]): Ditto.
(-[DOMXPathResult stringValue]): Ditto.
(-[DOMXPathResult booleanValue]): Ditto.
(-[DOMXPathResult singleNodeValue]): Ditto.
(-[DOMXPathResult snapshotLength]): Ditto.
(-[DOMXPathResult iterateNext]): Ditto.
(-[DOMXPathResult snapshotItem:]): Ditto.

Source/WebKit2:

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp:
(webkit_dom_document_create_expression): Use ExceptionOr.
(webkit_dom_document_evaluate): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp:
(webkit_dom_xpath_expression_evaluate): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathResult.cpp:
(webkit_dom_xpath_result_iterate_next): Ditto.
(webkit_dom_xpath_result_snapshot_item): Ditto.
(webkit_dom_xpath_result_get_number_value): Ditto.
(webkit_dom_xpath_result_get_string_value): Ditto.
(webkit_dom_xpath_result_get_boolean_value): Ditto.
(webkit_dom_xpath_result_get_single_node_value): Ditto.
(webkit_dom_xpath_result_get_snapshot_length): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@207541 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/xml/XPathExpression.h b/Source/WebCore/xml/XPathExpression.h
index b1eae8a..5a478a8 100644
--- a/Source/WebCore/xml/XPathExpression.h
+++ b/Source/WebCore/xml/XPathExpression.h
@@ -26,8 +26,7 @@
 
 #pragma once
 
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
+#include "ExceptionOr.h"
 
 namespace WebCore {
 
@@ -36,17 +35,15 @@
 class XPathResult;
 
 namespace XPath {
-    class Expression;
+class Expression;
 }
 
-using ExceptionCode = int;
-
 class XPathExpression : public RefCounted<XPathExpression> {
 public:
-    static RefPtr<XPathExpression> createExpression(const String& expression, RefPtr<XPathNSResolver>&&, ExceptionCode&);
+    static ExceptionOr<Ref<XPathExpression>> createExpression(const String& expression, RefPtr<XPathNSResolver>&&);
     WEBCORE_EXPORT ~XPathExpression();
 
-    WEBCORE_EXPORT RefPtr<XPathResult> evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionCode&);
+    WEBCORE_EXPORT ExceptionOr<Ref<XPathResult>> evaluate(Node* contextNode, unsigned short type, XPathResult*);
 
 private:
     explicit XPathExpression(std::unique_ptr<XPath::Expression>);