Next step on moving to modern way to return DOM exceptions
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2016 23:01:27 +0000 (23:01 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2016 23:01:27 +0000 (23:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163016

Reviewed by Ryosuke Niwa.

Source/WebCore:

* Modules/fetch/FetchRequest.idl:
Added MayThrowException to initializeWith since it throws an exception.

* bindings/js/JSCallbackData.cpp:
(WebCore::JSCallbackData::invokeCallback):
* bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::invokeCallback):
* bindings/js/JSCustomSQLStatementErrorCallback.cpp:
(WebCore::JSSQLStatementErrorCallback::handleEvent):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/js/JSDOMBinding.cpp:
(WebCore::reportException):
(WebCore::reportCurrentException):
* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSMutationCallback.cpp:
(WebCore::JSMutationCallback::call):
* bindings/js/JSNodeFilterCustom.cpp:
(WebCore::JSNodeFilter::acceptNode):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::executeFunctionInContext):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate):
* inspector/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::reportException):
Use JSC::Exception explicitly to avoid ambiguity with WebCore::Exception,
or in some cases use auto instead.

* bindings/js/JSDOMBinding.cpp:
(WebCore::hasUnpairedSurrogate): Factored this inline function out of valueToUSVString
for clarity.
(WebCore::createDOMException): Removed unused TRY_TO_CREATE_EXCEPTION macro.
(WebCore::propagateExceptionSlowPath): Added.
(WebCore::propagateException): Added.
(WebCore::setDOMException): Removed overload that takes an exception code and message
string separately; no longer needed.

* bindings/js/JSDOMBinding.h: Include the ExceptionOr header
rather than forward declaring. Added more of the ExceptionOr handling
functions; some just declared and not yet defined. Updated for changes
to ExceptionOr interface. Removed the createDOMException function that takes
only an exception code; not needed outside JSDOMBinding.cpp.

* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::send): Rewrote this to use ExceptionOr instead
of ExceptionCode. Added some FIXMEs as well.
(WebCore::JSXMLHttpRequest::responseText): Ditto.
(WebCore::JSXMLHttpRequest::retrieveResponse): Ditto.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Fixed if statements to follow WebKit coding style
rather than using extra braces. Added call to propagateException for SetterMayThrowException.
(GenerateSerializerFunction): Fixed if statements as above.
(GenerateParametersCheck): Ditto. Also added call to propagateException for functions with
void return type and MayThrowException.
(GenerateReturnParameters): Tweaked coding style a bit.
(addIterableProperties): Fixed if statements as above.
(NativeToJSValue): Added code to handle various cases of GetterMayThrowException
and MayThrowException.
(GenerateConstructorDefinition): Used encodedJSValue() instead of
JSValue::encode(JSValue()), a longer way to say the same thing.

* bindings/scripts/IDLAttributes.txt: Added GetterMayThrowException,
MayThrowException, and SetterMayThrowException.

* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
* bindings/scripts/test/JS/JSTestException.cpp:
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
* bindings/scripts/test/JS/JSTestInterface.cpp:
* bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
* bindings/scripts/test/JS/JSTestNode.cpp:
* bindings/scripts/test/JS/JSTestNondeterministic.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
* bindings/scripts/test/JS/JSattribute.cpp:
Regenerated results.

* bindings/scripts/test/TestObj.idl: Added some test cases.

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocumentType): Tweaked formatting.
(WebCore::DOMImplementation::createDocument): Ditto.

* dom/DOMImplementation.idl: Added MayThrowException to two functions since
I am abandoning, for now, the ability to throw exceptions without any extended
attribute in the IDL file. This feature may return at some point if we figure
out a way to do it for functions without return values as well as functions with.

* dom/Document.cpp:
(WebCore::Document::exitPointerLock): Rewrote to streamline logic.
(WebCore::Document::pointerLockElement): Ditto.
(WebCore::Document::inputCursor): Added. No need for this to be inlined.
(WebCore::Document::setInputCursor): Changed to take Ref&&.
(WebCore::Document::getSelection): Added. Moved here from TreeScope.

* dom/Document.h: Updated for above changes.

* dom/Document.idl: Tweaked formatting.

* dom/Exception.h: Merged the two constructors into one with a default
argument value, which should be equally efficient. Added releaseMessage function.
Added assertion that this is only created for actual exceptions with non-zero
ExceptionCode. Unlike ExceptionCode, which has a value of 0 which means no
exception, we do not create an Exception if there is no exception.

* dom/ExceptionOr.h: Renamed takeReturnValue to releaseReturnValue. Replaced
exceptionCode and exceptionMessage with releaseException. Added ExceptionOr<void>
specialization.

* dom/TreeScope.cpp:
(WebCore::TreeScope::~TreeScope): Removed code dealing with
m_selection, which is now in Document.
(WebCore::TreeScope::getSelection): Deleted.

* dom/TreeScope.h: Removed DOMSelection.

* page/DOMSelection.cpp:
(WebCore::selectionShadowAncestor): Changed to take a reference rather than
a guaranteed-non-null pointer.
(WebCore::DOMSelection::DOMSelection): Changed to take a Frame& instead of
of a TreeScope*.
(WebCore::DOMSelection::clearTreeScope): Deleted.
(WebCore::DOMSelection::isCollapsed): Updated call to selectionShadowAncestor.
(WebCore::DOMSelection::type): Took out obsolete uneeeded comment. Got rid
of case where this returns a null string. Use ASCIILiteral.
(WebCore::DOMSelection::rangeCount): Streamlined code.
(WebCore::DOMSelection::collapse): Removed redundant check of m_frame for
null which is already handled by the isValidForPosition function.
Removed non-helpful FIXME.
(WebCore::DOMSelection::collapseToEnd): Changed to use ExceptionOr instead of
ExceptionCode.
(WebCore::DOMSelection::collapseToStart): Ditto.
(WebCore::DOMSelection::setBaseAndExtent): Removed redundant check of m_frame
for null which is already handled by the isValidForPosition function. Removed
non-helpful FIXME.
(WebCore::DOMSelection::setPosition): Ditto.
(WebCore::DOMSelection::extend): Changed to use ExceptionOr instead of
ExceptionCode.
(WebCore::DOMSelection::getRangeAt): Ditto.
(WebCore::DOMSelection::isValidForPosition): Changed to return false when
m_frame is null rather than asserting is is non-null and having every caller
check m_frame before calling this.

* page/DOMSelection.h: Use #pragma once. Fix indentation. Removed unneeded
comments. Use ExceptionOr rather than ExceptionCode.

* page/DOMSelection.idl: Move from MayThrowLegacyException to MayThrowException.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::resetDOMWindowProperties): Sorted properties alphabetically
to make it more obvious if any are accidentally omitted or listed twice.
(WebCore::DOMWindow::getSelection): Changed ownership so that the window owns
the selection like all the other objects, rather than having it be owned by the
document instead.

* page/DOMWindow.h: Added m_selection, sorted all the other related properties
alphabetically so it's easy to compare the list here with elsewhere.

* replay/ReplayController.cpp:
(WebCore::ReplayController::frameNavigated): Updated to call setInputCursor
with a reference rather than a pointer.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseText): Use ExceptionOr rather than ExceptionCode.
(WebCore::XMLHttpRequest::responseXML): Ditto.
(WebCore::XMLHttpRequest::setTimeout): Ditto.
(WebCore::XMLHttpRequest::setResponseType): Ditto.
(WebCore::XMLHttpRequest::setWithCredentials): Ditto.
(WebCore::XMLHttpRequest::open): Ditto.
(WebCore::XMLHttpRequest::prepareToSend): Changed to return an
Optional<ExceptionOr> to reflect the three different states: an exception,
a value to return without sending, or "continue with the send algorithm".
The old code did this with a boolean plus an exception code. This sounds
confusing but is easy to read at the call sites, so probably OK to keep.
(WebCore::XMLHttpRequest::send): Use ExceptionOr rather than ExceptionCode.
(WebCore::XMLHttpRequest::sendBytesData): Ditto.
(WebCore::XMLHttpRequest::createRequest): Ditto.
(WebCore::XMLHttpRequest::overrideMimeType): Ditto.
(WebCore::XMLHttpRequest::setRequestHeader): Ditto.

* xml/XMLHttpRequest.h: Updated for changes above.

* xml/XMLHttpRequest.idl: Sorted interface extended attributes alphabetically.
Changed from MayThrowLegacyException to MayThrowException.

Source/WebKit/mac:

* DOM/DOMDOMImplementation.mm:
(-[DOMImplementation createDocumentType:publicId:systemId:]): Updated for
name change from takeReturnValue to releaseReturnValue.
(-[DOMImplementation createDocument:qualifiedName:doctype:]): Ditto.

Source/WebKit2:

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp:
(webkit_dom_dom_implementation_create_document_type): Updated for name change
from takeReturnValue to releaseReturnValue.
(webkit_dom_dom_implementation_create_document): Ditto.
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMSelection.cpp:
(webkit_dom_dom_selection_collapse_to_end): Use ExceptionOr instead of ExceptionCode.
(webkit_dom_dom_selection_collapse_to_start): Ditto.
(webkit_dom_dom_selection_extend): Ditto.
(webkit_dom_dom_selection_get_range_at): Ditto.

Tools:

* Scripts/do-webcore-rename: Add proposed name change of setDOMException
to propagateException, since this function is primarily used to take an
exception already effectively "thrown" by setting an ExceptionCode out
argument and propagate it into the JavaScript engine's exception machinery.

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

54 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchRequest.idl
Source/WebCore/bindings/js/JSCallbackData.cpp
Source/WebCore/bindings/js/JSCustomElementInterface.cpp
Source/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSErrorHandler.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JSMutationCallback.cpp
Source/WebCore/bindings/js/JSNodeFilterCustom.cpp
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/dom/DOMImplementation.idl
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/dom/Exception.h
Source/WebCore/dom/ExceptionOr.h
Source/WebCore/dom/TreeScope.cpp
Source/WebCore/dom/TreeScope.h
Source/WebCore/inspector/PageScriptDebugServer.cpp
Source/WebCore/page/DOMSelection.cpp
Source/WebCore/page/DOMSelection.h
Source/WebCore/page/DOMSelection.idl
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/replay/ReplayController.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h
Source/WebCore/xml/XMLHttpRequest.idl
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/DOMDOMImplementation.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMSelection.cpp
Tools/ChangeLog
Tools/Scripts/do-webcore-rename

index 0103caa..1cd3984 100644 (file)
@@ -1,3 +1,203 @@
+2016-10-06  Darin Adler  <darin@apple.com>
+
+        Next step on moving to modern way to return DOM exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=163016
+
+        Reviewed by Ryosuke Niwa.
+
+        * Modules/fetch/FetchRequest.idl:
+        Added MayThrowException to initializeWith since it throws an exception.
+
+        * bindings/js/JSCallbackData.cpp:
+        (WebCore::JSCallbackData::invokeCallback):
+        * bindings/js/JSCustomElementInterface.cpp:
+        (WebCore::JSCustomElementInterface::invokeCallback):
+        * bindings/js/JSCustomSQLStatementErrorCallback.cpp:
+        (WebCore::JSSQLStatementErrorCallback::handleEvent):
+        * bindings/js/JSCustomXPathNSResolver.cpp:
+        (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::reportException):
+        (WebCore::reportCurrentException):
+        * bindings/js/JSErrorHandler.cpp:
+        (WebCore::JSErrorHandler::handleEvent):
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::handleEvent):
+        * bindings/js/JSMutationCallback.cpp:
+        (WebCore::JSMutationCallback::call):
+        * bindings/js/JSNodeFilterCustom.cpp:
+        (WebCore::JSNodeFilter::acceptNode):
+        * bindings/js/ScheduledAction.cpp:
+        (WebCore::ScheduledAction::executeFunctionInContext):
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::evaluateInWorld):
+        * bindings/js/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::evaluate):
+        * inspector/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::reportException):
+        Use JSC::Exception explicitly to avoid ambiguity with WebCore::Exception,
+        or in some cases use auto instead.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::hasUnpairedSurrogate): Factored this inline function out of valueToUSVString
+        for clarity.
+        (WebCore::createDOMException): Removed unused TRY_TO_CREATE_EXCEPTION macro.
+        (WebCore::propagateExceptionSlowPath): Added.
+        (WebCore::propagateException): Added.
+        (WebCore::setDOMException): Removed overload that takes an exception code and message
+        string separately; no longer needed.
+
+        * bindings/js/JSDOMBinding.h: Include the ExceptionOr header
+        rather than forward declaring. Added more of the ExceptionOr handling
+        functions; some just declared and not yet defined. Updated for changes
+        to ExceptionOr interface. Removed the createDOMException function that takes
+        only an exception code; not needed outside JSDOMBinding.cpp.
+
+        * bindings/js/JSXMLHttpRequestCustom.cpp:
+        (WebCore::JSXMLHttpRequest::send): Rewrote this to use ExceptionOr instead
+        of ExceptionCode. Added some FIXMEs as well.
+        (WebCore::JSXMLHttpRequest::responseText): Ditto.
+        (WebCore::JSXMLHttpRequest::retrieveResponse): Ditto.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation): Fixed if statements to follow WebKit coding style
+        rather than using extra braces. Added call to propagateException for SetterMayThrowException.
+        (GenerateSerializerFunction): Fixed if statements as above.
+        (GenerateParametersCheck): Ditto. Also added call to propagateException for functions with
+        void return type and MayThrowException.
+        (GenerateReturnParameters): Tweaked coding style a bit.
+        (addIterableProperties): Fixed if statements as above.
+        (NativeToJSValue): Added code to handle various cases of GetterMayThrowException
+        and MayThrowException.
+        (GenerateConstructorDefinition): Used encodedJSValue() instead of
+        JSValue::encode(JSValue()), a longer way to say the same thing.
+
+        * bindings/scripts/IDLAttributes.txt: Added GetterMayThrowException,
+        MayThrowException, and SetterMayThrowException.
+
+        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
+        * bindings/scripts/test/JS/JSTestException.cpp:
+        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp:
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+        * bindings/scripts/test/JS/JSTestNode.cpp:
+        * bindings/scripts/test/JS/JSTestNondeterministic.cpp:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        * bindings/scripts/test/JS/JSattribute.cpp:
+        Regenerated results.
+
+        * bindings/scripts/test/TestObj.idl: Added some test cases.
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createDocumentType): Tweaked formatting.
+        (WebCore::DOMImplementation::createDocument): Ditto.
+
+        * dom/DOMImplementation.idl: Added MayThrowException to two functions since
+        I am abandoning, for now, the ability to throw exceptions without any extended
+        attribute in the IDL file. This feature may return at some point if we figure
+        out a way to do it for functions without return values as well as functions with.
+
+        * dom/Document.cpp:
+        (WebCore::Document::exitPointerLock): Rewrote to streamline logic.
+        (WebCore::Document::pointerLockElement): Ditto.
+        (WebCore::Document::inputCursor): Added. No need for this to be inlined.
+        (WebCore::Document::setInputCursor): Changed to take Ref&&.
+        (WebCore::Document::getSelection): Added. Moved here from TreeScope.
+
+        * dom/Document.h: Updated for above changes.
+
+        * dom/Document.idl: Tweaked formatting.
+
+        * dom/Exception.h: Merged the two constructors into one with a default
+        argument value, which should be equally efficient. Added releaseMessage function.
+        Added assertion that this is only created for actual exceptions with non-zero
+        ExceptionCode. Unlike ExceptionCode, which has a value of 0 which means no
+        exception, we do not create an Exception if there is no exception.
+
+        * dom/ExceptionOr.h: Renamed takeReturnValue to releaseReturnValue. Replaced
+        exceptionCode and exceptionMessage with releaseException. Added ExceptionOr<void>
+        specialization.
+
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::~TreeScope): Removed code dealing with
+        m_selection, which is now in Document.
+        (WebCore::TreeScope::getSelection): Deleted.
+
+        * dom/TreeScope.h: Removed DOMSelection.
+
+        * page/DOMSelection.cpp:
+        (WebCore::selectionShadowAncestor): Changed to take a reference rather than
+        a guaranteed-non-null pointer.
+        (WebCore::DOMSelection::DOMSelection): Changed to take a Frame& instead of
+        of a TreeScope*.
+        (WebCore::DOMSelection::clearTreeScope): Deleted.
+        (WebCore::DOMSelection::isCollapsed): Updated call to selectionShadowAncestor.
+        (WebCore::DOMSelection::type): Took out obsolete uneeeded comment. Got rid
+        of case where this returns a null string. Use ASCIILiteral.
+        (WebCore::DOMSelection::rangeCount): Streamlined code.
+        (WebCore::DOMSelection::collapse): Removed redundant check of m_frame for
+        null which is already handled by the isValidForPosition function.
+        Removed non-helpful FIXME.
+        (WebCore::DOMSelection::collapseToEnd): Changed to use ExceptionOr instead of
+        ExceptionCode.
+        (WebCore::DOMSelection::collapseToStart): Ditto.
+        (WebCore::DOMSelection::setBaseAndExtent): Removed redundant check of m_frame
+        for null which is already handled by the isValidForPosition function. Removed
+        non-helpful FIXME.
+        (WebCore::DOMSelection::setPosition): Ditto.
+        (WebCore::DOMSelection::extend): Changed to use ExceptionOr instead of
+        ExceptionCode.
+        (WebCore::DOMSelection::getRangeAt): Ditto.
+        (WebCore::DOMSelection::isValidForPosition): Changed to return false when
+        m_frame is null rather than asserting is is non-null and having every caller
+        check m_frame before calling this.
+
+        * page/DOMSelection.h: Use #pragma once. Fix indentation. Removed unneeded
+        comments. Use ExceptionOr rather than ExceptionCode.
+
+        * page/DOMSelection.idl: Move from MayThrowLegacyException to MayThrowException.
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::resetDOMWindowProperties): Sorted properties alphabetically
+        to make it more obvious if any are accidentally omitted or listed twice.
+        (WebCore::DOMWindow::getSelection): Changed ownership so that the window owns
+        the selection like all the other objects, rather than having it be owned by the
+        document instead.
+
+        * page/DOMWindow.h: Added m_selection, sorted all the other related properties
+        alphabetically so it's easy to compare the list here with elsewhere.
+
+        * replay/ReplayController.cpp:
+        (WebCore::ReplayController::frameNavigated): Updated to call setInputCursor
+        with a reference rather than a pointer.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::responseText): Use ExceptionOr rather than ExceptionCode.
+        (WebCore::XMLHttpRequest::responseXML): Ditto.
+        (WebCore::XMLHttpRequest::setTimeout): Ditto.
+        (WebCore::XMLHttpRequest::setResponseType): Ditto.
+        (WebCore::XMLHttpRequest::setWithCredentials): Ditto.
+        (WebCore::XMLHttpRequest::open): Ditto.
+        (WebCore::XMLHttpRequest::prepareToSend): Changed to return an
+        Optional<ExceptionOr> to reflect the three different states: an exception,
+        a value to return without sending, or "continue with the send algorithm".
+        The old code did this with a boolean plus an exception code. This sounds
+        confusing but is easy to read at the call sites, so probably OK to keep.
+        (WebCore::XMLHttpRequest::send): Use ExceptionOr rather than ExceptionCode.
+        (WebCore::XMLHttpRequest::sendBytesData): Ditto.
+        (WebCore::XMLHttpRequest::createRequest): Ditto.
+        (WebCore::XMLHttpRequest::overrideMimeType): Ditto.
+        (WebCore::XMLHttpRequest::setRequestHeader): Ditto.
+
+        * xml/XMLHttpRequest.h: Updated for changes above.
+
+        * xml/XMLHttpRequest.idl: Sorted interface extended attributes alphabetically.
+        Changed from MayThrowLegacyException to MayThrowException.
+
 2016-10-06  Sam Weinig  <sam@webkit.org>
 
         Autogenerate passing union types as part of a functions variadic arguments
