[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.20-204-g221d8e8
yurys at chromium.org
yurys at chromium.org
Wed Feb 10 22:11:06 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 570694a135fad2889ec049ef0535ac8f7bd397cb
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Feb 3 18:11:20 2010 +0000
2010-02-03 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Pavel Feldman.
Provide strongly typed C++ interface for inspector's injected script.
https://bugs.webkit.org/show_bug.cgi?id=33616
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::injectedScriptFor):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::injectedScriptFor):
* inspector/InjectedScript.cpp: Added.
(WebCore::InjectedScript::InjectedScript):
(WebCore::InjectedScript::dispatch):
(WebCore::InjectedScript::callFrames):
(WebCore::InjectedScript::wrapAndStringify):
(WebCore::InjectedScript::releaseWrapperObjectGroup):
* inspector/InjectedScript.h: Added.
(WebCore::InjectedScript::InjectedScript):
(WebCore::InjectedScript::~InjectedScript):
(WebCore::InjectedScript::hasNoValue):
* inspector/InjectedScriptHost.cpp:
(WebCore::InjectedScriptHost::injectedScriptForId):
(WebCore::InjectedScriptHost::releaseWrapperObjectGroup):
* inspector/InjectedScriptHost.h:
* inspector/InspectorBackend.cpp:
(WebCore::InspectorBackend::dispatchOnInjectedScript):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::~InspectorController):
(WebCore::InspectorController::inspectedPageDestroyed):
(WebCore::InspectorController::windowScriptObjectAvailable):
(WebCore::InspectorController::scriptObjectReady):
(WebCore::InspectorController::setFrontendProxyObject):
(WebCore::InspectorController::close):
(WebCore::InspectorController::getProfile):
(WebCore::InspectorController::enableDebugger):
(WebCore::InspectorController::didPause):
(WebCore::InspectorController::injectedScriptForNodeId):
* inspector/InspectorController.h:
(WebCore::InspectorController::frontendScriptState):
* inspector/InspectorFrontend.cpp:
(WebCore::InspectorFrontend::addConsoleMessage):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54285 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fb13434..f67492f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,52 @@
+2010-02-03 Yury Semikhatsky <yurys at chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Provide strongly typed C++ interface for inspector's injected script.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33616
+
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSInjectedScriptHostCustom.cpp:
+ (WebCore::InjectedScriptHost::injectedScriptFor):
+ * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+ (WebCore::InjectedScriptHost::injectedScriptFor):
+ * inspector/InjectedScript.cpp: Added.
+ (WebCore::InjectedScript::InjectedScript):
+ (WebCore::InjectedScript::dispatch):
+ (WebCore::InjectedScript::callFrames):
+ (WebCore::InjectedScript::wrapAndStringify):
+ (WebCore::InjectedScript::releaseWrapperObjectGroup):
+ * inspector/InjectedScript.h: Added.
+ (WebCore::InjectedScript::InjectedScript):
+ (WebCore::InjectedScript::~InjectedScript):
+ (WebCore::InjectedScript::hasNoValue):
+ * inspector/InjectedScriptHost.cpp:
+ (WebCore::InjectedScriptHost::injectedScriptForId):
+ (WebCore::InjectedScriptHost::releaseWrapperObjectGroup):
+ * inspector/InjectedScriptHost.h:
+ * inspector/InspectorBackend.cpp:
+ (WebCore::InspectorBackend::dispatchOnInjectedScript):
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ (WebCore::InspectorController::~InspectorController):
+ (WebCore::InspectorController::inspectedPageDestroyed):
+ (WebCore::InspectorController::windowScriptObjectAvailable):
+ (WebCore::InspectorController::scriptObjectReady):
+ (WebCore::InspectorController::setFrontendProxyObject):
+ (WebCore::InspectorController::close):
+ (WebCore::InspectorController::getProfile):
+ (WebCore::InspectorController::enableDebugger):
+ (WebCore::InspectorController::didPause):
+ (WebCore::InspectorController::injectedScriptForNodeId):
+ * inspector/InspectorController.h:
+ (WebCore::InspectorController::frontendScriptState):
+ * inspector/InspectorFrontend.cpp:
+ (WebCore::InspectorFrontend::addConsoleMessage):
+
2010-02-03 Andras Becsi <abecsi at webkit.org>
Unreviewed build fix.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index ed49e83..8291811 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1581,6 +1581,8 @@
'inspector/InspectorClient.h',
'inspector/ConsoleMessage.cpp',
'inspector/ConsoleMessage.h',
+ 'inspector/InjectedScript.cpp',
+ 'inspector/InjectedScript.h',
'inspector/InjectedScriptHost.cpp',
'inspector/InjectedScriptHost.h',
'inspector/InspectorBackend.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 61e8c3c..be4244d 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -664,6 +664,7 @@ SOURCES += \
html/PreloadScanner.cpp \
html/ValidityState.cpp \
inspector/ConsoleMessage.cpp \
+ inspector/InjectedScript.cpp \
inspector/InjectedScriptHost.cpp \
inspector/InspectorBackend.cpp \
inspector/InspectorController.cpp \
@@ -1355,6 +1356,7 @@ HEADERS += \
html/TimeRanges.h \
html/ValidityState.h \
inspector/ConsoleMessage.h \
+ inspector/InjectedScript.h \
inspector/InjectedScriptHost.h \
inspector/InspectorBackend.h \
inspector/InspectorController.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index c31de7d..8bcca83 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42557,6 +42557,14 @@
>
</File>
<File
+ RelativePath="..\inspector\InjectedScript.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\inspector\InjectedScript.h"
+ >
+ </File>
+ <File
RelativePath="..\inspector\InjectedScriptHost.cpp"
>
</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 4b34eb0..f4b8b02 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4814,6 +4814,8 @@
ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED501DC50B249F2900AE18D9 /* EditorMac.mm */; };
EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = EDE3A4FF0C7A430600956A37 /* ColorMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; };
+ F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; };
+ F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; };
F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; };
F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */; };
F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5C041D70FFCA7CE00839D4A /* HTMLDataListElement.cpp */; };
@@ -10093,6 +10095,8 @@
ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = EditorMac.mm; path = mac/EditorMac.mm; sourceTree = "<group>"; };
EDE3A4FF0C7A430600956A37 /* ColorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMac.h; sourceTree = "<group>"; };
EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
+ F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; };
+ F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; };
F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OpenTypeSanitizer.h; path = opentype/OpenTypeSanitizer.h; sourceTree = "<group>"; };
F523D23B02DE4396018635CA /* HTMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDocument.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -10592,6 +10596,8 @@
1C81B9590E97330800266E07 /* front-end */,
41F0618D0F5F069800A07EAC /* ConsoleMessage.cpp */,
41F0618C0F5F069800A07EAC /* ConsoleMessage.h */,
+ F3644AFD1119805900E0D537 /* InjectedScript.cpp */,
+ F3644AFE1119805900E0D537 /* InjectedScript.h */,
7A0E76F610BF08ED00A0276E /* InjectedScriptHost.cpp */,
7A0E76F710BF08ED00A0276E /* InjectedScriptHost.h */,
7A0E76F810BF08ED00A0276E /* InjectedScriptHost.idl */,
@@ -18493,6 +18499,7 @@
E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */,
93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
+ F3644B001119805900E0D537 /* InjectedScript.h in Headers */,
97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */,
B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
@@ -20669,6 +20676,7 @@
93F19B0308245E59001E9ABC /* XSLStyleSheetLibxslt.cpp in Sources */,
E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */,
93F19B0408245E59001E9ABC /* XSLTProcessor.cpp in Sources */,
+ F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */,
93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index d38d8ee..96c5c43 100644
--- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -43,6 +43,7 @@
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorController.h"
#include "InspectorResource.h"
@@ -194,20 +195,21 @@ JSValue JSInjectedScriptHost::selectDOMStorage(ExecState*, const ArgList& args)
}
#endif
-ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
+InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
{
JSLock lock(SilenceAssertionsOnly);
JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
JSObject* injectedScript = globalObject->injectedScript();
if (injectedScript)
- return ScriptObject(scriptState, injectedScript);
+ return InjectedScript(ScriptObject(scriptState, injectedScript));
ASSERT(!m_injectedScriptSource.isEmpty());
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
globalObject->setInjectedScript(injectedScriptObject.jsObject());
- m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject);
+ InjectedScript result(injectedScriptObject);
+ m_idToInjectedScript.set(m_nextInjectedScriptId, result);
m_nextInjectedScriptId++;
- return injectedScriptObject;
+ return result;
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 0ddcf97..32c4b33 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -34,6 +34,7 @@
#include "DOMWindow.h"
#include "Database.h"
#include "Frame.h"
+#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorController.h"
#include "Node.h"
@@ -194,7 +195,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::selectDOMStorageCallback(const v8::A
}
#endif
-ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState)
+InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState)
{
v8::HandleScope handleScope;
v8::Local<v8::Context> context = inspectedScriptState->context();
@@ -208,14 +209,15 @@ ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptS
v8::Local<v8::String> key = v8::String::New("Devtools_InjectedScript");
v8::Local<v8::Value> val = global->GetHiddenValue(key);
if (!val.IsEmpty() && val->IsObject())
- return ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val));
+ return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
ASSERT(!m_injectedScriptSource.isEmpty());
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId);
- m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject);
+ InjectedScript result(injectedScriptObject);
+ m_idToInjectedScript.set(m_nextInjectedScriptId, result);
++m_nextInjectedScriptId;
global->SetHiddenValue(key, injectedScriptObject.v8Object());
- return injectedScriptObject;
+ return result;
}
} // namespace WebCore
diff --git a/WebCore/inspector/InjectedScript.cpp b/WebCore/inspector/InjectedScript.cpp
new file mode 100644
index 0000000..5275401
--- /dev/null
+++ b/WebCore/inspector/InjectedScript.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 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 "InjectedScript.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "PlatformString.h"
+#include "ScriptFunctionCall.h"
+
+namespace WebCore {
+
+InjectedScript::InjectedScript(ScriptObject injectedScriptObject)
+ : m_injectedScriptObject(injectedScriptObject)
+{
+}
+
+void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException)
+{
+ ASSERT(!hasNoValue());
+ ScriptState* scriptState = m_injectedScriptObject.scriptState();
+ ScriptFunctionCall function(scriptState, m_injectedScriptObject, "dispatch");
+ function.appendArgument(methodName);
+ function.appendArgument(arguments);
+ if (async)
+ function.appendArgument(callId);
+ *hadException = false;
+ ScriptValue resultValue = function.call(*hadException);
+ if (!*hadException)
+ *result = resultValue.toString(scriptState);
+}
+
+String InjectedScript::callFrames()
+{
+ ASSERT(!hasNoValue());
+ ScriptState* scriptState = m_injectedScriptObject.scriptState();
+ ScriptFunctionCall function(scriptState, m_injectedScriptObject, "callFrames");
+ ScriptValue callFramesValue = function.call();
+ return callFramesValue.toString(scriptState);
+}
+
+String InjectedScript::wrapAndStringifyForConsole(ScriptValue value)
+{
+ ASSERT(!hasNoValue());
+ ScriptState* scriptState = m_injectedScriptObject.scriptState();
+ ScriptFunctionCall wrapFunction(scriptState, m_injectedScriptObject, "wrapAndStringifyObject");
+ wrapFunction.appendArgument(value);
+ wrapFunction.appendArgument("console");
+ ScriptValue r = wrapFunction.call();
+ if (r.hasNoValue())
+ return "";
+ return r.toString(scriptState);
+}
+
+void InjectedScript::releaseWrapperObjectGroup(const String& objectGroup)
+{
+ ASSERT(!hasNoValue());
+ ScriptState* scriptState = m_injectedScriptObject.scriptState();
+ ScriptFunctionCall releaseFunction(scriptState, m_injectedScriptObject, "releaseWrapperObjectGroup");
+ releaseFunction.appendArgument(objectGroup);
+ releaseFunction.call();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InjectedScript.h b/WebCore/inspector/InjectedScript.h
new file mode 100644
index 0000000..dc8a808
--- /dev/null
+++ b/WebCore/inspector/InjectedScript.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef InjectedScript_h
+#define InjectedScript_h
+
+#include "InjectedScriptHost.h"
+#include "ScriptObject.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class String;
+
+class InjectedScript {
+public:
+ InjectedScript() { }
+ ~InjectedScript() { }
+
+ bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
+
+ void dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException);
+ String callFrames();
+ String wrapAndStringifyForConsole(ScriptValue);
+ void releaseWrapperObjectGroup(const String&);
+
+private:
+ friend InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState*);
+ explicit InjectedScript(ScriptObject);
+ ScriptObject m_injectedScriptObject;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp
index d5bbd1c..f88528d 100644
--- a/WebCore/inspector/InjectedScriptHost.cpp
+++ b/WebCore/inspector/InjectedScriptHost.cpp
@@ -38,6 +38,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLFrameOwnerElement.h"
+#include "InjectedScript.h"
#include "InspectorClient.h"
#include "InspectorController.h"
#include "InspectorDOMAgent.h"
@@ -167,7 +168,7 @@ void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, const St
frontend->didDispatchOnInjectedScript(callId, result, isException);
}
-ScriptObject InjectedScriptHost::injectedScriptForId(long id)
+InjectedScript InjectedScriptHost::injectedScriptForId(long id)
{
return m_idToInjectedScript.get(id);
}
@@ -180,13 +181,13 @@ void InjectedScriptHost::discardInjectedScripts()
void InjectedScriptHost::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup)
{
if (injectedScriptId) {
- ScriptObject injectedScript = m_idToInjectedScript.get(injectedScriptId);
+ InjectedScript injectedScript = m_idToInjectedScript.get(injectedScriptId);
if (!injectedScript.hasNoValue())
- releaseWrapperObjectGroup(injectedScript, objectGroup);
+ injectedScript.releaseWrapperObjectGroup(objectGroup);
} else {
// Iterate over all injected scripts if injectedScriptId is not specified.
for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it)
- releaseWrapperObjectGroup(it->second, objectGroup);
+ it->second.releaseWrapperObjectGroup(objectGroup);
}
}
@@ -204,13 +205,6 @@ InspectorFrontend* InjectedScriptHost::inspectorFrontend()
return m_inspectorController->m_frontend.get();
}
-void InjectedScriptHost::releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup)
-{
- ScriptFunctionCall releaseFunction(injectedScript.scriptState(), injectedScript, "releaseWrapperObjectGroup");
- releaseFunction.appendArgument(objectGroup);
- releaseFunction.call();
-}
-
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h
index d91c8e2..2b0f8b4 100644
--- a/WebCore/inspector/InjectedScriptHost.h
+++ b/WebCore/inspector/InjectedScriptHost.h
@@ -41,6 +41,7 @@
namespace WebCore {
class Database;
+class InjectedScript;
class InspectorDOMAgent;
class InspectorFrontend;
class JavaScriptCallFrame;
@@ -83,8 +84,8 @@ public:
#endif
void reportDidDispatchOnInjectedScript(long callId, const String& result, bool isException);
- ScriptObject injectedScriptFor(ScriptState*);
- ScriptObject injectedScriptForId(long);
+ InjectedScript injectedScriptFor(ScriptState*);
+ InjectedScript injectedScriptForId(long);
void discardInjectedScripts();
void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
@@ -93,12 +94,10 @@ private:
InspectorDOMAgent* inspectorDOMAgent();
InspectorFrontend* inspectorFrontend();
- void releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup);
-
InspectorController* m_inspectorController;
String m_injectedScriptSource;
long m_nextInjectedScriptId;
- typedef HashMap<long, ScriptObject> IdToInjectedScriptMap;
+ typedef HashMap<long, InjectedScript> IdToInjectedScriptMap;
IdToInjectedScriptMap m_idToInjectedScript;
};
diff --git a/WebCore/inspector/InspectorBackend.cpp b/WebCore/inspector/InspectorBackend.cpp
index 999a4b7..2c74212 100644
--- a/WebCore/inspector/InspectorBackend.cpp
+++ b/WebCore/inspector/InspectorBackend.cpp
@@ -40,6 +40,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLFrameOwnerElement.h"
+#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorClient.h"
#include "InspectorController.h"
@@ -285,7 +286,7 @@ void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScript
// FIXME: explicitly pass injectedScriptId along with node id to the frontend.
bool injectedScriptIdIsNodeId = injectedScriptId <= 0;
- ScriptObject injectedScript;
+ InjectedScript injectedScript;
if (injectedScriptIdIsNodeId)
injectedScript = m_inspectorController->injectedScriptForNodeId(-injectedScriptId);
else
@@ -294,19 +295,12 @@ void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScript
if (injectedScript.hasNoValue())
return;
- ScriptFunctionCall function(injectedScript.scriptState(), injectedScript, "dispatch");
- function.appendArgument(methodName);
- function.appendArgument(arguments);
- if (async)
- function.appendArgument(callId);
+ String result;
bool hadException = false;
- ScriptValue result = function.call(hadException);
+ injectedScript.dispatch(callId, methodName, arguments, async, &result, &hadException);
if (async)
return; // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript.
- if (hadException)
- frontend->didDispatchOnInjectedScript(callId, "", true);
- else
- frontend->didDispatchOnInjectedScript(callId, result.toString(injectedScript.scriptState()), false);
+ frontend->didDispatchOnInjectedScript(callId, result, hadException);
}
void InspectorBackend::getChildNodes(long callId, long nodeId)
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index 4e3b423..dbc5275 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -54,6 +54,7 @@
#include "HTMLFrameOwnerElement.h"
#include "HitTestResult.h"
#include "InjectedScriptHost.h"
+#include "InjectedScript.h"
#include "InspectorBackend.h"
#include "InspectorClient.h"
#include "InspectorDOMAgent.h"
@@ -131,7 +132,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
, m_client(client)
, m_page(0)
, m_expiredConsoleMessageCount(0)
- , m_scriptState(0)
+ , m_frontendScriptState(0)
, m_windowVisible(false)
, m_showAfterVisible(CurrentPanel)
, m_groupLevel(0)
@@ -161,7 +162,7 @@ InspectorController::~InspectorController()
{
// These should have been cleared in inspectedPageDestroyed().
ASSERT(!m_client);
- ASSERT(!m_scriptState);
+ ASSERT(!m_frontendScriptState);
ASSERT(!m_inspectedPage);
ASSERT(!m_page || (m_page && !m_page->parentInspectorController()));
@@ -182,10 +183,9 @@ void InspectorController::inspectedPageDestroyed()
{
close();
- if (m_scriptState) {
- ScriptGlobalObject::remove(m_scriptState, "InspectorBackend");
- ScriptGlobalObject::remove(m_scriptState, "InspectorFrontendHost");
- ScriptGlobalObject::remove(m_scriptState, "InjectedScriptHost");
+ if (m_frontendScriptState) {
+ ScriptGlobalObject::remove(m_frontendScriptState, "InspectorBackend");
+ ScriptGlobalObject::remove(m_frontendScriptState, "InspectorFrontendHost");
}
ASSERT(m_inspectedPage);
m_inspectedPage = 0;
@@ -508,22 +508,21 @@ void InspectorController::windowScriptObjectAvailable()
// Grant the inspector the ability to script the inspected page.
m_page->mainFrame()->document()->securityOrigin()->grantUniversalAccess();
- m_scriptState = scriptStateFromPage(debuggerWorld(), m_page);
- ScriptGlobalObject::set(m_scriptState, "InspectorBackend", m_inspectorBackend.get());
- ScriptGlobalObject::set(m_scriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get());
+ m_frontendScriptState = scriptStateFromPage(debuggerWorld(), m_page);
+ ScriptGlobalObject::set(m_frontendScriptState, "InspectorBackend", m_inspectorBackend.get());
+ ScriptGlobalObject::set(m_frontendScriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get());
}
void InspectorController::scriptObjectReady()
{
- ASSERT(m_scriptState);
- if (!m_scriptState)
+ ASSERT(m_frontendScriptState);
+ if (!m_frontendScriptState)
return;
ScriptObject webInspectorObj;
- if (!ScriptGlobalObject::get(m_scriptState, "WebInspector", webInspectorObj))
+ if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj))
return;
- ScriptObject injectedScriptObj;
- setFrontendProxyObject(m_scriptState, webInspectorObj, injectedScriptObj);
+ setFrontendProxyObject(m_frontendScriptState, webInspectorObj);
#if ENABLE(JAVASCRIPT_DEBUGGER)
String debuggerEnabled = setting(debuggerEnabledSettingName);
@@ -542,7 +541,7 @@ void InspectorController::scriptObjectReady()
void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject)
{
- m_scriptState = scriptState;
+ m_frontendScriptState = scriptState;
m_frontend.set(new InspectorFrontend(this, scriptState, webInspectorObj));
releaseDOMAgent();
m_domAgent = InspectorDOMAgent::create(m_frontend.get());
@@ -603,7 +602,7 @@ void InspectorController::close()
releaseDOMAgent();
m_frontend.set(0);
m_timelineAgent = 0;
- m_scriptState = 0;
+ m_frontendScriptState = 0;
if (m_page) {
if (!m_page->mainFrame() || !m_page->mainFrame()->loader() || !m_page->mainFrame()->loader()->isLoading()) {
m_page->setParentInspectorController(0);
@@ -1392,7 +1391,7 @@ void InspectorController::getProfile(long callId, unsigned uid)
return;
ProfilesMap::iterator it = m_profiles.find(uid);
if (it != m_profiles.end())
- m_frontend->didGetProfile(callId, toJS(m_scriptState, it->second.get()));
+ m_frontend->didGetProfile(callId, toJS(m_frontendScriptState, it->second.get()));
}
ScriptObject InspectorController::createProfileHeader(const ScriptProfile& profile)
@@ -1518,7 +1517,7 @@ void InspectorController::enableDebugger()
if (m_debuggerEnabled)
return;
- if (!m_scriptState || !m_frontend)
+ if (!m_frontendScriptState || !m_frontend)
m_attachDebuggerWhenShown = true;
else {
m_frontend->attachDebuggerWhenShown();
@@ -1569,11 +1568,8 @@ void InspectorController::didPause()
JavaScriptCallFrame* callFrame = m_injectedScriptHost->currentCallFrame();
ScriptState* scriptState = callFrame->scopeChain()->globalObject->globalExec();
ASSERT(scriptState);
- ScriptObject injectedScriptObj = m_injectedScriptHost->injectedScriptFor(scriptState);
- ScriptFunctionCall function(scriptState, injectedScriptObj, "getCallFrames");
- ScriptValue callFramesValue = function.call();
- String callFrames = callFramesValue.toString(scriptState);
-
+ InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(scriptState);
+ String callFrames = injectedScript.callFrames();
m_frontend->pausedScript(callFrames);
}
@@ -1810,7 +1806,7 @@ void InspectorController::deleteCookie(const String& cookieName, const String& d
}
}
-ScriptObject InspectorController::injectedScriptForNodeId(long id)
+InjectedScript InspectorController::injectedScriptForNodeId(long id)
{
Frame* frame = 0;
@@ -1828,7 +1824,7 @@ ScriptObject InspectorController::injectedScriptForNodeId(long id)
if (frame)
return m_injectedScriptHost->injectedScriptFor(mainWorldScriptState(frame));
- return ScriptObject();
+ return InjectedScript();
}
} // namespace WebCore
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index 9ef202f..0b914fb 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -64,6 +64,7 @@ class DocumentLoader;
class Element;
class GraphicsContext;
class HitTestResult;
+class InjectedScript;
class InjectedScriptHost;
class InspectorBackend;
class InspectorClient;
@@ -157,7 +158,7 @@ public:
void windowScriptObjectAvailable();
void setFrontendProxyObject(ScriptState* state, ScriptObject webInspectorObj, ScriptObject injectedScriptObj = ScriptObject());
- ScriptState* frontendScriptState() const { return m_scriptState; }
+ ScriptState* frontendScriptState() const { return m_frontendScriptState; }
void populateScriptObjects();
void resetScriptObjects();
@@ -248,7 +249,7 @@ public:
void evaluateForTestInFrontend(long callId, const String& script);
- ScriptObject injectedScriptForNodeId(long id);
+ InjectedScript injectedScriptForNodeId(long id);
private:
static const char* const FrontendSettingsSettingName;
@@ -328,7 +329,7 @@ private:
#if ENABLE(DOM_STORAGE)
DOMStorageResourcesMap m_domStorageResources;
#endif
- ScriptState* m_scriptState;
+ ScriptState* m_frontendScriptState;
bool m_windowVisible;
SpecialPanels m_showAfterVisible;
RefPtr<Node> m_highlightedNode;
diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp
index d5c817d..cc92976 100644
--- a/WebCore/inspector/InspectorFrontend.cpp
+++ b/WebCore/inspector/InspectorFrontend.cpp
@@ -34,6 +34,7 @@
#include "ConsoleMessage.h"
#include "Frame.h"
+#include "InjectedScript.h"
#include "InjectedScriptHost.h"
#include "InspectorController.h"
#include "Node.h"
@@ -105,15 +106,9 @@ void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const
function.appendArgument(frames[i]);
} else if (!arguments.isEmpty()) {
function.appendArgument(true);
- ScriptObject injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState);
+ InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState);
for (unsigned i = 0; i < arguments.size(); ++i) {
- ScriptFunctionCall wrapFunction(scriptState, injectedScript, "wrapAndStringifyObject");
- wrapFunction.appendArgument(arguments[i]);
- wrapFunction.appendArgument("console");
- ScriptValue r = wrapFunction.call();
- if (r.hasNoValue())
- return;
- String s = r.toString(scriptState);
+ String s = injectedScript.wrapAndStringifyForConsole(arguments[i]);
function.appendArgument(s);
}
} else {
diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js
index 9389117..337628f 100644
--- a/WebCore/inspector/front-end/InjectedScript.js
+++ b/WebCore/inspector/front-end/InjectedScript.js
@@ -923,7 +923,7 @@ InjectedScript.openInInspectedWindow = function(url)
return true;
}
-InjectedScript.getCallFrames = function()
+InjectedScript.callFrames = function()
{
var callFrame = InjectedScriptHost.currentCallFrame();
if (!callFrame)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list