Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (219756 => 219757)
--- trunk/Source/WebCore/CMakeLists.txt 2017-07-22 03:01:51 UTC (rev 219756)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-07-22 03:54:16 UTC (rev 219757)
@@ -3843,7 +3843,6 @@
${WEBCORE_DIR}/Modules/streams/WritableStream.js
${WEBCORE_DIR}/Modules/streams/WritableStreamInternals.js
${WEBCORE_DIR}/bindings/js/JSDOMBindingInternals.js
- ${WEBCORE_DIR}/xml/XMLHttpRequest.js
)
set(BUILTINS_GENERATOR_SCRIPTS
Modified: trunk/Source/WebCore/ChangeLog (219756 => 219757)
--- trunk/Source/WebCore/ChangeLog 2017-07-22 03:01:51 UTC (rev 219756)
+++ trunk/Source/WebCore/ChangeLog 2017-07-22 03:54:16 UTC (rev 219757)
@@ -1,3 +1,27 @@
+2017-07-21 Sam Weinig <[email protected]>
+
+ [WebIDL] Simplify XMLHttpRequest bindings by removing built-ins
+ https://bugs.webkit.org/show_bug.cgi?id=174740
+
+ Reviewed by Chris Dumez.
+
+ The behavior we were getting from XMLHttpRequest.js can be implemented
+ with the [CachedAttribute] extended attribute. This reduces the number
+ of JS -> C++ jumps required and makes the code more similar to other
+ bindings that need caching of an IDL any value.
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * xml/XMLHttpRequest.js: Removed.
+ Remove XMLHttpRequest.js.
+
+ * bindings/js/JSXMLHttpRequestCustom.cpp:
+ (WebCore::JSXMLHttpRequest::response):
+ (WebCore::JSXMLHttpRequest::retrieveResponse): Deleted.
+ * xml/XMLHttpRequest.idl:
+ Replace builtin with a [CachedAttribute] and [CustomGetter]
+ for the response property.
+
2017-07-21 Timothy Horton <[email protected]>
Drag and Drop preview image for Twitter link is the wrong shape
Modified: trunk/Source/WebCore/DerivedSources.make (219756 => 219757)
--- trunk/Source/WebCore/DerivedSources.make 2017-07-22 03:01:51 UTC (rev 219756)
+++ trunk/Source/WebCore/DerivedSources.make 2017-07-22 03:54:16 UTC (rev 219757)
@@ -1398,7 +1398,6 @@
$(WebCore)/Modules/streams/WritableStream.js \
$(WebCore)/Modules/streams/WritableStreamInternals.js \
$(WebCore)/bindings/js/JSDOMBindingInternals.js \
- $(WebCore)/xml/XMLHttpRequest.js \
#
BUILTINS_GENERATOR_SCRIPTS = \
Modified: trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp (219756 => 219757)
--- trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp 2017-07-22 03:01:51 UTC (rev 219756)
+++ trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp 2017-07-22 03:54:16 UTC (rev 219757)
@@ -50,8 +50,17 @@
visitor.addOpaqueRoot(responseDocument);
}
-JSValue JSXMLHttpRequest::retrieveResponse(ExecState& state)
+JSValue JSXMLHttpRequest::response(ExecState& state) const
{
+ auto cacheResult = [&] (JSValue value) -> JSValue {
+ m_response.set(state.vm(), this, value);
+ return value;
+ };
+
+
+ if (wrapped().responseCacheIsValid())
+ return m_response.get();
+
auto type = wrapped().responseType();
switch (type) {
@@ -58,7 +67,7 @@
case XMLHttpRequest::ResponseType::EmptyString:
case XMLHttpRequest::ResponseType::Text: {
auto scope = DECLARE_THROW_SCOPE(state.vm());
- return toJS<IDLNullable<IDLUSVString>>(state, scope, wrapped().responseText());
+ return cacheResult(toJS<IDLNullable<IDLUSVString>>(state, scope, wrapped().responseText()));
}
default:
break;
@@ -65,7 +74,7 @@
}
if (!wrapped().doneWithoutErrors())
- return jsNull();
+ return cacheResult(jsNull());
JSValue value;
switch (type) {
@@ -97,7 +106,7 @@
}
wrapped().didCacheResponse();
- return value;
+ return cacheResult(value);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.idl (219756 => 219757)
--- trunk/Source/WebCore/xml/XMLHttpRequest.idl 2017-07-22 03:01:51 UTC (rev 219756)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.idl 2017-07-22 03:54:16 UTC (rev 219757)
@@ -47,8 +47,6 @@
JSCustomMarkFunction,
JSGenerateToJSObject,
JSGenerateToNativeObject,
- PrivateIdentifier,
- PublicIdentifier,
] interface XMLHttpRequest : XMLHttpRequestEventTarget {
// event handler
attribute EventHandler onreadystatechange;
@@ -79,13 +77,8 @@
ByteString getAllResponseHeaders();
[MayThrowException] void overrideMimeType(DOMString mime);
[SetterMayThrowException] attribute XMLHttpRequestResponseType responseType;
- [JSBuiltin] readonly attribute any response;
+ [CachedAttribute, CustomGetter] readonly attribute any response;
[GetterMayThrowException] readonly attribute USVString responseText;
// FIXME: responseXML should be annotated with [Exposed=Window].
[GetterMayThrowException] readonly attribute Document? responseXML;
-
- // internals
- [PrivateIdentifier] boolean responseCacheIsValid();
- [PrivateIdentifier, Custom] any retrieveResponse();
-
};
Deleted: trunk/Source/WebCore/xml/XMLHttpRequest.js (219756 => 219757)
--- trunk/Source/WebCore/xml/XMLHttpRequest.js 2017-07-22 03:01:51 UTC (rev 219756)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.js 2017-07-22 03:54:16 UTC (rev 219757)
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-function response()
-{
- "use strict";
-
- // FIXME: Add a helper routine for that kind of checks.
- if (!(this instanceof @XMLHttpRequest))
- @throwTypeError("The XMLHttpRequest.response getter can only be used on instances of XMLHttpRequest");
-
- if (@XMLHttpRequest.prototype.@responseCacheIsValid.@call(this))
- return this.@response;
-
- this.@response = @XMLHttpRequest.prototype.@retrieveResponse.@call(this);
- return this.@response;
-}