Diff
Modified: trunk/Source/WebCore/ChangeLog (219598 => 219599)
--- trunk/Source/WebCore/ChangeLog 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/ChangeLog 2017-07-18 03:52:23 UTC (rev 219599)
@@ -1,3 +1,65 @@
+2017-07-17 Sam Weinig <s...@webkit.org>
+
+ [WebIDL] Remove custom bindings that require non-caching JS strings
+ https://bugs.webkit.org/show_bug.cgi?id=174552
+
+ Reviewed by Darin Adler.
+
+ Adds two new types, UncachedString and OwnedString (both of which
+ are simple structs that wrap a String) to communicate to the bindings
+ layer which function to use when converting to a JS string.
+
+ * bindings/IDLTypes.h:
+ (WebCore::IDLString::isNullValue):
+ Add overloads of isNullValue for UncachedString and OwnedString.
+
+ * bindings/js/JSDOMConvertStrings.h:
+ (WebCore::JSConverter<IDLDOMString>::convert):
+ (WebCore::JSConverter<IDLByteString>::convert):
+ (WebCore::JSConverter<IDLUSVString>::convert):
+ Add overloads of convert for UncachedString that uses JSC::jsString
+ and for OwnedString that uses JSC::jsOwnedString.
+
+ * bindings/js/JSHTMLCanvasElementCustom.cpp:
+ (WebCore::JSHTMLCanvasElement::toDataURL): Deleted.
+ Remove custom binding for toDataURL.
+
+ * bindings/js/JSXMLHttpRequestCustom.cpp:
+ (WebCore::JSXMLHttpRequest::retrieveResponse):
+ (WebCore::JSXMLHttpRequest::responseText): Deleted.
+ Remove custom binding for responseText. Replace the caller of the
+ binding function with a simple conversion that will do the same thing.
+
+ * bindings/js/StringAdaptors.h: Added.
+ Add UncachedString and OwnedString adaptors.
+
+ * html/HTMLCanvasElement.cpp:
+ (WebCore::HTMLCanvasElement::toDataURL):
+ Move quality conversion here, matching toBlob and the spec. Return a UncachedString
+ to instruct the bindings to use JSC::jsString and not JSC::jsStringWithCache.
+
+ (WebCore::HTMLCanvasElement::toBlob):
+ Use asNumber() rather than toNumber(), since we just checked that it is a number.
+
+ * html/HTMLCanvasElement.h:
+ Update header to account for returning an UncachedString.
+
+ * html/HTMLCanvasElement.idl:
+ Remove [Custom] and make the signature of toDataURL match the spec (and what we have been doing).
+
+ * inspector/InspectorCanvasAgent.cpp:
+ (WebCore::InspectorCanvasAgent::requestContent):
+ Update to account for UncachedString.
+
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::responseText):
+ * xml/XMLHttpRequest.h:
+ Update responseText to return OwnedString. OwnedString instruct the bindings to
+ use JSC::jsOwnedString and not JSC::jsStringWithCache.
+
+ * xml/XMLHttpRequest.idl:
+ Remove [CustomGetter].
+
2017-07-17 Daniel Bates <daba...@apple.com>
Cleanup: Use OptionSet to represent marker types
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (219598 => 219599)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-07-18 03:52:23 UTC (rev 219599)
@@ -3179,6 +3179,7 @@
7C52229D1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C52229B1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.cpp */; };
7C52229E1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C52229C1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */; };
+ 7C5266981F1B0302000F068B /* StringAdaptors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C5266961F1B02FC000F068B /* StringAdaptors.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C5343FC17B74B63004232F0 /* JSMediaQueryListListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */; };
7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */; };
7C57BFE71EDE2F6100534A48 /* JSDOMAbstractOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C57BFE61EDE2F5B00534A48 /* JSDOMAbstractOperations.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11232,6 +11233,7 @@
7C52229C1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeEnabledFeatures.h; sourceTree = "<group>"; };
7C522D4915B477E8009B7C95 /* InspectorOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorOverlay.cpp; sourceTree = "<group>"; };
7C522D4A15B478B2009B7C95 /* InspectorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorOverlay.h; sourceTree = "<group>"; };
+ 7C5266961F1B02FC000F068B /* StringAdaptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringAdaptors.h; sourceTree = "<group>"; };
7C5343FA17B74B63004232F0 /* JSMediaQueryListListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaQueryListListener.cpp; sourceTree = "<group>"; };
7C5343FB17B74B63004232F0 /* JSMediaQueryListListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JSMediaQueryListListener.h; sourceTree = "<group>"; };
7C57BFE61EDE2F5B00534A48 /* JSDOMAbstractOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMAbstractOperations.h; sourceTree = "<group>"; };
@@ -23593,6 +23595,7 @@
1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */,
A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */,
A75E497410752ACB00C9B896 /* SerializedScriptValue.h */,
+ 7C5266961F1B02FC000F068B /* StringAdaptors.h */,
414B82021D6DF0D90077EBE3 /* StructuredClone.cpp */,
414B82031D6DF0D90077EBE3 /* StructuredClone.h */,
419BE7521BC7F3DB00E1C85B /* WebCoreBuiltinNames.h */,
@@ -27749,6 +27752,7 @@
1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */,
44DFF6431A6FF92700D45EEC /* IOSurfaceSPI.h in Headers */,
44EFF6431A6FF92700D45EEC /* IOTypesSPI.h in Headers */,
+ 7C5266981F1B0302000F068B /* StringAdaptors.h in Headers */,
07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */,
418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */,
5704405A1E53936200356601 /* JSAesCbcCfbParams.h in Headers */,
Modified: trunk/Source/WebCore/bindings/IDLTypes.h (219598 => 219599)
--- trunk/Source/WebCore/bindings/IDLTypes.h 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/bindings/IDLTypes.h 2017-07-18 03:52:23 UTC (rev 219599)
@@ -25,6 +25,7 @@
#pragma once
+#include "StringAdaptors.h"
#include <heap/HandleTypes.h>
#include <wtf/Brigand.h>
#include <wtf/HashMap.h>
@@ -121,6 +122,8 @@
using NullableType = StringType;
static StringType nullValue() { return StringType(); }
static bool isNullValue(const StringType& value) { return value.isNull(); }
+ static bool isNullValue(const UncachedString& value) { return value.string.isNull(); }
+ static bool isNullValue(const OwnedString& value) { return value.string.isNull(); }
template <typename U> static U&& extractValueFromNullable(U&& value) { return std::forward<U>(value); }
};
struct IDLDOMString : IDLString<String> { };
Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h (219598 => 219599)
--- trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h 2017-07-18 03:52:23 UTC (rev 219599)
@@ -27,6 +27,7 @@
#include "IDLTypes.h"
#include "JSDOMConvertBase.h"
+#include "StringAdaptors.h"
namespace WebCore {
@@ -64,6 +65,16 @@
{
return JSC::jsStringWithCache(&state, value);
}
+
+ static JSC::JSValue convert(JSC::ExecState& state, const UncachedString& value)
+ {
+ return JSC::jsString(&state, value.string);
+ }
+
+ static JSC::JSValue convert(JSC::ExecState& state, const OwnedString& value)
+ {
+ return JSC::jsOwnedString(&state, value.string);
+ }
};
template<> struct Converter<IDLByteString> : DefaultConverter<IDLByteString> {
@@ -81,6 +92,16 @@
{
return JSC::jsStringWithCache(&state, value);
}
+
+ static JSC::JSValue convert(JSC::ExecState& state, const UncachedString& value)
+ {
+ return JSC::jsString(&state, value.string);
+ }
+
+ static JSC::JSValue convert(JSC::ExecState& state, const OwnedString& value)
+ {
+ return JSC::jsOwnedString(&state, value.string);
+ }
};
template<> struct Converter<IDLUSVString> : DefaultConverter<IDLUSVString> {
@@ -98,6 +119,16 @@
{
return JSC::jsStringWithCache(&state, value);
}
+
+ static JSC::JSValue convert(JSC::ExecState& state, const UncachedString& value)
+ {
+ return JSC::jsString(&state, value.string);
+ }
+
+ static JSC::JSValue convert(JSC::ExecState& state, const OwnedString& value)
+ {
+ return JSC::jsOwnedString(&state, value.string);
+ }
};
// MARK: -
Modified: trunk/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp (219598 => 219599)
--- trunk/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp 2017-07-18 03:52:23 UTC (rev 219599)
@@ -87,27 +87,4 @@
return jsNull();
}
-JSValue JSHTMLCanvasElement::toDataURL(ExecState& state)
-{
- VM& vm = state.vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- auto type = convert<IDLNullable<IDLDOMString>>(state, state.argument(0));
- RETURN_IF_EXCEPTION(scope, JSC::JSValue());
-
- std::optional<double> quality;
- auto qualityValue = state.argument(1);
- if (qualityValue.isNumber())
- quality = qualityValue.toNumber(&state);
-
- // We would use toJS<IDLString> here, but it uses jsStringWithCache and we historically
- // did not cache here, presumably because results are likely to be differing long strings.
- auto result = wrapped().toDataURL(type, quality);
- if (result.hasException()) {
- propagateException(state, scope, result.releaseException());
- return { };
- }
- return jsString(&state, result.releaseReturnValue());
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp (219598 => 219599)
--- trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp 2017-07-18 03:52:23 UTC (rev 219599)
@@ -33,10 +33,9 @@
#include "JSDOMConvertBufferSource.h"
#include "JSDOMConvertInterface.h"
#include "JSDOMConvertJSON.h"
+#include "JSDOMConvertNullable.h"
+#include "JSDOMConvertStrings.h"
#include "JSDocument.h"
-#include <runtime/ArrayBuffer.h>
-#include <runtime/JSArrayBuffer.h>
-#include <runtime/JSArrayBufferView.h>
using namespace JSC;
@@ -51,26 +50,6 @@
visitor.addOpaqueRoot(responseDocument);
}
-JSValue JSXMLHttpRequest::responseText(ExecState& state) const
-{
- auto result = wrapped().responseText();
-
- if (UNLIKELY(result.hasException())) {
- auto& vm = state.vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- propagateException(state, scope, result.releaseException());
- return { };
- }
-
- auto resultValue = result.releaseReturnValue();
- if (resultValue.isNull())
- return jsNull();
-
- // See _javascript_Core for explanation: Should be used for any string that is already owned by another
- // object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
- return jsOwnedString(&state, resultValue);
-}
-
JSValue JSXMLHttpRequest::retrieveResponse(ExecState& state)
{
auto type = wrapped().responseType();
@@ -77,8 +56,10 @@
switch (type) {
case XMLHttpRequest::ResponseType::EmptyString:
- case XMLHttpRequest::ResponseType::Text:
- return responseText(state);
+ case XMLHttpRequest::ResponseType::Text: {
+ auto scope = DECLARE_THROW_SCOPE(state.vm());
+ return toJS<IDLNullable<IDLUSVString>>(state, scope, wrapped().responseText());
+ }
default:
break;
}
Added: trunk/Source/WebCore/bindings/js/StringAdaptors.h (0 => 219599)
--- trunk/Source/WebCore/bindings/js/StringAdaptors.h (rev 0)
+++ trunk/Source/WebCore/bindings/js/StringAdaptors.h 2017-07-18 03:52:23 UTC (rev 219599)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+// This exists to communicate to the bindings that this string is not a good candidate
+// for caching.
+// Forces the use of the jsString() converter (rather than the normal jsStringWithCache()).
+struct UncachedString {
+ String string;
+};
+
+// This exists to communicate to the bindings that this string is owned by another
+// object and therefore that collecting the JSString wrapper is unlikely to save memory.
+// Forces the use of the jsOwnedString() converter (rather than the normal jsStringWithCache()).
+struct OwnedString {
+ String string;
+};
+
+}
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (219598 => 219599)
--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp 2017-07-18 03:52:23 UTC (rev 219599)
@@ -51,6 +51,7 @@
#include "RuntimeEnabledFeatures.h"
#include "ScriptController.h"
#include "Settings.h"
+#include "StringAdaptors.h"
#include <math.h>
#include <runtime/JSCInlines.h>
#include <runtime/JSLock.h>
@@ -531,7 +532,7 @@
clearCopiedImage();
}
-String HTMLCanvasElement::toEncodingMimeType(const String& mimeType)
+static String toEncodingMimeType(const String& mimeType)
{
if (!MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType))
return ASCIILiteral("image/png");
@@ -538,27 +539,46 @@
return mimeType.convertToASCIILowercase();
}
-ExceptionOr<String> HTMLCanvasElement::toDataURL(const String& mimeType, std::optional<double> quality)
+// https://html.spec.whatwg.org/multipage/canvas.html#a-serialisation-of-the-bitmap-as-a-file
+static std::optional<double> qualityFromJSValue(JSC::JSValue qualityValue)
{
+ if (!qualityValue.isNumber())
+ return std::nullopt;
+
+ double qualityNumber = qualityValue.asNumber();
+ if (qualityNumber < 0 || qualityNumber > 1)
+ return std::nullopt;
+
+ return qualityNumber;
+}
+
+ExceptionOr<UncachedString> HTMLCanvasElement::toDataURL(const String& mimeType, JSC::JSValue qualityValue)
+{
if (!m_originClean)
return Exception { SECURITY_ERR };
if (m_size.isEmpty() || !buffer())
- return String { ASCIILiteral { "data:," } };
+ return UncachedString { ASCIILiteral { "data:," } };
- String encodingMIMEType = toEncodingMimeType(mimeType);
+ auto encodingMIMEType = toEncodingMimeType(mimeType);
+ auto quality = qualityFromJSValue(qualityValue);
#if USE(CG)
// Try to get ImageData first, as that may avoid lossy conversions.
if (auto imageData = getImageData())
- return dataURL(*imageData, encodingMIMEType, quality);
+ return UncachedString { dataURL(*imageData, encodingMIMEType, quality) };
#endif
makeRenderingResultsAvailable();
- return buffer()->toDataURL(encodingMIMEType, quality);
+ return UncachedString { buffer()->toDataURL(encodingMIMEType, quality) };
}
+ExceptionOr<UncachedString> HTMLCanvasElement::toDataURL(const String& mimeType)
+{
+ return toDataURL(mimeType, { });
+}
+
ExceptionOr<void> HTMLCanvasElement::toBlob(ScriptExecutionContext& context, Ref<BlobCallback>&& callback, const String& mimeType, JSC::JSValue qualityValue)
{
if (!m_originClean)
@@ -569,10 +589,8 @@
return { };
}
- String encodingMIMEType = toEncodingMimeType(mimeType);
- std::optional<double> quality;
- if (qualityValue.isNumber())
- quality = qualityValue.toNumber(context.execState());
+ auto encodingMIMEType = toEncodingMimeType(mimeType);
+ auto quality = qualityFromJSValue(qualityValue);
#if USE(CG)
if (auto imageData = getImageData()) {
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (219598 => 219599)
--- trunk/Source/WebCore/html/HTMLCanvasElement.h 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h 2017-07-18 03:52:23 UTC (rev 219599)
@@ -50,6 +50,7 @@
class ImageData;
class MediaSample;
class MediaStream;
+struct UncachedString;
namespace DisplayList {
using AsTextFlags = unsigned;
@@ -109,10 +110,9 @@
CanvasRenderingContext* getContextWebGPU(const String&);
#endif
- static String toEncodingMimeType(const String& mimeType);
- WEBCORE_EXPORT ExceptionOr<String> toDataURL(const String& mimeType, std::optional<double> quality);
- ExceptionOr<String> toDataURL(const String& mimeType) { return toDataURL(mimeType, std::nullopt); }
- ExceptionOr<void> toBlob(ScriptExecutionContext&, Ref<BlobCallback>&&, const String& mimeType, JSC::JSValue qualityValue);
+ WEBCORE_EXPORT ExceptionOr<UncachedString> toDataURL(const String& mimeType, JSC::JSValue quality);
+ WEBCORE_EXPORT ExceptionOr<UncachedString> toDataURL(const String& mimeType);
+ ExceptionOr<void> toBlob(ScriptExecutionContext&, Ref<BlobCallback>&&, const String& mimeType, JSC::JSValue quality);
// Used for rendering
void didDraw(const FloatRect&);
Modified: trunk/Source/WebCore/html/HTMLCanvasElement.idl (219598 => 219599)
--- trunk/Source/WebCore/html/HTMLCanvasElement.idl 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.idl 2017-07-18 03:52:23 UTC (rev 219599)
@@ -36,7 +36,7 @@
[Custom] RenderingContext? getContext(DOMString contextId, any... arguments);
- [Custom, MayThrowException] DOMString toDataURL(optional DOMString? type);
+ [MayThrowException] DOMString toDataURL(optional DOMString type, optional any quality);
[CallWith=ScriptExecutionContext, MayThrowException] void toBlob(BlobCallback callback, optional DOMString type, optional any quality);
[Conditional=MEDIA_STREAM, CallWith=ScriptExecutionContext, MayThrowException, NewObject] MediaStream captureStream(optional double frameRequestRate);
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp (219598 => 219599)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2017-07-18 03:52:23 UTC (rev 219599)
@@ -26,7 +26,6 @@
#include "config.h"
#include "InspectorCanvasAgent.h"
-#include "CanvasRenderingContext.h"
#include "CanvasRenderingContext2D.h"
#include "Document.h"
#include "Element.h"
@@ -38,6 +37,7 @@
#include "JSMainThreadExecState.h"
#include "MainFrame.h"
#include "ScriptState.h"
+#include "StringAdaptors.h"
#include <inspector/IdentifiersFactory.h>
#include <inspector/InjectedScript.h>
#include <inspector/InjectedScriptManager.h>
@@ -46,19 +46,14 @@
#if ENABLE(WEBGL)
#include "JSWebGLRenderingContext.h"
-#include "WebGLContextAttributes.h"
-#include "WebGLRenderingContext.h"
-#include "WebGLRenderingContextBase.h"
#endif
#if ENABLE(WEBGL2)
#include "JSWebGL2RenderingContext.h"
-#include "WebGL2RenderingContext.h"
#endif
#if ENABLE(WEBGPU)
#include "JSWebGPURenderingContext.h"
-#include "WebGPURenderingContext.h"
#endif
using namespace Inspector;
@@ -144,12 +139,12 @@
CanvasRenderingContext* context = canvasEntry->element->renderingContext();
if (is<CanvasRenderingContext2D>(context)) {
- ExceptionOr<String> result = canvasEntry->element->toDataURL(ASCIILiteral("image/png"));
+ auto result = canvasEntry->element->toDataURL(ASCIILiteral("image/png"));
if (result.hasException()) {
errorString = result.releaseException().releaseMessage();
return;
}
- *content = result.releaseReturnValue();
+ *content = result.releaseReturnValue().string;
}
#if ENABLE(WEBGL)
else if (is<WebGLRenderingContextBase>(context)) {
@@ -156,7 +151,7 @@
WebGLRenderingContextBase* gl = downcast<WebGLRenderingContextBase>(context);
gl->setPreventBufferClearForInspector(true);
- ExceptionOr<String> result = canvasEntry->element->toDataURL(ASCIILiteral("image/png"));
+ auto result = canvasEntry->element->toDataURL(ASCIILiteral("image/png"));
gl->setPreventBufferClearForInspector(false);
if (result.hasException()) {
@@ -163,7 +158,7 @@
errorString = result.releaseException().releaseMessage();
return;
}
- *content = result.releaseReturnValue();
+ *content = result.releaseReturnValue().string;
}
#endif
// FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebGPU contexts
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (219598 => 219599)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2017-07-18 03:52:23 UTC (rev 219599)
@@ -48,6 +48,7 @@
#include "SecurityOriginPolicy.h"
#include "Settings.h"
#include "SharedBuffer.h"
+#include "StringAdaptors.h"
#include "TextResourceDecoder.h"
#include "ThreadableLoader.h"
#include "XMLDocument.h"
@@ -156,11 +157,11 @@
return m_state;
}
-ExceptionOr<String> XMLHttpRequest::responseText()
+ExceptionOr<OwnedString> XMLHttpRequest::responseText()
{
if (m_responseType != ResponseType::EmptyString && m_responseType != ResponseType::Text)
return Exception { INVALID_STATE_ERR };
- return responseTextIgnoringResponseType();
+ return OwnedString { responseTextIgnoringResponseType() };
}
void XMLHttpRequest::didCacheResponse()
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (219598 => 219599)
--- trunk/Source/WebCore/xml/XMLHttpRequest.h 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h 2017-07-18 03:52:23 UTC (rev 219599)
@@ -48,6 +48,7 @@
class TextResourceDecoder;
class ThreadableLoader;
class XMLHttpRequestUpload;
+struct OwnedString;
class XMLHttpRequest final : public RefCounted<XMLHttpRequest>, public XMLHttpRequestEventTarget, private ThreadableLoaderClient, public ActiveDOMObject {
WTF_MAKE_FAST_ALLOCATED;
@@ -86,7 +87,7 @@
bool doneWithoutErrors() const { return !m_error && m_state == DONE; }
String getAllResponseHeaders() const;
String getResponseHeader(const String& name) const;
- ExceptionOr<String> responseText();
+ ExceptionOr<OwnedString> responseText();
String responseTextIgnoringResponseType() const { return m_responseBuilder.toStringPreserveCapacity(); }
String responseMIMEType() const;
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.idl (219598 => 219599)
--- trunk/Source/WebCore/xml/XMLHttpRequest.idl 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.idl 2017-07-18 03:52:23 UTC (rev 219599)
@@ -80,7 +80,7 @@
[MayThrowException] void overrideMimeType(DOMString mime);
[SetterMayThrowException] attribute XMLHttpRequestResponseType responseType;
[JSBuiltin] readonly attribute any response;
- [GetterMayThrowException, CustomGetter] readonly attribute USVString? responseText;
+ [GetterMayThrowException] readonly attribute USVString responseText;
// FIXME: responseXML should be annotated with [Exposed=Window].
[GetterMayThrowException] readonly attribute Document? responseXML;
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (219598 => 219599)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2017-07-18 03:52:23 UTC (rev 219599)
@@ -1,3 +1,14 @@
+2017-07-17 Sam Weinig <s...@webkit.org>
+
+ [WebIDL] Remove custom bindings that require non-caching JS strings
+ https://bugs.webkit.org/show_bug.cgi?id=174552
+
+ Reviewed by Darin Adler.
+
+ * DOM/DOMHTMLCanvasElement.mm:
+ (-[DOMHTMLCanvasElement toDataURL:]):
+ Update to account for implementation now returning an UncachedString.
+
2017-07-17 Darin Adler <da...@apple.com>
Improve use of NeverDestroyed
Modified: trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLCanvasElement.mm (219598 => 219599)
--- trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLCanvasElement.mm 2017-07-18 03:35:46 UTC (rev 219598)
+++ trunk/Source/WebKitLegacy/mac/DOM/DOMHTMLCanvasElement.mm 2017-07-18 03:52:23 UTC (rev 219599)
@@ -29,6 +29,7 @@
#import "ExceptionHandlers.h"
#import <WebCore/HTMLCanvasElement.h>
#import <WebCore/JSMainThreadExecState.h>
+#import <WebCore/StringAdaptors.h>
#import <WebCore/ThreadCheck.h>
#import <WebCore/URL.h>
#import <WebCore/WebScriptObjectPrivate.h>
@@ -65,7 +66,12 @@
- (NSString *)toDataURL:(NSString *)type
{
WebCore::JSMainThreadNullState state;
- return raiseOnDOMError(IMPL->toDataURL(type));
+
+ auto exceptionOrReturnValue = IMPL->toDataURL(type);
+ if (exceptionOrReturnValue.hasException())
+ raiseDOMErrorException(exceptionOrReturnValue.releaseException());
+
+ return exceptionOrReturnValue.releaseReturnValue().string;
}
@end