Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (219674 => 219675)
--- trunk/Source/WebCore/CMakeLists.txt 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-07-20 05:46:30 UTC (rev 219675)
@@ -1155,7 +1155,6 @@
bindings/js/JSFontFaceSetCustom.cpp
bindings/js/JSCallbackData.cpp
bindings/js/JSCanvasRenderingContext2DCustom.cpp
- bindings/js/JSCommandLineAPIHostCustom.cpp
bindings/js/JSCryptoAlgorithmBuilder.cpp
bindings/js/JSCryptoAlgorithmDictionary.cpp
bindings/js/JSCryptoKeyCustom.cpp
Modified: trunk/Source/WebCore/ChangeLog (219674 => 219675)
--- trunk/Source/WebCore/ChangeLog 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/ChangeLog 2017-07-20 05:46:30 UTC (rev 219675)
@@ -1,3 +1,34 @@
+2017-07-19 Sam Weinig <[email protected]>
+
+ [WebIDL] Remove custom bindings for CommandLineAPIHost
+ https://bugs.webkit.org/show_bug.cgi?id=174642
+
+ Reviewed by Joseph Pecoraro.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSBindingsAllInOne.cpp:
+ * bindings/js/JSCommandLineAPIHostCustom.cpp: Removed.
+ Remove JSCommandLineAPIHostCustom.cpp.
+
+ * bindings/js/JSDOMConvertObject.h:
+ (WebCore::JSConverter<IDLObject>::convert):
+ Add missing JSConverter specialization for IDLObject.
+
+ * inspector/CommandLineAPIHost.cpp:
+ (WebCore::CommandLineAPIHost::inspect):
+ (WebCore::listenerEntriesFromListenerInfo):
+ (WebCore::CommandLineAPIHost::inspectedObject):
+ (WebCore::CommandLineAPIHost::databaseId):
+ (WebCore::CommandLineAPIHost::storageId):
+ (WebCore::CommandLineAPIHost::inspectImpl): Deleted.
+ (WebCore::CommandLineAPIHost::getEventListenersImpl): Deleted.
+ (WebCore::CommandLineAPIHost::databaseIdImpl): Deleted.
+ (WebCore::CommandLineAPIHost::storageIdImpl): Deleted.
+ * inspector/CommandLineAPIHost.h:
+ * inspector/CommandLineAPIHost.idl:
+ Replace custom bindings with modern bindings affordances: dictionaries, records and sequences.
+
2017-07-19 Zan Dobersek <[email protected]>
Unreviewed CoordGraphics build fix.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (219674 => 219675)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-07-20 05:46:30 UTC (rev 219675)
@@ -4408,7 +4408,6 @@
A584FE301864CB8400843B10 /* WebInjectedScriptManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE2E1864CB8400843B10 /* WebInjectedScriptManager.h */; };
A584FE341864D5AF00843B10 /* CommandLineAPIHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE311864D5AF00843B10 /* CommandLineAPIHost.cpp */; };
A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE321864D5AF00843B10 /* CommandLineAPIHost.h */; };
- A584FE381864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */; };
A584FE3B1864E2D800843B10 /* JSCommandLineAPIHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE391864E2D800843B10 /* JSCommandLineAPIHost.cpp */; };
A584FE3C1864E2D800843B10 /* JSCommandLineAPIHost.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE3A1864E2D800843B10 /* JSCommandLineAPIHost.h */; };
A58C59D01E382EAC0047859C /* JSPerformanceMark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A58C59CC1E382EA90047859C /* JSPerformanceMark.cpp */; };
@@ -12667,7 +12666,6 @@
A584FE311864D5AF00843B10 /* CommandLineAPIHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLineAPIHost.cpp; sourceTree = "<group>"; };
A584FE321864D5AF00843B10 /* CommandLineAPIHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLineAPIHost.h; sourceTree = "<group>"; };
A584FE331864D5AF00843B10 /* CommandLineAPIHost.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CommandLineAPIHost.idl; sourceTree = "<group>"; };
- A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCommandLineAPIHostCustom.cpp; sourceTree = "<group>"; };
A584FE391864E2D800843B10 /* JSCommandLineAPIHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCommandLineAPIHost.cpp; sourceTree = "<group>"; };
A584FE3A1864E2D800843B10 /* JSCommandLineAPIHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCommandLineAPIHost.h; sourceTree = "<group>"; };
A58C59CC1E382EA90047859C /* JSPerformanceMark.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformanceMark.cpp; sourceTree = "<group>"; };
@@ -23606,7 +23604,6 @@
children = (
7C3D8EE41E08BABE0023B084 /* GC / Wrapping Only */,
7CBA5BA91F0B51480034D745 /* Promises Only */,
- A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */,
E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */,
BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */,
@@ -31792,7 +31789,6 @@
836D03311DA8A13F00FFD96B /* JSClipboardEvent.cpp in Sources */,
51FB5505113E3E9100821176 /* JSCloseEvent.cpp in Sources */,
A584FE3B1864E2D800843B10 /* JSCommandLineAPIHost.cpp in Sources */,
- A584FE381864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp in Sources */,
93F9B6E00BA0FB7200854064 /* JSComment.cpp in Sources */,
79AC9218109945C80021266E /* JSCompositionEvent.cpp in Sources */,
FDA15EBD12B03F0B003A583A /* JSConvolverNode.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (219674 => 219675)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2017-07-20 05:46:30 UTC (rev 219675)
@@ -38,7 +38,6 @@
#include "JSCSSStyleDeclarationCustom.cpp"
#include "JSCallbackData.cpp"
#include "JSCanvasRenderingContext2DCustom.cpp"
-#include "JSCommandLineAPIHostCustom.cpp"
#include "JSCustomEventCustom.cpp"
#include "JSCustomXPathNSResolver.cpp"
#include "JSDOMBindingSecurity.cpp"
Deleted: trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp (219674 => 219675)
--- trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp 2017-07-20 05:46:30 UTC (rev 219675)
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2007-2008, 2016 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Matt Lilek <[email protected]>
- * Copyright (C) 2010-2011 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER 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.
- */
-
-#include "config.h"
-#include "JSCommandLineAPIHost.h"
-
-#include "CommandLineAPIHost.h"
-#include "Database.h"
-#include "Document.h"
-#include "InspectorDOMAgent.h"
-#include "JSDatabase.h"
-#include "JSEventListener.h"
-#include "JSNode.h"
-#include "JSStorage.h"
-#include "Storage.h"
-#include <bindings/ScriptValue.h>
-#include <inspector/InspectorValues.h>
-#include <parser/SourceCode.h>
-#include <runtime/IdentifierInlines.h>
-#include <runtime/JSArray.h>
-#include <runtime/JSFunction.h>
-#include <runtime/JSLock.h>
-#include <runtime/ObjectConstructor.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSValue JSCommandLineAPIHost::inspectedObject(ExecState& state)
-{
- CommandLineAPIHost::InspectableObject* object = wrapped().inspectedObject();
- if (!object)
- return jsUndefined();
-
- JSLockHolder lock(&state);
- auto scriptValue = object->get(state);
- return scriptValue ? scriptValue : jsUndefined();
-}
-
-static JSArray* getJSListenerFunctions(ExecState& state, Document* document, const EventListenerInfo& listenerInfo)
-{
- VM& vm = state.vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
- JSArray* result = constructEmptyArray(&state, nullptr);
- RETURN_IF_EXCEPTION(scope, nullptr);
- size_t handlersCount = listenerInfo.eventListenerVector.size();
- for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
- const JSEventListener* jsListener = JSEventListener::cast(&listenerInfo.eventListenerVector[i]->callback());
- if (!jsListener) {
- ASSERT_NOT_REACHED();
- continue;
- }
-
- // Hide listeners from other contexts.
- if (&jsListener->isolatedWorld() != ¤tWorld(&state))
- continue;
-
- JSObject* function = jsListener->jsFunction(document);
- if (!function)
- continue;
-
- JSObject* listenerEntry = constructEmptyObject(&state);
- listenerEntry->putDirect(vm, Identifier::fromString(&state, "listener"), function);
- listenerEntry->putDirect(vm, Identifier::fromString(&state, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i]->useCapture()));
- result->putDirectIndex(&state, outputIndex++, JSValue(listenerEntry));
- RETURN_IF_EXCEPTION(scope, nullptr);
- }
- return result;
-}
-
-JSValue JSCommandLineAPIHost::getEventListeners(ExecState& state)
-{
- if (state.argumentCount() < 1)
- return jsUndefined();
-
- VM& vm = state.vm();
- JSValue value = state.uncheckedArgument(0);
- if (!value.isObject() || value.isNull())
- return jsUndefined();
-
- Node* node = JSNode::toWrapped(vm, value);
- if (!node)
- return jsUndefined();
-
- Vector<EventListenerInfo> listenersArray;
- wrapped().getEventListenersImpl(node, listenersArray);
-
- JSObject* result = constructEmptyObject(&state);
- for (size_t i = 0; i < listenersArray.size(); ++i) {
- JSArray* listeners = getJSListenerFunctions(state, &node->document(), listenersArray[i]);
- if (!listeners->length())
- continue;
- AtomicString eventType = listenersArray[i].eventType;
- result->putDirect(state.vm(), Identifier::fromString(&state, eventType.impl()), JSValue(listeners));
- }
-
- return result;
-}
-
-JSValue JSCommandLineAPIHost::inspect(ExecState& state)
-{
- if (state.argumentCount() < 2)
- return jsUndefined();
- wrapped().inspectImpl(Inspector::toInspectorValue(state, state.uncheckedArgument(0)),
- Inspector::toInspectorValue(state, state.uncheckedArgument(1)));
- return jsUndefined();
-}
-
-JSValue JSCommandLineAPIHost::databaseId(ExecState& state)
-{
- if (state.argumentCount() < 1)
- return jsUndefined();
-
- VM& vm = state.vm();
- Database* database = JSDatabase::toWrapped(vm, state.uncheckedArgument(0));
- if (database)
- return jsStringWithCache(&state, wrapped().databaseIdImpl(database));
-
- return jsUndefined();
-}
-
-JSValue JSCommandLineAPIHost::storageId(ExecState& state)
-{
- if (state.argumentCount() < 1)
- return jsUndefined();
-
- VM& vm = state.vm();
- Storage* storage = JSStorage::toWrapped(vm, state.uncheckedArgument(0));
- if (storage)
- return jsStringWithCache(&state, wrapped().storageIdImpl(storage));
-
- return jsUndefined();
-}
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertObject.h (219674 => 219675)
--- trunk/Source/WebCore/bindings/js/JSDOMConvertObject.h 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertObject.h 2017-07-20 05:46:30 UTC (rev 219675)
@@ -49,4 +49,14 @@
}
};
+template<> struct JSConverter<IDLObject> {
+ static constexpr bool needsState = false;
+ static constexpr bool needsGlobalObject = false;
+
+ static JSC::JSValue convert(const JSC::Strong<JSC::JSObject>& value)
+ {
+ return value.get();
+ }
+};
+
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (219674 => 219675)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp 2017-07-20 05:46:30 UTC (rev 219675)
@@ -32,17 +32,21 @@
#include "CommandLineAPIHost.h"
#include "Database.h"
+#include "Document.h"
#include "InspectorDOMAgent.h"
#include "InspectorDOMStorageAgent.h"
#include "InspectorDatabaseAgent.h"
#include "JSCommandLineAPIHost.h"
#include "JSDOMGlobalObject.h"
+#include "JSEventListener.h"
#include "Pasteboard.h"
#include "Storage.h"
+#include <bindings/ScriptValue.h>
#include <inspector/InspectorValues.h>
#include <inspector/agents/InspectorAgent.h>
#include <inspector/agents/InspectorConsoleAgent.h>
#include <runtime/JSCInlines.h>
+#include <runtime/JSLock.h>
#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
@@ -74,23 +78,66 @@
m_databaseAgent = nullptr;
}
-void CommandLineAPIHost::inspectImpl(RefPtr<InspectorValue>&& object, RefPtr<InspectorValue>&& hints)
+void CommandLineAPIHost::inspect(JSC::ExecState& state, JSC::JSValue valueToInspect, JSC::JSValue hintsValue)
{
if (!m_inspectorAgent)
return;
RefPtr<InspectorObject> hintsObject;
- if (!hints->asObject(hintsObject))
+ if (!Inspector::toInspectorValue(state, hintsValue)->asObject(hintsObject))
return;
- auto remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(WTFMove(object));
+ auto remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(Inspector::toInspectorValue(state, valueToInspect));
m_inspectorAgent->inspect(WTFMove(remoteObject), WTFMove(hintsObject));
}
-void CommandLineAPIHost::getEventListenersImpl(Node* node, Vector<EventListenerInfo>& listenersArray)
+static Vector<CommandLineAPIHost::ListenerEntry> listenerEntriesFromListenerInfo(ExecState& state, Document& document, const EventListenerInfo& listenerInfo)
{
+ VM& vm = state.vm();
+
+ Vector<CommandLineAPIHost::ListenerEntry> entires;
+ for (auto& eventListener : listenerInfo.eventListenerVector) {
+ auto jsListener = JSEventListener::cast(&eventListener->callback());
+ if (!jsListener) {
+ ASSERT_NOT_REACHED();
+ continue;
+ }
+
+ // Hide listeners from other contexts.
+ if (&jsListener->isolatedWorld() != ¤tWorld(&state))
+ continue;
+
+ auto function = jsListener->jsFunction(&document);
+ if (!function)
+ continue;
+
+ entires.append({ JSC::Strong<JSC::JSObject>(vm, function), eventListener->useCapture() });
+ }
+
+ return entires;
+}
+
+auto CommandLineAPIHost::getEventListeners(JSC::ExecState& state, Node* node) -> EventListenersRecord
+{
if (m_domAgent)
- m_domAgent->getEventListeners(node, listenersArray, false);
+ return { };
+
+ if (!node)
+ return { };
+
+ Vector<EventListenerInfo> listenerInfoArray;
+ m_domAgent->getEventListeners(node, listenerInfoArray, false);
+
+ EventListenersRecord result;
+
+ for (auto& listenerInfo : listenerInfoArray) {
+ auto entries = listenerEntriesFromListenerInfo(state, node->document(), listenerInfo);
+ if (entries.isEmpty())
+ continue;
+ result.append({ listenerInfo.eventType, WTFMove(entries) });
+ }
+
+ return result;
}
void CommandLineAPIHost::clearConsoleMessages()
@@ -116,23 +163,28 @@
m_inspectedObject = WTFMove(object);
}
-CommandLineAPIHost::InspectableObject* CommandLineAPIHost::inspectedObject()
+JSC::JSValue CommandLineAPIHost::inspectedObject(JSC::ExecState& state)
{
- return m_inspectedObject.get();
+ if (!m_inspectedObject)
+ return jsUndefined();
+
+ JSC::JSLockHolder lock(&state);
+ auto scriptValue = m_inspectedObject->get(state);
+ return scriptValue ? scriptValue : jsUndefined();
}
-String CommandLineAPIHost::databaseIdImpl(Database* database)
+String CommandLineAPIHost::databaseId(Database* database)
{
if (m_databaseAgent)
return m_databaseAgent->databaseId(database);
- return String();
+ return { };
}
-String CommandLineAPIHost::storageIdImpl(Storage* storage)
+String CommandLineAPIHost::storageId(Storage* storage)
{
if (m_domStorageAgent)
return m_domStorageAgent->storageId(storage);
- return String();
+ return { };
}
JSValue CommandLineAPIHost::wrapper(ExecState* exec, JSDOMGlobalObject* globalObject)
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.h (219674 => 219675)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.h 2017-07-20 05:46:30 UTC (rev 219675)
@@ -88,14 +88,20 @@
virtual ~InspectableObject() { }
};
void addInspectedObject(std::unique_ptr<InspectableObject>);
- InspectableObject* inspectedObject();
- void inspectImpl(RefPtr<Inspector::InspectorValue>&& objectToInspect, RefPtr<Inspector::InspectorValue>&& hints);
+ JSC::JSValue inspectedObject(JSC::ExecState&);
+ void inspect(JSC::ExecState&, JSC::JSValue objectToInspect, JSC::JSValue hints);
- void getEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray);
+ struct ListenerEntry {
+ JSC::Strong<JSC::JSObject> function;
+ bool useCapture;
+ };
- String databaseIdImpl(Database*);
- String storageIdImpl(Storage*);
+ using EventListenersRecord = Vector<WTF::KeyValuePair<String, Vector<ListenerEntry>>>;
+ EventListenersRecord getEventListeners(JSC::ExecState&, Node*);
+ String databaseId(Database*);
+ String storageId(Storage*);
+
JSC::JSValue wrapper(JSC::ExecState*, JSDOMGlobalObject*);
void clearAllWrappers();
Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.idl (219674 => 219675)
--- trunk/Source/WebCore/inspector/CommandLineAPIHost.idl 2017-07-20 05:43:11 UTC (rev 219674)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.idl 2017-07-20 05:46:30 UTC (rev 219675)
@@ -36,9 +36,19 @@
] interface CommandLineAPIHost {
void clearConsoleMessages();
void copyText(DOMString text);
- [Custom] void inspect(any objectId, any hints);
- [Custom] any inspectedObject();
- [Custom] Array getEventListeners(Node node);
- [Custom] DOMString databaseId(any database);
- [Custom] DOMString storageId(any storage);
+
+ [CallWith=ScriptState] void inspect(any objectToInspect, any hints);
+ [CallWith=ScriptState] any inspectedObject();
+
+ [CallWith=ScriptState] record<DOMString, sequence<ListenerEntry>> getEventListeners(Node? node);
+
+ DOMString databaseId(Database? database);
+ DOMString storageId(Storage? storage);
};
+
+[
+ JSGenerateToJSObject
+] dictionary ListenerEntry {
+ required object function;
+ required boolean useCapture;
+};