Reduce special handling of XPathNSResolver type in the bindings
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 May 2016 04:39:13 +0000 (04:39 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 May 2016 04:39:13 +0000 (04:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157454

Reviewed by Darin Adler.

Reduce special handling of XPathNSResolver type in the bindings.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
Add new JSXPathNSResolverCustom.cpp file.

* bindings/js/JSDOMStringListCustom.cpp:
(WebCore::JSDOMStringList::toWrapped):
Take the ExecState by reference instead of pointer.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::toWrapped):
Update to take an ExecState& parameter. The bindings now pass
an ExecState to all custom toWrapped() methods for consistency
and flexibility.

* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue):
Pass an ExecState now that those toWrapped() methods expect
it.

* bindings/js/JSEventTargetCustom.cpp:
(WebCore::JSEventTarget::toWrapped):
Update to take an ExecState& parameter.

* bindings/js/JSIDBDatabaseCustom.cpp:
(WebCore::JSIDBDatabase::transaction):
Pass ExecState by reference instead of pointer.

* bindings/js/JSMessageEventCustom.cpp:
(WebCore::handleInitMessageEvent):
Pass ExecState to JSDOMWindow::toWrapped().

* bindings/js/JSXPathNSResolverCustom.cpp: Added.
(WebCore::JSXPathNSResolver::toWrapped):
Provide a custom implementation of JSXPathNSResolver::toWrapped()
instead of having the custom code in the bindings generator.

* bindings/scripts/CodeGeneratorJS.pm:
(AddIncludesForType):
Drop special includes for XPathNSResolver as they are no longer needed.

(GenerateHeader):
Drop special casing of certain types for generating the toWrapped()
declaration by:
1. Relying on GetNativeType() for the return value as certain types
   return a RefPtr instead of a raw pointer.
2. Adding an extra ExecState parameter when a custom implementation of
   toWrapped() is provided, given that some of them need it.

(GenerateParametersCheck):
Drop custom code for XPathNSResolver and use the normal code path for
this type now. The custom code now resides in the custom implementation
of JSXPathNSResolver::toWrapped(), in custom bindings.

(JSValueToNative):
- Drop NodeFilter from the nativeType hash map as it was updated to
  be a callback interface a while back.
- Add XPathNSResolver to nativeType hash map so that we now to use
  a RefPtr<> instead of a raw pointer in the bindings. We should
  probably add an IDL extended attribute for this at some point.
- Drop special casing for DOMStringList which was outdated since there
  is no toDOMStringList() function. DOMStringList has a custom
  toWrapped() function instead nowadays so we now call this one
  instead. We apparently do not have any DOMStringList parameters
  outside our bindings tests at the moment, which is why no one
  noticed.
- Pass an ExecState to toWrapped() if the interface has the
  JSCustomToNativeObject IDL extended attribute.

* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
* bindings/scripts/test/TestObj.idl:
Add bindings test coverage for having an operation with an
XPathNSResolver parameter.

* dom/Document.idl:
* xml/XPathEvaluator.idl:
Drop some unnecessary default parameter values.

* xml/XPathNSResolver.idl:
Add JSCustomToNativeObject IDL extended attribute so that we can
provide our own custom implementation of JSXPathNSResolver::toWrapped(),
instead of having the custom code in the bindings generator.

* dom/Document.cpp:
(WebCore::Document::createExpression):
(WebCore::Document::evaluate):
* dom/Document.h:
* inspector/InspectorNodeFinder.cpp:
* xml/XPathEvaluator.cpp:
(WebCore::XPathEvaluator::createExpression):
(WebCore::XPathEvaluator::evaluate):
* xml/XPathEvaluator.h:
* xml/XPathExpression.cpp:
(WebCore::XPathExpression::createExpression):
* xml/XPathExpression.h:
* xml/XPathParser.cpp:
(WebCore::XPath::Parser::Parser):
(WebCore::XPath::Parser::parseStatement):
* xml/XPathParser.h:
Take XPathNSResolver parameter as a Ref<XPathNSResolver>&& as this is
what the generated bindings now provide us, given that this sometimes
have to create a wrapper around a JSObject.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSDOMStringListCustom.cpp
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSDictionary.cpp
Source/WebCore/bindings/js/JSEventTargetCustom.cpp
Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp
Source/WebCore/bindings/js/JSMessageEventCustom.cpp
Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/inspector/InspectorNodeFinder.cpp
Source/WebCore/xml/XPathEvaluator.cpp
Source/WebCore/xml/XPathEvaluator.h
Source/WebCore/xml/XPathEvaluator.idl
Source/WebCore/xml/XPathExpression.cpp
Source/WebCore/xml/XPathExpression.h
Source/WebCore/xml/XPathNSResolver.idl
Source/WebCore/xml/XPathParser.cpp
Source/WebCore/xml/XPathParser.h