index cee212e..8689da1 100644 (file)
@@ -62,8 +62,8 @@ interface FetchRequest {
 
     [NewObject, CallWith=ScriptExecutionContext, MayThrowLegacyException] FetchRequest clone();
 
-    [PrivateIdentifier, NewObject] FetchHeaders initializeWith(FetchRequest input, Dictionary init);
-    [PrivateIdentifier, NewObject] FetchHeaders initializeWith(DOMString input, Dictionary init);
-    [PrivateIdentifier, MayThrowLegacyException, CallWith=ScriptState] void setBody(any body, FetchRequest? request);
+    [MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(FetchRequest input, Dictionary init);
+    [MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(DOMString input, Dictionary init);
+    [CallWith=ScriptState, MayThrowLegacyException, PrivateIdentifier] void setBody(any body, FetchRequest? request);
 };
 FetchRequest implements FetchBody;
index 945ac91..2d52efd 100644 (file)
@@ -39,7 +39,7 @@ using namespace JSC;
     
 namespace WebCore {
 
-JSValue JSCallbackData::invokeCallback(JSObject* callback, MarkedArgumentBuffer& args, CallbackType method, PropertyName functionName, NakedPtr<Exception>& returnedException)
+JSValue JSCallbackData::invokeCallback(JSObject* callback, MarkedArgumentBuffer& args, CallbackType method, PropertyName functionName, NakedPtr<JSC::Exception>& returnedException)
 {
     ASSERT(callback);
 
@@ -57,7 +57,7 @@ JSValue JSCallbackData::invokeCallback(JSObject* callback, MarkedArgumentBuffer&
     }
     if (callType == CallType::None) {
         if (method == CallbackType::Function) {
-            returnedException = Exception::create(exec->vm(), createTypeError(exec));
+            returnedException = JSC::Exception::create(exec->vm(), createTypeError(exec));
             return JSValue();
         }
 
@@ -65,7 +65,7 @@ JSValue JSCallbackData::invokeCallback(JSObject* callback, MarkedArgumentBuffer&
         function = callback->get(exec, functionName);
         callType = getCallData(function, callData);
         if (callType == CallType::None) {
-            returnedException = Exception::create(exec->vm(), createTypeError(exec));
+            returnedException = JSC::Exception::create(exec->vm(), createTypeError(exec));
             return JSValue();
         }
     }
index 3d68538..8d39389 100644 (file)
@@ -234,7 +234,7 @@ void JSCustomElementInterface::invokeCallback(Element& element, JSObject* callba
 
     InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);
 
-    NakedPtr<Exception> exception;
+    NakedPtr<JSC::Exception> exception;
     JSMainThreadExecState::call(state, callback, callType, callData, jsElement, args, exception);
 
     InspectorInstrumentation::didCallFunction(cookie, context);
index 79733e5..3c95d42 100644 (file)
@@ -54,7 +54,7 @@ bool JSSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLEr
     args.append(toJS(exec, m_data->globalObject(), transaction));
     args.append(toJS(exec, m_data->globalObject(), error));
 
-    NakedPtr<Exception> returnedException;
+    NakedPtr<JSC::Exception> returnedException;
     JSValue result = m_data->invokeCallback(args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
     if (returnedException) {
         reportException(exec, returnedException);
index bf31a76..6e5eecb 100644 (file)
@@ -91,7 +91,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
     MarkedArgumentBuffer args;
     args.append(jsStringWithCache(exec, prefix));
 
-    NakedPtr<Exception> exception;
+    NakedPtr<JSC::Exception> exception;
     JSValue retval = JSMainThreadExecState::call(exec, function, callType, callData, m_customResolver.get(), args, exception);
 
     String result;
index 6a8a6e4..1fc53ae 100644 (file)
@@ -117,6 +117,18 @@ String valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value)
     return value.toString(exec)->value(exec);
 }
 
+static inline bool hasUnpairedSurrogate(StringView string)
+{
+    // Fast path for 8-bit strings; they can't have any surrogates.
+    if (string.is8Bit())
+        return false;
+    for (auto codePoint : string.codePoints()) {
+        if (U_IS_SURROGATE(codePoint))
+            return true;
+    }
+    return false;
+}
+
 String valueToUSVString(ExecState* exec, JSValue value)
 {
     VM& vm = exec->vm();
@@ -124,27 +136,16 @@ String valueToUSVString(ExecState* exec, JSValue value)
 
     String string = value.toWTFString(exec);
     RETURN_IF_EXCEPTION(scope, { });
-    StringView view { string };
-
-    // Fast path for 8-bit strings, since they can't have any surrogates.
-    if (view.is8Bit())
-        return string;
 
     // Fast path for the case where there are no unpaired surrogates.
-    bool foundUnpairedSurrogate = false;
-    for (auto codePoint : view.codePoints()) {
-        if (U_IS_SURROGATE(codePoint)) {
-            foundUnpairedSurrogate = true;
-            break;
-        }
-    }
-    if (!foundUnpairedSurrogate)
+    if (!hasUnpairedSurrogate(string))
         return string;
 
     // Slow path: http://heycam.github.io/webidl/#dfn-obtain-unicode
     // Replaces unpaired surrogates with the replacement character.
     StringBuilder result;
-    result.reserveCapacity(view.length());
+    result.reserveCapacity(string.length());
+    StringView view { string };
     for (auto codePoint : view.codePoints()) {
         if (U_IS_SURROGATE(codePoint))
             result.append(replacementCharacter);
@@ -190,17 +191,17 @@ void reportException(ExecState* exec, JSValue exceptionValue, CachedScript* cach
 {
     VM& vm = exec->vm();
     RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
-    Exception* exception = jsDynamicCast<Exception*>(exceptionValue);
+    auto* exception = jsDynamicCast<JSC::Exception*>(exceptionValue);
     if (!exception) {
         exception = vm.lastException();
         if (!exception)
-            exception = Exception::create(exec->vm(), exceptionValue, Exception::DoNotCaptureStack);
+            exception = JSC::Exception::create(exec->vm(), exceptionValue, JSC::Exception::DoNotCaptureStack);
     }
 
     reportException(exec, exception, cachedScript);
 }
 
-void reportException(ExecState* exec, Exception* exception, CachedScript* cachedScript, ExceptionDetails* exceptionDetails)
+void reportException(ExecState* exec, JSC::Exception* exception, CachedScript* cachedScript, ExceptionDetails* exceptionDetails)
 {
     VM& vm = exec->vm();
     auto scope = DECLARE_CATCH_SCOPE(vm);
@@ -263,17 +264,12 @@ void reportCurrentException(ExecState* exec)
 {
     VM& vm = exec->vm();
     auto scope = DECLARE_CATCH_SCOPE(vm);
-    Exception* exception = scope.exception();
+    auto* exception = scope.exception();
     scope.clearException();
     reportException(exec, exception);
 }
 
-#define TRY_TO_CREATE_EXCEPTION(interfaceName) \
-    case interfaceName##Type: \
-        errorObject = toJS(exec, globalObject, interfaceName::create(description)); \
-        break;
-
-static JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String* message)
+static JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String* message = nullptr)
 {
     if (!ec)
         return jsUndefined();
@@ -338,11 +334,6 @@ JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String& mess
     return createDOMException(exec, ec, &message);
 }
 
-JSValue createDOMException(ExecState* exec, ExceptionCode ec)
-{
-    return createDOMException(exec, ec, nullptr);
-}
-
 ALWAYS_INLINE static void throwDOMException(ExecState* exec, ThrowScope& throwScope, ExceptionCode ec)
 {
     ASSERT(ec && !throwScope.exception());
@@ -355,6 +346,19 @@ ALWAYS_INLINE static void throwDOMException(ExecState* exec, ThrowScope& throwSc
     throwException(exec, throwScope, createDOMException(exec, ec.code, ec.message));
 }
 
+void propagateExceptionSlowPath(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
+{
+    ASSERT(!throwScope.exception());
+    throwException(&state, throwScope, createDOMException(&state, exception.code(), exception.releaseMessage()));
+}
+
+void propagateException(JSC::ExecState& state, Exception&& exception)
+{
+    auto throwScope = DECLARE_THROW_SCOPE(state.vm());
+    if (!throwScope.exception())
+        propagateExceptionSlowPath(state, throwScope, WTFMove(exception));
+}
+
 void setDOMExceptionSlow(ExecState* exec, ThrowScope& throwScope, ExceptionCode ec)
 {
     throwDOMException(exec, throwScope, ec);
@@ -376,17 +380,6 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
     throwDOMException(exec, scope, ec);
 }
 
-void setDOMException(ExecState* exec, ExceptionCode ec, const String& message)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (!ec || scope.exception())
-        return;
-
-    throwException(exec, scope, createDOMException(exec, ec, message));
-}
-
 void setDOMException(ExecState* exec, const ExceptionCodeWithMessage& ec)
 {
     VM& vm = exec->vm();
@@ -398,8 +391,6 @@ void setDOMException(ExecState* exec, const ExceptionCodeWithMessage& ec)
     throwDOMException(exec, scope, ec);
 }
 
-#undef TRY_TO_CREATE_EXCEPTION
-
 bool hasIteratorMethod(JSC::ExecState& state, JSC::JSValue value)
 {
     auto& vm = state.vm();
index 86be703..4420a6e 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "DOMWrapperWorld.h"
 #include "ExceptionCode.h"
+#include "ExceptionOr.h"
 #include "JSDOMGlobalObject.h"
 #include "JSDOMWrapper.h"
 #include "ScriptWrappable.h"
@@ -70,10 +71,6 @@ class Frame;
 class URL;
 class Node;
 
-template<typename> class ExceptionOr;
-
-using ExceptionCode = int;
-
 struct ExceptionDetails {
     String message;
     int lineNumber { 0 };
@@ -182,33 +179,22 @@ WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::JSValue exception, Cac
 WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
 void reportCurrentException(JSC::ExecState*);
 
-JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode);
 JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode, const String&);
 
-// Convert a DOM implementation exception code into a JavaScript exception in the execution state.
+// Convert a DOM implementation exception into a JavaScript exception in the execution state.
+void propagateException(JSC::ExecState&, JSC::ThrowScope&, Exception&&);
+void setDOMException(JSC::ExecState*, JSC::ThrowScope&, ExceptionCode);
+void setDOMException(JSC::ExecState*, JSC::ThrowScope&, const ExceptionCodeWithMessage&);
+
+// Slower versions of the above for use when the caller doesn't have a ThrowScope.
+void propagateException(JSC::ExecState&, Exception&&);
 WEBCORE_EXPORT void setDOMException(JSC::ExecState*, ExceptionCode);
-void setDOMException(JSC::ExecState*, ExceptionCode, const String&);
 void setDOMException(JSC::ExecState*, const ExceptionCodeWithMessage&);
 
+// Implementation details of the above.
 WEBCORE_EXPORT void setDOMExceptionSlow(JSC::ExecState*, JSC::ThrowScope&, ExceptionCode);
 void setDOMExceptionSlow(JSC::ExecState*, JSC::ThrowScope&, const ExceptionCodeWithMessage&);
-
-ALWAYS_INLINE void setDOMException(JSC::ExecState* exec, JSC::ThrowScope& throwScope, const ExceptionCodeWithMessage& message)
-{
-    if (LIKELY(!message.code || throwScope.exception()))
-        return;
-    setDOMExceptionSlow(exec, throwScope, message);
-}
-
-ALWAYS_INLINE void setDOMException(JSC::ExecState* exec, JSC::ThrowScope& throwScope, ExceptionCode ec)
-{
-    if (LIKELY(!ec || throwScope.exception()))
-        return;
-    setDOMExceptionSlow(exec, throwScope, ec);
-}
-
-template<typename T> inline JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ExceptionOr<T>&&);
-template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, ExceptionOr<T>&&);
+void propagateExceptionSlowPath(JSC::ExecState&, JSC::ThrowScope&, Exception&&);
 
 JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
 
@@ -365,6 +351,18 @@ struct BindingCaller {
     }
 };
 
+// ExceptionOr handling.
+void propagateException(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<void>&&);
+template<typename T> JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&&);
+JSC::JSValue toJSBoolean(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<bool>&&);
+JSC::JSValue toJSDate(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<double>&&);
+JSC::JSValue toJSNullableDate(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<Optional<double>>&&);
+JSC::JSValue toJSNullableString(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<String>&&);
+template<typename T> JSC::JSValue toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&& value);
+template<typename T> JSC::JSValue toJSNumber(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&& value);
+template<typename T> JSC::JSValue toJSNullableNumber(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&& value);
+JSC::JSValue toJSString(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<String>&&);
+
 // Inline functions and template definitions.
 
 inline JSC::Structure* DOMConstructorObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
@@ -886,23 +884,49 @@ template<typename T> inline JSC::JSValue toNullableJSNumber(Optional<T> optional
     return optionalNumber ? JSC::jsNumber(optionalNumber.value()) : JSC::jsNull();
 }
 
-template<typename T> inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ExceptionOr<T>&& value)
+ALWAYS_INLINE void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
+{
+    if (throwScope.exception())
+        return;
+    propagateExceptionSlowPath(state, throwScope, WTFMove(exception));
+}
+
+ALWAYS_INLINE void setDOMException(JSC::ExecState* exec, JSC::ThrowScope& throwScope, ExceptionCode ec)
+{
+    if (LIKELY(!ec || throwScope.exception()))
+        return;
+    setDOMExceptionSlow(exec, throwScope, ec);
+}
+
+ALWAYS_INLINE void setDOMException(JSC::ExecState* exec, JSC::ThrowScope& throwScope, const ExceptionCodeWithMessage& exception)
+{
+    if (LIKELY(!exception.code || throwScope.exception()))
+        return;
+    setDOMExceptionSlow(exec, throwScope, exception);
+}
+
+inline void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<void>&& value)
+{
+    if (UNLIKELY(value.hasException()))
+        propagateException(state, throwScope, value.releaseException());
+}
+
+template<typename T> inline JSC::JSValue toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
 {
     if (UNLIKELY(value.hasException())) {
-        setDOMException(state, value.exceptionCode(), value.exceptionMessage());
-        return JSC::jsUndefined();
+        propagateException(state, throwScope, value.releaseException());
+        return { };
     }
-    return toJS(state, globalObject, value.takeReturnValue());
+    return toJS(&state, &globalObject, value.releaseReturnValue());
 }
 
-template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ExceptionOr<T>&& value)
+template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
 {
-    // FIXME: It's really annoying to have two of these functions. Should find a way to combine toJS and toJSNewlyCreated.
     if (UNLIKELY(value.hasException())) {
-        setDOMException(state, value.exceptionCode(), value.exceptionMessage());
-        return JSC::jsUndefined();
+        propagateException(state, throwScope, value.releaseException());
+        return { };
     }
-    return toJSNewlyCreated(state, globalObject, value.takeReturnValue());
+    return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
 }
 
 } // namespace WebCore
index c281a83..b66769a 100644 (file)
@@ -101,7 +101,7 @@ void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext,
 
         InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(scriptExecutionContext, callType, callData);
 
-        NakedPtr<Exception> exception;
+        NakedPtr<JSC::Exception> exception;
         JSValue returnValue = scriptExecutionContext->isDocument()
             ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, jsFunction, callType, callData, globalObject, args, exception)
             : JSC::profiledCall(exec, JSC::ProfilingReason::Other, jsFunction, callType, callData, globalObject, args, exception);
index c921d17..e06f816 100644 (file)
@@ -115,7 +115,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
     if (callType == CallType::None) {
         handleEventFunction = jsFunction->get(exec, Identifier::fromString(exec, "handleEvent"));
         if (UNLIKELY(scope.exception())) {
-            Exception* exception = scope.exception();
+            auto* exception = scope.exception();
             scope.clearException();
 
             event->target()->uncaughtExceptionInEventHandler();
@@ -139,7 +139,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
         InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(scriptExecutionContext, callType, callData);
 
         JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event->currentTarget()) : jsFunction;
-        NakedPtr<Exception> exception;
+        NakedPtr<JSC::Exception> exception;
         JSValue retval = scriptExecutionContext->isDocument()
             ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, handleEventFunction, callType, callData, thisValue, args, exception)
             : JSC::profiledCall(exec, JSC::ProfilingReason::Other, handleEventFunction, callType, callData, thisValue, args, exception);
index fee976e..5f2516c 100644 (file)
@@ -87,7 +87,7 @@ void JSMutationCallback::call(const Vector<Ref<MutationRecord>>& mutations, Muta
 
     InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);
 
-    NakedPtr<Exception> exception;
+    NakedPtr<JSC::Exception> exception;
     JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, callback, callType, callData, jsObserver, args, exception);
 
     InspectorInstrumentation::didCallFunction(cookie, context);
index 20c5a11..933f72b 100644 (file)
@@ -51,7 +51,7 @@ uint16_t JSNodeFilter::acceptNode(Node* node)
     args.append(toJS(state, m_data->globalObject(), node));
     RETURN_IF_EXCEPTION(scope, NodeFilter::FILTER_REJECT);
 
-    NakedPtr<Exception> returnedException;
+    NakedPtr<JSC::Exception> returnedException;
     JSValue value = m_data->invokeCallback(args, JSCallbackData::CallbackType::FunctionOrObject, Identifier::fromString(state, "acceptNode"), returnedException);
     ASSERT(!scope.exception() || returnedException);
     if (returnedException) {
index 523db16..3e58e92 100644 (file)
@@ -105,44 +105,52 @@ JSValue JSXMLHttpRequest::send(ExecState& state)
 {
     InspectorInstrumentation::willSendXMLHttpRequest(wrapped().scriptExecutionContext(), wrapped().url());
 
-    ExceptionCode ec = 0;
-    JSValue val = state.argument(0);
-    if (val.isUndefinedOrNull())
-        wrapped().send(ec);
-    else if (val.inherits(JSDocument::info()))
-        wrapped().send(JSDocument::toWrapped(val), ec);
-    else if (val.inherits(JSBlob::info()))
-        wrapped().send(JSBlob::toWrapped(val), ec);
-    else if (val.inherits(JSDOMFormData::info()))
-        wrapped().send(JSDOMFormData::toWrapped(val), ec);
-    else if (val.inherits(JSArrayBuffer::info()))
-        wrapped().send(toArrayBuffer(val), ec);
-    else if (val.inherits(JSArrayBufferView::info())) {
-        RefPtr<ArrayBufferView> view = toArrayBufferView(val);
-        wrapped().send(view.get(), ec);
-    } else
-        wrapped().send(val.toString(&state)->value(&state), ec);
-
-    // FIXME: This should probably use ShadowChicken so that we get the right frame even when it did
-    // a tail call.
+    JSValue value = state.argument(0);
+    ExceptionOr<void> result;
+    if (value.isUndefinedOrNull())
+        result = wrapped().send();
+    else if (value.inherits(JSDocument::info()))
+        result = wrapped().send(*JSDocument::toWrapped(value));
+    else if (value.inherits(JSBlob::info()))
+        result = wrapped().send(*JSBlob::toWrapped(value));
+    else if (value.inherits(JSDOMFormData::info()))
+        result = wrapped().send(*JSDOMFormData::toWrapped(value));
+    else if (value.inherits(JSArrayBuffer::info()))
+        result = wrapped().send(*toArrayBuffer(value));
+    else if (value.inherits(JSArrayBufferView::info()))
+        result = wrapped().send(*toArrayBufferView(value).get());
+    else {
+        // FIXME: If toString raises an exception, should we exit before calling willSendXMLHttpRequest?
+        // FIXME: If toString raises an exception, should we exit before calling send?
+        result = wrapped().send(value.toString(&state)->value(&state));
+    }
+
+    // FIXME: This should probably use ShadowChicken so that we get the right frame even when it did a tail call.
     // https://bugs.webkit.org/show_bug.cgi?id=155688
     SendFunctor functor;
     state.iterate(functor);
     wrapped().setLastSendLineAndColumnNumber(functor.line(), functor.column());
     wrapped().setLastSendURL(functor.url());
-    setDOMException(&state, ec);
+
+    // FIXME: Is it correct to do this only after the paragraph code of code just above, or should we exit earlier?
+    if (UNLIKELY(result.hasException())) {
+        propagateException(state, result.releaseException());
+        return { };
+    }
+
     return jsUndefined();
 }
 
 JSValue JSXMLHttpRequest::responseText(ExecState& state) const
 {
-    ExceptionCode ec = 0;
-    String text = wrapped().responseText(ec);
-    if (ec) {
-        setDOMException(&state, ec);
-        return jsUndefined();
+    auto result = wrapped().responseText();
+
+    if (UNLIKELY(result.hasException())) {
+        propagateException(state, result.releaseException());
+        return { };
     }
-    return jsOwnedStringOrNull(&state, text);
+
+    return jsOwnedStringOrNull(&state, result.releaseReturnValue());
 }
 
 JSValue JSXMLHttpRequest::retrieveResponse(ExecState& state)
@@ -174,12 +182,12 @@ JSValue JSXMLHttpRequest::retrieveResponse(ExecState& state)
         break;
 
     case XMLHttpRequest::ResponseType::Document: {
-        ExceptionCode ec = 0;
-        auto document = wrapped().responseXML(ec);
-        ASSERT(!ec);
-        value = toJS(&state, globalObject(), document);
+        auto document = wrapped().responseXML();
+        ASSERT(!document.hasException());
+        value = toJS(&state, globalObject(), document.releaseReturnValue());
         break;
     }
+
     case XMLHttpRequest::ResponseType::Blob:
         value = toJSNewlyCreated(&state, globalObject(), wrapped().createResponseBlob());
         break;
@@ -188,6 +196,7 @@ JSValue JSXMLHttpRequest::retrieveResponse(ExecState& state)
         value = toJS(&state, globalObject(), wrapped().createResponseArrayBuffer());
         break;
     }
+
     wrapped().didCacheResponse();
     return value;
 }
index f4adecf..e5a387b 100644 (file)
@@ -101,7 +101,7 @@ void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSV
 
     InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(&context, callType, callData);
 
-    NakedPtr<Exception> exception;
+    NakedPtr<JSC::Exception> exception;
     if (is<Document>(context))
         JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, m_function.get(), callType, callData, thisValue, args, exception);
     else
