diff options
Diffstat (limited to 'Source/WebCore/inspector/CommandLineAPIHost.cpp')
-rw-r--r-- | Source/WebCore/inspector/CommandLineAPIHost.cpp | 103 |
1 files changed, 48 insertions, 55 deletions
diff --git a/Source/WebCore/inspector/CommandLineAPIHost.cpp b/Source/WebCore/inspector/CommandLineAPIHost.cpp index 92f1d27d2..2e5f2cdb3 100644 --- a/Source/WebCore/inspector/CommandLineAPIHost.cpp +++ b/Source/WebCore/inspector/CommandLineAPIHost.cpp @@ -12,7 +12,7 @@ * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -31,50 +31,34 @@ #include "config.h" #include "CommandLineAPIHost.h" -#if ENABLE(INSPECTOR) - -#include "Element.h" -#include "Frame.h" -#include "FrameLoader.h" -#include "HTMLFrameOwnerElement.h" -#include "InspectorClient.h" -#include "InspectorConsoleAgent.h" +#include "Database.h" #include "InspectorDOMAgent.h" #include "InspectorDOMStorageAgent.h" #include "InspectorDatabaseAgent.h" -#include "InspectorWebFrontendDispatchers.h" +#include "JSCommandLineAPIHost.h" +#include "JSDOMGlobalObject.h" #include "Pasteboard.h" #include "Storage.h" -#include "markup.h" -#include <bindings/ScriptValue.h> #include <inspector/InspectorValues.h> #include <inspector/agents/InspectorAgent.h> +#include <inspector/agents/InspectorConsoleAgent.h> +#include <runtime/JSCInlines.h> #include <wtf/RefPtr.h> #include <wtf/StdLibExtras.h> -#if ENABLE(SQL_DATABASE) -#include "Database.h" -#endif - +using namespace JSC; using namespace Inspector; namespace WebCore { -PassRefPtr<CommandLineAPIHost> CommandLineAPIHost::create() +Ref<CommandLineAPIHost> CommandLineAPIHost::create() { - return adoptRef(new CommandLineAPIHost); + return adoptRef(*new CommandLineAPIHost); } CommandLineAPIHost::CommandLineAPIHost() - : m_inspectorAgent(nullptr) - , m_consoleAgent(nullptr) - , m_domAgent(nullptr) - , m_domStorageAgent(nullptr) -#if ENABLE(SQL_DATABASE) - , m_databaseAgent(nullptr) -#endif + : m_inspectedObject(std::make_unique<InspectableObject>()) { - m_defaultInspectableObject = adoptPtr(new InspectableObject); } CommandLineAPIHost::~CommandLineAPIHost() @@ -87,17 +71,20 @@ void CommandLineAPIHost::disconnect() m_consoleAgent = nullptr; m_domAgent = nullptr; m_domStorageAgent = nullptr; -#if ENABLE(SQL_DATABASE) m_databaseAgent = nullptr; -#endif } -void CommandLineAPIHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints) +void CommandLineAPIHost::inspectImpl(RefPtr<InspectorValue>&& object, RefPtr<InspectorValue>&& hints) { - if (m_inspectorAgent) { - RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> remoteObject = Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(object); - m_inspectorAgent->inspect(remoteObject, hints->asObject()); - } + if (!m_inspectorAgent) + return; + + RefPtr<InspectorObject> hintsObject; + if (!hints->asObject(hintsObject)) + return; + + auto remoteObject = BindingTraits<Inspector::Protocol::Runtime::RemoteObject>::runtimeCast(WTFMove(object)); + m_inspectorAgent->inspect(WTFMove(remoteObject), WTFMove(hintsObject)); } void CommandLineAPIHost::getEventListenersImpl(Node* node, Vector<EventListenerInfo>& listenersArray) @@ -109,8 +96,8 @@ void CommandLineAPIHost::getEventListenersImpl(Node* node, Vector<EventListenerI void CommandLineAPIHost::clearConsoleMessages() { if (m_consoleAgent) { - ErrorString error; - m_consoleAgent->clearMessages(&error); + ErrorString unused; + m_consoleAgent->clearMessages(unused); } } @@ -119,39 +106,27 @@ void CommandLineAPIHost::copyText(const String& text) Pasteboard::createForCopyAndPaste()->writePlainText(text, Pasteboard::CannotSmartReplace); } -Deprecated::ScriptValue CommandLineAPIHost::InspectableObject::get(JSC::ExecState*) +JSC::JSValue CommandLineAPIHost::InspectableObject::get(JSC::ExecState&) { - return Deprecated::ScriptValue(); -}; - -void CommandLineAPIHost::addInspectedObject(PassOwnPtr<CommandLineAPIHost::InspectableObject> object) -{ - m_inspectedObjects.insert(0, object); - while (m_inspectedObjects.size() > 5) - m_inspectedObjects.removeLast(); + return { }; } -void CommandLineAPIHost::clearInspectedObjects() +void CommandLineAPIHost::addInspectedObject(std::unique_ptr<CommandLineAPIHost::InspectableObject> object) { - m_inspectedObjects.clear(); + m_inspectedObject = WTFMove(object); } -CommandLineAPIHost::InspectableObject* CommandLineAPIHost::inspectedObject(unsigned index) +CommandLineAPIHost::InspectableObject* CommandLineAPIHost::inspectedObject() { - if (index >= m_inspectedObjects.size()) - return m_defaultInspectableObject.get(); - - return m_inspectedObjects[index].get(); + return m_inspectedObject.get(); } -#if ENABLE(SQL_DATABASE) String CommandLineAPIHost::databaseIdImpl(Database* database) { if (m_databaseAgent) return m_databaseAgent->databaseId(database); return String(); } -#endif String CommandLineAPIHost::storageIdImpl(Storage* storage) { @@ -160,6 +135,24 @@ String CommandLineAPIHost::storageIdImpl(Storage* storage) return String(); } -} // namespace WebCore +JSValue CommandLineAPIHost::wrapper(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + JSValue value = m_wrappers.getWrapper(globalObject); + if (value) + return value; + + JSObject* prototype = JSCommandLineAPIHost::createPrototype(exec->vm(), globalObject); + Structure* structure = JSCommandLineAPIHost::createStructure(exec->vm(), globalObject, prototype); + JSCommandLineAPIHost* commandLineAPIHost = JSCommandLineAPIHost::create(structure, globalObject, makeRef(*this)); + m_wrappers.addWrapper(globalObject, commandLineAPIHost); + + return commandLineAPIHost; +} -#endif // ENABLE(INSPECTOR) +void CommandLineAPIHost::clearAllWrappers() +{ + m_wrappers.clearAllWrappers(); + m_inspectedObject = std::make_unique<InspectableObject>(); +} + +} // namespace WebCore |