index 9f1958b..f05b70e 100644 (file)
@@ -1224,6 +1224,7 @@ set(WebCore_SOURCES
     bindings/js/JSWorkerGlobalScopeBase.cpp
     bindings/js/JSWorkerGlobalScopeCustom.cpp
     bindings/js/JSXMLHttpRequestCustom.cpp
+    bindings/js/JSXPathNSResolverCustom.cpp
     bindings/js/JSXPathResultCustom.cpp
     bindings/js/JSXSLTProcessorCustom.cpp
     bindings/js/ReadableStreamController.cpp
index 57f13a0..c52269e 100644 (file)
@@ -1,3 +1,119 @@
+2016-05-07  Chris Dumez  <cdumez@apple.com>
+
+        Reduce special handling of XPathNSResolver type in the bindings
+        https://bugs.webkit.org/show_bug.cgi?id=157454
+
+        Reviewed by Darin Adler.
+
+        Reduce special handling of XPathNSResolver type in the bindings.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        Add new JSXPathNSResolverCustom.cpp file.
+
+        * bindings/js/JSDOMStringListCustom.cpp:
+        (WebCore::JSDOMStringList::toWrapped):
+        Take the ExecState by reference instead of pointer.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::toWrapped):
+        Update to take an ExecState& parameter. The bindings now pass
+        an ExecState to all custom toWrapped() methods for consistency
+        and flexibility.
+
+        * bindings/js/JSDictionary.cpp:
+        (WebCore::JSDictionary::convertValue):
+        Pass an ExecState now that those toWrapped() methods expect
+        it.
+
+        * bindings/js/JSEventTargetCustom.cpp:
+        (WebCore::JSEventTarget::toWrapped):
+        Update to take an ExecState& parameter.
+
+        * bindings/js/JSIDBDatabaseCustom.cpp:
+        (WebCore::JSIDBDatabase::transaction):
+        Pass ExecState by reference instead of pointer.
+
+        * bindings/js/JSMessageEventCustom.cpp:
+        (WebCore::handleInitMessageEvent):
+        Pass ExecState to JSDOMWindow::toWrapped().
+
+        * bindings/js/JSXPathNSResolverCustom.cpp: Added.
+        (WebCore::JSXPathNSResolver::toWrapped):
+        Provide a custom implementation of JSXPathNSResolver::toWrapped()
+        instead of having the custom code in the bindings generator.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (AddIncludesForType):
+        Drop special includes for XPathNSResolver as they are no longer needed.
+
+        (GenerateHeader):
+        Drop special casing of certain types for generating the toWrapped()
+        declaration by:
+        1. Relying on GetNativeType() for the return value as certain types
+           return a RefPtr instead of a raw pointer.
+        2. Adding an extra ExecState parameter when a custom implementation of
+           toWrapped() is provided, given that some of them need it.
+
+        (GenerateParametersCheck):
+        Drop custom code for XPathNSResolver and use the normal code path for
+        this type now. The custom code now resides in the custom implementation
+        of JSXPathNSResolver::toWrapped(), in custom bindings.
+
+        (JSValueToNative):
+        - Drop NodeFilter from the nativeType hash map as it was updated to
+          be a callback interface a while back.
+        - Add XPathNSResolver to nativeType hash map so that we now to use
+          a RefPtr<> instead of a raw pointer in the bindings. We should
+          probably add an IDL extended attribute for this at some point.
+        - Drop special casing for DOMStringList which was outdated since there
+          is no toDOMStringList() function. DOMStringList has a custom
+          toWrapped() function instead nowadays so we now call this one
+          instead. We apparently do not have any DOMStringList parameters
+          outside our bindings tests at the moment, which is why no one
+          noticed.
+        - Pass an ExecState to toWrapped() if the interface has the
+          JSCustomToNativeObject IDL extended attribute.
+
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        * bindings/scripts/test/TestObj.idl:
+        Add bindings test coverage for having an operation with an
+        XPathNSResolver parameter.
+
+        * dom/Document.idl:
+        * xml/XPathEvaluator.idl:
+        Drop some unnecessary default parameter values.
+
+        * xml/XPathNSResolver.idl:
+        Add JSCustomToNativeObject IDL extended attribute so that we can
+        provide our own custom implementation of JSXPathNSResolver::toWrapped(),
+        instead of having the custom code in the bindings generator.
+
+        * dom/Document.cpp:
+        (WebCore::Document::createExpression):
+        (WebCore::Document::evaluate):
+        * dom/Document.h:
+        * inspector/InspectorNodeFinder.cpp:
+        * xml/XPathEvaluator.cpp:
+        (WebCore::XPathEvaluator::createExpression):
+        (WebCore::XPathEvaluator::evaluate):
+        * xml/XPathEvaluator.h:
+        * xml/XPathExpression.cpp:
+        (WebCore::XPathExpression::createExpression):
+        * xml/XPathExpression.h:
+        * xml/XPathParser.cpp:
+        (WebCore::XPath::Parser::Parser):
+        (WebCore::XPath::Parser::parseStatement):
+        * xml/XPathParser.h:
+        Take XPathNSResolver parameter as a Ref<XPathNSResolver>&& as this is
+        what the generated bindings now provide us, given that this sometimes
+        have to create a wrapper around a JSObject.
+
 2016-05-07  Darin Adler  <darin@apple.com>
 
         Fix crash introduced by the last patch.
index e44a529..cac7247 100644 (file)
                8367587F1C56E99B008A1087 /* JSHTMLDataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B86A81C56E93E00F3F0E3 /* JSHTMLDataElement.h */; };
                836BAD211BD1CA670037356A /* HTMLTableHeaderCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 836BAD1F1BD1CA670037356A /* HTMLTableHeaderCellElement.h */; };
                836BAD221BD1CA670037356A /* HTMLTableDataCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 836BAD201BD1CA670037356A /* HTMLTableDataCellElement.h */; };
+               836C14431CDEAFD80073493F /* JSXPathNSResolverCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836C14421CDEAFCA0073493F /* JSXPathNSResolverCustom.cpp */; };
                836CB1F61BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 836CB1F21BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.h */; };
                836CB1F71BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836CB1F31BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.cpp */; };
                836CB1F81BD1E41800AF1591 /* JSHTMLTableDataCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 836CB1F41BD1E41800AF1591 /* JSHTMLTableDataCellElement.h */; };
                8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NonDocumentTypeChildNode.idl; sourceTree = "<group>"; };
                836BAD1F1BD1CA670037356A /* HTMLTableHeaderCellElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableHeaderCellElement.h; sourceTree = "<group>"; };
                836BAD201BD1CA670037356A /* HTMLTableDataCellElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableDataCellElement.h; sourceTree = "<group>"; };
+               836C14421CDEAFCA0073493F /* JSXPathNSResolverCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXPathNSResolverCustom.cpp; sourceTree = "<group>"; };
                836CB1F21BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTableHeaderCellElement.h; sourceTree = "<group>"; };
                836CB1F31BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTableHeaderCellElement.cpp; sourceTree = "<group>"; };
                836CB1F41BD1E41800AF1591 /* JSHTMLTableDataCellElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTableDataCellElement.h; sourceTree = "<group>"; };
                                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
                                E1C36D320EB0A094007410BC /* JSWorkerGlobalScopeBase.cpp */,
                                E1C36D330EB0A094007410BC /* JSWorkerGlobalScopeBase.h */,