index 688397a..9a20030 100644 (file)
@@ -159,7 +159,7 @@ JSValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode, DO
 
     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine());
 
-    NakedPtr<Exception> evaluationException;
+    NakedPtr<JSC::Exception> evaluationException;
     JSValue returnValue = JSMainThreadExecState::profiledEvaluate(exec, JSC::ProfilingReason::Other, jsSourceCode, shell, evaluationException);
 
     InspectorInstrumentation::didEvaluateScript(cookie, m_frame);
index cdf31f9..8aced0f 100644 (file)
@@ -109,7 +109,7 @@ void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
     if (isExecutionForbidden())
         return;
 
-    NakedPtr<Exception> exception;
+    NakedPtr<JSC::Exception> exception;
     evaluate(sourceCode, exception);
     if (exception) {
         JSLockHolder lock(vm());
@@ -142,7 +142,7 @@ void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, NakedP
         String sourceURL = sourceCode.url().string();
         Deprecated::ScriptValue error;
         if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, error, sourceCode.cachedScript()))
-            returnedException = Exception::create(vm, createError(exec, errorMessage.impl()));
+            returnedException = JSC::Exception::create(vm, createError(exec, errorMessage.impl()));
     }
 }
 
index 31125f2..b571460 100644 (file)
@@ -2330,9 +2330,7 @@ sub GetCastingHelperForThisObject
 sub GetIndexedGetterExpression
 {
     my $indexedGetterFunction = shift;
-    if ($indexedGetterFunction->signature->type eq "DOMString") {
-        return "jsStringOrUndefined(state, thisObject->wrapped().item(index))";
-    }
+    return "jsStringOrUndefined(state, thisObject->wrapped().item(index))" if $indexedGetterFunction->signature->type eq "DOMString";
     return "toJS(state, thisObject->globalObject(), thisObject->wrapped().item(index))";
 }
 
@@ -3229,13 +3227,12 @@ sub GenerateImplementation
                 } else {
                     push(@implContent, "    ${className}* castedThis = " . GetCastingHelperForThisObject($interface) . "(JSValue::decode(thisValue));\n");
                 }
-                push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
+                push(@implContent, "    if (UNLIKELY(!castedThis))\n");
                 if ($attribute->signature->extendedAttributes->{LenientThis}) {
                     push(@implContent, "        return false;\n");
                 } else {
                     push(@implContent, "        return throwSetterTypeError(*state, throwScope, \"$visibleInterfaceName\", \"$name\");\n");
                 }
-                push(@implContent, "    }\n");
             }
             if ($interface->extendedAttributes->{CheckSecurity} && !$attribute->signature->extendedAttributes->{DoNotCheckSecurity} && !$attribute->signature->extendedAttributes->{DoNotCheckSecurityOnSetter}) {
                 if ($interfaceName eq "DOMWindow") {
@@ -3371,6 +3368,7 @@ sub GenerateImplementation
                     push(@implContent, "    return true;\n");
                 } else {
                     my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
+
                     if ($codeGenerator->IsTypedArrayType($type) and not $type eq "ArrayBuffer") {
                         push(@arguments, "nativeValue.get()");
                     } elsif ($codeGenerator->IsEnumType($type)) {
@@ -3393,7 +3391,11 @@ sub GenerateImplementation
                     unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{CallWith}, \@implContent, "false"));
 
                     push(@arguments, "ec") if $setterMayThrowLegacyException;
-                    push(@implContent, "    ${functionName}(" . join(", ", @arguments) . ");\n");
+
+                    my $functionString = "$functionName(" . join(", ", @arguments) . ")";
+                    $functionString = "propagateException(*state, throwScope, $functionString)" if $attribute->signature->extendedAttributes->{SetterMayThrowException};
+
+                    push(@implContent, "    $functionString;\n");
                     push(@implContent, "    setDOMException(state, throwScope, ec);\n") if $setterMayThrowLegacyException;
                     push(@implContent, "    return true;\n");
                 }
@@ -3833,9 +3835,8 @@ sub GenerateSerializerFunction
     push(@implContent, "    auto castedThis = jsDynamicCast<JS$interfaceName*>(thisValue);\n");
     push(@implContent, "    VM& vm = state->vm();\n");
     push(@implContent, "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n");
-    push(@implContent, "    if (UNLIKELY(!castedThis)){\n");
+    push(@implContent, "    if (UNLIKELY(!castedThis))\n");
     push(@implContent, "        return throwThisTypeError(*state, throwScope, \"$interfaceName\", \"$serializerFunctionName\");\n");
-    push(@implContent, "    }\n");
     push(@implContent, "    ASSERT_GC_OBJECT_INHERITS(castedThis, ${className}::info());\n\n") unless $interfaceName eq "EventTarget";
     push(@implContent, "    auto* result = constructEmptyObject(state);\n");
     foreach my $attribute (@{$interface->attributes}) {
@@ -4129,9 +4130,9 @@ sub GenerateParametersCheck
                 if (!defined $parameter->default) {
                     push(@$outputArray, "    if (!${name}Value.isUndefined()) {\n");
                 } else {
-                    push(@$outputArray, "    if (${name}Value.isUndefined()) {\n");
+                    push(@$outputArray, "    if (${name}Value.isUndefined())\n");
                     push(@$outputArray, "        $name = " . GenerateDefaultValue($interface, $parameter) . ";\n");
-                    push(@$outputArray, "    else {\n");
+                    push(@$outputArray, "    else {\n");
                 }
                 $indent = "    ";
             }
@@ -4222,18 +4223,18 @@ sub GenerateParametersCheck
     }
 
     push @arguments, GenerateReturnParameters($function);
+    my $functionString = "$functionName(" . join(", ", @arguments) . ")";
+    $functionString = "propagateException(*state, throwScope, $functionString)" if $function->signature->type && $function->signature->type eq "void" && $function->signature->extendedAttributes->{MayThrowException};
 
-    return ("$functionName(" . join(", ", @arguments) . ")", scalar @arguments);
+    return ($functionString, scalar @arguments);
 }
 
 sub GenerateReturnParameters
 {
     my $function = shift;
-    my @arguments;
 
-    if (IsReturningPromise($function)) {
-        push(@arguments, "WTFMove(promise)");
-    }
+    my @arguments;
+    push(@arguments, "WTFMove(promise)") if IsReturningPromise($function);
     push(@arguments, "ec") if $function->signature->extendedAttributes->{MayThrowLegacyException} || $function->signature->extendedAttributes->{MayThrowLegacyExceptionWithMessage};
     return @arguments;
 }
@@ -4592,6 +4593,7 @@ sub GenerateImplementationFunctionCall()
         } else {
             push(@implContent, $indent . "JSValue result = " . NativeToJSValue($function->signature, 1, $interface, $functionString, $thisObject) . ";\n");
         }
+
         push(@implContent, "\n" . $indent . "setDOMException(state, throwScope, ec);\n") if $mayThrowLegacyException;
 
         if ($codeGenerator->ExtendedAttributeContains($function->signature->extendedAttributes->{CallWith}, "ScriptState")) {
@@ -4680,7 +4682,7 @@ sub addIterableProperties()
     if ($interface->iterable->extendedAttributes->{EnabledAtRuntime}) {
         AddToImplIncludes("RuntimeEnabledFeatures.h");
         my $enable_function = GetRuntimeEnableFunctionName($interface->iterable);
-        push(@implContent, "    if (${enable_function}()) {\n    ");
+        push(@implContent, "    if (${enable_function}())\n    ");
     }
 
     if (IsKeyValueIterableInterface($interface)) {
@@ -4689,11 +4691,6 @@ sub addIterableProperties()
     } else {
         push(@implContent, "    addValueIterableMethods(*globalObject(), *this);\n");
     }
-
-    if ($interface->iterable->extendedAttributes->{EnabledAtRuntime}) {
-        push(@implContent, "    }\n");
-    }
-
 }
 
 sub GetNativeTypeFromSignature
@@ -4928,25 +4925,29 @@ sub NativeToJSValue
 
     my $conditional = $signature->extendedAttributes->{Conditional};
     my $type = $signature->type;
+    my $isNullable = $signature->isNullable;
+    my $mayThrowException = $signature->extendedAttributes->{GetterMayThrowException} || $signature->extendedAttributes->{MayThrowException};
 
     my $globalObject = $thisValue ? "$thisValue->globalObject()" : "jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())";
 
+    return "toJSBoolean(*state, throwScope, $value)" if $type eq "boolean" && $mayThrowException;
     return "jsBoolean($value)" if $type eq "boolean";
-
-    if ($type eq "Date") {
-        return "jsDateOrNull(state, $value)" if $signature->isNullable;
-        return "jsDate(state, $value)";
-    }
+    return "toJSNullableDate(*state, throwScope, $value)" if $type eq "Date" && $isNullable && $mayThrowException;
+    return "jsDateOrNull(state, $value)" if $type eq "Date" && $isNullable;
+    return "toJSDate(*state, throwScope, $value)" if $type eq "Date" && $mayThrowException;
+    return "jsDate(state, $value)" if $type eq "Date";
 
     if ($codeGenerator->IsNumericType($type) or $type eq "DOMTimeStamp") {
         # We could instead overload a function to work with optional as well as non-optional numbers, but this
         # is slightly better because it guarantees we will fail to compile if the IDL file doesn't match the C++.
-        my $function = $signature->isNullable ? "toNullableJSNumber" : "jsNumber";
         if ($signature->extendedAttributes->{Reflect} and ($type eq "unsigned long" or $type eq "unsigned short")) {
             $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
             $value = "std::max(0, $value)";
         }
-        return "$function($value)";
+        return "toJSNullableNumber(*state, throwScope, $value)" if $isNullable && $mayThrowException;
+        return "toNullableJSNumber($value)" if $isNullable;
+        return "toJSNumber(*state, throwScope, $value)" if $mayThrowException;
+        return "jsNumber($value)";
     }
 
     if ($codeGenerator->IsEnumType($type)) {
@@ -4956,17 +4957,14 @@ sub NativeToJSValue
 
     if ($codeGenerator->IsStringType($type)) {
         AddToImplIncludes("URL.h", $conditional);
-        return "jsStringOrNull(state, $value)" if $signature->isNullable;
+        return "jsStringOrNull(state, $value)" if $isNullable;
         AddToImplIncludes("<runtime/JSString.h>", $conditional);
         return "jsStringWithCache(state, $value)";
     }
 
     if ($codeGenerator->IsSequenceOrFrozenArrayType($type)) {
         my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
-        if ($codeGenerator->IsRefPtrType($innerType)) {
-            AddToImplIncludes("JS${innerType}.h", $conditional);
-        }
-
+        AddToImplIncludes("JS${innerType}.h", $conditional) if $codeGenerator->IsRefPtrType($innerType);
         return "jsArray(state, $globalObject, $value)" if $codeGenerator->IsSequenceType($type);
         return "jsFrozenArray(state, $globalObject, $value)" if $codeGenerator->IsFrozenArrayType($type);
     }
@@ -5024,8 +5022,13 @@ sub NativeToJSValue
         }
     }
 
-    my $function = $signature->extendedAttributes->{NewObject} ? "toJSNewlyCreated" : "toJS";
-    return "$function(state, $globalObject, $value)";
+    my $functionName = "toJS";
+    $functionName = "toJSNewlyCreated" if $signature->extendedAttributes->{NewObject};
+
+    my $arguments = "state, $globalObject, $value";
+    $arguments = "*state, *$globalObject, throwScope, $value" if $mayThrowException;
+
+    return "$functionName($arguments)";
 }
 
 sub ceilingToPowerOf2
@@ -5568,7 +5571,7 @@ END
             if ($interface->extendedAttributes->{ConstructorMayThrowLegacyException}) {
                 push(@$outputArray, "    if (UNLIKELY(ec)) {\n");
                 push(@$outputArray, "        setDOMException(state, throwScope, ec);\n");
-                push(@$outputArray, "        return JSValue::encode(JSValue());\n");
+                push(@$outputArray, "        return encodedJSValue();\n");
                 push(@$outputArray, "    }\n");
             }
 
index 3c24a54..6d26c55 100644 (file)
@@ -68,6 +68,7 @@ ExportToWrappedFunction
 Exposed=*
 ForwardDeclareInHeader
 GenerateIsReachable=|Impl|ImplWebGLRenderingContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot|ImplScriptExecutionContext
+GetterMayThrowException
 GetterMayThrowLegacyException
 GetterMayThrowLegacyExceptionWithMessage
 Immutable
@@ -95,6 +96,7 @@ JSGenerateToNativeObject
 JSLegacyParent=*
 LenientThis
 MasqueradesAsUndefined
+MayThrowException
 MayThrowLegacyException
 MayThrowLegacyExceptionWithMessage
 NamedConstructor=*
@@ -114,6 +116,7 @@ ReportExtraMemoryCost
 ReportExternalMemoryCost
 RequiresExistingAtomicString
 SetterCallWith=ScriptExecutionContext|ScriptState|ScriptArguments|CallStack|ActiveWindow|FirstWindow
+SetterMayThrowException
 SetterMayThrowLegacyException
 SetterMayThrowLegacyExceptionWithMessage
 SkipVTableValidation
index 22a52b0..1aa7ebe 100644 (file)
@@ -284,9 +284,8 @@ bool setJSTestGlobalObjectRegularAttribute(ExecState* state, EncodedJSValue this
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "regularAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -303,9 +302,8 @@ bool setJSTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "publicAndPrivateAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -323,9 +321,8 @@ bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -344,9 +341,8 @@ bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "enabledAtRuntimeAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
index 946ade0..e4bedb5 100644 (file)
@@ -240,7 +240,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::construct(Ex
     auto object = TestInterface::create(*context, WTFMove(str1), WTFMove(str2), ec);
     if (UNLIKELY(ec)) {
         setDOMException(state, throwScope, ec);
-        return JSValue::encode(JSValue());
+        return encodedJSValue();
     }
     return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
@@ -701,9 +701,8 @@ bool setJSTestInterfaceImplementsStr2(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestInterface", "implementsStr2");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -722,9 +721,8 @@ bool setJSTestInterfaceImplementsStr3(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestInterface", "implementsStr3");
-    }
     castedThis->setImplementsStr3(*state, value);
     return true;
 }
@@ -740,9 +738,8 @@ bool setJSTestInterfaceImplementsNode(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestInterface", "implementsNode");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSNode::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -779,9 +776,8 @@ bool setJSTestInterfaceSupplementalStr2(ExecState* state, EncodedJSValue thisVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestInterface", "supplementalStr2");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -800,9 +796,8 @@ bool setJSTestInterfaceSupplementalStr3(ExecState* state, EncodedJSValue thisVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestInterface", "supplementalStr3");
-    }
     castedThis->setSupplementalStr3(*state, value);
     return true;
 }
@@ -818,9 +813,8 @@ bool setJSTestInterfaceSupplementalNode(ExecState* state, EncodedJSValue thisVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestInterface* castedThis = jsDynamicCast<JSTestInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestInterface", "supplementalNode");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSNode::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
index 828a3e2..181f9f3 100644 (file)
@@ -197,9 +197,8 @@ bool setJSTestJSBuiltinConstructorTestAttributeRWCustom(ExecState* state, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestJSBuiltinConstructor* castedThis = jsDynamicCast<JSTestJSBuiltinConstructor*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestJSBuiltinConstructor", "testAttributeRWCustom");
-    }
     castedThis->setTestAttributeRWCustom(*state, value);
     return true;
 }
index 787e8dc..4642292 100644 (file)
@@ -99,7 +99,7 @@ template<> EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::
     auto object = TestNamedConstructor::createForJSConstructor(*castedThis->document(), WTFMove(str1), WTFMove(str2), WTFMove(str3), ec);
     if (UNLIKELY(ec)) {
         setDOMException(state, throwScope, ec);
-        return JSValue::encode(JSValue());
+        return encodedJSValue();
     }
     return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
index 694fd2f..aa67a8b 100644 (file)
@@ -146,9 +146,8 @@ void JSTestNodePrototype::finishCreation(VM& vm)
         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
     }
-    if (RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
+    if (RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled())
         putDirect(vm, vm.propertyNames->iteratorSymbol, JSFunction::create(vm, globalObject(), 0, ASCIILiteral("[Symbol.Iterator]"), jsTestNodePrototypeFunctionSymbolIterator), DontEnum);
-    }
 }
 
 const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNode) };
@@ -221,9 +220,8 @@ bool setJSTestNodeName(ExecState* state, EncodedJSValue thisValue, EncodedJSValu
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestNode* castedThis = jsDynamicCast<JSTestNode*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestNode", "name");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -301,9 +299,8 @@ EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(ExecState* state)
     auto castedThis = jsDynamicCast<JSTestNode*>(thisValue);
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    if (UNLIKELY(!castedThis)){
+    if (UNLIKELY(!castedThis))
         return throwThisTypeError(*state, throwScope, "TestNode", "toJSON");
-    }
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestNode::info());
 
     auto* result = constructEmptyObject(state);
index 0513731..26ac58e 100644 (file)
@@ -364,9 +364,8 @@ bool setJSTestNondeterministicNondeterministicWriteableAttr(ExecState* state, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestNondeterministic", "nondeterministicWriteableAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -383,9 +382,8 @@ bool setJSTestNondeterministicNondeterministicExceptionAttr(ExecState* state, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestNondeterministic", "nondeterministicExceptionAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -402,9 +400,8 @@ bool setJSTestNondeterministicNondeterministicGetterExceptionAttr(ExecState* sta
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestNondeterministic", "nondeterministicGetterExceptionAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -421,9 +418,8 @@ bool setJSTestNondeterministicNondeterministicSetterExceptionAttr(ExecState* sta
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestNondeterministic", "nondeterministicSetterExceptionAttr");
-    }
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
     auto nativeValue = value.toWTFString(state);
index fbc7607..5c758d6 100644 (file)
@@ -894,6 +894,9 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUSVStringA
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithExceptionReturningLong(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithExceptionReturningObject(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithLegacyException(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithExceptionWithMessage(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*);
@@ -1085,12 +1088,16 @@ bool setJSTestObjEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue,
 #endif
 JSC::EncodedJSValue jsTestObjTypedArrayAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjTypedArrayAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
-JSC::EncodedJSValue jsTestObjAttrWithGetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
-bool setJSTestObjAttrWithGetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjAttributeWithGetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjAttributeWithGetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjAttributeWithGetterLegacyException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjAttributeWithGetterLegacyException(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjAttrWithGetterExceptionWithMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjAttrWithGetterExceptionWithMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
-JSC::EncodedJSValue jsTestObjAttrWithSetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
-bool setJSTestObjAttrWithSetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjAttributeWithSetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjAttributeWithSetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjAttributeWithSetterLegacyException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjAttributeWithSetterLegacyException(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjAttrWithSetterExceptionWithMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjAttrWithSetterExceptionWithMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjStringAttrWithGetterException(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -1399,9 +1406,11 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { 0, 0, NoIntrinsic, { 0, 0 } },
 #endif
     { "typedArrayAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTypedArrayAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjTypedArrayAttr) } },
-    { "attrWithGetterException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttrWithGetterException) } },
+    { "attributeWithGetterException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithGetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithGetterException) } },
+    { "attributeWithGetterLegacyException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithGetterLegacyException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithGetterLegacyException) } },
     { "attrWithGetterExceptionWithMessage", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterExceptionWithMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttrWithGetterExceptionWithMessage) } },
-    { "attrWithSetterException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttrWithSetterException) } },
+    { "attributeWithSetterException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithSetterException) } },
+    { "attributeWithSetterLegacyException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithSetterLegacyException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithSetterLegacyException) } },
     { "attrWithSetterExceptionWithMessage", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterExceptionWithMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttrWithSetterExceptionWithMessage) } },
     { "stringAttrWithGetterException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithGetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringAttrWithGetterException) } },
     { "stringAttrWithSetterException", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringAttrWithSetterException) } },
@@ -1495,6 +1504,9 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "serializedValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t) (1) } },
     { "optionsObject", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOptionsObject), (intptr_t) (1) } },
     { "methodWithException", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t) (0) } },
+    { "methodWithExceptionReturningLong", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithExceptionReturningLong), (intptr_t) (0) } },
+    { "methodWithExceptionReturningObject", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithExceptionReturningObject), (intptr_t) (0) } },
+    { "methodWithLegacyException", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithLegacyException), (intptr_t) (0) } },
     { "methodWithExceptionWithMessage", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithExceptionWithMessage), (intptr_t) (0) } },
     { "customMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t) (0) } },
     { "customMethodWithArgs", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t) (3) } },
@@ -1654,9 +1666,8 @@ void JSTestObjPrototype::finishCreation(VM& vm)
     JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);
     putDirect(vm, clientData.builtinNames().privateMethodPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsTestObjPrototypeFunctionPrivateMethod), ReadOnly | DontEnum);
     putDirect(vm, clientData.builtinNames().publicAndPrivateMethodPrivateName(), JSFunction::create(vm, globalObject(), 0, String(), jsTestObjPrototypeFunctionPublicAndPrivateMethod), ReadOnly | DontEnum);
