Title: [207541] trunk/Source
Revision
207541
Author
da...@apple.com
Date
2016-10-19 09:57:31 -0700 (Wed, 19 Oct 2016)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207540 => 207541)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,3 +1,63 @@
+2016-10-19  Darin Adler  <da...@apple.com>
+
+        Move XPath from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163656
+
+        Reviewed by Chris Dumez.
+
+        * 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.
+
 2016-10-19  Nan Wang  <n_w...@apple.com>
 
         AX: [Mac] Meter element should use AXValueDescription to descrbe the status of the value

Modified: trunk/Source/WebCore/dom/Document.cpp (207540 => 207541)


--- trunk/Source/WebCore/dom/Document.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -5117,14 +5117,14 @@
 
 #endif
 
-RefPtr<XPathExpression> Document::createExpression(const String& _expression_, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
+ExceptionOr<Ref<XPathExpression>> Document::createExpression(const String& _expression_, RefPtr<XPathNSResolver>&& resolver)
 {
     if (!m_xpathEvaluator)
         m_xpathEvaluator = XPathEvaluator::create();
-    return m_xpathEvaluator->createExpression(_expression_, WTFMove(resolver), ec);
+    return m_xpathEvaluator->createExpression(_expression_, WTFMove(resolver));
 }
 
-RefPtr<XPathNSResolver> Document::createNSResolver(Node* nodeResolver)
+Ref<XPathNSResolver> Document::createNSResolver(Node* nodeResolver)
 {
     if (!m_xpathEvaluator)
         m_xpathEvaluator = XPathEvaluator::create();
@@ -5131,11 +5131,11 @@
     return m_xpathEvaluator->createNSResolver(nodeResolver);
 }
 
-RefPtr<XPathResult> Document::evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result, ExceptionCode& ec)
+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();
-    return m_xpathEvaluator->evaluate(_expression_, contextNode, WTFMove(resolver), type, result, ec);
+    return m_xpathEvaluator->evaluate(_expression_, contextNode, WTFMove(resolver), type, result);
 }
 
 static bool shouldInheritSecurityOriginFromOwner(const URL& url)

Modified: trunk/Source/WebCore/dom/Document.h (207540 => 207541)


--- trunk/Source/WebCore/dom/Document.h	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/dom/Document.h	2016-10-19 16:57:31 UTC (rev 207541)
@@ -32,6 +32,7 @@
 #include "ContainerNode.h"
 #include "DocumentEventQueue.h"
 #include "DocumentTiming.h"
+#include "ExceptionOr.h"
 #include "FocusDirection.h"
 #include "FontSelectorClient.h"
 #include "MediaProducer.h"
@@ -943,9 +944,9 @@
     uint64_t domTreeVersion() const { return m_domTreeVersion; }
 
     // XPathEvaluator methods
-    WEBCORE_EXPORT RefPtr<XPathExpression> createExpression(const String& _expression_, RefPtr<XPathNSResolver>&&, ExceptionCode&);
-    WEBCORE_EXPORT RefPtr<XPathNSResolver> createNSResolver(Node* nodeResolver);
-    WEBCORE_EXPORT RefPtr<XPathResult> evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*, ExceptionCode&);
+    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*);
 
     enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
 

Modified: trunk/Source/WebCore/dom/Document.idl (207540 => 207541)


--- trunk/Source/WebCore/dom/Document.idl	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/dom/Document.idl	2016-10-19 16:57:31 UTC (rev 207541)
@@ -76,12 +76,11 @@
     readonly attribute DOMString contentType;
 
     // FIXME: Using "undefined" as default parameter value is wrong.
-    [MayThrowLegacyException] XPathExpression createExpression(optional DOMString _expression_ = "undefined", optional XPathNSResolver? resolver);
+    [MayThrowException] XPathExpression createExpression(optional DOMString _expression_ = "undefined", optional XPathNSResolver? resolver);
     XPathNSResolver createNSResolver(Node? nodeResolver);
 
     // FIXME: Using "undefined" as default parameter value is wrong.
-    [MayThrowLegacyException] XPathResult evaluate(optional DOMString _expression_ = "undefined", optional Node? contextNode, optional XPathNSResolver? resolver,
-        optional unsigned short type = 0, optional XPathResult? inResult);
+    [MayThrowException] XPathResult evaluate(optional DOMString _expression_ = "undefined", optional Node? contextNode, optional XPathNSResolver? resolver, optional unsigned short type = 0, optional XPathResult? inResult);
 
     // FIXME: The default value for the last parameter should be the empty string.
     boolean execCommand(DOMString command, optional boolean userInterface = false, optional DOMString? value = null);

Modified: trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp (207540 => 207541)


--- trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -132,19 +132,21 @@
 
 void InspectorNodeFinder::searchUsingXPath(Node* parentNode)
 {
-    ExceptionCode ec = 0;
-    RefPtr<XPathResult> result = parentNode->document().evaluate(m_whitespaceTrimmedQuery, parentNode, nullptr, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE, nullptr, ec);
-    if (ec || !result)
+    auto evaluateResult = parentNode->document().evaluate(m_whitespaceTrimmedQuery, parentNode, nullptr, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE, nullptr);
+    if (evaluateResult.hasException())
         return;
+    auto result = evaluateResult.releaseReturnValue();
 
-    unsigned long size = result->snapshotLength(ec);
-    if (ec)
+    auto snapshotLengthResult = result->snapshotLength();
+    if (snapshotLengthResult.hasException())
         return;
+    unsigned size = snapshotLengthResult.releaseReturnValue();
 
-    for (unsigned long i = 0; i < size; ++i) {
-        Node* node = result->snapshotItem(i, ec);
-        if (ec)
+    for (unsigned i = 0; i < size; ++i) {
+        auto snapshotItemResult = result->snapshotItem(i);
+        if (snapshotItemResult.hasException())
             return;
+        Node* node = snapshotItemResult.releaseReturnValue();
 
         if (is<Attr>(*node))
             node = downcast<Attr>(*node).ownerElement();

Modified: trunk/Source/WebCore/xml/DOMParser.cpp (207540 => 207541)


--- trunk/Source/WebCore/xml/DOMParser.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/DOMParser.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -21,27 +21,24 @@
 
 #include "DOMImplementation.h"
 #include "ExceptionCode.h"
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-DOMParser::DOMParser(Document& contextDocument)
+inline DOMParser::DOMParser(Document& contextDocument)
     : m_contextDocument(contextDocument.createWeakPtr())
 {
 }
 
-RefPtr<Document> DOMParser::parseFromString(const String& string, const String& contentType, ExceptionCode& ec)
+Ref<DOMParser> DOMParser::create(Document& contextDocument)
 {
-    if (contentType != "text/html"
-        && contentType != "text/xml"
-        && contentType != "application/xml"
-        && contentType != "application/xhtml+xml"
-        && contentType != "image/svg+xml") {
-        ec = TypeError;
-        return nullptr;
-    }
+    return adoptRef(*new DOMParser(contextDocument));
+}
 
-    Ref<Document> document = DOMImplementation::createDocument(contentType, nullptr, URL());
+ExceptionOr<Ref<Document>> DOMParser::parseFromString(const String& string, const String& contentType)
+{
+    if (contentType != "text/html" && contentType != "text/xml" && contentType != "application/xml" && contentType != "application/xhtml+xml" && contentType != "image/svg+xml")
+        return Exception { TypeError };
+    auto document = DOMImplementation::createDocument(contentType, nullptr, URL { });
     if (m_contextDocument)
         document->setContextDocument(*m_contextDocument.get());
     document->setContent(string);

Modified: trunk/Source/WebCore/xml/DOMParser.h (207540 => 207541)


--- trunk/Source/WebCore/xml/DOMParser.h	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/DOMParser.h	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2003, 2006 Apple Inc.
+ *  Copyright (C) 2003, 2006 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -16,28 +16,20 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef DOMParser_h
-#define DOMParser_h
+#pragma once
 
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include "ExceptionOr.h"
 #include <wtf/WeakPtr.h>
 
 namespace WebCore {
-typedef int ExceptionCode;
 
 class Document;
 
 class DOMParser : public RefCounted<DOMParser> {
 public:
-    static Ref<DOMParser> create(Document& contextDocument)
-    {
-        return adoptRef(*new DOMParser(contextDocument));
-    }
+    static Ref<DOMParser> create(Document& contextDocument);
+    ExceptionOr<Ref<Document>> parseFromString(const String&, const String& contentType);
 
-    RefPtr<Document> parseFromString(const String&, const String& contentType, ExceptionCode&);
-
 private:
     explicit DOMParser(Document& contextDocument);
 
@@ -45,5 +37,3 @@
 };
 
 }
-
-#endif // XMLSerializer.h

Modified: trunk/Source/WebCore/xml/DOMParser.idl (207540 => 207541)


--- trunk/Source/WebCore/xml/DOMParser.idl	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/DOMParser.idl	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Inc.
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -22,5 +22,5 @@
     ConstructorCallWith=Document,
     ImplementationLacksVTable,
 ] interface DOMParser {
-    [MayThrowLegacyException, NewObject] Document parseFromString(DOMString str, DOMString contentType);
+    [MayThrowException, NewObject] Document parseFromString(DOMString string, DOMString contentType);
 };

Modified: trunk/Source/WebCore/xml/XPathEvaluator.cpp (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathEvaluator.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathEvaluator.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -37,9 +37,9 @@
 
 using namespace XPath;
 
-RefPtr<XPathExpression> XPathEvaluator::createExpression(const String& _expression_, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
+ExceptionOr<Ref<XPathExpression>> XPathEvaluator::createExpression(const String& _expression_, RefPtr<XPathNSResolver>&& resolver)
 {
-    return XPathExpression::createExpression(_expression_, WTFMove(resolver), ec);
+    return XPathExpression::createExpression(_expression_, WTFMove(resolver));
 }
 
 Ref<XPathNSResolver> XPathEvaluator::createNSResolver(Node* nodeResolver)
@@ -47,19 +47,16 @@
     return NativeXPathNSResolver::create(nodeResolver);
 }
 
-RefPtr<XPathResult> XPathEvaluator::evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result, ExceptionCode& ec)
+ExceptionOr<Ref<XPathResult>> XPathEvaluator::evaluate(const String& _expression_, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result)
 {
-    if (!isValidContextNode(contextNode)) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
+    if (!isValidContextNode(contextNode))
+        return Exception { NOT_SUPPORTED_ERR };
 
-    ec = 0;
-    RefPtr<XPathExpression> expr = createExpression(_expression_, WTFMove(resolver), ec);
-    if (ec)
-        return nullptr;
-    
-    return expr->evaluate(contextNode, type, result, ec);
+    auto createResult = createExpression(_expression_, WTFMove(resolver));
+    if (createResult.hasException())
+        return createResult.releaseException();
+
+    return createResult.releaseReturnValue()->evaluate(contextNode, type, result);
 }
 
 }

Modified: trunk/Source/WebCore/xml/XPathEvaluator.h (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathEvaluator.h	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathEvaluator.h	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,6 +1,6 @@
 /*
  * Copyright 2005 Frerich Raabe <ra...@kde.org>
- * Copyright (C) 2006 Apple Inc.
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -24,35 +24,27 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef XPathEvaluator_h
-#define XPathEvaluator_h
+#pragma once
 
-#include <wtf/Forward.h>
-#include <wtf/Ref.h>
-#include <wtf/RefCounted.h>
+#include "ExceptionOr.h"
 
 namespace WebCore {
 
-    typedef int ExceptionCode;
+class Node;
+class XPathExpression;
+class XPathNSResolver;
+class XPathResult;
 
-    class Node;
-    class XPathExpression;
-    class XPathNSResolver;
-    class XPathResult;
+class XPathEvaluator : public RefCounted<XPathEvaluator> {
+public:
+    static Ref<XPathEvaluator> create() { return adoptRef(*new XPathEvaluator); }
 
-    class XPathEvaluator : public RefCounted<XPathEvaluator> {
-    public:
-        static Ref<XPathEvaluator> create() { return adoptRef(*new XPathEvaluator); }
-        
-        RefPtr<XPathExpression> createExpression(const String& _expression_, RefPtr<XPathNSResolver>&&, ExceptionCode&);
-        Ref<XPathNSResolver> createNSResolver(Node* nodeResolver);
-        RefPtr<XPathResult> evaluate(const String& _expression_, Node* contextNode,
-            RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*, ExceptionCode&);
+    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*);
 
-    private:
-        XPathEvaluator() { }
-    };
+private:
+    XPathEvaluator() = default;
+};
 
 }
-
-#endif // XPathEvaluator_h

Modified: trunk/Source/WebCore/xml/XPathEvaluator.idl (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathEvaluator.idl	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathEvaluator.idl	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Apple Inc.
+ * Copyright (C) 2006 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -22,14 +22,10 @@
     ImplementationLacksVTable,
 ] interface XPathEvaluator {
     // FIXME: Using "undefined" as default parameter value is wrong.
-    [MayThrowLegacyException] XPathExpression createExpression(optional DOMString _expression_ = "undefined", optional XPathNSResolver? resolver);
+    [MayThrowException] XPathExpression createExpression(optional DOMString _expression_ = "undefined", optional XPathNSResolver? resolver);
 
     XPathNSResolver createNSResolver(optional Node? nodeResolver);
 
     // FIXME: Using "undefined" as default parameter value is wrong.
-    [MayThrowLegacyException] XPathResult evaluate(optional DOMString _expression_ = "undefined",
-                         optional Node? contextNode,
-                         optional XPathNSResolver? resolver,
-                         optional unsigned short type = 0,
-                         optional XPathResult? inResult);
+    [MayThrowException] XPathResult evaluate(optional DOMString _expression_ = "undefined", optional Node? contextNode, optional XPathNSResolver? resolver, optional unsigned short type = 0, optional XPathResult? inResult);
 };

Modified: trunk/Source/WebCore/xml/XPathExpression.cpp (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathExpression.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathExpression.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -34,7 +34,6 @@
 #include "XPathParser.h"
 #include "XPathResult.h"
 #include "XPathUtil.h"
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -45,13 +44,13 @@
 {
 }
 
-RefPtr<XPathExpression> XPathExpression::createExpression(const String& _expression_, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
+ExceptionOr<Ref<XPathExpression>> XPathExpression::createExpression(const String& _expression_, RefPtr<XPathNSResolver>&& resolver)
 {
-    auto parsedExpression = Parser::parseStatement(_expression_, WTFMove(resolver), ec);
-    if (!parsedExpression)
-        return nullptr;
+    auto parseResult = Parser::parseStatement(_expression_, WTFMove(resolver));
+    if (parseResult.hasException())
+        return parseResult.releaseException();
 
-    return adoptRef(*new XPathExpression(WTFMove(parsedExpression)));
+    return adoptRef(*new XPathExpression(parseResult.releaseReturnValue()));
 }
 
 XPathExpression::~XPathExpression()
@@ -58,12 +57,11 @@
 {
 }
 
-RefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionCode& ec)
+// FIXME: Why does this take an XPathResult that it ignores?
+ExceptionOr<Ref<XPathResult>> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*)
 {
-    if (!isValidContextNode(contextNode)) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
+    if (!isValidContextNode(contextNode))
+        return Exception { NOT_SUPPORTED_ERR };
 
     EvaluationContext& evaluationContext = _expression_::evaluationContext();
     evaluationContext.node = contextNode;
@@ -70,24 +68,22 @@
     evaluationContext.size = 1;
     evaluationContext.position = 1;
     evaluationContext.hadTypeConversionError = false;
-    RefPtr<XPathResult> 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) {
         // It is not specified what to do if type conversion fails while evaluating an _expression_, and INVALID_EXPRESSION_ERR is not exactly right
         // when the failure happens in an otherwise valid _expression_ because of a variable. But XPathEvaluator does not support variables, so it's close enough.
-        ec = XPathException::INVALID_EXPRESSION_ERR;
-        return nullptr;
+        return Exception { XPathException::INVALID_EXPRESSION_ERR };
     }
 
     if (type != XPathResult::ANY_TYPE) {
-        ec = 0;
-        result->convertTo(type, ec);
-        if (ec)
-            return nullptr;
+        auto convertToResult = result->convertTo(type);
+        if (convertToResult.hasException())
+            return convertToResult.releaseException();
     }
 
-    return result;
+    return WTFMove(result);
 }
 
 }

Modified: trunk/Source/WebCore/xml/XPathExpression.h (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathExpression.h	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathExpression.h	2016-10-19 16:57:31 UTC (rev 207541)
@@ -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_>);

Modified: trunk/Source/WebCore/xml/XPathExpression.idl (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathExpression.idl	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathExpression.idl	2016-10-19 16:57:31 UTC (rev 207541)
@@ -22,5 +22,5 @@
     ExportToWrappedFunction,
     ImplementationLacksVTable,
 ] interface XPathExpression {
-    [MayThrowLegacyException] XPathResult evaluate(optional Node? contextNode = null, optional unsigned short type = 0, optional XPathResult? inResult = null);
+    [MayThrowException] XPathResult evaluate(optional Node? contextNode = null, optional unsigned short type = 0, optional XPathResult? inResult = null);
 };

Modified: trunk/Source/WebCore/xml/XPathGrammar.y (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathGrammar.y	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathGrammar.y	2016-10-19 16:57:31 UTC (rev 207541)
@@ -32,6 +32,7 @@
 #include "XPathFunctions.h"
 #include "XPathParser.h"
 #include "XPathPath.h"
+#include "XPathStep.h"
 #include "XPathVariableReference.h"
 
 #if COMPILER(MSVC)

Modified: trunk/Source/WebCore/xml/XPathParser.cpp (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathParser.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathParser.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -33,6 +33,7 @@
 #include "XPathException.h"
 #include "XPathNSResolver.h"
 #include "XPathPath.h"
+#include "XPathStep.h"
 #include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/StringHash.h>
@@ -402,9 +403,6 @@
 Parser::Parser(const String& statement, RefPtr<XPathNSResolver>&& resolver)
     : m_data(statement)
     , m_resolver(WTFMove(resolver))
-    , m_nextPos(0)
-    , m_lastTokenType(0)
-    , m_sawNamespaceError(false)
 {
 }
 
@@ -452,25 +450,20 @@
         localName = qualifiedName.substring(colon + 1);
     } else
         localName = qualifiedName;
-
     return true;
 }
 
-std::unique_ptr<_expression_> Parser::parseStatement(const String& statement, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
+ExceptionOr<std::unique_ptr<_expression_>> Parser::parseStatement(const String& statement, RefPtr<XPathNSResolver>&& resolver)
 {
-    Parser parser(statement, WTFMove(resolver));
+    Parser parser { statement, WTFMove(resolver) };
 
     int parseError = xpathyyparse(parser);
 
-    if (parser.m_sawNamespaceError) {
-        ec = NAMESPACE_ERR;
-        return nullptr;
-    }
+    if (parser.m_sawNamespaceError)
+        return Exception { NAMESPACE_ERR };
 
-    if (parseError) {
-        ec = XPathException::INVALID_EXPRESSION_ERR;
-        return nullptr;
-    }
+    if (parseError)
+        return Exception { XPathException::INVALID_EXPRESSION_ERR };
 
     return WTFMove(parser.m_result);
 }

Modified: trunk/Source/WebCore/xml/XPathParser.h (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathParser.h	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathParser.h	2016-10-19 16:57:31 UTC (rev 207541)
@@ -24,10 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef XPathParser_h
-#define XPathParser_h
+#pragma once
 
-#include "XPathStep.h"
+#include "ExceptionOr.h"
 #include "XPathPredicate.h"
 
 union YYSTYPE;
@@ -34,54 +33,49 @@
 
 namespace WebCore {
 
-    typedef int ExceptionCode;
+class XPathNSResolver;
 
-    class XPathNSResolver;
+namespace XPath {
 
-    namespace XPath {
+class Parser {
+    WTF_MAKE_NONCOPYABLE(Parser);
+public:
+    static ExceptionOr<std::unique_ptr<_expression_>> parseStatement(const String& statement, RefPtr<XPathNSResolver>&&);
 
-        class Parser {
-            WTF_MAKE_NONCOPYABLE(Parser);
-        public:
-            static std::unique_ptr<_expression_> parseStatement(const String& statement, RefPtr<XPathNSResolver>&&, ExceptionCode&);
+    int lex(YYSTYPE&);
+    bool expandQualifiedName(const String& qualifiedName, String& localName, String& namespaceURI);
+    void setParseResult(std::unique_ptr<_expression_>&& _expression_) { m_result = WTFMove(_expression_); }
 
-            int lex(YYSTYPE&);
-            bool expandQualifiedName(const String& qualifiedName, String& localName, String& namespaceURI);
-            void setParseResult(std::unique_ptr<_expression_> _expression_) { m_result = WTFMove(_expression_); }
+private:
+    Parser(const String&, RefPtr<XPathNSResolver>&&);
 
-        private:
-            Parser(const String&, RefPtr<XPathNSResolver>&&);
+    struct Token;
 
-            struct Token;
+    bool isBinaryOperatorContext() const;
 
-            bool isBinaryOperatorContext() const;
+    void skipWS();
+    Token makeTokenAndAdvance(int type, int advance = 1);
+    Token makeTokenAndAdvance(int type, NumericOp::Opcode, int advance = 1);
+    Token makeTokenAndAdvance(int type, EqTestOp::Opcode, int advance = 1);
+    char peekAheadHelper();
+    char peekCurHelper();
 
-            void skipWS();
-            Token makeTokenAndAdvance(int type, int advance = 1);
-            Token makeTokenAndAdvance(int type, NumericOp::Opcode, int advance = 1);
-            Token makeTokenAndAdvance(int type, EqTestOp::Opcode, int advance = 1);
-            char peekAheadHelper();
-            char peekCurHelper();
+    Token lexString();
+    Token lexNumber();
+    bool lexNCName(String&);
+    bool lexQName(String&);
 
-            Token lexString();
-            Token lexNumber();
-            bool lexNCName(String&);
-            bool lexQName(String&);
+    Token nextToken();
+    Token nextTokenInternal();
 
-            Token nextToken();
-            Token nextTokenInternal();
+    const String& m_data;
+    RefPtr<XPathNSResolver> m_resolver;
 
-            const String& m_data;
-            RefPtr<XPathNSResolver> m_resolver;
+    unsigned m_nextPos { 0 };
+    int m_lastTokenType { 0 };
 
-            unsigned m_nextPos;
-            int m_lastTokenType;
+    std::unique_ptr<_expression_> m_result;
+    bool m_sawNamespaceError { false };
+};
 
-            std::unique_ptr<_expression_> m_result;
-            bool m_sawNamespaceError;
-        };
-
-    }
-}
-
-#endif
+} }

Modified: trunk/Source/WebCore/xml/XPathResult.cpp (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathResult.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathResult.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -36,10 +36,8 @@
 
 using namespace XPath;
 
-XPathResult::XPathResult(Document* document, const Value& value)
+XPathResult::XPathResult(Document& document, const Value& value)
     : m_value(value)
-    , m_nodeSetPosition(0)
-    , m_domTreeVersion(0)
 {
     switch (m_value.type()) {
         case Value::BooleanValue:
@@ -55,8 +53,8 @@
             m_resultType = UNORDERED_NODE_ITERATOR_TYPE;
             m_nodeSetPosition = 0;
             m_nodeSet = m_value.toNodeSet();
-            m_document = document;
-            m_domTreeVersion = document->domTreeVersion();
+            m_document = &document;
+            m_domTreeVersion = document.domTreeVersion();
             return;
     }
     ASSERT_NOT_REACHED();
@@ -66,50 +64,45 @@
 {
 }
 
-void XPathResult::convertTo(unsigned short type, ExceptionCode& ec)
+ExceptionOr<void> XPathResult::convertTo(unsigned short type)
 {
     switch (type) {
-        case ANY_TYPE:
-            break;
-        case NUMBER_TYPE:
-            m_resultType = type;
-            m_value = m_value.toNumber();
-            break;
-        case STRING_TYPE:
-            m_resultType = type;
-            m_value = m_value.toString();
-            break;
-        case BOOLEAN_TYPE:
-            m_resultType = type;
-            m_value = m_value.toBoolean();
-            break;
-        case UNORDERED_NODE_ITERATOR_TYPE:
-        case UNORDERED_NODE_SNAPSHOT_TYPE:
-        case ANY_UNORDERED_NODE_TYPE:
-        case FIRST_ORDERED_NODE_TYPE: // This is correct - singleNodeValue() will take care of ordering.
-            if (!m_value.isNodeSet()) {
-                ec = XPathException::TYPE_ERR;
-                return;
-            }
-            m_resultType = type;
-            break;
-        case ORDERED_NODE_ITERATOR_TYPE:
-            if (!m_value.isNodeSet()) {
-                ec = XPathException::TYPE_ERR;
-                return;
-            }
-            m_nodeSet.sort();
-            m_resultType = type;
-            break;
-        case ORDERED_NODE_SNAPSHOT_TYPE:
-            if (!m_value.isNodeSet()) {
-                ec = XPathException::TYPE_ERR;
-                return;
-            }
-            m_value.toNodeSet().sort();
-            m_resultType = type;
-            break;
+    case ANY_TYPE:
+        break;
+    case NUMBER_TYPE:
+        m_resultType = type;
+        m_value = m_value.toNumber();
+        break;
+    case STRING_TYPE:
+        m_resultType = type;
+        m_value = m_value.toString();
+        break;
+    case BOOLEAN_TYPE:
+        m_resultType = type;
+        m_value = m_value.toBoolean();
+        break;
+    case UNORDERED_NODE_ITERATOR_TYPE:
+    case UNORDERED_NODE_SNAPSHOT_TYPE:
+    case ANY_UNORDERED_NODE_TYPE:
+    case FIRST_ORDERED_NODE_TYPE: // This is correct - singleNodeValue() will take care of ordering.
+        if (!m_value.isNodeSet())
+            return Exception { XPathException::TYPE_ERR };
+        m_resultType = type;
+        break;
+    case ORDERED_NODE_ITERATOR_TYPE:
+        if (!m_value.isNodeSet())
+            return Exception { XPathException::TYPE_ERR };
+        m_nodeSet.sort();
+        m_resultType = type;
+        break;
+    case ORDERED_NODE_SNAPSHOT_TYPE:
+        if (!m_value.isNodeSet())
+            return Exception { XPathException::TYPE_ERR };
+        m_value.toNodeSet().sort();
+        m_resultType = type;
+        break;
     }
+    return { };
 }
 
 unsigned short XPathResult::resultType() const
@@ -117,41 +110,33 @@
     return m_resultType;
 }
 
-double XPathResult::numberValue(ExceptionCode& ec) const
+ExceptionOr<double> XPathResult::numberValue() const
 {
-    if (resultType() != NUMBER_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return 0.0;
-    }
+    if (resultType() != NUMBER_TYPE)
+        return Exception { XPathException::TYPE_ERR };
     return m_value.toNumber();
 }
 
-String XPathResult::stringValue(ExceptionCode& ec) const
+ExceptionOr<String> XPathResult::stringValue() const
 {
-    if (resultType() != STRING_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return String();
-    }
+    if (resultType() != STRING_TYPE)
+        return Exception { XPathException::TYPE_ERR };
     return m_value.toString();
 }
 
-bool XPathResult::booleanValue(ExceptionCode& ec) const
+ExceptionOr<bool> XPathResult::booleanValue() const
 {
-    if (resultType() != BOOLEAN_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return false;
-    }
+    if (resultType() != BOOLEAN_TYPE)
+        return Exception { XPathException::TYPE_ERR };
     return m_value.toBoolean();
 }
 
-Node* XPathResult::singleNodeValue(ExceptionCode& ec) const
+ExceptionOr<Node*> XPathResult::singleNodeValue() const
 {
-    if (resultType() != ANY_UNORDERED_NODE_TYPE && resultType() != FIRST_ORDERED_NODE_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return 0;
-    }
-  
-    const NodeSet& nodes = m_value.toNodeSet();
+    if (resultType() != ANY_UNORDERED_NODE_TYPE && resultType() != FIRST_ORDERED_NODE_TYPE)
+        return Exception { XPathException::TYPE_ERR };
+
+    auto& nodes = m_value.toNodeSet();
     if (resultType() == FIRST_ORDERED_NODE_TYPE)
         return nodes.firstNode();
     else
@@ -167,49 +152,37 @@
     return m_document->domTreeVersion() != m_domTreeVersion;
 }
 
-unsigned XPathResult::snapshotLength(ExceptionCode& ec) const
+ExceptionOr<unsigned> XPathResult::snapshotLength() const
 {
-    if (resultType() != UNORDERED_NODE_SNAPSHOT_TYPE && resultType() != ORDERED_NODE_SNAPSHOT_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return 0;
-    }
+    if (resultType() != UNORDERED_NODE_SNAPSHOT_TYPE && resultType() != ORDERED_NODE_SNAPSHOT_TYPE)
+        return Exception { XPathException::TYPE_ERR };
 
     return m_value.toNodeSet().size();
 }
 
-Node* XPathResult::iterateNext(ExceptionCode& ec)
+ExceptionOr<Node*> XPathResult::iterateNext()
 {
-    if (resultType() != UNORDERED_NODE_ITERATOR_TYPE && resultType() != ORDERED_NODE_ITERATOR_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return 0;
-    }
-    
-    if (invalidIteratorState()) {
-        ec = INVALID_STATE_ERR;
-        return 0;
-    }
-    
-    if (m_nodeSetPosition + 1 > m_nodeSet.size())
-        return 0;
+    if (resultType() != UNORDERED_NODE_ITERATOR_TYPE && resultType() != ORDERED_NODE_ITERATOR_TYPE)
+        return Exception { XPathException::TYPE_ERR };
 
-    Node* node = m_nodeSet[m_nodeSetPosition];
-    
-    m_nodeSetPosition++;
+    if (invalidIteratorState())
+        return Exception { INVALID_STATE_ERR };
 
-    return node;
+    if (m_nodeSetPosition >= m_nodeSet.size())
+        return nullptr;
+
+    return m_nodeSet[m_nodeSetPosition++];
 }
 
-Node* XPathResult::snapshotItem(unsigned index, ExceptionCode& ec)
+ExceptionOr<Node*> XPathResult::snapshotItem(unsigned index)
 {
-    if (resultType() != UNORDERED_NODE_SNAPSHOT_TYPE && resultType() != ORDERED_NODE_SNAPSHOT_TYPE) {
-        ec = XPathException::TYPE_ERR;
-        return 0;
-    }
-    
-    const NodeSet& nodes = m_value.toNodeSet();
+    if (resultType() != UNORDERED_NODE_SNAPSHOT_TYPE && resultType() != ORDERED_NODE_SNAPSHOT_TYPE)
+        return Exception { XPathException::TYPE_ERR };
+
+    auto& nodes = m_value.toNodeSet();
     if (index >= nodes.size())
-        return 0;
-    
+        return nullptr;
+
     return nodes[index];
 }
 

Modified: trunk/Source/WebCore/xml/XPathResult.h (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathResult.h	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathResult.h	2016-10-19 16:57:31 UTC (rev 207541)
@@ -26,60 +26,54 @@
 
 #pragma once
 
+#include "ExceptionOr.h"
 #include "XPathValue.h"
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-    typedef int ExceptionCode;
+class XPathResult : public RefCounted<XPathResult> {
+public:
+    enum XPathResultType {
+        ANY_TYPE = 0,
+        NUMBER_TYPE = 1,
+        STRING_TYPE = 2,
+        BOOLEAN_TYPE = 3,
+        UNORDERED_NODE_ITERATOR_TYPE = 4,
+        ORDERED_NODE_ITERATOR_TYPE = 5,
+        UNORDERED_NODE_SNAPSHOT_TYPE = 6,
+        ORDERED_NODE_SNAPSHOT_TYPE = 7,
+        ANY_UNORDERED_NODE_TYPE = 8,
+        FIRST_ORDERED_NODE_TYPE = 9
+    };
 
-    class Document;
-    class Node;
+    static Ref<XPathResult> create(Document& document, const XPath::Value& value) { return adoptRef(*new XPathResult(document, value)); }
+    WEBCORE_EXPORT ~XPathResult();
 
-    class XPathResult : public RefCounted<XPathResult> {
-    public:
-        enum XPathResultType {
-            ANY_TYPE = 0,
-            NUMBER_TYPE = 1,
-            STRING_TYPE = 2,
-            BOOLEAN_TYPE = 3,
-            UNORDERED_NODE_ITERATOR_TYPE = 4,
-            ORDERED_NODE_ITERATOR_TYPE = 5,
-            UNORDERED_NODE_SNAPSHOT_TYPE = 6,
-            ORDERED_NODE_SNAPSHOT_TYPE = 7,
-            ANY_UNORDERED_NODE_TYPE = 8,
-            FIRST_ORDERED_NODE_TYPE = 9
-        };
-        
-        static Ref<XPathResult> create(Document* document, const XPath::Value& value) { return adoptRef(*new XPathResult(document, value)); }
-        WEBCORE_EXPORT ~XPathResult();
-        
-        void convertTo(unsigned short type, ExceptionCode&);
+    ExceptionOr<void> convertTo(unsigned short type);
 
-        WEBCORE_EXPORT unsigned short resultType() const;
+    WEBCORE_EXPORT unsigned short resultType() const;
 
-        WEBCORE_EXPORT double numberValue(ExceptionCode&) const;
-        WEBCORE_EXPORT String stringValue(ExceptionCode&) const;
-        WEBCORE_EXPORT bool booleanValue(ExceptionCode&) const;
-        WEBCORE_EXPORT Node* singleNodeValue(ExceptionCode&) const;
+    WEBCORE_EXPORT ExceptionOr<double> numberValue() const;
+    WEBCORE_EXPORT ExceptionOr<String> stringValue() const;
+    WEBCORE_EXPORT ExceptionOr<bool> booleanValue() const;
+    WEBCORE_EXPORT ExceptionOr<Node*> singleNodeValue() const;
 
-        WEBCORE_EXPORT bool invalidIteratorState() const;
-        WEBCORE_EXPORT unsigned snapshotLength(ExceptionCode&) const;
-        WEBCORE_EXPORT Node* iterateNext(ExceptionCode&);
-        WEBCORE_EXPORT Node* snapshotItem(unsigned index, ExceptionCode&);
+    WEBCORE_EXPORT bool invalidIteratorState() const;
+    WEBCORE_EXPORT ExceptionOr<unsigned> snapshotLength() const;
+    WEBCORE_EXPORT ExceptionOr<Node*> iterateNext();
+    WEBCORE_EXPORT ExceptionOr<Node*> snapshotItem(unsigned index);
 
-        const XPath::Value& value() const { return m_value; }
+    const XPath::Value& value() const { return m_value; }
 
-    private:
-        XPathResult(Document*, const XPath::Value&);
-        
-        XPath::Value m_value;
-        unsigned m_nodeSetPosition;
-        XPath::NodeSet m_nodeSet; // FIXME: why duplicate the node set stored in m_value?
-        unsigned short m_resultType;
-        RefPtr<Document> m_document;
-        uint64_t m_domTreeVersion;
-    };
+private:
+    XPathResult(Document&, const XPath::Value&);
 
+    XPath::Value m_value;
+    unsigned m_nodeSetPosition { 0 };
+    XPath::NodeSet m_nodeSet; // FIXME: why duplicate the node set stored in m_value?
+    unsigned short m_resultType;
+    RefPtr<Document> m_document;
+    uint64_t m_domTreeVersion { 0 };
+};
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/xml/XPathResult.idl (207540 => 207541)


--- trunk/Source/WebCore/xml/XPathResult.idl	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebCore/xml/XPathResult.idl	2016-10-19 16:57:31 UTC (rev 207541)
@@ -34,14 +34,14 @@
     const unsigned short FIRST_ORDERED_NODE_TYPE = 9;
 
     readonly attribute unsigned short resultType;
-    [GetterMayThrowLegacyException] readonly attribute unrestricted double numberValue;
-    [GetterMayThrowLegacyException] readonly attribute DOMString stringValue;
-    [GetterMayThrowLegacyException] readonly attribute boolean booleanValue;
-    [GetterMayThrowLegacyException] readonly attribute Node singleNodeValue;
+    [GetterMayThrowException] readonly attribute unrestricted double numberValue;
+    [GetterMayThrowException] readonly attribute DOMString stringValue;
+    [GetterMayThrowException] readonly attribute boolean booleanValue;
+    [GetterMayThrowException] readonly attribute Node singleNodeValue;
 
     readonly attribute boolean invalidIteratorState;
-    [GetterMayThrowLegacyException] readonly attribute unsigned long snapshotLength;
+    [GetterMayThrowException] readonly attribute unsigned long snapshotLength;
 
-    [MayThrowLegacyException] Node iterateNext();
-    [MayThrowLegacyException] Node snapshotItem(optional unsigned long index = 0);
+    [MayThrowException] Node iterateNext();
+    [MayThrowException] Node snapshotItem(optional unsigned long index = 0);
 };

Modified: trunk/Source/WebKit/mac/ChangeLog (207540 => 207541)


--- trunk/Source/WebKit/mac/ChangeLog	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,3 +1,25 @@
+2016-10-19  Darin Adler  <da...@apple.com>
+
+        Move XPath from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163656
+
+        Reviewed by Chris Dumez.
+
+        * 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.
+
 2016-10-18  Sam Weinig  <s...@webkit.org>
 
         Replace std::experimental::variant with WTF::Variant (or similar)

Modified: trunk/Source/WebKit/mac/DOM/DOMDocument.mm (207540 => 207541)


--- trunk/Source/WebKit/mac/DOM/DOMDocument.mm	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit/mac/DOM/DOMDocument.mm	2016-10-19 16:57:31 UTC (rev 207541)
@@ -612,23 +612,19 @@
     return kit(WTF::getPtr(IMPL->getOverrideStyle(core(element), pseudoElement)));
 }
 
+static RefPtr<WebCore::XPathNSResolver> wrap(id <DOMXPathNSResolver> resolver)
+{
+    if (!resolver)
+        return nullptr;
+    if ([resolver isMemberOfClass:[DOMNativeXPathNSResolver class]])
+        return core(static_cast<DOMNativeXPathNSResolver *>(resolver));
+    return DOMCustomXPathNSResolver::create(resolver);
+}
+
 - (DOMXPathExpression *)createExpression:(NSString *)_expression_ resolver:(id <DOMXPathNSResolver>)resolver
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::XPathNSResolver* nativeResolver = 0;
-    RefPtr<WebCore::XPathNSResolver> customResolver;
-    if (resolver) {
-        if ([resolver isMemberOfClass:[DOMNativeXPathNSResolver class]])
-            nativeResolver = core(static_cast<DOMNativeXPathNSResolver *>(resolver));
-        else {
-            customResolver = DOMCustomXPathNSResolver::create(resolver);
-            nativeResolver = WTF::getPtr(customResolver);
-        }
-    }
-    WebCore::ExceptionCode ec = 0;
-    DOMXPathExpression *result = kit(WTF::getPtr(IMPL->createExpression(_expression_, WTF::getPtr(nativeResolver), ec)));
-    raiseOnDOMError(ec);
-    return result;
+    return kit(raiseOnDOMError(IMPL->createExpression(_expression_, wrap(resolver))).ptr());
 }
 
 - (id <DOMXPathNSResolver>)createNSResolver:(DOMNode *)nodeResolver
@@ -640,20 +636,7 @@
 - (DOMXPathResult *)evaluate:(NSString *)_expression_ contextNode:(DOMNode *)contextNode resolver:(id <DOMXPathNSResolver>)resolver type:(unsigned short)type inResult:(DOMXPathResult *)inResult
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::XPathNSResolver* nativeResolver = 0;
-    RefPtr<WebCore::XPathNSResolver> customResolver;
-    if (resolver) {
-        if ([resolver isMemberOfClass:[DOMNativeXPathNSResolver class]])
-            nativeResolver = core(static_cast<DOMNativeXPathNSResolver *>(resolver));
-        else {
-            customResolver = DOMCustomXPathNSResolver::create(resolver);
-            nativeResolver = WTF::getPtr(customResolver);
-        }
-    }
-    WebCore::ExceptionCode ec = 0;
-    DOMXPathResult *result = kit(WTF::getPtr(IMPL->evaluate(_expression_, core(contextNode), WTF::getPtr(nativeResolver), type, core(inResult), ec)));
-    raiseOnDOMError(ec);
-    return result;
+    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/WebKit/mac/DOM/DOMXPathExpression.mm (207540 => 207541)


--- trunk/Source/WebKit/mac/DOM/DOMXPathExpression.mm	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit/mac/DOM/DOMXPathExpression.mm	2016-10-19 16:57:31 UTC (rev 207541)
@@ -55,10 +55,7 @@
 - (DOMXPathResult *)evaluate:(DOMNode *)contextNode type:(unsigned short)type inResult:(DOMXPathResult *)inResult
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    DOMXPathResult *result = kit(WTF::getPtr(IMPL->evaluate(core(contextNode), type, core(inResult), ec)));
-    raiseOnDOMError(ec);
-    return result;
+    return kit(raiseOnDOMError(IMPL->evaluate(core(contextNode), type, core(inResult))).ptr());
 }
 
 @end

Modified: trunk/Source/WebKit/mac/DOM/DOMXPathResult.mm (207540 => 207541)


--- trunk/Source/WebKit/mac/DOM/DOMXPathResult.mm	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit/mac/DOM/DOMXPathResult.mm	2016-10-19 16:57:31 UTC (rev 207541)
@@ -60,37 +60,25 @@
 - (double)numberValue
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    double result = IMPL->numberValue(ec);
-    raiseOnDOMError(ec);
-    return result;
+    return raiseOnDOMError(IMPL->numberValue());
 }
 
 - (NSString *)stringValue
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    NSString *result = IMPL->stringValue(ec);
-    raiseOnDOMError(ec);
-    return result;
+    return raiseOnDOMError(IMPL->stringValue());
 }
 
 - (BOOL)booleanValue
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    BOOL result = IMPL->booleanValue(ec);
-    raiseOnDOMError(ec);
-    return result;
+    return raiseOnDOMError(IMPL->booleanValue());
 }
 
 - (DOMNode *)singleNodeValue
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    DOMNode *result = kit(WTF::getPtr(IMPL->singleNodeValue(ec)));
-    raiseOnDOMError(ec);
-    return result;
+    return kit(raiseOnDOMError(IMPL->singleNodeValue()));
 }
 
 - (BOOL)invalidIteratorState
@@ -102,28 +90,19 @@
 - (unsigned)snapshotLength
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    unsigned result = IMPL->snapshotLength(ec);
-    raiseOnDOMError(ec);
-    return result;
+    return raiseOnDOMError(IMPL->snapshotLength());
 }
 
 - (DOMNode *)iterateNext
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    DOMNode *result = kit(WTF::getPtr(IMPL->iterateNext(ec)));
-    raiseOnDOMError(ec);
-    return result;
+    return kit(raiseOnDOMError(IMPL->iterateNext()));
 }
 
 - (DOMNode *)snapshotItem:(unsigned)index
 {
     WebCore::JSMainThreadNullState state;
-    WebCore::ExceptionCode ec = 0;
-    DOMNode *result = kit(WTF::getPtr(IMPL->snapshotItem(index, ec)));
-    raiseOnDOMError(ec);
-    return result;
+    return kit(raiseOnDOMError(IMPL->snapshotItem(index)));
 }
 
 @end
@@ -130,7 +109,7 @@
 
 WebCore::XPathResult* core(DOMXPathResult *wrapper)
 {
-    return wrapper ? reinterpret_cast<WebCore::XPathResult*>(wrapper->_internal) : 0;
+    return wrapper ? reinterpret_cast<WebCore::XPathResult*>(wrapper->_internal) : nullptr;
 }
 
 DOMXPathResult *kit(WebCore::XPathResult* value)

Modified: trunk/Source/WebKit2/ChangeLog (207540 => 207541)


--- trunk/Source/WebKit2/ChangeLog	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1,3 +1,24 @@
+2016-10-19  Darin Adler  <da...@apple.com>
+
+        Move XPath from ExceptionCode to Exception
+        https://bugs.webkit.org/show_bug.cgi?id=163656
+
+        Reviewed by Chris Dumez.
+
+        * 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.
+
 2016-10-19  Carlos Garcia Campos  <cgar...@igalia.com>
 
         NetworkSession: updatedRequest parameter of NetworkProcess::findPendingDownloadLocation is unused since r206988

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp (207540 => 207541)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocument.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -1169,13 +1169,13 @@
     WebCore::Document* item = WebKit::core(self);
     WTF::String convertedExpression = WTF::String::fromUTF8(_expression_);
     RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::XPathExpression> gobjectResult = WTF::getPtr(item->createExpression(convertedExpression, WTF::getPtr(convertedResolver), ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->createExpression(convertedExpression, WTFMove(convertedResolver));
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue().ptr());
 }
 
 WebKitDOMXPathNSResolver* webkit_dom_document_create_ns_resolver(WebKitDOMDocument* self, WebKitDOMNode* nodeResolver)
@@ -1203,13 +1203,13 @@
     WebCore::Node* convertedContextNode = WebKit::core(contextNode);
     RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
     WebCore::XPathResult* convertedInResult = WebKit::core(inResult);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::XPathResult> gobjectResult = WTF::getPtr(item->evaluate(convertedExpression, convertedContextNode, WTF::getPtr(convertedResolver), type, convertedInResult, ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->evaluate(convertedExpression, convertedContextNode, WTFMove(convertedResolver), type, convertedInResult);
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue().ptr());
 }
 
 gboolean webkit_dom_document_exec_command(WebKitDOMDocument* self, const gchar* command, gboolean userInterface, const gchar* value)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp (207540 => 207541)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathExpression.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -114,12 +114,12 @@
     WebCore::XPathExpression* item = WebKit::core(self);
     WebCore::Node* convertedContextNode = WebKit::core(contextNode);
     WebCore::XPathResult* convertedInResult = WebKit::core(inResult);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::XPathResult> gobjectResult = WTF::getPtr(item->evaluate(convertedContextNode, type, convertedInResult, ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->evaluate(convertedContextNode, type, convertedInResult);
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue().ptr());
 }
 

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathResult.cpp (207540 => 207541)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathResult.cpp	2016-10-19 16:48:41 UTC (rev 207540)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMXPathResult.cpp	2016-10-19 16:57:31 UTC (rev 207541)
@@ -224,13 +224,13 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->iterateNext(ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->iterateNext();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue());
 }
 
 WebKitDOMNode* webkit_dom_xpath_result_snapshot_item(WebKitDOMXPathResult* self, gulong index, GError** error)
@@ -239,13 +239,13 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->snapshotItem(index, ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->snapshotItem(index);
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue());
 }
 
 gushort webkit_dom_xpath_result_get_result_type(WebKitDOMXPathResult* self)
@@ -263,13 +263,13 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    gdouble result = item->numberValue(ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->numberValue();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return 0;
     }
-    return result;
+    return result.releaseReturnValue();
 }
 
 gchar* webkit_dom_xpath_result_get_string_value(WebKitDOMXPathResult* self, GError** error)
@@ -278,9 +278,10 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    gchar* result = convertToUTF8String(item->stringValue(ec));
-    return result;
+    auto result = item->stringValue();
+    if (result.hasException())
+        return nullptr;
+    return convertToUTF8String(result.releaseReturnValue());
 }
 
 gboolean webkit_dom_xpath_result_get_boolean_value(WebKitDOMXPathResult* self, GError** error)
@@ -289,13 +290,13 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), FALSE);
     g_return_val_if_fail(!error || !*error, FALSE);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    gboolean result = item->booleanValue(ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->booleanValue();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return false;
     }
-    return result;
+    return result.releaseReturnValue();
 }
 
 WebKitDOMNode* webkit_dom_xpath_result_get_single_node_value(WebKitDOMXPathResult* self, GError** error)
@@ -304,13 +305,13 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->singleNodeValue(ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->singleNodeValue();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue());
 }
 
 gboolean webkit_dom_xpath_result_get_invalid_iterator_state(WebKitDOMXPathResult* self)
@@ -328,12 +329,11 @@
     g_return_val_if_fail(WEBKIT_DOM_IS_XPATH_RESULT(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::XPathResult* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    gulong result = item->snapshotLength(ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->snapshotLength();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
     }
-    return result;
+    return result.releaseReturnValue();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to