+                               836C14421CDEAFCA0073493F /* JSXPathNSResolverCustom.cpp */,
                                418C395E1C8F0AAB0051C8A3 /* ReadableStreamController.cpp */,
                                418C395F1C8F0AAB0051C8A3 /* ReadableStreamController.h */,
                                BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
                                DB23C2CB0A508D29002489EB /* IndentOutdentCommand.cpp in Sources */,
                                517138EF1BED1D1A000D5F01 /* IndexKey.cpp in Sources */,
                                51EEAA731BEFFAB100218008 /* IndexValueEntry.cpp in Sources */,
+                               836C14431CDEAFD80073493F /* JSXPathNSResolverCustom.cpp in Sources */,
                                517138F71BF128BB000D5F01 /* IndexValueStore.cpp in Sources */,
                                A8CFF5E60A155A05000A4234 /* InlineBox.cpp in Sources */,
                                B57CB52D182A3EED0079A647 /* InlineElementBox.cpp in Sources */,
index 8a9f36c..30b6fc0 100644 (file)
 #include "JSWorkerGlobalScopeBase.cpp"
 #include "JSWorkerGlobalScopeCustom.cpp"
 #include "JSXMLHttpRequestCustom.cpp"
+#include "JSXPathNSResolverCustom.cpp"
 #include "JSXPathResultCustom.cpp"
 #include "JSXSLTProcessorCustom.cpp"
 #include "ScheduledAction.cpp"
index 5bd33cb..0181de7 100644 (file)
@@ -26,7 +26,7 @@ using namespace JSC;
 
 namespace WebCore {
 
-RefPtr<DOMStringList> JSDOMStringList::toWrapped(ExecState* exec, JSValue value)
+RefPtr<DOMStringList> JSDOMStringList::toWrapped(ExecState& state, JSValue value)
 {
     if (value.inherits(JSDOMStringList::info()))
         return &jsCast<JSDOMStringList*>(asObject(value))->wrapped();
@@ -37,7 +37,7 @@ RefPtr<DOMStringList> JSDOMStringList::toWrapped(ExecState* exec, JSValue value)
     JSArray* array = asArray(value);
     RefPtr<DOMStringList> stringList = DOMStringList::create();
     for (unsigned i = 0; i < array->length(); ++i)
-        stringList->append(array->getIndex(exec, i).toString(exec)->value(exec));
+        stringList->append(array->getIndex(&state, i).toString(&state)->value(&state));
 
     return stringList;
 }
index 3b26dfd..f7ea017 100644 (file)
@@ -612,16 +612,16 @@ JSValue JSDOMWindow::setInterval(ExecState& state)
     return jsNumber(result);
 }
 
-DOMWindow* JSDOMWindow::toWrapped(JSValue value)
+DOMWindow* JSDOMWindow::toWrapped(ExecState&, JSValue value)
 {
     if (!value.isObject())
-        return 0;
+        return nullptr;
     JSObject* object = asObject(value);
     if (object->inherits(JSDOMWindow::info()))
         return &jsCast<JSDOMWindow*>(object)->wrapped();
     if (object->inherits(JSDOMWindowShell::info()))
         return &jsCast<JSDOMWindowShell*>(object)->wrapped();
-    return 0;
+    return nullptr;
 }
 
 } // namespace WebCore
index 51e045c..f27b0c6 100644 (file)
@@ -173,14 +173,14 @@ void JSDictionary::convertValue(ExecState* exec, JSValue value, RefPtr<Serialize
     result = SerializedScriptValue::create(exec, value, 0, 0);
 }
 
-void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<DOMWindow>& result)
+void JSDictionary::convertValue(ExecState* state, JSValue value, RefPtr<DOMWindow>& result)
 {
-    result = JSDOMWindow::toWrapped(value);
+    result = JSDOMWindow::toWrapped(*state, value);
 }
 
-void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<EventTarget>& result)
+void JSDictionary::convertValue(ExecState* state, JSValue value, RefPtr<EventTarget>& result)
 {
-    result = JSEventTarget::toWrapped(value);
+    result = JSEventTarget::toWrapped(*state, value);
 }
 
 void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<Node>& result)