-    if (RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
+    if (RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled())
         addValueIterableMethods(*globalObject(), *this);
-    }
     JSObject& unscopables = *constructEmptyObject(globalObject()->globalExec(), globalObject()->nullPrototypeObjectStructure());
     unscopables.putDirect(vm, Identifier::fromString(&vm, "voidMethod"), jsBoolean(true));
     unscopables.putDirect(vm, Identifier::fromString(&vm, "shortAttr"), jsBoolean(true));
@@ -2375,20 +2386,36 @@ static inline JSValue jsTestObjTypedArrayAttrGetter(ExecState* state, JSTestObj*
     return result;
 }
 
-static inline JSValue jsTestObjAttrWithGetterExceptionGetter(ExecState*, JSTestObj*, ThrowScope& throwScope);
+static inline JSValue jsTestObjAttributeWithGetterExceptionGetter(ExecState*, JSTestObj*, ThrowScope& throwScope);
 
-EncodedJSValue jsTestObjAttrWithGetterException(ExecState* state, EncodedJSValue thisValue, PropertyName)
+EncodedJSValue jsTestObjAttributeWithGetterException(ExecState* state, EncodedJSValue thisValue, PropertyName)
 {
-    return BindingCaller<JSTestObj>::attribute<jsTestObjAttrWithGetterExceptionGetter>(state, thisValue, "attrWithGetterException");
+    return BindingCaller<JSTestObj>::attribute<jsTestObjAttributeWithGetterExceptionGetter>(state, thisValue, "attributeWithGetterException");
 }
 
-static inline JSValue jsTestObjAttrWithGetterExceptionGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope)
+static inline JSValue jsTestObjAttributeWithGetterExceptionGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(state);
+    auto& impl = thisObject->wrapped();
+    JSValue result = toJSNumber(*state, throwScope, impl.attributeWithGetterException());
+    return result;
+}
+
+static inline JSValue jsTestObjAttributeWithGetterLegacyExceptionGetter(ExecState*, JSTestObj*, ThrowScope& throwScope);
+
+EncodedJSValue jsTestObjAttributeWithGetterLegacyException(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    return BindingCaller<JSTestObj>::attribute<jsTestObjAttributeWithGetterLegacyExceptionGetter>(state, thisValue, "attributeWithGetterLegacyException");
+}
+
+static inline JSValue jsTestObjAttributeWithGetterLegacyExceptionGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope)
 {
     UNUSED_PARAM(throwScope);
     UNUSED_PARAM(state);
     ExceptionCode ec = 0;
     auto& impl = thisObject->wrapped();
-    JSValue result = jsNumber(impl.attrWithGetterException(ec));
+    JSValue result = jsNumber(impl.attributeWithGetterLegacyException(ec));
     setDOMException(state, throwScope, ec);
     return result;
 }
@@ -2411,19 +2438,35 @@ static inline JSValue jsTestObjAttrWithGetterExceptionWithMessageGetter(ExecStat
     return result;
 }
 
-static inline JSValue jsTestObjAttrWithSetterExceptionGetter(ExecState*, JSTestObj*, ThrowScope& throwScope);
+static inline JSValue jsTestObjAttributeWithSetterExceptionGetter(ExecState*, JSTestObj*, ThrowScope& throwScope);
+
+EncodedJSValue jsTestObjAttributeWithSetterException(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    return BindingCaller<JSTestObj>::attribute<jsTestObjAttributeWithSetterExceptionGetter>(state, thisValue, "attributeWithSetterException");
+}
+
+static inline JSValue jsTestObjAttributeWithSetterExceptionGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope)
+{
+    UNUSED_PARAM(throwScope);
+    UNUSED_PARAM(state);
+    auto& impl = thisObject->wrapped();
+    JSValue result = jsNumber(impl.attributeWithSetterException());
+    return result;
+}
+
+static inline JSValue jsTestObjAttributeWithSetterLegacyExceptionGetter(ExecState*, JSTestObj*, ThrowScope& throwScope);
 
-EncodedJSValue jsTestObjAttrWithSetterException(ExecState* state, EncodedJSValue thisValue, PropertyName)
+EncodedJSValue jsTestObjAttributeWithSetterLegacyException(ExecState* state, EncodedJSValue thisValue, PropertyName)
 {
-    return BindingCaller<JSTestObj>::attribute<jsTestObjAttrWithSetterExceptionGetter>(state, thisValue, "attrWithSetterException");
+    return BindingCaller<JSTestObj>::attribute<jsTestObjAttributeWithSetterLegacyExceptionGetter>(state, thisValue, "attributeWithSetterLegacyException");
 }
 
-static inline JSValue jsTestObjAttrWithSetterExceptionGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope)
+static inline JSValue jsTestObjAttributeWithSetterLegacyExceptionGetter(ExecState* state, JSTestObj* thisObject, ThrowScope& throwScope)
 {
     UNUSED_PARAM(throwScope);
     UNUSED_PARAM(state);
     auto& impl = thisObject->wrapped();
-    JSValue result = jsNumber(impl.attrWithSetterException());
+    JSValue result = jsNumber(impl.attributeWithSetterLegacyException());
     return result;
 }
 
@@ -3228,9 +3271,8 @@ bool setJSTestObjTestSubObjEnabledBySettingConstructor(ExecState* state, Encoded
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "TestSubObjEnabledBySetting");
-    }
     // Shadowing a built-in constructor.
     return castedThis->putDirect(state->vm(), Identifier::fromString(state, "TestSubObjEnabledBySetting"), value);
 }
