haikuwebkit/Source/WebCore/xml/CustomXPathNSResolver.cpp

41 lines
1.7 KiB
C++
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/175581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-08 04:39:13 +00:00
/*
Reduce the amount of custom binding code for JSXPathNSResolver https://bugs.webkit.org/show_bug.cgi?id=161030 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: * web-platform-tests/domxpath/callback-interface-expected.txt: Source/WebCore: This patch introduces CustomXPathNSResolver callback interface, cleaning up CodeGeneratorJS.pm and removing custom binding code. XPathNSResolver is kept as a wrapper for NativeXPathNSResolver, preserving common case performance via IDL interface converter, and because a callback interface can't be returned from a function without substantial code generator change. Also, improves non-callable method error message and fixes 2 spec incompatibilities: a) no "lookupNamespaceURI" method lookup on functions [1]; b) resolver's "prefix" parameter is required [2]. Since C++ methods can't be overload based on return type, this patch adds [ImplementedAs] IDL attribute support for callback interface methods. Because XPathNSResolver wrappers are always temporary (no reference is kept), [IsWeakCallback] IDL attribute isn't added, preserving strong reference. [1]: https://heycam.github.io/webidl/#call-a-user-objects-operation (step 10.1) [2]: https://dom.spec.whatwg.org/#dom-xpathnsresolver-lookupnamespaceuri Tests: imported/w3c/web-platform-tests/dom/idlharness.window.js imported/w3c/web-platform-tests/domxpath/callback-interface.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/IDLTypes.h: * bindings/js/JSCallbackData.cpp: (WebCore::JSCallbackData::invokeCallback): * bindings/js/JSCustomXPathNSResolver.cpp: Removed. * bindings/js/JSCustomXPathNSResolver.h: Removed. * bindings/js/JSDOMConvertXPathNSResolver.h: (WebCore::Converter<IDLInterface<XPathNSResolver>>::convert): (WebCore::Converter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convertNewlyCreated): Deleted. * bindings/scripts/CodeGenerator.pm: (IsBuiltinType): (IsWrapperType): * bindings/scripts/CodeGeneratorJS.pm: (AddToIncludesForIDLType): (GenerateHeader): (GenerateCallbackHeaderContent): (GenerateCallbackImplementationContent): (GetBaseIDLType): (NativeToJSValueDOMConvertNeedsState): (NativeToJSValueDOMConvertNeedsGlobalObject): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameterBody): (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolverBody): * xml/CustomXPathNSResolver.cpp: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. (WebCore::CustomXPathNSResolver::lookupNamespaceURI): * xml/CustomXPathNSResolver.h: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/CustomXPathNSResolver.idl: Renamed from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/XPathNSResolver.idl: LayoutTests: * fast/dom/TreeWalker/acceptNode-filter-expected.txt: * fast/xpath/nsresolver-bad-object-expected.txt: Canonical link: https://commits.webkit.org/228065@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-07 19:27:56 +00:00
* Copyright (C) 2020 Alexey Shvayka <shvaikalesh@gmail.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. Canonical link: https://commits.webkit.org/175581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-08 04:39:13 +00:00
*
* 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"
Reduce the amount of custom binding code for JSXPathNSResolver https://bugs.webkit.org/show_bug.cgi?id=161030 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: * web-platform-tests/domxpath/callback-interface-expected.txt: Source/WebCore: This patch introduces CustomXPathNSResolver callback interface, cleaning up CodeGeneratorJS.pm and removing custom binding code. XPathNSResolver is kept as a wrapper for NativeXPathNSResolver, preserving common case performance via IDL interface converter, and because a callback interface can't be returned from a function without substantial code generator change. Also, improves non-callable method error message and fixes 2 spec incompatibilities: a) no "lookupNamespaceURI" method lookup on functions [1]; b) resolver's "prefix" parameter is required [2]. Since C++ methods can't be overload based on return type, this patch adds [ImplementedAs] IDL attribute support for callback interface methods. Because XPathNSResolver wrappers are always temporary (no reference is kept), [IsWeakCallback] IDL attribute isn't added, preserving strong reference. [1]: https://heycam.github.io/webidl/#call-a-user-objects-operation (step 10.1) [2]: https://dom.spec.whatwg.org/#dom-xpathnsresolver-lookupnamespaceuri Tests: imported/w3c/web-platform-tests/dom/idlharness.window.js imported/w3c/web-platform-tests/domxpath/callback-interface.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/IDLTypes.h: * bindings/js/JSCallbackData.cpp: (WebCore::JSCallbackData::invokeCallback): * bindings/js/JSCustomXPathNSResolver.cpp: Removed. * bindings/js/JSCustomXPathNSResolver.h: Removed. * bindings/js/JSDOMConvertXPathNSResolver.h: (WebCore::Converter<IDLInterface<XPathNSResolver>>::convert): (WebCore::Converter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convertNewlyCreated): Deleted. * bindings/scripts/CodeGenerator.pm: (IsBuiltinType): (IsWrapperType): * bindings/scripts/CodeGeneratorJS.pm: (AddToIncludesForIDLType): (GenerateHeader): (GenerateCallbackHeaderContent): (GenerateCallbackImplementationContent): (GetBaseIDLType): (NativeToJSValueDOMConvertNeedsState): (NativeToJSValueDOMConvertNeedsGlobalObject): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameterBody): (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolverBody): * xml/CustomXPathNSResolver.cpp: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. (WebCore::CustomXPathNSResolver::lookupNamespaceURI): * xml/CustomXPathNSResolver.h: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/CustomXPathNSResolver.idl: Renamed from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/XPathNSResolver.idl: LayoutTests: * fast/dom/TreeWalker/acceptNode-filter-expected.txt: * fast/xpath/nsresolver-bad-object-expected.txt: Canonical link: https://commits.webkit.org/228065@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-07 19:27:56 +00:00
#include "CustomXPathNSResolver.h"
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. Canonical link: https://commits.webkit.org/175581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-08 04:39:13 +00:00
namespace WebCore {
Reduce the amount of custom binding code for JSXPathNSResolver https://bugs.webkit.org/show_bug.cgi?id=161030 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: * web-platform-tests/domxpath/callback-interface-expected.txt: Source/WebCore: This patch introduces CustomXPathNSResolver callback interface, cleaning up CodeGeneratorJS.pm and removing custom binding code. XPathNSResolver is kept as a wrapper for NativeXPathNSResolver, preserving common case performance via IDL interface converter, and because a callback interface can't be returned from a function without substantial code generator change. Also, improves non-callable method error message and fixes 2 spec incompatibilities: a) no "lookupNamespaceURI" method lookup on functions [1]; b) resolver's "prefix" parameter is required [2]. Since C++ methods can't be overload based on return type, this patch adds [ImplementedAs] IDL attribute support for callback interface methods. Because XPathNSResolver wrappers are always temporary (no reference is kept), [IsWeakCallback] IDL attribute isn't added, preserving strong reference. [1]: https://heycam.github.io/webidl/#call-a-user-objects-operation (step 10.1) [2]: https://dom.spec.whatwg.org/#dom-xpathnsresolver-lookupnamespaceuri Tests: imported/w3c/web-platform-tests/dom/idlharness.window.js imported/w3c/web-platform-tests/domxpath/callback-interface.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/IDLTypes.h: * bindings/js/JSCallbackData.cpp: (WebCore::JSCallbackData::invokeCallback): * bindings/js/JSCustomXPathNSResolver.cpp: Removed. * bindings/js/JSCustomXPathNSResolver.h: Removed. * bindings/js/JSDOMConvertXPathNSResolver.h: (WebCore::Converter<IDLInterface<XPathNSResolver>>::convert): (WebCore::Converter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convertNewlyCreated): Deleted. * bindings/scripts/CodeGenerator.pm: (IsBuiltinType): (IsWrapperType): * bindings/scripts/CodeGeneratorJS.pm: (AddToIncludesForIDLType): (GenerateHeader): (GenerateCallbackHeaderContent): (GenerateCallbackImplementationContent): (GetBaseIDLType): (NativeToJSValueDOMConvertNeedsState): (NativeToJSValueDOMConvertNeedsGlobalObject): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameterBody): (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolverBody): * xml/CustomXPathNSResolver.cpp: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. (WebCore::CustomXPathNSResolver::lookupNamespaceURI): * xml/CustomXPathNSResolver.h: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/CustomXPathNSResolver.idl: Renamed from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/XPathNSResolver.idl: LayoutTests: * fast/dom/TreeWalker/acceptNode-filter-expected.txt: * fast/xpath/nsresolver-bad-object-expected.txt: Canonical link: https://commits.webkit.org/228065@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-07 19:27:56 +00:00
String CustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
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. Canonical link: https://commits.webkit.org/175581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-08 04:39:13 +00:00
{
Reduce the amount of custom binding code for JSXPathNSResolver https://bugs.webkit.org/show_bug.cgi?id=161030 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/dom/idlharness.window-expected.txt: * web-platform-tests/domxpath/callback-interface-expected.txt: Source/WebCore: This patch introduces CustomXPathNSResolver callback interface, cleaning up CodeGeneratorJS.pm and removing custom binding code. XPathNSResolver is kept as a wrapper for NativeXPathNSResolver, preserving common case performance via IDL interface converter, and because a callback interface can't be returned from a function without substantial code generator change. Also, improves non-callable method error message and fixes 2 spec incompatibilities: a) no "lookupNamespaceURI" method lookup on functions [1]; b) resolver's "prefix" parameter is required [2]. Since C++ methods can't be overload based on return type, this patch adds [ImplementedAs] IDL attribute support for callback interface methods. Because XPathNSResolver wrappers are always temporary (no reference is kept), [IsWeakCallback] IDL attribute isn't added, preserving strong reference. [1]: https://heycam.github.io/webidl/#call-a-user-objects-operation (step 10.1) [2]: https://dom.spec.whatwg.org/#dom-xpathnsresolver-lookupnamespaceuri Tests: imported/w3c/web-platform-tests/dom/idlharness.window.js imported/w3c/web-platform-tests/domxpath/callback-interface.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/IDLTypes.h: * bindings/js/JSCallbackData.cpp: (WebCore::JSCallbackData::invokeCallback): * bindings/js/JSCustomXPathNSResolver.cpp: Removed. * bindings/js/JSCustomXPathNSResolver.h: Removed. * bindings/js/JSDOMConvertXPathNSResolver.h: (WebCore::Converter<IDLInterface<XPathNSResolver>>::convert): (WebCore::Converter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convert): Deleted. (WebCore::JSConverter<IDLXPathNSResolver<T>>::convertNewlyCreated): Deleted. * bindings/scripts/CodeGenerator.pm: (IsBuiltinType): (IsWrapperType): * bindings/scripts/CodeGeneratorJS.pm: (AddToIncludesForIDLType): (GenerateHeader): (GenerateCallbackHeaderContent): (GenerateCallbackImplementationContent): (GetBaseIDLType): (NativeToJSValueDOMConvertNeedsState): (NativeToJSValueDOMConvertNeedsGlobalObject): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjPrototypeFunctionMethodWithXPathNSResolverParameterBody): (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalXPathNSResolverBody): * xml/CustomXPathNSResolver.cpp: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. (WebCore::CustomXPathNSResolver::lookupNamespaceURI): * xml/CustomXPathNSResolver.h: Copied from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/CustomXPathNSResolver.idl: Renamed from Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp. * xml/XPathNSResolver.idl: LayoutTests: * fast/dom/TreeWalker/acceptNode-filter-expected.txt: * fast/xpath/nsresolver-bad-object-expected.txt: Canonical link: https://commits.webkit.org/228065@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-07 19:27:56 +00:00
auto result = lookupNamespaceURIForBindings(prefix);
if (result.type() != CallbackResultType::Success)
return String();
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. Canonical link: https://commits.webkit.org/175581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-08 04:39:13 +00:00
Remove setDOMException and a few custom bindings https://bugs.webkit.org/show_bug.cgi?id=166002 Reviewed by Sam Weinig. * CMakeLists.txt: Removed JSFileReaderCustom.cpp. * WebCore.xcodeproj/project.pbxproj: Removed JSFileReaderCustom.cpp. * bindings/js/CallbackFunction.cpp: (WebCore::checkFunctionOnlyCallback): Use throwTypeMismatchError instead of calling setDOMException with TYPE_MISMATCH_ERR. * bindings/js/JSBindingsAllInOne.cpp: Removed JSFileReaderCustom.cpp. * bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::putDelegate): Pass a throw scope in to propagateException. * bindings/js/JSCryptoAlgorithmDictionary.cpp: (WebCore::JSCryptoAlgorithmDictionary::parseAlgorithmIdentifier): Renamed from getAlgorithmIdentifier. Got rid of bool return value, instead use a conventional return value and conventional JavaScript exception handling. Added a ThrowScope argument. (WebCore::optionalHashAlgorithm): Added. Returns an optional hash algorithm. Also makes the same changes as above, conventional exception handling and ThrowScope argument. (WebCore::requiredHashAlgorithm): Added. Like the above but throws an exception if the algorithm is omitted. (WebCore::getHashAlgorithm): Deleted. Replaced by the two functions above. (WebCore::createAesCbcParams): Updated for above changes. (WebCore::createHmacParams): Ditto. (WebCore::createHmacKeyParams): Ditto. (WebCore::createRsaKeyGenParams): Ditto. (WebCore::createRsaOaepParams): Ditto. (WebCore::createRsaSsaParams): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt): Added a ThrowScope argument, and changed to use throwNotSupportedError instead of setDOMException with NOT_SUPPORTED_ERROR. (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForSign): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForVerify): (WebCore::JSCryptoAlgorithmDictionary::createParametersForDigest): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveKey): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveBits): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey): Ditto. (WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey): Ditto. * bindings/js/JSCryptoAlgorithmDictionary.h: Updated for the above changes. * bindings/js/JSCryptoOperationData.cpp: (WebCore::cryptoOperationDataFromJSValue): Got rid of bool return value and instead use a conventional return value and conventional JS exception handling. Added a ThrowScope argument. * bindings/js/JSCryptoOperationData.h: Updated for the above. * bindings/js/JSCustomXPathNSResolver.cpp: (WebCore::JSCustomXPathNSResolver::create): Use ExceptionOr. (WebCore::JSCustomXPathNSResolver::JSCustomXPathNSResolver): Take a VM& rather than an ExecState*. * bindings/js/JSCustomXPathNSResolver.h: Updated for the changes above. Also marked class final and fixed indentation. * bindings/js/JSDOMBinding.cpp: (WebCore::createDOMException): Updated comment. (WebCore::throwDOMException): Deleted. (WebCore::propagateException): Deleted non-inline overload that does not take a throw scope, now that all callers pass a throw scope. (WebCore::setDOMExceptionSlow): Deleted. (WebCore::setDOMException): Deleted. (WebCore::throwNotSupportedError): Added. (WebCore::throwDOMSyntaxError): Added. (WebCore::throwDataCloneError): Added. (WebCore::throwIndexSizeError): Added. (WebCore::throwTypeMismatchError): Added. * bindings/js/JSDOMBinding.h: Updated for the additions and removals above. Also grouped the standard DOM exception throwing functions separately from the special ones for getters and setters, and sorted them alphabetically. * bindings/js/JSDataCueCustom.cpp: (WebCore::createJSDataCue): Added, helper function for the below. (WebCore::constructJSDataCue): Tightened and tweaked a bit. * bindings/js/JSFileReaderCustom.cpp: Removed. * bindings/js/JSHTMLOptionsCollectionCustom.cpp: (WebCore::JSHTMLOptionsCollection::setLength): Use throwIndexSizeError instead of setDOMException with INDEX_SIZE_ERR. * bindings/js/JSHTMLSelectElementCustom.cpp: (WebCore::selectElementIndexSetter): Use throwTypeMismatchError instead of setDOMExceptoin with TYPEMISMATCH_ERR. * bindings/js/JSIDBRequestCustom.cpp: (WebCore::JSIDBRequest::result): Pass a throw scope in to propagateException. * bindings/js/JSSQLResultSetRowListCustom.cpp: (WebCore::JSSQLResultSetRowList::item): Use throwTypeMismatchError and throwIndexSizeError instead of setDOMException with TYPE_MISMATCH_ERR and INDEX_ERR. This required adding a throw scope. * bindings/js/JSSQLTransactionCustom.cpp: (WebCore::JSSQLTransaction::executeSql): Use throwDOMSyntaxError and throwTypeMismatchError instead of setDOMException with SYNTAX_ERR and TYPE_MISMATCH_ERR. * bindings/js/JSStorageCustom.cpp: (WebCore::JSStorage::nameGetter): Pass a throw scope in to propagateException. * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): Use throwNotSupportedError instead of setDOMException with NOT_SUPPORTED_ERR. (WebCore::createAlgorithm): Deleted. (WebCore::supportExportKeyThrow): Added ThrowScope argument and use throwNotSupportedError instead of setDOMException with NOT_SUPPORTED_ERR. (WebCore::jsSubtleCryptoFunctionEncryptPromise): Updated for above changes, throwing a not supported exception at this level rather than in a helper. (WebCore::jsSubtleCryptoFunctionDecryptPromise): Ditto. (WebCore::jsSubtleCryptoFunctionSignPromise): Ditto. (WebCore::jsSubtleCryptoFunctionVerifyPromise): Ditto. (WebCore::jsSubtleCryptoFunctionDigestPromise): Ditto. (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): Ditto. (WebCore::jsSubtleCryptoFunctionImportKeyPromise): Ditto. (WebCore::jsSubtleCryptoFunctionExportKeyPromise): Ditto. (WebCore::jsSubtleCryptoFunctionWrapKeyPromise): Ditto. (WebCore::jsSubtleCryptoFunctionUnwrapKeyPromise): Ditto. * bindings/js/JSWebKitSubtleCryptoCustom.cpp: (WebCore::createAlgorithmFromJSValue): Got rid of bool return value and instead use a conventional return value and conventional JS exception handling. Added a ThrowScope argument. (WebCore::cryptoKeyFormatFromJSValue): Ditto. (WebCore::cryptoKeyUsagesFromJSValue): Ditto. (WebCore::JSWebKitSubtleCrypto::encrypt): Updated for above changes. (WebCore::JSWebKitSubtleCrypto::decrypt): Ditto. (WebCore::JSWebKitSubtleCrypto::sign): Ditto. (WebCore::JSWebKitSubtleCrypto::verify): Ditto. (WebCore::JSWebKitSubtleCrypto::digest): Ditto. (WebCore::JSWebKitSubtleCrypto::generateKey): Ditto. (WebCore::JSWebKitSubtleCrypto::importKey): Ditto. (WebCore::JSWebKitSubtleCrypto::exportKey): Ditto. (WebCore::JSWebKitSubtleCrypto::wrapKey): Ditto. (WebCore::JSWebKitSubtleCrypto::unwrapKey): Ditto. * bindings/js/JSXMLHttpRequestCustom.cpp: (WebCore::JSXMLHttpRequest::send): Pass a throw scope in to propagateException. (WebCore::JSXMLHttpRequest::responseText): Ditto. * bindings/js/JSXPathNSResolverCustom.cpp: (WebCore::JSXPathNSResolver::toWrapped): Updated since JSCustomXPathNSResolver::create now uses ExceptionOr. * bindings/js/SerializedScriptValue.cpp: (WebCore::maybeThrowExceptionIfSerializationFailed): Updated to take a reference instead of a pointer. Fixed the handling of success to be simpler; no need to check the code twice. Use throwDataCloneError instead of setDOMException with DATA_CLONE_ERR. (WebCore::SerializedScriptValue::create): Updated for above. (WebCore::SerializedScriptValue::deserialize): Ditto. * bindings/js/StructuredClone.cpp: (WebCore::structuredCloneArrayBuffer): Use throwDataCloneError instead of setDOMException with DATA_CLONE_ERR. (WebCore::structuredCloneArrayBufferView): Ditto. * crypto/CryptoAlgorithmParametersDeprecated.h: Removed unneeded empty constructor. * crypto/parameters/CryptoAlgorithmHmacKeyParamsDeprecated.h: Ditto, moving initialization to where the data member is defined. * crypto/parameters/CryptoAlgorithmRsaKeyGenParamsDeprecated.h: Ditto. * crypto/parameters/CryptoAlgorithmRsaOaepParamsDeprecated.h: Ditto. * fileapi/FileReader.cpp: (WebCore::FileReader::result): Added. Returns a combination of optional and variant that matches what the ID specifies. Moved the code from the two following functions in here. (WebCore::FileReader::arrayBufferResult): Deleted. (WebCore::FileReader::stringResult): Deleted. * fileapi/FileReader.h: Updated for the above. * fileapi/FileReader.idl: Removed [Custom] from the result attribute and declared it with the type mentioned in the specification, a nullable union. Canonical link: https://commits.webkit.org/183777@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-31 09:57:11 +00:00
return result.releaseReturnValue();
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. Canonical link: https://commits.webkit.org/175581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-08 04:39:13 +00:00
}
} // namespace WebCore