index e57499a..4229677 100644 (file)
@@ -63,7 +63,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ
     if (value.inherits(JS##interfaceName::info()))                      \
         return &jsCast<JS##interfaceName*>(asObject(value))->wrapped();
 
-EventTarget* JSEventTarget::toWrapped(JSC::JSValue value)
+EventTarget* JSEventTarget::toWrapped(ExecState&, JSValue value)
 {
     TRY_TO_UNWRAP_WITH_INTERFACE(DOMWindowShell)
     TRY_TO_UNWRAP_WITH_INTERFACE(DOMWindow)
@@ -74,9 +74,9 @@ EventTarget* JSEventTarget::toWrapped(JSC::JSValue value)
 
 #undef TRY_TO_UNWRAP_WITH_INTERFACE
 
-std::unique_ptr<JSEventTargetWrapper> jsEventTargetCast(JSC::JSValue thisValue)
+std::unique_ptr<JSEventTargetWrapper> jsEventTargetCast(JSValue thisValue)
 {
-    if (auto* target = JSC::jsDynamicCast<JSEventTarget*>(thisValue))
+    if (auto* target = jsDynamicCast<JSEventTarget*>(thisValue))
         return std::make_unique<JSEventTargetWrapper>(target->wrapped(), *target);
     if (auto* window = toJSDOMWindow(thisValue))
         return std::make_unique<JSEventTargetWrapper>(window->wrapped(), *window);
index 4adefe0..19ff0ed 100644 (file)
@@ -94,7 +94,7 @@ JSValue JSIDBDatabase::transaction(ExecState& exec)
 
     Vector<String> scope;
     JSValue scopeArg(exec.argument(0));
-    auto domStringList = JSDOMStringList::toWrapped(&exec, scopeArg);
+    auto domStringList = JSDOMStringList::toWrapped(exec, scopeArg);
     if (exec.hadException())
         return jsUndefined();
 
index 4f32a1e..f8c1d80 100644 (file)
@@ -109,7 +109,7 @@ static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecSta
     bool cancelableArg = state.argument(2).toBoolean(&state);
     const String originArg = state.argument(4).toString(&state)->value(&state);
     const String lastEventIdArg = state.argument(5).toString(&state)->value(&state);
-    DOMWindow* sourceArg = JSDOMWindow::toWrapped(state.argument(6));
+    DOMWindow* sourceArg = JSDOMWindow::toWrapped(state, state.argument(6));
     std::unique_ptr<MessagePortArray> messagePorts;
     std::unique_ptr<ArrayBufferArray> arrayBuffers;
     if (!state.argument(7).isUndefinedOrNull()) {
diff --git a/Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp b/Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp
new file mode 100644 (file)
index 0000000..faed13a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSXPathNSResolver.h"
+
+#include "JSCustomXPathNSResolver.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+RefPtr<XPathNSResolver> JSXPathNSResolver::toWrapped(ExecState& state, JSValue value)
+{
+    if (value.inherits(JSXPathNSResolver::info()))
+        return &jsCast<JSXPathNSResolver*>(asObject(value))->wrapped();
+
+    return JSCustomXPathNSResolver::create(&state, value);
+}
+
+} // namespace WebCore
index 8d5a369..4a94c8b 100644 (file)
@@ -220,10 +220,7 @@ sub AddIncludesForType
     return if $codeGenerator->SkipIncludeHeader($type);
     
     # When we're finished with the one-file-per-class reorganization, we won't need these special cases.
-    if ($type eq "XPathNSResolver") {
-        $includesRef->{"JSXPathNSResolver.h"} = 1;
-        $includesRef->{"JSCustomXPathNSResolver.h"} = 1;
-    } elsif ($isCallback && $codeGenerator->IsWrapperType($type)) {
+    if ($isCallback && $codeGenerator->IsWrapperType($type)) {
         $includesRef->{"JS${type}.h"} = 1;
     } elsif ($codeGenerator->GetArrayOrSequenceType($type)) {
         my $arrayType = $codeGenerator->GetArrayType($type);
@@ -1115,12 +1112,11 @@ sub GenerateHeader
 
     # JSValue to implementation type
     if (ShouldGenerateToWrapped($hasParent, $interface)) {
-        if ($interfaceName eq "NodeFilter") {
-            push(@headerContent, "    static RefPtr<NodeFilter> toWrapped(JSC::VM&, JSC::JSValue);\n");
-        } elsif ($interfaceName eq "DOMStringList") {
-            push(@headerContent, "    static RefPtr<DOMStringList> toWrapped(JSC::ExecState*, JSC::JSValue);\n");
+        my $nativeType = GetNativeType($interface, $implType);
+        if ($interface->extendedAttributes->{"JSCustomToNativeObject"}) {
+            push(@headerContent, "    static $nativeType toWrapped(JSC::ExecState&, JSC::JSValue);\n");
         } else {
-            push(@headerContent, "    static $implType* toWrapped(JSC::JSValue);\n");
+            push(@headerContent, "    static $nativeType toWrapped(JSC::JSValue);\n");
         }
     }
 
@@ -3623,16 +3619,7 @@ sub GenerateParametersCheck
         my $name = $parameter->name;
         my $value = $name;
 
-        if ($argType eq "XPathNSResolver") {
-            push(@$outputArray, "    RefPtr<XPathNSResolver> customResolver;\n");
-            push(@$outputArray, "    XPathNSResolver* resolver = JSXPathNSResolver::toWrapped(state->argument($argsIndex));\n");
-            push(@$outputArray, "    if (!resolver) {\n");
-            push(@$outputArray, "        customResolver = JSCustomXPathNSResolver::create(state, state->argument($argsIndex));\n");
-            push(@$outputArray, "        if (UNLIKELY(state->hadException()))\n");
-            push(@$outputArray, "            return JSValue::encode(jsUndefined());\n");
-            push(@$outputArray, "        resolver = customResolver.get();\n");
-            push(@$outputArray, "    }\n");
-        } elsif ($codeGenerator->IsCallbackInterface($argType)) {
+        if ($codeGenerator->IsCallbackInterface($argType)) {
             my $callbackClassName = GetCallbackClassName($argType);
             $implIncludes{"$callbackClassName.h"} = 1;
             if ($parameter->isOptional) {
@@ -4242,8 +4229,8 @@ my %nativeType = (
     "DOMTimeStamp" => "DOMTimeStamp",
     "Date" => "double",
     "Dictionary" => "Dictionary",
-    "NodeFilter" => "RefPtr<NodeFilter>",
     "SerializedScriptValue" => "RefPtr<SerializedScriptValue>",
+    "XPathNSResolver" => "RefPtr<XPathNSResolver>",
     "any" => "JSC::JSValue",
     "boolean" => "bool",
     "byte" => "int8_t",
@@ -4433,9 +4420,8 @@ sub JSValueToNative
 
     AddToImplIncludes("JS$type.h", $conditional);
 
-    return ("toDOMStringList(state, $value)", 1) if $type eq "DOMStringList";
-    return ("JSNodeFilter::toWrapped(state->vm(), $value)", 1) if $type eq "NodeFilter";
-
+    my $extendedAttributes = $codeGenerator->getInterfaceExtendedAttributesFromName($type);
+    return ("JS${type}::toWrapped(*state, $value)", 1) if $extendedAttributes->{"JSCustomToNativeObject"};
     return ("JS${type}::toWrapped($value)", 0);
 }
 
index d6091de..8a56cd1 100644 (file)
@@ -38,6 +38,7 @@
 #include "WebKitDOMTestEnumTypePrivate.h"
 #include "WebKitDOMTestNodePrivate.h"
 #include "WebKitDOMTestObjPrivate.h"
+#include "WebKitDOMXPathNSResolverPrivate.h"
 #include "gobject/ConvertToUTF8String.h"
 #include <wtf/GetPtr.h>
 #include <wtf/RefPtr.h>
@@ -1374,6 +1375,16 @@ void webkit_dom_test_obj_method_with_arg_treating_null_as_empty_string(WebKitDOM
     item->methodWithArgTreatingNullAsEmptyString(convertedArg);
 }
 
+void webkit_dom_test_obj_method_with_xpath_ns_resolver_parameter(WebKitDOMTestObj* self, WebKitDOMXPathNSResolver* resolver)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver));
+    WebCore::TestObj* item = WebKit::core(self);
+    RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
+    item->methodWithXPathNSResolverParameter(WTF::getPtr(*convertedResolver));
+}
+
 gchar* webkit_dom_test_obj_nullable_string_method(WebKitDOMTestObj* self)
 {
     WebCore::JSMainThreadNullState state;
@@ -1804,6 +1815,16 @@ void webkit_dom_test_obj_method_with_optional_nullable_wrapper_is_null(WebKitDOM
     item->methodWithOptionalNullableWrapperIsNull(convertedObj);
 }
 
+void webkit_dom_test_obj_method_with_optional_xpath_ns_resolver(WebKitDOMTestObj* self, WebKitDOMXPathNSResolver* resolver)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(WEBKIT_DOM_IS_XPATH_NS_RESOLVER(resolver));
+    WebCore::TestObj* item = WebKit::core(self);
+    RefPtr<WebCore::XPathNSResolver> convertedResolver = WebKit::core(resolver);
+    item->methodWithOptionalXPathNSResolver(WTF::getPtr(convertedResolver));
+}
+
 gchar* webkit_dom_test_obj_conditional_method1(WebKitDOMTestObj* self)
 {
 #if ENABLE(Condition1)
index c752cab..e5ffa51 100644 (file)
@@ -277,6 +277,16 @@ WEBKIT_API void
 webkit_dom_test_obj_method_with_arg_treating_null_as_empty_string(WebKitDOMTestObj* self, const gchar* arg);
 
 /**
+ * webkit_dom_test_obj_method_with_xpath_ns_resolver_parameter:
+ * @self: A #WebKitDOMTestObj
+ * @resolver: A #WebKitDOMXPathNSResolver
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_xpath_ns_resolver_parameter(WebKitDOMTestObj* self, WebKitDOMXPathNSResolver* resolver);
+
+/**
  * webkit_dom_test_obj_nullable_string_method:
  * @self: A #WebKitDOMTestObj
  *
@@ -729,6 +739,16 @@ WEBKIT_API void
 webkit_dom_test_obj_method_with_optional_nullable_wrapper_is_null(WebKitDOMTestObj* self, WebKitDOMTestObj* obj);
 
 /**
+ * webkit_dom_test_obj_method_with_optional_xpath_ns_resolver:
+ * @self: A #WebKitDOMTestObj
+ * @resolver: A #WebKitDOMXPathNSResolver
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_xpath_ns_resolver(WebKitDOMTestObj* self, WebKitDOMXPathNSResolver* resolver);
+
+/**
  * webkit_dom_test_obj_conditional_method1:
  * @self: A #WebKitDOMTestObj
  *
index 79f24da..f0260c5 100644 (file)
@@ -46,6 +46,7 @@
 #include "JSTestNode.h"
 #include "JSTestObj.h"
 #include "JSTestSubObj.h"
+#include "JSXPathNSResolver.h"
 #include "LifecycleCallbackQueue.h"
 #include "RuntimeEnabledFeatures.h"
 #include "SVGDocument.h"
@@ -527,6 +528,7 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecS
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjInstanceFunctionUnforgeableMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithArgTreatingNullAsEmptyString(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameter(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionNullableStringMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionNullableStringStaticMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionNullableStringSpecialMethod(JSC::ExecState*);
@@ -581,6 +583,7 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalBo
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAny(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg(JSC::ExecState*);
@@ -1096,6 +1099,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "objMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t) (0) } },
     { "objMethodWithArgs", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t) (3) } },
     { "methodWithArgTreatingNullAsEmptyString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithArgTreatingNullAsEmptyString), (intptr_t) (1) } },
+    { "methodWithXPathNSResolverParameter", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameter), (intptr_t) (1) } },
     { "nullableStringMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionNullableStringMethod), (intptr_t) (0) } },
     { "nullableStringSpecialMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionNullableStringSpecialMethod), (intptr_t) (1) } },
     { "methodWithSequenceArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithSequenceArg), (intptr_t) (1) } },
@@ -1158,6 +1162,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "methodWithOptionalAny", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAny), (intptr_t) (0) } },
     { "methodWithOptionalNullableWrapper", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper), (intptr_t) (0) } },
     { "methodWithOptionalNullableWrapperIsNull", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull), (intptr_t) (0) } },
+    { "methodWithOptionalXPathNSResolver", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver), (intptr_t) (0) } },
     { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
     { "methodWithNonCallbackArgAndCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t) (2) } },
     { "methodWithCallbackAndOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg), (intptr_t) (0) } },
@@ -4072,6 +4077,25 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithArgTreatingNull
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameter(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithXPathNSResolverParameter");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    if (UNLIKELY(state->argumentCount() < 1))
+        return throwVMError(state, createNotEnoughArgumentsError(state));
+    auto resolver = JSXPathNSResolver::toWrapped(*state, state->argument(0));
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    if (UNLIKELY(!resolver))
+        return throwVMTypeError(state);
+    impl.methodWithXPathNSResolverParameter(*resolver);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionNullableStringMethod(ExecState* state)
 {
     JSValue thisValue = state->thisValue();
@@ -4904,6 +4928,21 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalNullabl
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolver(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObj", "methodWithOptionalXPathNSResolver");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    auto resolver = JSXPathNSResolver::toWrapped(*state, state->argument(0));
+    if (UNLIKELY(state->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalXPathNSResolver(WTFMove(resolver));
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(ExecState* state)
 {
     JSValue thisValue = state->thisValue();
@@ -5179,7 +5218,7 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod6(ExecSta
     auto& impl = castedThis->wrapped();
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
-    auto listArg = toDOMStringList(state, state->argument(0));
+    auto listArg = JSDOMStringList::toWrapped(*state, state->argument(0));
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     impl.overloadedMethod(WTFMove(listArg));
@@ -5528,7 +5567,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionDomStringListFunction(Exe
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     ExceptionCode ec = 0;
-    auto values = toDOMStringList(state, state->argument(0));
+    auto values = JSDOMStringList::toWrapped(*state, state->argument(0));
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     if (UNLIKELY(!values))
index 8a4b801..b469253 100644 (file)
@@ -42,6 +42,7 @@
 @class DOMany;
 @class NSString;
 @protocol DOMEventListener;
+@protocol DOMXPathNSResolver;
 
 enum {
     DOM_CONST_VALUE_0 = 0,
@@ -149,6 +150,7 @@ WEBCORE_EXPORT @interface DOMTestObj : DOMObject
 - (DOMTestObj *)objMethodWithArgs:(int)longArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg;
 - (int)unforgeableMethod;
 - (void)methodWithArgTreatingNullAsEmptyString:(NSString *)arg;
+- (void)methodWithXPathNSResolverParameter:(id <DOMXPathNSResolver>)resolver;
 - (NSString *)nullableStringMethod;
 - (NSString *)nullableStringStaticMethod;
 - (NSString *)nullableStringSpecialMethod:(unsigned)index;
@@ -197,6 +199,7 @@ WEBCORE_EXPORT @interface DOMTestObj : DOMObject
 - (void)methodWithOptionalAny:(DOMany *)a;
 - (void)methodWithOptionalNullableWrapper:(DOMTestObj *)obj;
 - (void)methodWithOptionalNullableWrapperIsNull:(DOMTestObj *)obj;
+- (void)methodWithOptionalXPathNSResolver:(id <DOMXPathNSResolver>)resolver;
 - (void)classMethod;
 - (int)classMethodWithOptional:(int)arg;
 - (void)classMethod2:(int)arg;
index 0e35eb6..7546485 100644 (file)
@@ -29,6 +29,7 @@
 
 #import "DOMTestObj.h"
 
+#import "DOMCustomXPathNSResolver.h"
 #import "DOMDictionaryInternal.h"
 #import "DOMDocumentInternal.h"
 #import "DOMNodeInternal.h"
@@ -66,6 +67,7 @@
 #import "URL.h"
 #import "WebCoreObjCExtras.h"
 #import "WebScriptObjectPrivate.h"
+#import "XPathNSResolver.h"
 #import <wtf/GetPtr.h>
 
 #define IMPL reinterpret_cast<WebCore::TestObj*>(_internal)
     IMPL->methodWithArgTreatingNullAsEmptyString(arg);
 }
 
+- (void)methodWithXPathNSResolverParameter:(id <DOMXPathNSResolver>)resolver
+{
+    WebCore::JSMainThreadNullState state;
+    if (!resolver)
+        WebCore::raiseTypeErrorException();
+    WebCore::XPathNSResolver* nativeResolver = 0;
+    RefPtr<WebCore::XPathNSResolver> customResolver;
+    if (resolver) {
+        if ([resolver isMemberOfClass:[DOMNativeXPathNSResolver class]])
+            nativeResolver = core(static_cast<DOMNativeXPathNSResolver *>(resolver));
+        else {
+            customResolver = WebCore::DOMCustomXPathNSResolver::create(resolver);
+            nativeResolver = WTF::getPtr(customResolver);
+        }
+    }
+    IMPL->methodWithXPathNSResolverParameter(*WTF::getPtr(nativeResolver));
+}
+
 - (NSString *)nullableStringMethod
 {
     WebCore::JSMainThreadNullState state;
     IMPL->methodWithOptionalNullableWrapperIsNull(core(obj));
 }
 
+- (void)methodWithOptionalXPathNSResolver:(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 = WebCore::DOMCustomXPathNSResolver::create(resolver);
+            nativeResolver = WTF::getPtr(customResolver);
+        }
+    }
+    IMPL->methodWithOptionalXPathNSResolver(WTF::getPtr(nativeResolver));
+}
+
 
 #if ENABLE(Condition1)
 - (NSString *)conditionalMethod1
index bde0b7d..5e8bc6a 100644 (file)
@@ -110,6 +110,7 @@ enum TestConfidence { "high", "kinda-low" };
     TestObj objMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
     [Unforgeable] long unforgeableMethod();
     void methodWithArgTreatingNullAsEmptyString([TreatNullAs=EmptyString] DOMString arg);
+    void methodWithXPathNSResolverParameter(XPathNSResolver resolver);
 
     // Nullable String return values.
     DOMString? nullableStringMethod();
@@ -208,6 +209,7 @@ enum TestConfidence { "high", "kinda-low" };
     void    methodWithOptionalAny(optional any a);
     void    methodWithOptionalNullableWrapper(optional TestObj? obj);
     void    methodWithOptionalNullableWrapperIsNull(optional TestObj? obj = null);
+    void    methodWithOptionalXPathNSResolver(optional XPathNSResolver? resolver);
 
 #if defined(TESTING_JS)
     // Callback interface parameters.
index 5737fd9..6feae2a 100644 (file)
@@ -5081,13 +5081,11 @@ bool Document::isTelephoneNumberParsingAllowed() const
 }
 #endif
 
-RefPtr<XPathExpression> Document::createExpression(const String& expression,
-                                                       XPathNSResolver* resolver,
-                                                       ExceptionCode& ec)
+RefPtr<XPathExpression> Document::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
 {
     if (!m_xpathEvaluator)
         m_xpathEvaluator = XPathEvaluator::create();
-    return m_xpathEvaluator->createExpression(expression, resolver, ec);
+    return m_xpathEvaluator->createExpression(expression, WTFMove(resolver), ec);
 }
 
 RefPtr<XPathNSResolver> Document::createNSResolver(Node* nodeResolver)
@@ -5097,11 +5095,11 @@ RefPtr<XPathNSResolver> Document::createNSResolver(Node* nodeResolver)
     return m_xpathEvaluator->createNSResolver(nodeResolver);
 }
 
-RefPtr<XPathResult> Document::evaluate(const String& expression, Node* contextNode, XPathNSResolver* resolver, unsigned short type, XPathResult* result, ExceptionCode& ec)
+RefPtr<XPathResult> Document::evaluate(const String& expression, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result, ExceptionCode& ec)
 {
     if (!m_xpathEvaluator)
         m_xpathEvaluator = XPathEvaluator::create();
-    return m_xpathEvaluator->evaluate(expression, contextNode, resolver, type, result, ec);
+    return m_xpathEvaluator->evaluate(expression, contextNode, WTFMove(resolver), type, result, ec);
 }
 
 void Document::initSecurityContext()
index 2d3e862..eab9c8d 100644 (file)
@@ -952,9 +952,9 @@ public:
     uint64_t domTreeVersion() const { return m_domTreeVersion; }
 
     // XPathEvaluator methods
-    RefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&);
+    RefPtr<XPathExpression> createExpression(const String& expression, RefPtr<XPathNSResolver>&&, ExceptionCode&);
     RefPtr<XPathNSResolver> createNSResolver(Node* nodeResolver);
-    RefPtr<XPathResult> evaluate(const String& expression, Node* contextNode, XPathNSResolver*, unsigned short type, XPathResult*, ExceptionCode&);
+    RefPtr<XPathResult> evaluate(const String& expression, Node* contextNode, RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*, ExceptionCode&);
 
     enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
 
index 186a7ee..e13d70d 100644 (file)
 
     // DOM Level 3 XPath (XPathEvaluator interface)
     // FIXME: Using "undefined" as default parameter value is wrong.
-    [ObjCLegacyUnnamedParameters, RaisesException] XPathExpression createExpression(optional DOMString expression = "undefined",
-                                                    optional XPathNSResolver? resolver = null);
-    XPathNSResolver    createNSResolver(Node? nodeResolver);
+    [ObjCLegacyUnnamedParameters, RaisesException] XPathExpression createExpression(optional DOMString expression = "undefined", optional XPathNSResolver? resolver);
+    XPathNSResolver createNSResolver(Node? nodeResolver);
 
     // FIXME: Using "undefined" as default parameter value is wrong.
     [ObjCLegacyUnnamedParameters, RaisesException] XPathResult evaluate(optional DOMString expression = "undefined",
-                                                  optional Node? contextNode = null,
-                                                  optional XPathNSResolver? resolver = null,
+                                                  optional Node? contextNode,
+                                                  optional XPathNSResolver? resolver,
                                                   optional unsigned short type = 0,
-                                                  optional XPathResult? inResult = null);
+                                                  optional XPathResult? inResult);
 
     // Common extensions
     // FIXME: Using "undefined" as default parameter value is wrong.
index d37e855..645636e 100644 (file)
@@ -38,6 +38,7 @@
 #include "HTMLFrameOwnerElement.h"
 #include "NodeList.h"
 #include "NodeTraversal.h"
+#include "XPathNSResolver.h"
 #include "XPathResult.h"
 
 namespace WebCore {
index de0aa0d..fc75c31 100644 (file)
@@ -37,11 +37,9 @@ namespace WebCore {
 
 using namespace XPath;
 
-RefPtr<XPathExpression> XPathEvaluator::createExpression(const String& expression,
-                                                             XPathNSResolver* resolver,
-                                                             ExceptionCode& ec)
+RefPtr<XPathExpression> XPathEvaluator::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
 {
-    return XPathExpression::createExpression(expression, resolver, ec);
+    return XPathExpression::createExpression(expression, WTFMove(resolver), ec);
 }
 
 Ref<XPathNSResolver> XPathEvaluator::createNSResolver(Node* nodeResolver)
@@ -49,12 +47,7 @@ Ref<XPathNSResolver> XPathEvaluator::createNSResolver(Node* nodeResolver)
     return NativeXPathNSResolver::create(nodeResolver);
 }
 
-RefPtr<XPathResult> XPathEvaluator::evaluate(const String& expression,
-                                                 Node* contextNode,
-                                                 XPathNSResolver* resolver,
-                                                 unsigned short type,
-                                                 XPathResult* result,
-                                                 ExceptionCode& ec)
+RefPtr<XPathResult> XPathEvaluator::evaluate(const String& expression, Node* contextNode, RefPtr<XPathNSResolver>&& resolver, unsigned short type, XPathResult* result, ExceptionCode& ec)
 {
     if (!isValidContextNode(contextNode)) {
         ec = NOT_SUPPORTED_ERR;
@@ -62,7 +55,7 @@ RefPtr<XPathResult> XPathEvaluator::evaluate(const String& expression,
     }
 
     ec = 0;
-    RefPtr<XPathExpression> expr = createExpression(expression, resolver, ec);
+    RefPtr<XPathExpression> expr = createExpression(expression, WTFMove(resolver), ec);
     if (ec)
         return nullptr;
     
index b16c248..f2bb5cb 100644 (file)
@@ -44,10 +44,10 @@ namespace WebCore {
     public:
         static Ref<XPathEvaluator> create() { return adoptRef(*new XPathEvaluator); }
         
-        RefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&);
+        RefPtr<XPathExpression> createExpression(const String& expression, RefPtr<XPathNSResolver>&&, ExceptionCode&);
         Ref<XPathNSResolver> createNSResolver(Node* nodeResolver);
         RefPtr<XPathResult> evaluate(const String& expression, Node* contextNode,
-            XPathNSResolver*, unsigned short type, XPathResult*, ExceptionCode&);
+            RefPtr<XPathNSResolver>&&, unsigned short type, XPathResult*, ExceptionCode&);
 
     private:
         XPathEvaluator() { }
index 74d950e..35040ec 100644 (file)
     ImplementationLacksVTable,
 ] interface XPathEvaluator {
     // FIXME: Using "undefined" as default parameter value is wrong.
-    [RaisesException] XPathExpression createExpression(optional DOMString expression = "undefined",
-                                     optional XPathNSResolver? resolver = null);
+    [RaisesException] XPathExpression createExpression(optional DOMString expression = "undefined", optional XPathNSResolver? resolver);
 
-    XPathNSResolver createNSResolver(optional Node? nodeResolver = null);
+    XPathNSResolver createNSResolver(optional Node? nodeResolver);
 
     // FIXME: Using "undefined" as default parameter value is wrong.
     [RaisesException] XPathResult evaluate(optional DOMString expression = "undefined",
-                         optional Node? contextNode = null,
-                         optional XPathNSResolver? resolver = null,
+                         optional Node? contextNode,
+                         optional XPathNSResolver? resolver,
                          optional unsigned short type = 0,
-                         optional XPathResult? inResult = null);
+                         optional XPathResult? inResult);
 };
index 1449093..8d53f03 100644 (file)
@@ -45,9 +45,9 @@ inline XPathExpression::XPathExpression(std::unique_ptr<XPath::Expression> expre
 {
 }
 
-RefPtr<XPathExpression> XPathExpression::createExpression(const String& expression, XPathNSResolver* resolver, ExceptionCode& ec)
+RefPtr<XPathExpression> XPathExpression::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
 {
-    auto parsedExpression = Parser::parseStatement(expression, resolver, ec);
+    auto parsedExpression = Parser::parseStatement(expression, WTFMove(resolver), ec);
     if (!parsedExpression)
         return nullptr;
 
index 90da675..d0614c4 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
 
     class XPathExpression : public RefCounted<XPathExpression> {
     public:
-        static RefPtr<XPathExpression> createExpression(const String& expression, XPathNSResolver*, ExceptionCode&);
+        static RefPtr<XPathExpression> createExpression(const String& expression, RefPtr<XPathNSResolver>&&, ExceptionCode&);
         ~XPathExpression();
         
         RefPtr<XPathResult> evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionCode&);
index 869b3d6..52e15e3 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 [
+    JSCustomToNativeObject,
     NoInterfaceObject,
     ObjCProtocol,
     SkipVTableValidation,
index c30e9fb..107d6ae 100644 (file)
@@ -399,9 +399,9 @@ inline Parser::Token Parser::nextToken()
     return token;
 }
 
-Parser::Parser(const String& statement, XPathNSResolver* resolver)
+Parser::Parser(const String& statement, RefPtr<XPathNSResolver>&& resolver)
     : m_data(statement)
-    , m_resolver(resolver)
+    , m_resolver(WTFMove(resolver))
     , m_nextPos(0)
     , m_lastTokenType(0)
     , m_sawNamespaceError(false)
@@ -456,9 +456,9 @@ bool Parser::expandQualifiedName(const String& qualifiedName, String& localName,
     return true;
 }
 
-std::unique_ptr<Expression> Parser::parseStatement(const String& statement, XPathNSResolver* resolver, ExceptionCode& ec)
+std::unique_ptr<Expression> Parser::parseStatement(const String& statement, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
 {
-    Parser parser(statement, resolver);
+    Parser parser(statement, WTFMove(resolver));
 
     int parseError = xpathyyparse(parser);
 
index e55ddbb..e419591 100644 (file)
@@ -43,14 +43,14 @@ namespace WebCore {
         class Parser {
             WTF_MAKE_NONCOPYABLE(Parser);
         public:
-            static std::unique_ptr<Expression> parseStatement(const String& statement, XPathNSResolver*, ExceptionCode&);
+            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); }
 
         private:
-            Parser(const String&, XPathNSResolver*);
+            Parser(const String&, RefPtr<XPathNSResolver>&&);
 
             struct Token;
 
@@ -72,7 +72,7 @@ namespace WebCore {
             Token nextTokenInternal();
 
             const String& m_data;
-            XPathNSResolver* m_resolver;
+            RefPtr<XPathNSResolver> m_resolver;
 
             unsigned m_nextPos;
             int m_lastTokenType;