@@ -3244,9 +3286,8 @@ bool setJSTestObjEnumAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "enumAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = parse<TestObj::EnumType>(*state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3265,9 +3306,8 @@ bool setJSTestObjByteAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "byteAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int8_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3284,9 +3324,8 @@ bool setJSTestObjOctetAttr(ExecState* state, EncodedJSValue thisValue, EncodedJS
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "octetAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<uint8_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3303,9 +3342,8 @@ bool setJSTestObjShortAttr(ExecState* state, EncodedJSValue thisValue, EncodedJS
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "shortAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int16_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3322,9 +3360,8 @@ bool setJSTestObjClampedShortAttr(ExecState* state, EncodedJSValue thisValue, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "clampedShortAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int16_t>(*state, value, Clamp);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3341,9 +3378,8 @@ bool setJSTestObjEnforceRangeShortAttr(ExecState* state, EncodedJSValue thisValu
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "enforceRangeShortAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int16_t>(*state, value, EnforceRange);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3360,9 +3396,8 @@ bool setJSTestObjUnsignedShortAttr(ExecState* state, EncodedJSValue thisValue, E
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "unsignedShortAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<uint16_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3379,9 +3414,8 @@ bool setJSTestObjLongAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "longAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3398,9 +3432,8 @@ bool setJSTestObjLongLongAttr(ExecState* state, EncodedJSValue thisValue, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "longLongAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int64_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3417,9 +3450,8 @@ bool setJSTestObjUnsignedLongLongAttr(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "unsignedLongLongAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<uint64_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3436,9 +3468,8 @@ bool setJSTestObjStringAttr(ExecState* state, EncodedJSValue thisValue, EncodedJ
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "stringAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3455,9 +3486,8 @@ bool setJSTestObjUsvstringAttr(ExecState* state, EncodedJSValue thisValue, Encod
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "usvstringAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToUSVString(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3474,9 +3504,8 @@ bool setJSTestObjTestObjAttr(ExecState* state, EncodedJSValue thisValue, Encoded
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "testObjAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -3496,9 +3525,8 @@ bool setJSTestObjTestNullableObjAttr(ExecState* state, EncodedJSValue thisValue,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "testNullableObjAttr");
-    }
     auto& impl = castedThis->wrapped();
     TestObj* nativeValue = nullptr;
     if (!value.isUndefinedOrNull()) {
@@ -3521,9 +3549,8 @@ bool setJSTestObjLenientTestObjAttr(ExecState* state, EncodedJSValue thisValue,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return false;
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -3543,9 +3570,8 @@ bool setJSTestObjStringAttrTreatingNullAsEmptyString(ExecState* state, EncodedJS
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "stringAttrTreatingNullAsEmptyString");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToStringTreatingNullAsEmptyString(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3562,9 +3588,8 @@ bool setJSTestObjUsvstringAttrTreatingNullAsEmptyString(ExecState* state, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "usvstringAttrTreatingNullAsEmptyString");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToUSVStringTreatingNullAsEmptyString(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3581,9 +3606,8 @@ bool setJSTestObjImplementationEnumAttr(ExecState* state, EncodedJSValue thisVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "implementationEnumAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = parse<AlternateEnumName>(*state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3602,9 +3626,8 @@ bool setJSTestObjXMLObjAttr(ExecState* state, EncodedJSValue thisValue, EncodedJ
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "XMLObjAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -3624,9 +3647,8 @@ bool setJSTestObjCreate(ExecState* state, EncodedJSValue thisValue, EncodedJSVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "create");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toBoolean(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3643,9 +3665,8 @@ bool setJSTestObjReflectedStringAttr(ExecState* state, EncodedJSValue thisValue,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedStringAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3662,9 +3683,8 @@ bool setJSTestObjReflectedUSVStringAttr(ExecState* state, EncodedJSValue thisVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedUSVStringAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToUSVString(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3681,9 +3701,8 @@ bool setJSTestObjReflectedIntegralAttr(ExecState* state, EncodedJSValue thisValu
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedIntegralAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3700,9 +3719,8 @@ bool setJSTestObjReflectedUnsignedIntegralAttr(ExecState* state, EncodedJSValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedUnsignedIntegralAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<uint32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3719,9 +3737,8 @@ bool setJSTestObjReflectedBooleanAttr(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedBooleanAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toBoolean(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3738,9 +3755,8 @@ bool setJSTestObjReflectedURLAttr(ExecState* state, EncodedJSValue thisValue, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedURLAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3757,9 +3773,8 @@ bool setJSTestObjReflectedUSVURLAttr(ExecState* state, EncodedJSValue thisValue,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedUSVURLAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToUSVString(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3776,9 +3791,8 @@ bool setJSTestObjReflectedStringAttr(ExecState* state, EncodedJSValue thisValue,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedStringAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3795,9 +3809,8 @@ bool setJSTestObjReflectedCustomIntegralAttr(ExecState* state, EncodedJSValue th
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedCustomIntegralAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3814,9 +3827,8 @@ bool setJSTestObjReflectedCustomBooleanAttr(ExecState* state, EncodedJSValue thi
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedCustomBooleanAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toBoolean(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3833,9 +3845,8 @@ bool setJSTestObjReflectedCustomURLAttr(ExecState* state, EncodedJSValue thisVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "reflectedCustomURLAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3853,9 +3864,8 @@ bool setJSTestObjEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue this
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "enabledAtRuntimeAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3873,9 +3883,8 @@ bool setJSTestObjTypedArrayAttr(ExecState* state, EncodedJSValue thisValue, Enco
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "typedArrayAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = toFloat32Array(value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3888,7 +3897,7 @@ bool setJSTestObjTypedArrayAttr(ExecState* state, EncodedJSValue thisValue, Enco
 }
 
 
-bool setJSTestObjAttrWithGetterException(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+bool setJSTestObjAttributeWithGetterException(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -3896,13 +3905,30 @@ bool setJSTestObjAttrWithGetterException(ExecState* state, EncodedJSValue thisVa
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
-        return throwSetterTypeError(*state, throwScope, "TestObject", "attrWithGetterException");
-    }
+    if (UNLIKELY(!castedThis))
+        return throwSetterTypeError(*state, throwScope, "TestObject", "attributeWithGetterException");
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
-    impl.setAttrWithGetterException(WTFMove(nativeValue));
+    impl.setAttributeWithGetterException(WTFMove(nativeValue));
+    return true;
+}
+
+
+bool setJSTestObjAttributeWithGetterLegacyException(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis))
+        return throwSetterTypeError(*state, throwScope, "TestObject", "attributeWithGetterLegacyException");
+    auto& impl = castedThis->wrapped();
+    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
+    RETURN_IF_EXCEPTION(throwScope, false);
+    impl.setAttributeWithGetterLegacyException(WTFMove(nativeValue));
     return true;
 }
 
@@ -3915,9 +3941,8 @@ bool setJSTestObjAttrWithGetterExceptionWithMessage(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "attrWithGetterExceptionWithMessage");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3926,7 +3951,7 @@ bool setJSTestObjAttrWithGetterExceptionWithMessage(ExecState* state, EncodedJSV
 }
 
 
-bool setJSTestObjAttrWithSetterException(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+bool setJSTestObjAttributeWithSetterException(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -3934,14 +3959,31 @@ bool setJSTestObjAttrWithSetterException(ExecState* state, EncodedJSValue thisVa
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
-        return throwSetterTypeError(*state, throwScope, "TestObject", "attrWithSetterException");
-    }
+    if (UNLIKELY(!castedThis))
+        return throwSetterTypeError(*state, throwScope, "TestObject", "attributeWithSetterException");
+    auto& impl = castedThis->wrapped();
+    auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
+    RETURN_IF_EXCEPTION(throwScope, false);
+    propagateException(*state, throwScope, impl.setAttributeWithSetterException(WTFMove(nativeValue)));
+    return true;
+}
+
+
+bool setJSTestObjAttributeWithSetterLegacyException(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis))
+        return throwSetterTypeError(*state, throwScope, "TestObject", "attributeWithSetterLegacyException");
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
-    impl.setAttrWithSetterException(WTFMove(nativeValue), ec);
+    impl.setAttributeWithSetterLegacyException(WTFMove(nativeValue), ec);
     setDOMException(state, throwScope, ec);
     return true;
 }
@@ -3955,9 +3997,8 @@ bool setJSTestObjAttrWithSetterExceptionWithMessage(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "attrWithSetterExceptionWithMessage");
-    }
     auto& impl = castedThis->wrapped();
     ExceptionCodeWithMessage ec;
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
@@ -3976,9 +4017,8 @@ bool setJSTestObjStringAttrWithGetterException(ExecState* state, EncodedJSValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "stringAttrWithGetterException");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -3995,9 +4035,8 @@ bool setJSTestObjStringAttrWithSetterException(ExecState* state, EncodedJSValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "stringAttrWithSetterException");
-    }
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
     auto nativeValue = value.toWTFString(state);
@@ -4016,9 +4055,8 @@ bool setJSTestObjCustomAttr(ExecState* state, EncodedJSValue thisValue, EncodedJ
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "customAttr");
-    }
     castedThis->setCustomAttr(*state, value);
     return true;
 }
@@ -4032,9 +4070,8 @@ bool setJSTestObjOnfoo(ExecState* state, EncodedJSValue thisValue, EncodedJSValu
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "onfoo");
-    }
     setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().fooEvent, value);
     return true;
 }
@@ -4048,9 +4085,8 @@ bool setJSTestObjOnwebkitfoo(ExecState* state, EncodedJSValue thisValue, Encoded
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "onwebkitfoo");
-    }
     setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().fooEvent, value);
     return true;
 }
@@ -4064,9 +4100,8 @@ bool setJSTestObjWithScriptStateAttribute(ExecState* state, EncodedJSValue thisV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptStateAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4083,9 +4118,8 @@ bool setJSTestObjWithCallWithAndSetterCallWithAttribute(ExecState* state, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withCallWithAndSetterCallWithAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4102,9 +4136,8 @@ bool setJSTestObjWithScriptExecutionContextAttribute(ExecState* state, EncodedJS
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptExecutionContextAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4127,9 +4160,8 @@ bool setJSTestObjWithScriptStateAttributeRaises(ExecState* state, EncodedJSValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptStateAttributeRaises");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4149,9 +4181,8 @@ bool setJSTestObjWithScriptExecutionContextAttributeRaises(ExecState* state, Enc
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptExecutionContextAttributeRaises");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4174,9 +4205,8 @@ bool setJSTestObjWithScriptExecutionContextAndScriptStateAttribute(ExecState* st
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptExecutionContextAndScriptStateAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4199,9 +4229,8 @@ bool setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises(ExecSta
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptExecutionContextAndScriptStateAttributeRaises");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4224,9 +4253,8 @@ bool setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute(Exe
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptExecutionContextAndScriptStateWithSpacesAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4249,9 +4277,8 @@ bool setJSTestObjWithScriptArgumentsAndCallStackAttribute(ExecState* state, Enco
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "withScriptArgumentsAndCallStackAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(!nativeValue)) {
@@ -4272,9 +4299,8 @@ bool setJSTestObjConditionalAttr1(ExecState* state, EncodedJSValue thisValue, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "conditionalAttr1");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4293,9 +4319,8 @@ bool setJSTestObjConditionalAttr2(ExecState* state, EncodedJSValue thisValue, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "conditionalAttr2");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4314,9 +4339,8 @@ bool setJSTestObjConditionalAttr3(ExecState* state, EncodedJSValue thisValue, En
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "conditionalAttr3");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4335,9 +4359,8 @@ bool setJSTestObjConditionalAttr4Constructor(ExecState* state, EncodedJSValue th
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "conditionalAttr4");
-    }
     // Shadowing a built-in constructor.
     return castedThis->putDirect(state->vm(), Identifier::fromString(state, "conditionalAttr4"), value);
 }
@@ -4353,9 +4376,8 @@ bool setJSTestObjConditionalAttr5Constructor(ExecState* state, EncodedJSValue th
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "conditionalAttr5");
-    }
     // Shadowing a built-in constructor.
     return castedThis->putDirect(state->vm(), Identifier::fromString(state, "conditionalAttr5"), value);
 }
@@ -4371,9 +4393,8 @@ bool setJSTestObjConditionalAttr6Constructor(ExecState* state, EncodedJSValue th
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "conditionalAttr6");
-    }
     // Shadowing a built-in constructor.
     return castedThis->putDirect(state->vm(), Identifier::fromString(state, "conditionalAttr6"), value);
 }
@@ -4388,9 +4409,8 @@ bool setJSTestObjAnyAttribute(ExecState* state, EncodedJSValue thisValue, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "anyAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value;
     impl.setAnyAttribute(WTFMove(nativeValue));
@@ -4406,9 +4426,8 @@ bool setJSTestObjMutablePoint(ExecState* state, EncodedJSValue thisValue, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "mutablePoint");
-    }
     auto& impl = castedThis->wrapped();
     SVGPropertyTearOff<SVGPoint>* nativeValue = nullptr;
     if (!value.isUndefinedOrNull()) {
@@ -4431,9 +4450,8 @@ bool setJSTestObjImmutablePoint(ExecState* state, EncodedJSValue thisValue, Enco
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "immutablePoint");
-    }
     auto& impl = castedThis->wrapped();
     SVGPropertyTearOff<SVGPoint>* nativeValue = nullptr;
     if (!value.isUndefinedOrNull()) {
@@ -4456,9 +4474,8 @@ bool setJSTestObjStrawberry(ExecState* state, EncodedJSValue thisValue, EncodedJ
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "strawberry");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4475,9 +4492,8 @@ bool setJSTestObjId(ExecState* state, EncodedJSValue thisValue, EncodedJSValue e
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "id");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4494,9 +4510,8 @@ bool setJSTestObjReplaceableAttribute(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "replaceableAttribute");
-    }
     // Shadowing a built-in property.
     return castedThis->putDirect(state->vm(), Identifier::fromString(state, "replaceableAttribute"), value);
 }
@@ -4510,9 +4525,8 @@ bool setJSTestObjNullableLongSettableAttribute(ExecState* state, EncodedJSValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "nullableLongSettableAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4529,9 +4543,8 @@ bool setJSTestObjNullableStringSettableAttribute(ExecState* state, EncodedJSValu
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "nullableStringSettableAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToStringWithUndefinedOrNullCheck(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4548,9 +4561,8 @@ bool setJSTestObjNullableUSVStringSettableAttribute(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "nullableUSVStringSettableAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToUSVStringWithUndefinedOrNullCheck(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4567,9 +4579,8 @@ bool setJSTestObjNullableStringValue(ExecState* state, EncodedJSValue thisValue,
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "nullableStringValue");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4586,9 +4597,8 @@ bool setJSTestObjAttributeWithReservedEnumType(ExecState* state, EncodedJSValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "attributeWithReservedEnumType");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = parse<TestObj::Optional>(*state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -4607,9 +4617,8 @@ bool setJSTestObjPutForwardsAttribute(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "putForwardsAttribute");
-    }
     Ref<TestNode> forwardedImpl = castedThis->wrapped().putForwardsAttribute();
     auto& impl = forwardedImpl.get();
     auto nativeValue = value.toWTFString(state);
@@ -4627,9 +4636,8 @@ bool setJSTestObjPutForwardsNullableAttribute(ExecState* state, EncodedJSValue t
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "putForwardsNullableAttribute");
-    }
     RefPtr<TestNode> forwardedImpl = castedThis->wrapped().putForwardsNullableAttribute();
     if (!forwardedImpl)
         return false;
@@ -4649,9 +4657,8 @@ bool setJSTestObjStringifierAttribute(ExecState* state, EncodedJSValue thisValue
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestObject", "stringifierAttribute");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = valueToUSVString(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -5092,9 +5099,9 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalEnumArg
     auto& impl = castedThis->wrapped();
     auto enumArgValue = state->argument(0);
     TestObj::EnumType enumArg;
-    if (enumArgValue.isUndefined()) {
+    if (enumArgValue.isUndefined())
         enumArg = TestObj::EnumType::EnumValue1;
-    else {
+    else {
         auto optionalValue = parse<TestObj::EnumType>(*state, enumArgValue);
         RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         if (UNLIKELY(!optionalValue))
@@ -5236,8 +5243,53 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecS
         return throwThisTypeError(*state, throwScope, "TestObject", "methodWithException");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
+    propagateException(*state, throwScope, impl.methodWithException());
+    return JSValue::encode(jsUndefined());
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithExceptionReturningLong(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, throwScope, "TestObject", "methodWithExceptionReturningLong");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    JSValue result = toJSNumber(*state, throwScope, impl.methodWithExceptionReturningLong());
+    return JSValue::encode(result);
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithExceptionReturningObject(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, throwScope, "TestObject", "methodWithExceptionReturningObject");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    JSValue result = toJS(*state, *castedThis->globalObject(), throwScope, impl.methodWithExceptionReturningObject());
+    return JSValue::encode(result);
+}
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithLegacyException(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, throwScope, "TestObject", "methodWithLegacyException");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
-    impl.methodWithException(ec);
+    impl.methodWithLegacyException(ec);
     setDOMException(state, throwScope, ec);
     return JSValue::encode(jsUndefined());
 }
@@ -7596,9 +7648,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToJSON(ExecState* state)
     auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
-    if (UNLIKELY(!castedThis)){
+    if (UNLIKELY(!castedThis))
         return throwThisTypeError(*state, throwScope, "TestObj", "toJSON");
-    }
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
 
     auto* result = constructEmptyObject(state);
index 863dbdd..ae18f8d 100644 (file)
@@ -255,9 +255,8 @@ bool setJSTestSerializedScriptValueInterfaceValue(ExecState* state, EncodedJSVal
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestSerializedScriptValueInterface", "value");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -274,9 +273,8 @@ bool setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* state, Encode
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestSerializedScriptValueInterface", "cachedValue");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
     RETURN_IF_EXCEPTION(throwScope, false);
index 3f3e0a4..811148f 100644 (file)
@@ -361,9 +361,8 @@ bool setJSTestTypedefsUnsignedLongLongAttr(ExecState* state, EncodedJSValue this
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestTypedefs", "unsignedLongLongAttr");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<uint64_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -380,9 +379,8 @@ bool setJSTestTypedefsImmutableSerializedScriptValue(ExecState* state, EncodedJS
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestTypedefs", "immutableSerializedScriptValue");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -399,9 +397,8 @@ bool setJSTestTypedefsAttrWithGetterException(ExecState* state, EncodedJSValue t
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestTypedefs", "attrWithGetterException");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -418,9 +415,8 @@ bool setJSTestTypedefsAttrWithSetterException(ExecState* state, EncodedJSValue t
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestTypedefs", "attrWithSetterException");
-    }
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
     auto nativeValue = convert<int32_t>(*state, value, NormalConversion);
@@ -439,9 +435,8 @@ bool setJSTestTypedefsStringAttrWithGetterException(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestTypedefs", "stringAttrWithGetterException");
-    }
     auto& impl = castedThis->wrapped();
     auto nativeValue = value.toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, false);
@@ -458,9 +453,8 @@ bool setJSTestTypedefsStringAttrWithSetterException(ExecState* state, EncodedJSV
     JSValue value = JSValue::decode(encodedValue);
     UNUSED_PARAM(thisValue);
     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
-    if (UNLIKELY(!castedThis)) {
+    if (UNLIKELY(!castedThis))
         return throwSetterTypeError(*state, throwScope, "TestTypedefs", "stringAttrWithSetterException");
-    }
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
     auto nativeValue = value.toWTFString(state);
index a69f6ac..d0981f5 100644 (file)
@@ -115,14 +115,14 @@ enum TestConfidence { "high", "kinda-low" };
     [EnabledAtRuntime=DOMIterator] iterable<DOMString>;
 
     // Methods
-    [Unscopable] void    voidMethod();
-    void    voidMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
-    byte    byteMethod();
-    byte    byteMethodWithArgs(byte byteArg, DOMString strArg, TestObj objArg);
-    octet   octetMethod();
-    octet   octetMethodWithArgs(octet octetArg, DOMString strArg, TestObj objArg);
-    long    longMethod();
-    long    longMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
+    [Unscopable] void voidMethod();
+    void voidMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
+    byte byteMethod();
+    byte byteMethodWithArgs(byte byteArg, DOMString strArg, TestObj objArg);
+    octet octetMethod();
+    octet octetMethodWithArgs(octet octetArg, DOMString strArg, TestObj objArg);
+    long longMethod();
+    long longMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
     TestObj objMethod();
     TestObj objMethodWithArgs(long longArg, DOMString strArg, TestObj objArg);
     [Unforgeable] long unforgeableMethod();
@@ -149,11 +149,16 @@ enum TestConfidence { "high", "kinda-low" };
     void optionsObject(Dictionary oo, optional Dictionary ooo);
 
     // Exceptions
-    [MayThrowLegacyException] void methodWithException();
+    [MayThrowException] void methodWithException();
+    [MayThrowException] long methodWithExceptionReturningLong();
+    [MayThrowException] TestObj methodWithExceptionReturningObject();
+    [MayThrowLegacyException] void methodWithLegacyException();
     [MayThrowLegacyExceptionWithMessage] void methodWithExceptionWithMessage();
-    [GetterMayThrowLegacyException] attribute long attrWithGetterException;
+    [GetterMayThrowException] attribute long attributeWithGetterException;
+    [GetterMayThrowLegacyException] attribute long attributeWithGetterLegacyException;
     [GetterMayThrowLegacyExceptionWithMessage] attribute long attrWithGetterExceptionWithMessage;
-    [SetterMayThrowLegacyException] attribute long attrWithSetterException;
+    [SetterMayThrowException] attribute long attributeWithSetterException;
+    [SetterMayThrowLegacyException] attribute long attributeWithSetterLegacyException;
     [SetterMayThrowLegacyExceptionWithMessage] attribute long attrWithSetterExceptionWithMessage;
     [GetterMayThrowLegacyException] attribute DOMString stringAttrWithGetterException;
     [SetterMayThrowLegacyException] attribute DOMString stringAttrWithSetterException;
index a85e070..b7a34ca 100644 (file)
@@ -97,7 +97,7 @@ ExceptionOr<Ref<DocumentType>> DOMImplementation::createDocumentType(const Strin
     String localName;
     Document::parseQualifiedName(qualifiedName, prefix, localName, ec);
     if (ec)
-        return Exception(ec);
+        return Exception { ec };
 
     return DocumentType::create(m_document, qualifiedName, publicId, systemId);
 }
@@ -122,7 +122,7 @@ ExceptionOr<Ref<XMLDocument>> DOMImplementation::createDocument(const String& na
         ExceptionCode ec = 0;
         documentElement = document->createElementNS(namespaceURI, qualifiedName, ec);
         if (ec)
-            return Exception(ec);
+            return Exception { ec };
     }
 
     if (documentType)
index d8066b8..f5b40e9 100644 (file)
@@ -23,8 +23,8 @@
     GenerateIsReachable=ImplDocument,
     ImplementationLacksVTable,
 ] interface DOMImplementation {
-    [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
-    [NewObject] XMLDocument createDocument(DOMString? namespaceURI, [TreatNullAs=EmptyString] DOMString qualifiedName, optional DocumentType? doctype = null);
+    [NewObject, MayThrowException] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
+    [NewObject, MayThrowException] XMLDocument createDocument(DOMString? namespaceURI, [TreatNullAs=EmptyString] DOMString qualifiedName, optional DocumentType? doctype = null);
     [NewObject] HTMLDocument createHTMLDocument(optional DOMString title);
 
     boolean hasFeature();
index 53d62e3..3760482 100644 (file)
@@ -564,6 +564,7 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
 }
 
 #if ENABLE(FULLSCREEN_API)
+
 static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, const WebCore::QualifiedName& prefixedAttribute, const HTMLFrameOwnerElement* owner)
 {
     if (!owner)
@@ -574,14 +575,14 @@ static bool isAttributeOnAllOwners(const WebCore::QualifiedName& attribute, cons
     } while ((owner = owner->document().ownerElement()));
     return true;
 }
+
 #endif
 
 Ref<Document> Document::create(Document& contextDocument)
 {
-    Ref<Document> document = adoptRef(*new Document(nullptr, URL()));
+    auto document = adoptRef(*new Document(nullptr, URL()));
     document->setContextDocument(contextDocument);
     document->setSecurityOriginPolicy(contextDocument.securityOriginPolicy());
-
     return document;
 }
 
@@ -867,6 +868,7 @@ void Document::childrenChanged(const ChildChange& change)
 }
 
 #if ENABLE(CUSTOM_ELEMENTS)
+
 static ALWAYS_INLINE RefPtr<HTMLElement> createUpgradeCandidateElement(Document& document, const QualifiedName& name)
 {
     if (!RuntimeEnabledFeatures::sharedFeatures().customElementsEnabled())
@@ -879,17 +881,17 @@ static ALWAYS_INLINE RefPtr<HTMLElement> createUpgradeCandidateElement(Document&
     element->setIsCustomElementUpgradeCandidate();
     return WTFMove(element);
 }
+
 #endif
 
 static RefPtr<Element> createHTMLElementWithNameValidation(Document& document, const AtomicString& localName, ExceptionCode& ec)
 {
-    RefPtr<HTMLElement> element = HTMLElementFactory::createKnownElement(localName, document);
+    auto element = HTMLElementFactory::createKnownElement(localName, document);
     if (LIKELY(element))
         return element;
 
 #if ENABLE(CUSTOM_ELEMENTS)
-    auto* window = document.domWindow();
-    if (window) {
+    if (auto* window = document.domWindow()) {
         auto* registry = window->customElementRegistry();
         if (UNLIKELY(registry)) {
             if (auto* elementInterface = registry->findInterface(localName))
@@ -1071,8 +1073,7 @@ bool Document::hasValidNamespaceForAttributes(const QualifiedName& qName)
 static Ref<HTMLElement> createFallbackHTMLElement(Document& document, const QualifiedName& name)
 {
 #if ENABLE(CUSTOM_ELEMENTS)
-    auto* window = document.domWindow();
-    if (window) {
+    if (auto* window = document.domWindow()) {
         auto* registry = window->customElementRegistry();
         if (UNLIKELY(registry)) {
             if (auto* elementInterface = registry->findInterface(name)) {
@@ -1151,13 +1152,16 @@ CustomElementNameValidationStatus Document::validateCustomElementName(const Atom
 }
 
 #if ENABLE(CSS_GRID_LAYOUT)
+
 bool Document::isCSSGridLayoutEnabled() const
 {
     return RuntimeEnabledFeatures::sharedFeatures().isCSSGridLayoutEnabled();
 }
+
 #endif
 
 #if ENABLE(CSS_REGIONS)
+
 RefPtr<DOMNamedFlowCollection> Document::webkitGetNamedFlows()
 {
     if (!renderView())
@@ -1167,6 +1171,7 @@ RefPtr<DOMNamedFlowCollection> Document::webkitGetNamedFlows()
 
     return namedFlows().createCSSOMSnapshot();
 }
+
 #endif
 
 NamedFlowCollection& Document::namedFlows()
@@ -1665,8 +1670,8 @@ bool Document::hidden() const
     return pageVisibilityState() != PageVisibilityStateVisible;
 }
 
-
 #if ENABLE(VIDEO)
+
 void Document::registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(HTMLMediaElement& element)
 {
     m_allowsMediaDocumentInlinePlaybackElements.add(&element);
@@ -1682,6 +1687,7 @@ void Document::allowsMediaDocumentInlinePlaybackChanged()
     for (auto* element : m_allowsMediaDocumentInlinePlaybackElements)
         element->allowsMediaDocumentInlinePlaybackChanged();
 }
+
 #endif
 
 String Document::nodeName() const
@@ -2976,25 +2982,27 @@ void Document::disableEval(const String& errorMessage)
 }
 
 #if ENABLE(INDEXED_DATABASE)
+
 IDBClient::IDBConnectionProxy* Document::idbConnectionProxy()
 {
     if (!m_idbConnectionProxy) {
         Page* currentPage = page();
         if (!currentPage)
             return nullptr;
-
         m_idbConnectionProxy = &currentPage->idbConnection().proxy();
     }
-
     return m_idbConnectionProxy.get();
 }
-#endif // ENABLE(INDEXED_DATABASE)
+
+#endif
 
 #if ENABLE(WEB_SOCKETS)
+
 SocketProvider* Document::socketProvider()
 {
     return m_socketProvider.get();
 }
+
 #endif
     
 bool Document::canNavigate(Frame* targetFrame)
@@ -3596,6 +3604,7 @@ void Document::elementInActiveChainDidDetach(Element* element)
 }
 
 #if ENABLE(DASHBOARD_SUPPORT)
+
 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const
 {
     return m_annotatedRegions;
@@ -3606,6 +3615,7 @@ void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
     m_annotatedRegions = regions;
     setAnnotatedRegionsDirty(false);
 }
+
 #endif
 
 bool Document::setFocusedElement(Element* element, FocusDirection direction, FocusRemovalEventsMode eventsMode)
@@ -4366,7 +4376,7 @@ void Document::setDomain(const String& newDomain, ExceptionCode& ec)
 }
 
 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
-String Document::lastModified() const
+String Document::lastModified()
 {
     using namespace std::chrono;
     Optional<system_clock::time_point> dateTime;
@@ -4379,11 +4389,11 @@ String Document::lastModified() const
     if (!dateTime) {
         dateTime = system_clock::now();
 #if ENABLE(WEB_REPLAY)
-        InputCursor& cursor = inputCursor();
+        auto& cursor = inputCursor();
         if (cursor.isCapturing())
             cursor.appendInput<DocumentLastModifiedDate>(duration_cast<milliseconds>(dateTime.value().time_since_epoch()).count());
         else if (cursor.isReplaying()) {
-            if (DocumentLastModifiedDate* input = cursor.fetchInput<DocumentLastModifiedDate>())
+            if (auto* input = cursor.fetchInput<DocumentLastModifiedDate>())
                 dateTime = system_clock::time_point(milliseconds(static_cast<long long>(input->fallbackValue())));
         }
 #endif
@@ -4713,6 +4723,7 @@ void Document::unregisterForPrivateBrowsingStateChangedCallbacks(Element* e)
 }
 
 #if ENABLE(VIDEO_TRACK)
+
 void Document::registerForCaptionPreferencesChangedCallbacks(Element* e)
 {
     if (page())
@@ -4731,9 +4742,11 @@ void Document::captionPreferencesChanged()
     for (auto* element : m_captionPreferencesChangedElements)
         element->captionPreferencesChanged();
 }
+
 #endif
 
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
+
 void Document::registerForPageScaleFactorChangedCallbacks(HTMLMediaElement* element)
 {
     m_pageScaleFactorChangedElements.add(element);
@@ -4765,6 +4778,7 @@ void Document::userInterfaceLayoutDirectionChanged()
     for (auto* mediaElement : m_userInterfaceLayoutDirectionChangedElements)
         mediaElement->userInterfaceLayoutDirectionChanged();
 }
+
 #endif
 
 void Document::setShouldCreateRenderers(bool f)
@@ -5074,7 +5088,9 @@ void Document::clearSharedObjectPool()
 }
 
 #if ENABLE(TELEPHONE_NUMBER_DETECTION)
-// FIXME: Find a better place for this functionality.
+
+// FIXME: Find a better place for this code.
+
 bool Document::isTelephoneNumberParsingEnabled() const
 {
     Settings* settings = this->settings();
@@ -5090,6 +5106,7 @@ bool Document::isTelephoneNumberParsingAllowed() const
 {
     return m_isTelephoneNumberParsingAllowed;
 }
+
 #endif
 
 RefPtr<XPathExpression> Document::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)
@@ -5565,6 +5582,7 @@ MediaCanStartListener* Document::takeAnyMediaCanStartListener()
 }
 
 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS)
+
 DeviceMotionController* Document::deviceMotionController() const
 {
     return m_deviceMotionController.get();
@@ -5574,9 +5592,11 @@ DeviceOrientationController* Document::deviceOrientationController() const
 {
     return m_deviceOrientationController.get();
 }
+
 #endif
 
 #if ENABLE(FULLSCREEN_API)
+
 bool Document::fullScreenIsAllowedForElement(Element* element) const
 {
     ASSERT(element);
@@ -6035,30 +6055,34 @@ void Document::addDocumentToFullScreenChangeEventQueue(Document* doc)
         target = doc;
     m_fullScreenChangeEventTargetQueue.append(target);
 }
+
 #endif
 
 #if ENABLE(POINTER_LOCK)
+
 void Document::exitPointerLock()
 {
-    if (!page())
+    Page* page = this>page();
+    if (!page)
         return;
-    if (Element* target = page()->pointerLockController().element()) {
+    if (auto* target = page->pointerLockController().element()) {
         if (&target->document() != this)
             return;
     }
-    page()->pointerLockController().requestPointerUnlock();
+    page->pointerLockController().requestPointerUnlock();
 }
 
 Element* Document::pointerLockElement() const
 {
-    if (!page() || page()->pointerLockController().lockPending())
+    Page* page = this>page();
+    if (!page || page->pointerLockController().lockPending())
         return nullptr;
-    if (Element* element = page()->pointerLockController().element()) {
-        if (&element->document() == this)
-            return element;
-    }
-    return nullptr;
+    auto* element = page()->pointerLockController().element();
+    if (!element || &element->document() != this)
+        return nullptr;
+    return element;
 }
+
 #endif
 
 void Document::decrementLoadEventDelayCount()
@@ -6083,6 +6107,7 @@ double Document::monotonicTimestamp() const
 }
 
 #if ENABLE(REQUEST_ANIMATION_FRAME)
+
 int Document::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
 {
     if (!m_scriptedAnimationController) {
@@ -6122,6 +6147,7 @@ void Document::clearScriptedAnimationController()
         m_scriptedAnimationController->clearDocumentPointer();
     m_scriptedAnimationController = nullptr;
 }
+
 #endif
     
 void Document::sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, const IntPoint& newPosition, const IntRect& visibleRect, const IntSize& contentsSize, Element* target)
@@ -6195,8 +6221,8 @@ void Document::sendWillRevealEdgeEventsIfNeeded(const IntPoint& oldPosition, con
 #endif
 }
 
-#if !PLATFORM(IOS)
-#if ENABLE(TOUCH_EVENTS)
+#if ENABLE(TOUCH_EVENTS) && !PLATFORM(IOS)
+
 RefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, int radiusX, int radiusY, float rotationAngle, float force, ExceptionCode&) const
 {
     // FIXME: It's not clear from the documentation at
@@ -6206,8 +6232,8 @@ RefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int
     Frame* frame = window ? window->frame() : this->frame();
     return Touch::create(frame, target, identifier, screenX, screenY, pageX, pageY, radiusX, radiusY, rotationAngle, force);
 }
+
 #endif
-#endif // !PLATFORM(IOS)
 
 void Document::wheelEventHandlersChanged()
 {
@@ -6446,12 +6472,14 @@ DocumentLoader* Document::loader() const
 }
 
 #if ENABLE(CSS_DEVICE_ADAPTATION)
+
 IntSize Document::initialViewportSize() const
 {
     if (!view())
         return IntSize();
     return view()->initialViewportSize();
 }
+
 #endif
 
 Element* eventTargetElementForDocument(Document* document)
@@ -6759,6 +6787,7 @@ void Document::ensurePlugInsInjectedScript(DOMWrapperWorld& world)
 }
 
 #if ENABLE(SUBTLE_CRYPTO)
+
 bool Document::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey)
 {
     Page* page = this->page();
@@ -6774,6 +6803,7 @@ bool Document::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t
         return false;
     return page->chrome().client().unwrapCryptoKey(wrappedKey, key);
 }
+
 #endif // ENABLE(SUBTLE_CRYPTO)
 
 Element* Document::activeElement()
@@ -6796,13 +6826,21 @@ bool Document::hasFocus() const
 }
 
 #if ENABLE(WEB_REPLAY)
-void Document::setInputCursor(PassRefPtr<InputCursor> cursor)
+
+JSC::InputCursor& Document::inputCursor()
+{
+    return m_inputCursor;
+}
+
+void Document::setInputCursor(Ref<InputCursor>&& cursor)
 {
     m_inputCursor = WTFMove(cursor);
 }
+
 #endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
+
 static uint64_t nextPlaybackTargetClientContextId()
 {
     static uint64_t contextId = 0;
@@ -6893,16 +6931,18 @@ void Document::setShouldPlayToPlaybackTarget(uint64_t clientId, bool shouldPlay)
 
     it->value->setShouldPlayToPlaybackTarget(shouldPlay);
 }
+
 #endif // ENABLE(WIRELESS_PLAYBACK_TARGET)
 
 #if ENABLE(MEDIA_SESSION)
+
 MediaSession& Document::defaultMediaSession()
 {
     if (!m_defaultMediaSession)
         m_defaultMediaSession = MediaSession::create(*scriptExecutionContext());
-
     return *m_defaultMediaSession;
 }
+
 #endif
 
 ShouldOpenExternalURLsPolicy Document::shouldOpenExternalURLsPolicyToPropagate() const
@@ -6962,4 +7002,9 @@ void Document::setDir(const AtomicString& value)
         downcast<HTMLHtmlElement>(*documentElement).setDir(value);
 }
 
+DOMSelection* Document::getSelection()
+{
+    return m_domWindow ? m_domWindow->getSelection() : nullptr;
+}
+
 } // namespace WebCore
index 0b721c5..3460916 100644 (file)
@@ -443,8 +443,8 @@ public:
     WEBCORE_EXPORT void setDocumentURI(const String&);
 
 #if ENABLE(WEB_REPLAY)
-    JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
-    void setInputCursor(PassRefPtr<JSC::InputCursor>);
+    JSC::InputCursor& inputCursor();
+    void setInputCursor(Ref<JSC::InputCursor>&&);
 #endif
 
     void visibilityStateChanged();
@@ -852,7 +852,7 @@ public:
     WEBCORE_EXPORT String domain() const;
     void setDomain(const String& newDomain, ExceptionCode&);
 
-    WEBCORE_EXPORT String lastModified() const;
+    WEBCORE_EXPORT String lastModified();
 
     // The cookieURL is used to query the cookie database for this document's
     // cookies. For example, if the cookie URL is http://example.com, we'll
@@ -1292,6 +1292,8 @@ public:
     using ContainerNode::setAttributeEventListener;
     void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value);
 
+    DOMSelection* getSelection();
+
 protected:
     enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
     Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
@@ -1711,7 +1713,7 @@ private:
     Ref<CSSFontSelector> m_fontSelector;
 
 #if ENABLE(WEB_REPLAY)
-    RefPtr<JSC::InputCursor> m_inputCursor;
+    Ref<JSC::InputCursor> m_inputCursor;
 #endif
 
     Timer m_didAssociateFormControlsTimer;
index 8594974..587aee9 100644 (file)
@@ -32,7 +32,7 @@
     readonly attribute Element? documentElement;
 
     [NewObject, MayThrowLegacyException, ImplementedAs=createElementForBindings] Element createElement(DOMString tagName);
-    [NewObject] DocumentFragment   createDocumentFragment();
+    [NewObject] DocumentFragment createDocumentFragment();
 
     [NewObject] Text createTextNode(DOMString data);
     [NewObject] Comment createComment(DOMString data);
 
     [NewObject] Range createRange();
 
-    [NewObject] NodeIterator createNodeIterator(Node root,
-        optional unsigned long whatToShow = 0xFFFFFFFF,
-        optional NodeFilter? filter = null);
-    [NewObject] TreeWalker createTreeWalker(Node root,
-        optional unsigned long whatToShow = 0xFFFFFFFF,
-        optional NodeFilter? filter = null);
+    [NewObject] NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
+    [NewObject] TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
 
     readonly attribute DOMWindow defaultView;
 
index 882630d..2024201 100644 (file)
@@ -34,26 +34,22 @@ using ExceptionCode = int;
 
 class Exception {
 public:
-    explicit Exception(ExceptionCode);
-    explicit Exception(ExceptionCode, const String&);
+    explicit Exception(ExceptionCode, String&& = { });
 
     ExceptionCode code() const { return m_code; }
     const String& message() const { return m_message; }
+    String&& releaseMessage() { return WTFMove(m_message); }
 
 private:
     ExceptionCode m_code;
     String m_message;
 };
 
-inline Exception::Exception(ExceptionCode code)
+inline Exception::Exception(ExceptionCode code, String&& message)
     : m_code(code)
+    , m_message(WTFMove(message))
 {
-}
-
-inline Exception::Exception(ExceptionCode code, const String& message)
-    : m_code(code)
-    , m_message(message)
-{
+    ASSERT(code);
 }
 
 }
index 53a44de..258e112 100644 (file)
@@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #pragma once
 
 #include "Exception.h"
+#include <wtf/Optional.h>
 #include <wtf/Variant.h>
 
 namespace WebCore {
@@ -37,14 +38,25 @@ public:
     ExceptionOr(ReturnType&&);
 
     bool hasException() const;
-    ExceptionCode exceptionCode() const;
-    const String& exceptionMessage() const;
-    ReturnType&& takeReturnValue();
+    Exception&& releaseException();
+    ReturnType&& releaseReturnValue();
 
 private:
     std::experimental::variant<Exception, ReturnType> m_value;
 };
 
+template<> class ExceptionOr<void> {
+public:
+    ExceptionOr(Exception&&);
+    ExceptionOr() = default;
+
+    bool hasException() const;
+    Exception&& releaseException();
+
+private:
+    Optional<Exception> m_exception;
+};
+
 template<typename ReturnType> inline ExceptionOr<ReturnType>::ExceptionOr(Exception&& exception)
     : m_value(WTFMove(exception))
 {
@@ -60,19 +72,29 @@ template<typename ReturnType> inline bool ExceptionOr<ReturnType>::hasException(
     return std::experimental::holds_alternative<Exception>(m_value);
 }
 
-template<typename ReturnType> inline ExceptionCode ExceptionOr<ReturnType>::exceptionCode() const
+template<typename ReturnType> inline Exception&& ExceptionOr<ReturnType>::releaseException()
 {
-    return std::experimental::get<Exception>(m_value).code();
+    return std::experimental::get<Exception>(WTFMove(m_value));
 }
 
-template<typename ReturnType> inline const String& ExceptionOr<ReturnType>::exceptionMessage() const
+template<typename ReturnType> inline ReturnType&& ExceptionOr<ReturnType>::releaseReturnValue()
 {
-    return std::experimental::get<Exception>(m_value).message();
+    return std::experimental::get<ReturnType>(WTFMove(m_value));
 }
 
-template<typename ReturnType> inline ReturnType&& ExceptionOr<ReturnType>::takeReturnValue()
+inline ExceptionOr<void>::ExceptionOr(Exception&& exception)
+    : m_exception(WTFMove(exception))
 {
-    return std::experimental::get<ReturnType>(WTFMove(m_value));
+}
+
+inline bool ExceptionOr<void>::hasException() const
+{
+    return !!m_exception;
+}
+
+inline Exception&& ExceptionOr<void>::releaseException()
+{
+    return WTFMove(m_exception.value());
 }
 
 }
index 3606a65..a8fc9b3 100644 (file)
@@ -27,7 +27,6 @@
 #include "config.h"
 #include "TreeScope.h"
 
-#include "DOMSelection.h"
 #include "DOMWindow.h"
 #include "ElementIterator.h"
 #include "FocusController.h"
@@ -49,7 +48,7 @@
 namespace WebCore {
 
 struct SameSizeAsTreeScope {
-    void* pointers[9];
+    void* pointers[8];
 };
 
 COMPILE_ASSERT(sizeof(TreeScope) == sizeof(SameSizeAsTreeScope), treescope_should_stay_small);
@@ -76,10 +75,6 @@ TreeScope::TreeScope(Document& document)
 
 TreeScope::~TreeScope()
 {
-    if (m_selection) {
-        m_selection->clearTreeScope();
-        m_selection = nullptr;
-    }
 }
 
 void TreeScope::destroyTreeScopeData()
@@ -331,21 +326,6 @@ Element* TreeScope::elementFromPoint(int x, int y)
     return downcast<Element>(node);
 }
 
-DOMSelection* TreeScope::getSelection() const
-{
-    if (!m_rootNode.document().frame())
-        return nullptr;
-
-    if (m_selection)
-        return m_selection.get();
-
-    if (this != &m_rootNode.document())
-        return m_rootNode.document().getSelection();
-
-    m_selection = DOMSelection::create(&m_rootNode.document());
-    return m_selection.get();
-}
-
 Element* TreeScope::findAnchor(const String& name)
 {
     if (name.isEmpty())
index 0b66b64..06af5e1 100644 (file)
@@ -35,7 +35,6 @@
 namespace WebCore {
 
 class ContainerNode;
-class DOMSelection;
 class Document;
 class Element;
 class HTMLLabelElement;
@@ -88,8 +87,6 @@ public:
 
     WEBCORE_EXPORT Element* elementFromPoint(int x, int y);
 
-    DOMSelection* getSelection() const;
-
     // Find first anchor with the given name.
     // First searches for an element with the given ID, but if that fails, then looks
     // for an anchor with the given name. ID matching is always case sensitive, but
@@ -129,8 +126,6 @@ private:
     std::unique_ptr<DocumentOrderedMap> m_labelsByForAttribute;
 
     std::unique_ptr<IdTargetObserverRegistry> m_idTargetObserverRegistry;
-
-    mutable RefPtr<DOMSelection> m_selection;
 };
 
 inline bool TreeScope::hasElementWithId(const AtomicStringImpl& id) const
index b4af243..c77ad1d 100644 (file)
@@ -123,7 +123,7 @@ bool PageScriptDebugServer::isContentScript(ExecState* exec) const
     return &currentWorld(exec) != &mainThreadNormalWorld();
 }
 
-void PageScriptDebugServer::reportException(ExecState* exec, Exception* exception) const
+void PageScriptDebugServer::reportException(ExecState* exec, JSC::Exception* exception) const
 {
     WebCore::reportException(exec, exception);
 }
index 9f0ff86..26c8e8c 100644 (file)
 
 namespace WebCore {
 
-static Node* selectionShadowAncestor(Frame* frame)
+static Node* selectionShadowAncestor(Frame& frame)
 {
-    Node* node = frame->selection().selection().base().anchorNode();
+    auto* node = frame.selection().selection().base().anchorNode();
     if (!node)
-        return 0;
-
+        return nullptr;
     if (!node->isInShadowTree())
-        return 0;
-
-    return frame->document()->ancestorInThisScope(node);
-}
-
-DOMSelection::DOMSelection(const TreeScope* treeScope)
-    : DOMWindowProperty(treeScope->rootNode().document().frame())
-    , m_treeScope(treeScope)
-{
+        return nullptr;
+    // FIXME: Unclear on why this needs to be the possibly null frame.document() instead of the never null node->document().
+    return frame.document()->ancestorInThisScope(node);
 }
 
-void DOMSelection::clearTreeScope()
+DOMSelection::DOMSelection(Frame& frame)
+    : DOMWindowProperty(&frame)
 {
-    m_treeScope = nullptr;
 }
 
 const VisibleSelection& DOMSelection::visibleSelection() const
@@ -72,13 +65,13 @@ const VisibleSelection& DOMSelection::visibleSelection() const
 
 static Position anchorPosition(const VisibleSelection& selection)
 {
-    Position anchor = selection.isBaseFirst() ? selection.start() : selection.end();
+    auto anchor = selection.isBaseFirst() ? selection.start() : selection.end();
     return anchor.parentAnchoredEquivalent();
 }
 
 static Position focusPosition(const VisibleSelection& selection)
 {
-    Position focus = selection.isBaseFirst() ? selection.end() : selection.start();
+    auto focus = selection.isBaseFirst() ? selection.end() : selection.start();
     return focus.parentAnchoredEquivalent();
 }
 
@@ -96,7 +89,6 @@ Node* DOMSelection::anchorNode() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedNode(anchorPosition(visibleSelection()));
 }
 
@@ -104,15 +96,13 @@ unsigned DOMSelection::anchorOffset() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedOffset(anchorPosition(visibleSelection()));
 }
 
 Node* DOMSelection::focusNode() const
 {
     if (!m_frame)
-        return 0;
-
+        return nullptr;
     return shadowAdjustedNode(focusPosition(visibleSelection()));
 }
 
@@ -120,7 +110,6 @@ unsigned DOMSelection::focusOffset() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedOffset(focusPosition(visibleSelection()));
 }
 
@@ -128,7 +117,6 @@ Node* DOMSelection::baseNode() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedNode(basePosition(visibleSelection()));
 }
 
@@ -136,7 +124,6 @@ unsigned DOMSelection::baseOffset() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedOffset(basePosition(visibleSelection()));
 }
 
@@ -144,7 +131,6 @@ Node* DOMSelection::extentNode() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedNode(extentPosition(visibleSelection()));
 }
 
@@ -152,13 +138,12 @@ unsigned DOMSelection::extentOffset() const
 {
     if (!m_frame)
         return 0;
-
     return shadowAdjustedOffset(extentPosition(visibleSelection()));
 }
 
 bool DOMSelection::isCollapsed() const
 {
-    if (!m_frame || selectionShadowAncestor(m_frame))
+    if (!m_frame || selectionShadowAncestor(*m_frame))
         return true;
     return !m_frame->selection().isRange();
 }
@@ -166,67 +151,47 @@ bool DOMSelection::isCollapsed() const
 String DOMSelection::type() const
 {
     if (!m_frame)
-        return String();
-
-    FrameSelection& selection = m_frame->selection();
-
-    // This is a WebKit DOM extension, incompatible with an IE extension
-    // IE has this same attribute, but returns "none", "text" and "control"
-    // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx
+        return ASCIILiteral("None");
+    auto& selection = m_frame->selection();
     if (selection.isNone())
-        return "None";
+        return ASCIILiteral("None");
     if (selection.isCaret())
-        return "Caret";
-    return "Range";
+        return ASCIILiteral("Caret");
+    return ASCIILiteral("Range");
 }
 
 unsigned DOMSelection::rangeCount() const
 {
-    if (!m_frame)
-        return 0;
-    return m_frame->selection().isNone() ? 0 : 1;
+    return !m_frame || m_frame->selection().isNone() ? 0 : 1;
 }
 
 void DOMSelection::collapse(Node* node, unsigned offset)
 {
-    if (!m_frame)
-        return;
-
     if (!isValidForPosition(node))
         return;
-
-    // FIXME: Eliminate legacy editing positions
     m_frame->selection().moveTo(createLegacyEditingPosition(node, offset), DOWNSTREAM);
 }
 
-void DOMSelection::collapseToEnd(ExceptionCode& ec)
+ExceptionOr<void> DOMSelection::collapseToEnd()
 {
     if (!m_frame)
-        return;
-
-    const VisibleSelection& selection = m_frame->selection().selection();
-
-    if (selection.isNone()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
-
-    m_frame->selection().moveTo(selection.end(), DOWNSTREAM);
+        return { };
+    auto& selection = m_frame->selection();
+    if (selection.isNone())
+        return Exception { INVALID_STATE_ERR };
+    selection.moveTo(selection.selection().end(), DOWNSTREAM);
+    return { };
 }
 
-void DOMSelection::collapseToStart(ExceptionCode& ec)
+ExceptionOr<void> DOMSelection::collapseToStart()
 {
     if (!m_frame)
-        return;
-
-    const VisibleSelection& selection = m_frame->selection().selection();
-
-    if (selection.isNone()) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
-
-    m_frame->selection().moveTo(selection.start(), DOWNSTREAM);
+        return { };
+    auto& selection = m_frame->selection();
+    if (selection.isNone())
+        return Exception { INVALID_STATE_ERR };
+    selection.moveTo(selection.selection().start(), DOWNSTREAM);
+    return { };
 }
 
 void DOMSelection::empty()
@@ -238,25 +203,15 @@ void DOMSelection::empty()
 
 void DOMSelection::setBaseAndExtent(Node* baseNode, unsigned baseOffset, Node* extentNode, unsigned extentOffset)
 {
-    if (!m_frame)
-        return;
-
     if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
         return;
-
-    // FIXME: Eliminate legacy editing positions
     m_frame->selection().moveTo(createLegacyEditingPosition(baseNode, baseOffset), createLegacyEditingPosition(extentNode, extentOffset), DOWNSTREAM);
 }
 
 void DOMSelection::setPosition(Node* node, unsigned offset)
 {
-    if (!m_frame)
-        return;
-
     if (!isValidForPosition(node))
         return;
-
-    // FIXME: Eliminate legacy editing positions
     m_frame->selection().moveTo(createLegacyEditingPosition(node, offset), DOWNSTREAM);
 }
 
@@ -310,43 +265,33 @@ void DOMSelection::modify(const String& alterString, const String& directionStri
     m_frame->selection().modify(alter, direction, granularity);
 }
 
-void DOMSelection::extend(Node& node, unsigned offset, ExceptionCode& ec)
+ExceptionOr<void> DOMSelection::extend(Node& node, unsigned offset)
 {
     if (!m_frame)
-        return;
-
-    if (offset > (node.offsetInCharacters() ? caretMaxOffset(node) : node.countChildNodes())) {
-        ec = INDEX_SIZE_ERR;
-        return;
-    }
-
+        return { };
+    if (offset > (node.offsetInCharacters() ? caretMaxOffset(node) : node.countChildNodes()))
+        return Exception { INDEX_SIZE_ERR };
     if (!isValidForPosition(&node))
-        return;
-
-    // FIXME: Eliminate legacy editing positions
+        return { };
     m_frame->selection().setExtent(createLegacyEditingPosition(&node, offset), DOWNSTREAM);
+    return { };
 }
 
-RefPtr<Range> DOMSelection::getRangeAt(unsigned index, ExceptionCode& ec)
+ExceptionOr<Ref<Range>> DOMSelection::getRangeAt(unsigned index)
 {
-    if (!m_frame)
-        return nullptr;
-
-    if (index >= rangeCount()) {
-        ec = INDEX_SIZE_ERR;
-        return nullptr;
-    }
+    if (index >= rangeCount())
+        return Exception { INDEX_SIZE_ERR };
 
-    // If you're hitting this, you've added broken multi-range selection support
+    // If you're hitting this, you've added broken multi-range selection support.
     ASSERT(rangeCount() == 1);
 
-    if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) {
-        ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree();
+    if (auto* shadowAncestor = selectionShadowAncestor(*m_frame)) {
+        auto* container = shadowAncestor->parentNodeGuaranteedHostFree();
         unsigned offset = shadowAncestor->computeNodeIndex();
         return Range::create(shadowAncestor->document(), container, offset, container, offset);
     }
 
-    return m_frame->selection().selection().firstRange();
+    return m_frame->selection().selection().firstRange().releaseNonNull();
 }
 
 void DOMSelection::removeAllRanges()
@@ -361,13 +306,13 @@ void DOMSelection::addRange(Range& range)
     if (!m_frame)
         return;
 
-    FrameSelection& selection = m_frame->selection();
+    auto& selection = m_frame->selection();
     if (selection.isNone()) {
         selection.moveTo(&range);
         return;
     }
 
-    RefPtr<Range> normalizedRange = selection.selection().toNormalizedRange();
+    auto normalizedRange = selection.selection().toNormalizedRange();
     if (!normalizedRange)
         return;
 
@@ -402,17 +347,15 @@ void DOMSelection::deleteFromDocument()
     if (!m_frame)
         return;
 
-    FrameSelection& selection = m_frame->selection();
-
+    auto& selection = m_frame->selection();
     if (selection.isNone())
         return;
 
-    RefPtr<Range> selectedRange = selection.selection().toNormalizedRange();
+    auto selectedRange = selection.selection().toNormalizedRange();
     if (!selectedRange)
         return;
 
     selectedRange->deleteContents(ASSERT_NO_EXCEPTION);
-
     setBaseAndExtent(&selectedRange->startContainer(), selectedRange->startOffset(), &selectedRange->startContainer(), selectedRange->startOffset());
 }
 
@@ -421,13 +364,12 @@ bool DOMSelection::containsNode(Node& node, bool allowPartial) const
     if (!m_frame)
         return false;
 
-    FrameSelection& selection = m_frame->selection();
-
+    auto& selection = m_frame->selection();
     if (m_frame->document() != &node.document() || selection.isNone())
         return false;
 
     Ref<Node> protectedNode(node);
-    RefPtr<Range> selectedRange = selection.selection().toNormalizedRange();
+    auto selectedRange = selection.selection().toNormalizedRange();
 
     ContainerNode* parentNode = node.parentNode();
     if (!parentNode || !parentNode->inDocument())
@@ -460,20 +402,18 @@ String DOMSelection::toString()
 {
     if (!m_frame)
         return String();
-
     return plainText(m_frame->selection().selection().toNormalizedRange().get());
 }
 
 Node* DOMSelection::shadowAdjustedNode(const Position& position) const
 {
     if (position.isNull())
-        return 0;
-
-    Node* containerNode = position.containerNode();
-    Node* adjustedNode = m_treeScope->ancestorInThisScope(containerNode);
+        return nullptr;
 
+    auto* containerNode = position.containerNode();
+    auto* adjustedNode = m_frame->document()->ancestorInThisScope(containerNode);
     if (!adjustedNode)
-        return 0;
+        return nullptr;
 
     if (containerNode == adjustedNode)
         return containerNode;
@@ -486,9 +426,8 @@ unsigned DOMSelection::shadowAdjustedOffset(const Position& position) const
     if (position.isNull())
         return 0;
 
-    Node* containerNode = position.containerNode();
-    Node* adjustedNode = m_treeScope->ancestorInThisScope(containerNode);
-
+    auto* containerNode = position.containerNode();
+    auto* adjustedNode = m_frame->document()->ancestorInThisScope(containerNode);
     if (!adjustedNode)
         return 0;
 
@@ -500,7 +439,8 @@ unsigned DOMSelection::shadowAdjustedOffset(const Position& position) const
 
 bool DOMSelection::isValidForPosition(Node* node) const
 {
-    ASSERT(m_frame);
+    if (!m_frame)
+        return false;
     if (!node)
         return true;
     return &node->document() == m_frame->document();
index b353470..65836a9 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
- * Copyright (C) 2012 Google Inc.  All rights reserved.
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
-#ifndef DOMSelection_h
-#define DOMSelection_h
+#pragma once
 
 #include "DOMWindowProperty.h"
+#include "ExceptionOr.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-    class Frame;
-    class Node;
-    class Position;
-    class Range;
-    class TreeScope;
-    class VisibleSelection;
-
-    typedef int ExceptionCode;
-
-    class DOMSelection : public RefCounted<DOMSelection>, public DOMWindowProperty {
-    public:
-        static Ref<DOMSelection> create(const TreeScope* treeScope) { return adoptRef(*new DOMSelection(treeScope)); }
-
-        void clearTreeScope();
-
-        // Safari Selection Object API
-        // These methods return the valid equivalents of internal editing positions.
-        Node* baseNode() const;
-        Node* extentNode() const;
-        unsigned baseOffset() const;
-        unsigned extentOffset() const;
-        String type() const;
-        void setBaseAndExtent(Node* baseNode, unsigned baseOffset, Node* extentNode, unsigned extentOffset);
-        void setPosition(Node*, unsigned offset);
-        void modify(const String& alter, const String& direction, const String& granularity);
-
-        // Mozilla Selection Object API
-        // In Firefox, anchor/focus are the equal to the start/end of the selection,
-        // but reflect the direction in which the selection was made by the user.  That does
-        // not mean that they are base/extent, since the base/extent don't reflect
-        // expansion.
-        // These methods return the valid equivalents of internal editing positions.
-        Node* anchorNode() const;
-        unsigned anchorOffset() const;
-        Node* focusNode() const;
-        unsigned focusOffset() const;
-        bool isCollapsed() const;
-        unsigned rangeCount() const;
-        void collapse(Node*, unsigned offset);
-        void collapseToEnd(ExceptionCode&);
-        void collapseToStart(ExceptionCode&);
-        void extend(Node&, unsigned offset, ExceptionCode&);
-        RefPtr<Range> getRangeAt(unsigned, ExceptionCode&);
-        void removeAllRanges();
-        void addRange(Range&);
-        void deleteFromDocument();
-        bool containsNode(Node&, bool partlyContained) const;
-        void selectAllChildren(Node&);
-
-        String toString();
-
-        // Microsoft Selection Object API
-        void empty();
-
-    private:
-        const TreeScope* m_treeScope;
-
-        explicit DOMSelection(const TreeScope*);
-
-        // Convenience method for accessors, does not NULL check m_frame.
-        const VisibleSelection& visibleSelection() const;
-
-        Node* shadowAdjustedNode(const Position&) const;
-        unsigned shadowAdjustedOffset(const Position&) const;
-
-        bool isValidForPosition(Node*) const;
-    };
+class Node;
+class Position;
+class Range;
+class VisibleSelection;
+
+class DOMSelection : public RefCounted<DOMSelection>, public DOMWindowProperty {
+public:
+    static Ref<DOMSelection> create(Frame& frame) { return adoptRef(*new DOMSelection(frame)); }
+
+    Node* baseNode() const;
+    Node* extentNode() const;
+    unsigned baseOffset() const;
+    unsigned extentOffset() const;
+    String type() const;
+    void setBaseAndExtent(Node* baseNode, unsigned baseOffset, Node* extentNode, unsigned extentOffset);
+    void setPosition(Node*, unsigned offset);
+    void modify(const String& alter, const String& direction, const String& granularity);
+
+    // The anchor and focus are the start and end of the selection, and
+    // reflect the direction in which the selection was made by the user.
+    // The base and extent are different, because they don't reflect expansion.
+    Node* anchorNode() const;
+    unsigned anchorOffset() const;
+    Node* focusNode() const;
+    unsigned focusOffset() const;
+    bool isCollapsed() const;
+    unsigned rangeCount() const;
+    void collapse(Node*, unsigned offset);
+    ExceptionOr<void> collapseToEnd();
+    ExceptionOr<void> collapseToStart();
+    ExceptionOr<void> extend(Node&, unsigned offset);
+    ExceptionOr<Ref<Range>> getRangeAt(unsigned);
+    void removeAllRanges();
+    void addRange(Range&);
+    void deleteFromDocument();
+    bool containsNode(Node&, bool partlyContained) const;
+    void selectAllChildren(Node&);
+
+    String toString();
+
+    void empty();
+
+private:
+    explicit DOMSelection(Frame&);
+
+    // Convenience method for accessors, caller must null-check m_frame.
+    const VisibleSelection& visibleSelection() const;
+
+    Node* shadowAdjustedNode(const Position&) const;
+    unsigned shadowAdjustedOffset(const Position&) const;
+
+    bool isValidForPosition(Node*) const;
+};
 
 } // namespace WebCore
-
-#endif // DOMSelection_h
index f557ba7..110b8b1 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
- * Copyright (C) 2009 Google Inc.  All rights reserved.
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
     readonly attribute unsigned long rangeCount;
 
     void collapse(Node? node, optional unsigned long offset = 0);
-    [MayThrowLegacyException] void collapseToEnd();
-    [MayThrowLegacyException] void collapseToStart();
+    [MayThrowException] void collapseToEnd();
+    [MayThrowException] void collapseToStart();
 
     void deleteFromDocument();
     boolean containsNode(Node node, optional boolean allowPartial = false);
     void selectAllChildren(Node node);
 
-    [MayThrowLegacyException] void extend(Node node, optional unsigned long offset = 0);
+    [MayThrowException] void extend(Node node, optional unsigned long offset = 0);
 
-    [MayThrowLegacyException] Range getRangeAt(unsigned long index);
+    [MayThrowException] Range getRangeAt(unsigned long index);
     void removeAllRanges();
     void addRange(Range range);
 
     // FIXME: The following operation should be implemented.
     // void removeRange(Range range);
 
-    // WebKit extensions.
-
     // FIXME: Using "undefined" as default parameter value is wrong.
     void modify(optional DOMString alter = "undefined", optional DOMString direction = "undefined", optional DOMString granularity = "undefined");
 
-    readonly attribute Node baseNode;
+    readonly attribute Node? baseNode;
     readonly attribute unsigned long baseOffset;
-    readonly attribute Node extentNode;
+    readonly attribute Node? extentNode;
     readonly attribute unsigned long extentOffset;
 };
-
index 001d864..cdae5ff 100644 (file)
@@ -597,24 +597,26 @@ void DOMWindow::resetDOMWindowProperties()
 {
     m_properties.clear();
 
-    m_screen = nullptr;
-    m_history = nullptr;
+    m_applicationCache = nullptr;
     m_crypto = nullptr;
+    m_history = nullptr;
+    m_localStorage = nullptr;
+    m_location = nullptr;
     m_locationbar = nullptr;
+    m_media = nullptr;
     m_menubar = nullptr;
+    m_navigator = nullptr;
     m_personalbar = nullptr;
+    m_screen = nullptr;
     m_scrollbars = nullptr;
+    m_selection = nullptr;
+    m_sessionStorage = nullptr;
     m_statusbar = nullptr;
     m_toolbar = nullptr;
-    m_navigator = nullptr;
+
 #if ENABLE(WEB_TIMING)
     m_performance = nullptr;
 #endif
-    m_location = nullptr;
-    m_media = nullptr;
-    m_sessionStorage = nullptr;
-    m_localStorage = nullptr;
-    m_applicationCache = nullptr;
 }
 
 bool DOMWindow::isCurrentlyDisplayedInFrame() const
@@ -653,7 +655,7 @@ Screen* DOMWindow::screen() const
 History* DOMWindow::history() const
 {
     if (!isCurrentlyDisplayedInFrame())
-        return 0;
+        return nullptr;
     if (!m_history)
         m_history = History::create(m_frame);
     return m_history.get();
@@ -964,10 +966,11 @@ void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
 
 DOMSelection* DOMWindow::getSelection()
 {
-    if (!isCurrentlyDisplayedInFrame() || !m_frame)
-        return 0;
-
-    return m_frame->document()->getSelection();
+    if (!isCurrentlyDisplayedInFrame())
+        return nullptr;
+    if (!m_selection)
+        m_selection = DOMSelection::create(*m_frame);
+    return m_selection.get();
 }
 
 Element* DOMWindow::frameElement() const
index 3d3848c..e5fd32e 100644 (file)
@@ -141,8 +141,6 @@ namespace WebCore {
         static bool canShowModalDialog(const Frame*);
         WEBCORE_EXPORT void setCanShowModalDialogOverride(bool);
 
-        // DOM Level 0
-
         Screen* screen() const;
         History* history() const;
         Crypto* crypto() const;
@@ -380,18 +378,19 @@ namespace WebCore {
 
         HashSet<DOMWindowProperty*> m_properties;
 
-        mutable RefPtr<Screen> m_screen;
+        mutable RefPtr<Crypto> m_crypto;
         mutable RefPtr<History> m_history;
-        mutable RefPtr<Crypto>  m_crypto;
         mutable RefPtr<BarProp> m_locationbar;
+        mutable RefPtr<StyleMedia> m_media;
         mutable RefPtr<BarProp> m_menubar;
+        mutable RefPtr<Navigator> m_navigator;
         mutable RefPtr<BarProp> m_personalbar;
+        mutable RefPtr<Screen> m_screen;
         mutable RefPtr<BarProp> m_scrollbars;
+        mutable RefPtr<DOMSelection> m_selection;
         mutable RefPtr<BarProp> m_statusbar;
         mutable RefPtr<BarProp> m_toolbar;
-        mutable RefPtr<Navigator> m_navigator;
         mutable RefPtr<Location> m_location;
-        mutable RefPtr<StyleMedia> m_media;
 
         String m_status;
         String m_defaultStatus;
index d10501a..dae8ca6 100644 (file)
@@ -421,7 +421,7 @@ void ReplayController::frameNavigated(DocumentLoader* loader)
 
     // We store the input cursor in both Document and JSDOMWindow, so that
     // replay state is accessible from JavaScriptCore and script-free layout code.
-    loader->frame()->document()->setInputCursor(m_activeCursor.get());
+    loader->frame()->document()->setInputCursor(*m_activeCursor);
     loader->frame()->script().globalObject(mainThreadNormalWorld())->setInputCursor(m_activeCursor.get());
 }
 
index 766a3c7..c9615a4 100644 (file)
@@ -157,12 +157,10 @@ XMLHttpRequest::State XMLHttpRequest::readyState() const
     return m_state;
 }
 
-String XMLHttpRequest::responseText(ExceptionCode& ec)
+ExceptionOr<String> XMLHttpRequest::responseText()
 {
-    if (m_responseType != ResponseType::EmptyString && m_responseType != ResponseType::Text) {
-        ec = INVALID_STATE_ERR;
-        return { };
-    }
+    if (m_responseType != ResponseType::EmptyString && m_responseType != ResponseType::Text)
+        return Exception { INVALID_STATE_ERR };
     return responseTextIgnoringResponseType();
 }
 
@@ -173,12 +171,10 @@ void XMLHttpRequest::didCacheResponse()
     m_responseBuilder.clear();
 }
 
-Document* XMLHttpRequest::responseXML(ExceptionCode& ec)
+ExceptionOr<Document*> XMLHttpRequest::responseXML()
 {
-    if (m_responseType != ResponseType::EmptyString && m_responseType != ResponseType::Document) {
-        ec = INVALID_STATE_ERR;
-        return nullptr;
-    }
+    if (m_responseType != ResponseType::EmptyString && m_responseType != ResponseType::Document)
+        return Exception { INVALID_STATE_ERR };
 
     if (!doneWithoutErrors())
         return nullptr;
@@ -239,30 +235,28 @@ RefPtr<ArrayBuffer> XMLHttpRequest::createResponseArrayBuffer()
     return result;
 }
 
-void XMLHttpRequest::setTimeout(unsigned timeout, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::setTimeout(unsigned timeout)
 {
     if (scriptExecutionContext()->isDocument() && !m_async) {
         logConsoleError(scriptExecutionContext(), "XMLHttpRequest.timeout cannot be set for synchronous HTTP(S) requests made from the window context.");
-        ec = INVALID_ACCESS_ERR;
-        return;
+        return Exception { INVALID_ACCESS_ERR };
     }
     m_timeoutMilliseconds = timeout;
     if (!m_timeoutTimer.isActive())
-        return;
+        return { };
     if (!m_timeoutMilliseconds) {
         m_timeoutTimer.stop();
-        return;
+        return { };
     }
     std::chrono::duration<double> interval = std::chrono::milliseconds { m_timeoutMilliseconds } - (std::chrono::steady_clock::now() - m_sendingTime);
     m_timeoutTimer.startOneShot(std::max(0.0, interval.count()));
+    return { };
 }
 
-void XMLHttpRequest::setResponseType(ResponseType type, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::setResponseType(ResponseType type)
 {
-    if (m_state >= LOADING) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (m_state >= LOADING)
+        return Exception { INVALID_STATE_ERR };
 
     // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated
     // attempt to discourage synchronous XHR use. responseType is one such piece of functionality.
@@ -270,11 +264,11 @@ void XMLHttpRequest::setResponseType(ResponseType type, ExceptionCode& ec)
     // such as file: and data: still make sense to allow.
     if (!m_async && scriptExecutionContext()->isDocument() && m_url.protocolIsInHTTPFamily()) {
         logConsoleError(scriptExecutionContext(), "XMLHttpRequest.responseType cannot be changed for synchronous HTTP(S) requests made from the window context.");
-        ec = INVALID_ACCESS_ERR;
-        return;
+        return Exception { INVALID_ACCESS_ERR };
     }
 
     m_responseType = type;
+    return { };
 }
 
 String XMLHttpRequest::responseURL() const
@@ -323,14 +317,13 @@ void XMLHttpRequest::callReadyStateChangeListener()
     }
 }
 
-void XMLHttpRequest::setWithCredentials(bool value, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::setWithCredentials(bool value)
 {
-    if (m_state > OPENED || m_sendFlag) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (m_state > OPENED || m_sendFlag)
+        return Exception { INVALID_STATE_ERR };
 
     m_includeCredentials = value;
+    return { };
 }
 
 bool XMLHttpRequest::isAllowedHTTPMethod(const String& method)
@@ -404,16 +397,16 @@ bool XMLHttpRequest::isAllowedHTTPHeader(const String& name)
     return true;
 }
 
-void XMLHttpRequest::open(const String& method, const String& url, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url)
 {
     // If the async argument is omitted, set async to true.
-    return open(method, scriptExecutionContext()->completeURL(url), true, ec);
+    return open(method, scriptExecutionContext()->completeURL(url), true);
 }
 
-void XMLHttpRequest::open(const String& method, const URL& url, bool async, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::open(const String& method, const URL& url, bool async)
 {
     if (!internalAbort())
-        return;
+        return { };
 
     State previousState = m_state;
     m_state = UNSENT;
@@ -427,21 +420,16 @@ void XMLHttpRequest::open(const String& method, const URL& url, bool async, Exce
 
     ASSERT(m_state == UNSENT);
 
-    if (!isValidHTTPToken(method)) {
-        ec = SYNTAX_ERR;
-        return;
-    }
+    if (!isValidHTTPToken(method))
+        return Exception { SYNTAX_ERR };
 
-    if (!isAllowedHTTPMethod(method)) {
-        ec = SECURITY_ERR;
-        return;
-    }
+    if (!isAllowedHTTPMethod(method))
+        return Exception { SECURITY_ERR };
 
     if (!async && scriptExecutionContext()->isDocument()) {
         if (document()->settings() && !document()->settings()->syncXHRInDocumentsEnabled()) {
             logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests are disabled for this page.");
-            ec = INVALID_ACCESS_ERR;
-            return;
+            return Exception { INVALID_ACCESS_ERR };
         }
 
         // Newer functionality is not available to synchronous requests in window contexts, as a spec-mandated
@@ -450,15 +438,13 @@ void XMLHttpRequest::open(const String& method, const URL& url, bool async, Exce
         // such as file: and data: still make sense to allow.
         if (url.protocolIsInHTTPFamily() && m_responseType != ResponseType::EmptyString) {
             logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set.");
-            ec = INVALID_ACCESS_ERR;
-            return;
+            return Exception { INVALID_ACCESS_ERR };
         }
 
         // Similarly, timeouts are disabled for synchronous requests as well.
         if (m_timeoutMilliseconds > 0) {
             logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests must not have a timeout value set.");
-            ec = INVALID_ACCESS_ERR;
-            return;
+            return Exception { INVALID_ACCESS_ERR };
         }
     }
 
@@ -477,9 +463,11 @@ void XMLHttpRequest::open(const String& method, const URL& url, bool async, Exce
         changeState(OPENED);
     else
         m_state = OPENED;
+
+    return { };
 }
 
-void XMLHttpRequest::open(const String& method, const String& url, bool async, const String& user, const String& password, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url, bool async, const String& user, const String& password)
 {
     URL urlWithCredentials = scriptExecutionContext()->completeURL(url);
     if (!user.isNull()) {
@@ -488,48 +476,41 @@ void XMLHttpRequest::open(const String& method, const String& url, bool async, c
             urlWithCredentials.setPass(password);
     }
 
-    open(method, urlWithCredentials, async, ec);
+    return open(method, urlWithCredentials, async);
 }
 
-bool XMLHttpRequest::initSend(ExceptionCode& ec)
+Optional<ExceptionOr<void>> XMLHttpRequest::prepareToSend()
 {
+    // A return value other than Nullopt means we should not try to send, and we should return that value to the caller.
+    // Nullopt means we are ready to send and should continue with the send algorithm.
+
     if (!scriptExecutionContext())
-        return false;
+        return ExceptionOr<void> { };
 
     auto& context = *scriptExecutionContext();
 
-    if (m_state != OPENED || m_sendFlag) {
-        ec = INVALID_STATE_ERR;
-        return false;
-    }
+    if (m_state != OPENED || m_sendFlag)
+        return ExceptionOr<void> { Exception { INVALID_STATE_ERR } };
     ASSERT(!m_loader);
 
     // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
     if (!context.shouldBypassMainWorldContentSecurityPolicy() && !context.contentSecurityPolicy()->allowConnectToSource(m_url)) {
-        if (m_async) {
-            setPendingActivity(this);
-            m_timeoutTimer.stop();
-            m_networkErrorTimer.startOneShot(0);
-        } else
-            ec = NETWORK_ERR;
-        return false;
+        if (!m_async)
+            return ExceptionOr<void> { Exception { NETWORK_ERR } };
+        setPendingActivity(this);
+        m_timeoutTimer.stop();
+        m_networkErrorTimer.startOneShot(0);
+        return ExceptionOr<void> { };
     }
 
     m_error = false;
-    return true;
+    return Nullopt;
 }
 
-void XMLHttpRequest::send(ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::send(Document& document)
 {
-    send(String(), ec);
-}
-
-void XMLHttpRequest::send(Document* document, ExceptionCode& ec)
-{
-    ASSERT(document);
-
-    if (!initSend(ec))
-        return;
+    if (auto result = prepareToSend())
+        return WTFMove(result.value());
 
     if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
         if (!m_requestHeaders.contains(HTTPHeaderName::ContentType)) {
@@ -539,25 +520,23 @@ void XMLHttpRequest::send(Document* document, ExceptionCode& ec)
             else
 #endif
                 // FIXME: this should include the charset used for encoding.
-                m_requestHeaders.set(HTTPHeaderName::ContentType, document->isHTMLDocument() ? ASCIILiteral("text/html;charset=UTF-8") : ASCIILiteral("application/xml;charset=UTF-8"));
+                m_requestHeaders.set(HTTPHeaderName::ContentType, document.isHTMLDocument() ? ASCIILiteral("text/html;charset=UTF-8") : ASCIILiteral("application/xml;charset=UTF-8"));
         }
 
         // FIXME: According to XMLHttpRequest Level 2, this should use the Document.innerHTML algorithm
         // from the HTML5 specification to serialize the document.
-        String body = createMarkup(*document);
-
-        m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, EntitiesForUnencodables));
+        m_requestEntityBody = FormData::create(UTF8Encoding().encode(createMarkup(document), EntitiesForUnencodables));
         if (m_upload)
             m_requestEntityBody->setAlwaysStream(true);
     }
 
-    createRequest(ec);
+    return createRequest();
 }
 
-void XMLHttpRequest::send(const String& body, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::send(const String& body)
 {
-    if (!initSend(ec))
-        return;
+    if (auto result = prepareToSend())
+        return WTFMove(result.value());
 
     if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
         String contentType = m_requestHeaders.get(HTTPHeaderName::ContentType);
@@ -578,17 +557,17 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec)
             m_requestEntityBody->setAlwaysStream(true);
     }
 
-    createRequest(ec);
+    return createRequest();
 }
 
-void XMLHttpRequest::send(Blob* body, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::send(Blob& body)
 {
-    if (!initSend(ec))
-        return;
+    if (auto result = prepareToSend())
+        return WTFMove(result.value());
 
     if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
         if (!m_requestHeaders.contains(HTTPHeaderName::ContentType)) {
-            const String& blobType = body->type();
+            const String& blobType = body.type();
             if (!blobType.isEmpty() && isValidContentType(blobType))
                 m_requestHeaders.set(HTTPHeaderName::ContentType, blobType);
             else {
@@ -598,46 +577,43 @@ void XMLHttpRequest::send(Blob* body, ExceptionCode& ec)
         }
 
         m_requestEntityBody = FormData::create();
-        m_requestEntityBody->appendBlob(body->url());
+        m_requestEntityBody->appendBlob(body.url());
     }
 
-    createRequest(ec);
+    return createRequest();
 }
 
-void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::send(DOMFormData& body)
 {
-    if (!initSend(ec))
-        return;
+    if (auto result = prepareToSend())
+        return WTFMove(result.value());
 
     if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
-        m_requestEntityBody = FormData::createMultiPart(*(static_cast<FormDataList*>(body)), body->encoding(), document());
-
+        m_requestEntityBody = FormData::createMultiPart(body, body.encoding(), document());
         m_requestEntityBody->generateFiles(document());
-
         if (!m_requestHeaders.contains(HTTPHeaderName::ContentType))
             m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
     }
 
-    createRequest(ec);
+    return createRequest();
 }
 
-void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::send(ArrayBuffer& body)
 {
-    String consoleMessage("ArrayBuffer is deprecated in XMLHttpRequest.send(). Use ArrayBufferView instead.");
+    ASCIILiteral consoleMessage("ArrayBuffer is deprecated in XMLHttpRequest.send(). Use ArrayBufferView instead.");
     scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, consoleMessage);
-
-    sendBytesData(body->data(), body->byteLength(), ec);
+    return sendBytesData(body.data(), body.byteLength());
 }
 
-void XMLHttpRequest::send(ArrayBufferView* body, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::send(ArrayBufferView& body)
 {
-    sendBytesData(body->baseAddress(), body->byteLength(), ec);
+    return sendBytesData(body.baseAddress(), body.byteLength());
 }
 
-void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::sendBytesData(const void* data, size_t length)
 {
-    if (!initSend(ec))
-        return;
+    if (auto result = prepareToSend())
+        return WTFMove(result.value());
 
     if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
         m_requestEntityBody = FormData::create(data, length);
@@ -645,16 +621,14 @@ void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionCod
             m_requestEntityBody->setAlwaysStream(true);
     }
 
-    createRequest(ec);
+    return createRequest();
 }
 
-void XMLHttpRequest::createRequest(ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::createRequest()
 {
     // Only GET request is supported for blob URL.
-    if (!m_async && m_url.protocolIsBlob() && m_method != "GET") {
-        ec = NETWORK_ERR;
-        return;
-    }
+    if (!m_async && m_url.protocolIsBlob() && m_method != "GET")
+        return Exception { NETWORK_ERR };
 
     m_sendFlag = true;
 
@@ -733,9 +707,11 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
         InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext());
     }
 
-    if (!m_exceptionCode && m_error)
-        m_exceptionCode = NETWORK_ERR;
-    ec = m_exceptionCode;
+    if (m_exceptionCode)
+        return Exception { m_exceptionCode };
+    if (m_error)
+        return Exception { NETWORK_ERR };
+    return { };
 }
 
 void XMLHttpRequest::abort()
@@ -858,41 +834,37 @@ void XMLHttpRequest::dropProtection()
     unsetPendingActivity(this);
 }
 
-void XMLHttpRequest::overrideMimeType(const String& override, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::overrideMimeType(const String& override)
 {
-    if (m_state == LOADING || m_state == DONE) {
-        ec = INVALID_STATE_ERR;
-        return;
-    }
+    if (m_state == LOADING || m_state == DONE)
+        return Exception { INVALID_STATE_ERR };
 
     m_mimeTypeOverride = override;
+    return { };
 }
 
-void XMLHttpRequest::setRequestHeader(const String& name, const String& value, ExceptionCode& ec)
+ExceptionOr<void> XMLHttpRequest::setRequestHeader(const String& name, const String& value)
 {
     if (m_state != OPENED || m_sendFlag) {
 #if ENABLE(DASHBOARD_SUPPORT)
         if (usesDashboardBackwardCompatibilityMode())
-            return;
+            return { };
 #endif
-
-        ec = INVALID_STATE_ERR;
-        return;
+        return Exception { INVALID_STATE_ERR };
     }
 
     String normalizedValue = stripLeadingAndTrailingHTTPSpaces(value);
-    if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(normalizedValue)) {
-        ec = SYNTAX_ERR;
-        return;
-    }
+    if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(normalizedValue))
+        return Exception { SYNTAX_ERR };
 
     // A privileged script (e.g. a Dashboard widget) can set any headers.
     if (!securityOrigin()->canLoadLocalResources() && !isAllowedHTTPHeader(name)) {
         logConsoleError(scriptExecutionContext(), "Refused to set unsafe header \"" + name + "\"");
-        return;
+        return { };
     }
 
     m_requestHeaders.add(name, normalizedValue);
+    return { };
 }
 
 String XMLHttpRequest::getAllResponseHeaders() const
index c3ed3be..77a3eab 100644 (file)
@@ -22,6 +22,7 @@
 #pragma once
 
 #include "ActiveDOMObject.h"
+#include "ExceptionOr.h"
 #include "FormData.h"
 #include "ResourceResponse.h"
 #include "ThreadableLoaderClient.h"
@@ -57,7 +58,7 @@ public:
         LOADING = 3,
         DONE = 4
     };
-    
+
     virtual void didReachTimeout();
 
     EventTargetInterface eventTargetInterface() const override { return XMLHttpRequestEventTargetInterfaceType; }
@@ -68,35 +69,34 @@ public:
     int status() const;
     State readyState() const;
     bool withCredentials() const { return m_includeCredentials; }
-    void setWithCredentials(bool, ExceptionCode&);
-    void open(const String& method, const String& url, ExceptionCode&);
-    void open(const String& method, const URL&, bool async, ExceptionCode&);
-    void open(const String& method, const String&, bool async, const String& user, const String& password, ExceptionCode&);
-    void send(ExceptionCode&);
-    void send(Document*, ExceptionCode&);
-    void send(const String&, ExceptionCode&);
-    void send(Blob*, ExceptionCode&);
-    void send(DOMFormData*, ExceptionCode&);
-    void send(JSC::ArrayBuffer*, ExceptionCode&);
-    void send(JSC::ArrayBufferView*, ExceptionCode&);
+    ExceptionOr<void> setWithCredentials(bool);
+    ExceptionOr<void> open(const String& method, const String& url);
+    ExceptionOr<void> open(const String& method, const URL&, bool async);
+    ExceptionOr<void> open(const String& method, const String&, bool async, const String& user, const String& password);
+    ExceptionOr<void> send(Document&);
+    ExceptionOr<void> send(const String& = { });
+    ExceptionOr<void> send(Blob&);
+    ExceptionOr<void> send(DOMFormData&);
+    ExceptionOr<void> send(JSC::ArrayBuffer&);
+    ExceptionOr<void> send(JSC::ArrayBufferView&);
     void abort();
-    void setRequestHeader(const String& name, const String& value, ExceptionCode&);
-    void overrideMimeType(const String& override, ExceptionCode&);
+    ExceptionOr<void> setRequestHeader(const String& name, const String& value);
+    ExceptionOr<void> overrideMimeType(const String& override);
     bool doneWithoutErrors() const { return !m_error && m_state == DONE; }
     String getAllResponseHeaders() const;
     String getResponseHeader(const String& name) const;
-    String responseText(ExceptionCode&);
+    ExceptionOr<String> responseText();
     String responseTextIgnoringResponseType() const { return m_responseBuilder.toStringPreserveCapacity(); }
     String responseMIMEType() const;
 
     Document* optionalResponseXML() const { return m_responseDocument.get(); }
-    Document* responseXML(ExceptionCode&);
+    ExceptionOr<Document*> responseXML();
 
     Ref<Blob> createResponseBlob();
     RefPtr<JSC::ArrayBuffer> createResponseArrayBuffer();
 
     unsigned timeout() const { return m_timeoutMilliseconds; }
-    void setTimeout(unsigned timeout, ExceptionCode&);
+    ExceptionOr<void> setTimeout(unsigned);
 
     bool responseCacheIsValid() const { return m_responseCacheIsValid; }
     void didCacheResponse();
@@ -107,7 +107,7 @@ public:
     static bool isAllowedHTTPHeader(const String&);
 
     enum class ResponseType { EmptyString, Arraybuffer, Blob, Document, Json, Text };
-    void setResponseType(ResponseType, ExceptionCode&);
+    ExceptionOr<void> setResponseType(ResponseType);
     ResponseType responseType() const;
 
     String responseURL() const;
@@ -152,10 +152,10 @@ private:
 
     bool responseIsXML() const;
 
-    bool initSend(ExceptionCode&);
-    void sendBytesData(const void*, size_t, ExceptionCode&);
+    Optional<ExceptionOr<void>> prepareToSend();
+    ExceptionOr<void> sendBytesData(const void*, size_t);
 
-    void changeState(State newState);
+    void changeState(State);
     void callReadyStateChangeListener();
     void dropProtection();
 
@@ -167,7 +167,7 @@ private:
     void clearResponseBuffers();
     void clearRequest();
 
-    void createRequest(ExceptionCode&);
+    ExceptionOr<void> createRequest();
 
     void genericError();
     void networkError();
index 6bb7bb7..23affd1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-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
@@ -36,16 +36,16 @@ enum XMLHttpRequestResponseType {
 };
 
 [
-    Exposed=(Window,Worker),
     ActiveDOMObject,
     Constructor,
     ConstructorCallWith=ScriptExecutionContext,
+    ExportMacro=WEBCORE_EXPORT,
+    Exposed=(Window,Worker),
     JSCustomMarkFunction,
-    JSGenerateToNativeObject,
     JSGenerateToJSObject,
-    ExportMacro=WEBCORE_EXPORT,
-    PublicIdentifier,
+    JSGenerateToNativeObject,
     PrivateIdentifier,
+    PublicIdentifier,
 ] interface XMLHttpRequest : XMLHttpRequestEventTarget {
     attribute EventHandler onreadystatechange;
 
@@ -56,30 +56,29 @@ enum XMLHttpRequestResponseType {
     const unsigned short LOADING = 3;
     const unsigned short DONE = 4;
 
-    [SetterMayThrowLegacyException] attribute unsigned long timeout;
+    [SetterMayThrowException] attribute unsigned long timeout;
     readonly attribute unsigned short readyState;
 
-    [SetterMayThrowLegacyException] attribute boolean withCredentials;
+    [SetterMayThrowException] attribute boolean withCredentials;
 
     // Use overloading rather than "boolean async = true" because legacy content prevents treating the 'async' argument being undefined identical from it being omitted.
-    [MayThrowLegacyException] void open(DOMString method, DOMString url);
-    [MayThrowLegacyException] void open(DOMString method, DOMString url, boolean async, optional DOMString? user = null, optional DOMString? password = null);
+    [MayThrowException] void open(DOMString method, DOMString url);
+    [MayThrowException] void open(DOMString method, DOMString url, boolean async, optional DOMString? user = null, optional DOMString? password = null);
 
-    [MayThrowLegacyException] void setRequestHeader(DOMString header, DOMString value);
+    [MayThrowException] void setRequestHeader(DOMString header, DOMString value);
 
-    [Custom, MayThrowLegacyException] void send();
+    [Custom, MayThrowException] void send();
 
     void abort();
 
     readonly attribute XMLHttpRequestUpload upload;
 
-    // response
     DOMString getAllResponseHeaders();
     DOMString? getResponseHeader(DOMString header);
-    [GetterMayThrowLegacyException, CustomGetter] readonly attribute DOMString? responseText;
-    [GetterMayThrowLegacyException] readonly attribute Document responseXML;
+    [GetterMayThrowException, CustomGetter] readonly attribute DOMString? responseText;
+    [GetterMayThrowException] readonly attribute Document responseXML;
 
-    [SetterMayThrowLegacyException] attribute XMLHttpRequestResponseType responseType;
+    [SetterMayThrowException] attribute XMLHttpRequestResponseType responseType;
     [JSBuiltin] readonly attribute Object response;
 
     readonly attribute unsigned short status;
@@ -89,6 +88,5 @@ enum XMLHttpRequestResponseType {
     [PrivateIdentifier] boolean responseCacheIsValid();
     [PrivateIdentifier, Custom] any retrieveResponse();
 
-    // Extension
-    [MayThrowLegacyException] void overrideMimeType(DOMString override);
+    [MayThrowException] void overrideMimeType(DOMString override);
 };
index bd9a31e..8162299 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-06  Darin Adler  <darin@apple.com>
+
+        Next step on moving to modern way to return DOM exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=163016
+
+        Reviewed by Ryosuke Niwa.
+
+        * DOM/DOMDOMImplementation.mm:
+        (-[DOMImplementation createDocumentType:publicId:systemId:]): Updated for
+        name change from takeReturnValue to releaseReturnValue.
+        (-[DOMImplementation createDocument:qualifiedName:doctype:]): Ditto.
+
 2016-10-07  Simon Fraser  <simon.fraser@apple.com>
 
         [WK1 Mac] Fix repaints of fixed-background elements in layer-backed WebViews
index 18787ee..af0e714 100644 (file)
@@ -66,18 +66,22 @@ static inline WebCore::DOMImplementation& unwrap(DOMImplementation& wrapper)
 {
     WebCore::JSMainThreadNullState state;
     auto result = unwrap(*self).createDocumentType(qualifiedName, publicId, systemId);
-    if (result.hasException())
-        raiseDOMException(result.exceptionCode());
-    return kit(result.takeReturnValue().ptr());
+    if (result.hasException()) {
+        raiseDOMException(result.releaseException().code());
+        return nil;
+    }
+    return kit(result.releaseReturnValue().ptr());
 }
 
 - (DOMDocument *)createDocument:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName doctype:(DOMDocumentType *)doctype
 {
     WebCore::JSMainThreadNullState state;
     auto result = unwrap(*self).createDocument(namespaceURI, qualifiedName, core(doctype));
-    if (result.hasException())
-        raiseDOMException(result.exceptionCode());
-    return kit(result.takeReturnValue().ptr());
+    if (result.hasException()) {
+        raiseDOMException(result.releaseException().code());
+        return nil;
+    }
+    return kit(result.releaseReturnValue().ptr());
 }
 
 - (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title media:(NSString *)media
index 0e3c24f..1348719 100644 (file)
@@ -1,3 +1,20 @@
+2016-10-06  Darin Adler  <darin@apple.com>
+
+        Next step on moving to modern way to return DOM exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=163016
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMImplementation.cpp:
+        (webkit_dom_dom_implementation_create_document_type): Updated for name change
+        from takeReturnValue to releaseReturnValue.
+        (webkit_dom_dom_implementation_create_document): Ditto.
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMSelection.cpp:
+        (webkit_dom_dom_selection_collapse_to_end): Use ExceptionOr instead of ExceptionCode.
+        (webkit_dom_dom_selection_collapse_to_start): Ditto.
+        (webkit_dom_dom_selection_extend): Ditto.
+        (webkit_dom_dom_selection_get_range_at): Ditto.
+
 2016-10-08  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r206950.
index 0001ac6..ed4d5b0 100644 (file)
@@ -130,10 +130,11 @@ WebKitDOMDocumentType* webkit_dom_dom_implementation_create_document_type(WebKit
     WTF::String convertedSystemId = WTF::String::fromUTF8(systemId);
     auto result = item->createDocumentType(convertedQualifiedName, convertedPublicId, convertedSystemId);
     if (result.hasException()) {
-        WebCore::ExceptionCodeDescription ecdesc(result.exceptionCode());
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(result.takeReturnValue().ptr());
+    return WebKit::kit(result.releaseReturnValue().ptr());
 }
 
 WebKitDOMDocument* webkit_dom_dom_implementation_create_document(WebKitDOMDOMImplementation* self, const gchar* namespaceURI, const gchar* qualifiedName, WebKitDOMDocumentType* doctype, GError** error)
@@ -149,10 +150,11 @@ WebKitDOMDocument* webkit_dom_dom_implementation_create_document(WebKitDOMDOMImp
     WebCore::DocumentType* convertedDoctype = WebKit::core(doctype);
     auto result = item->createDocument(convertedNamespaceURI, convertedQualifiedName, convertedDoctype);
     if (result.hasException()) {
-        WebCore::ExceptionCodeDescription ecdesc(result.exceptionCode());
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(result.takeReturnValue().ptr());
+    return WebKit::kit(result.releaseReturnValue().ptr());
 }
 
 WebKitDOMCSSStyleSheet* webkit_dom_dom_implementation_create_css_style_sheet(WebKitDOMDOMImplementation* self, const gchar* title, const gchar* media, GError** error)
index 640f417..10c5b4b 100644 (file)
@@ -291,10 +291,9 @@ void webkit_dom_dom_selection_collapse_to_end(WebKitDOMDOMSelection* self, GErro
     g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self));
     g_return_if_fail(!error || !*error);
     WebCore::DOMSelection* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    item->collapseToEnd(ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->collapseToEnd();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
     }
 }
@@ -305,10 +304,9 @@ void webkit_dom_dom_selection_collapse_to_start(WebKitDOMDOMSelection* self, GEr
     g_return_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self));
     g_return_if_fail(!error || !*error);
     WebCore::DOMSelection* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    item->collapseToStart(ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->collapseToStart();
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
     }
 }
@@ -350,10 +348,9 @@ void webkit_dom_dom_selection_extend(WebKitDOMDOMSelection* self, WebKitDOMNode*
     g_return_if_fail(!error || !*error);
     WebCore::DOMSelection* item = WebKit::core(self);
     WebCore::Node* convertedNode = WebKit::core(node);
-    WebCore::ExceptionCode ec = 0;
-    item->extend(*convertedNode, offset, ec);
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->extend(*convertedNode, offset);
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
     }
 }
@@ -364,13 +361,13 @@ WebKitDOMRange* webkit_dom_dom_selection_get_range_at(WebKitDOMDOMSelection* sel
     g_return_val_if_fail(WEBKIT_DOM_IS_DOM_SELECTION(self), 0);
     g_return_val_if_fail(!error || !*error, 0);
     WebCore::DOMSelection* item = WebKit::core(self);
-    WebCore::ExceptionCode ec = 0;
-    RefPtr<WebCore::Range> gobjectResult = WTF::getPtr(item->getRangeAt(index, ec));
-    if (ec) {
-        WebCore::ExceptionCodeDescription ecdesc(ec);
+    auto result = item->getRangeAt(index);
+    if (result.hasException()) {
+        WebCore::ExceptionCodeDescription ecdesc(result.releaseException().code());
         g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
+        return nullptr;
     }
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(result.releaseReturnValue().ptr());
 }
 
 void webkit_dom_dom_selection_remove_all_ranges(WebKitDOMDOMSelection* self)
index 9f5be35..9041eaf 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-06  Darin Adler  <darin@apple.com>
+
+        Next step on moving to modern way to return DOM exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=163016
+
+        Reviewed by Ryosuke Niwa.
+
+        * Scripts/do-webcore-rename: Add proposed name change of setDOMException
+        to propagateException, since this function is primarily used to take an
+        exception already effectively "thrown" by setting an ExceptionCode out
+        argument and propagate it into the JavaScript engine's exception machinery.
+
 2016-10-07  Alex Christensen  <achristensen@webkit.org>
 
         Non-special URL fragments should percent-encode non-ASCII characters
index ab559f0..0aad007 100755 (executable)
@@ -109,6 +109,9 @@ my %renames = (
 );
 
 my %renamesContemplatedForTheFuture = (
+    "setDOMException" => "propagateException",
+    "setDOMExceptionSlow" => "propagateExceptionSlowPath",
+
     "PassRefPtr" => "DeprecatedPassRefPtr",
 
     "HTMLPlugInImageElement" => "HTMLEmbeddedObjectElement",