[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
yurys at chromium.org
yurys at chromium.org
Wed Jan 20 22:20:19 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 0c219933e8dd5e7544cd356baedc6e8e48c18ddc
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 12 08:18:48 2010 +0000
2010-01-12 Yury Semikhatsky <yurys at chromium.org>
Reviewed by Geoffrey Garen.
Allow creating injected script for the inspected script state. The InjectedScript is
cached on the inspected ExecState global object and will be garbage collected when the
object is collected. Each InjectedScript object is assigned unique id.
https://bugs.webkit.org/show_bug.cgi?id=33469
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::markChildren):
(WebCore::JSDOMGlobalObject::setInjectedScript):
(WebCore::JSDOMGlobalObject::injectedScript):
* bindings/js/JSDOMGlobalObject.h: InjectedScript is cached on the global object as a
field that is not visible from the inspected code. This InjectedScript should be alive as long as
the global object is alive and should be accessible from Web Inspector's native code.
(WebCore::JSDOMGlobalObject::JSDOMGlobalObjectData::JSDOMGlobalObjectData):
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::createInjectedScript): Creates injected script using the lexical global object of the
inspected ScriptState. Reference to the object is stored on the global DOM object.
(WebCore::InjectedScriptHost::injectedScriptFor):
* inspector/InjectedScriptHost.cpp:
(WebCore::InjectedScriptHost::InjectedScriptHost):
(WebCore::InjectedScriptHost::injectedScriptForId):
(WebCore::InjectedScriptHost::discardInjectedScripts): This method is expected to be called when the
the InjectedScript are no longer needed. In particular, this should be called before frame navigation.
* inspector/InjectedScriptHost.h:
(WebCore::InjectedScriptHost::setInjectedScriptSource): This allows to provide injected script source.
The source may be loaded in a platform specific way.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53119 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d3d23d4..1d8b560 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-01-12 Yury Semikhatsky <yurys at chromium.org>
+
+ Reviewed by Geoffrey Garen.
+
+ Allow creating injected script for the inspected script state. The InjectedScript is
+ cached on the inspected ExecState global object and will be garbage collected when the
+ object is collected. Each InjectedScript object is assigned unique id.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33469
+
+ * bindings/js/JSDOMGlobalObject.cpp:
+ (WebCore::JSDOMGlobalObject::markChildren):
+ (WebCore::JSDOMGlobalObject::setInjectedScript):
+ (WebCore::JSDOMGlobalObject::injectedScript):
+ * bindings/js/JSDOMGlobalObject.h: InjectedScript is cached on the global object as a
+ field that is not visible from the inspected code. This InjectedScript should be alive as long as
+ the global object is alive and should be accessible from Web Inspector's native code.
+ (WebCore::JSDOMGlobalObject::JSDOMGlobalObjectData::JSDOMGlobalObjectData):
+ * bindings/js/JSInjectedScriptHostCustom.cpp:
+ (WebCore::createInjectedScript): Creates injected script using the lexical global object of the
+ inspected ScriptState. Reference to the object is stored on the global DOM object.
+ (WebCore::InjectedScriptHost::injectedScriptFor):
+ * inspector/InjectedScriptHost.cpp:
+ (WebCore::InjectedScriptHost::InjectedScriptHost):
+ (WebCore::InjectedScriptHost::injectedScriptForId):
+ (WebCore::InjectedScriptHost::discardInjectedScripts): This method is expected to be called when the
+ the InjectedScript are no longer needed. In particular, this should be called before frame navigation.
+ * inspector/InjectedScriptHost.h:
+ (WebCore::InjectedScriptHost::setInjectedScriptSource): This allows to provide injected script source.
+ The source may be loaded in a platform specific way.
+
2010-01-11 Darin Adler <darin at apple.com>
Reviewed by Dan Bernstein.
diff --git a/WebCore/bindings/js/JSDOMGlobalObject.cpp b/WebCore/bindings/js/JSDOMGlobalObject.cpp
index 011a4e4..124ff50 100644
--- a/WebCore/bindings/js/JSDOMGlobalObject.cpp
+++ b/WebCore/bindings/js/JSDOMGlobalObject.cpp
@@ -56,6 +56,9 @@ void JSDOMGlobalObject::markChildren(MarkStack& markStack)
JSDOMConstructorMap::iterator end2 = constructors().end();
for (JSDOMConstructorMap::iterator it2 = constructors().begin(); it2 != end2; ++it2)
markStack.append(it2->second);
+
+ if (d()->m_injectedScript)
+ markStack.append(d()->m_injectedScript);
}
PassRefPtr<JSEventListener> JSDOMGlobalObject::createJSAttributeEventListener(JSValue val)
@@ -76,6 +79,16 @@ Event* JSDOMGlobalObject::currentEvent() const
return d()->evt;
}
+void JSDOMGlobalObject::setInjectedScript(JSObject* injectedScript)
+{
+ d()->m_injectedScript = injectedScript;
+}
+
+JSObject* JSDOMGlobalObject::injectedScript() const
+{
+ return d()->m_injectedScript;
+}
+
void JSDOMGlobalObject::destroyJSDOMGlobalObjectData(void* jsDOMGlobalObjectData)
{
delete static_cast<JSDOMGlobalObjectData*>(jsDOMGlobalObjectData);
diff --git a/WebCore/bindings/js/JSDOMGlobalObject.h b/WebCore/bindings/js/JSDOMGlobalObject.h
index 647730c..a55cc31 100644
--- a/WebCore/bindings/js/JSDOMGlobalObject.h
+++ b/WebCore/bindings/js/JSDOMGlobalObject.h
@@ -64,6 +64,9 @@ namespace WebCore {
void setCurrentEvent(Event*);
Event* currentEvent() const;
+ void setInjectedScript(JSObject*);
+ JSObject* injectedScript() const;
+
virtual void markChildren(JSC::MarkStack&);
DOMWrapperWorld* world() { return d()->m_world.get(); }
@@ -74,6 +77,7 @@ namespace WebCore {
: JSGlobalObjectData(destructor)
, evt(0)
, m_world(world)
+ , m_injectedScript(0)
{
}
@@ -82,6 +86,7 @@ namespace WebCore {
Event* evt;
RefPtr<DOMWrapperWorld> m_world;
+ JSObject* m_injectedScript;
};
private:
diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index 8dfc5e4..1409beb 100644
--- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -59,6 +59,7 @@
#endif
#include "TextIterator.h"
#include "VisiblePosition.h"
+#include <parser/SourceCode.h>
#include <runtime/JSArray.h>
#include <runtime/JSLock.h>
#include <wtf/Vector.h>
@@ -73,6 +74,31 @@ using namespace JSC;
namespace WebCore {
+static ScriptObject createInjectedScript(const String& source, InjectedScriptHost* injectedScriptHost, ScriptState* scriptState, long id)
+{
+ SourceCode sourceCode = makeSource(source);
+ JSLock lock(SilenceAssertionsOnly);
+ JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
+ JSValue globalThisValue = scriptState->globalThisValue();
+ Completion comp = JSC::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue);
+ if (comp.complType() != JSC::Normal && comp.complType() != JSC::ReturnValue)
+ return ScriptObject();
+ JSValue functionValue = comp.value();
+ CallData callData;
+ CallType callType = functionValue.getCallData(callData);
+ if (callType == CallTypeNone)
+ return ScriptObject();
+
+ MarkedArgumentBuffer args;
+ args.append(toJS(scriptState, globalObject, injectedScriptHost));
+ args.append(globalThisValue);
+ args.append(jsNumber(scriptState, id));
+ JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args);
+ if (result.isObject())
+ return ScriptObject(scriptState, result.getObject());
+ return ScriptObject();
+}
+
#if ENABLE(DATABASE)
JSValue JSInjectedScriptHost::databaseForId(ExecState* exec, const ArgList& args)
{
@@ -215,6 +241,22 @@ JSValue JSInjectedScriptHost::selectDOMStorage(ExecState*, const ArgList& args)
}
#endif
+ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
+{
+ JSLock lock(SilenceAssertionsOnly);
+ JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
+ JSObject* injectedScript = globalObject->injectedScript();
+ if (injectedScript)
+ return 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);
+ m_nextInjectedScriptId++;
+ return injectedScriptObject;
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp
index 47b2916..ce6f369 100644
--- a/WebCore/inspector/InjectedScriptHost.cpp
+++ b/WebCore/inspector/InjectedScriptHost.cpp
@@ -72,6 +72,7 @@ namespace WebCore {
InjectedScriptHost::InjectedScriptHost(InspectorController* inspectorController)
: m_inspectorController(inspectorController)
+ , m_nextInjectedScriptId(1)
{
}
@@ -180,6 +181,16 @@ void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, const St
frontend->didDispatchOnInjectedScript(callId, result, isException);
}
+ScriptObject InjectedScriptHost::injectedScriptForId(long id)
+{
+ return m_idToInjectedScript.get(id);
+}
+
+void InjectedScriptHost::discardInjectedScripts()
+{
+ m_idToInjectedScript.clear();
+}
+
InspectorDOMAgent* InjectedScriptHost::inspectorDOMAgent()
{
if (!m_inspectorController)
diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h
index e90217f..654b9f8 100644
--- a/WebCore/inspector/InjectedScriptHost.h
+++ b/WebCore/inspector/InjectedScriptHost.h
@@ -33,7 +33,9 @@
#include "Console.h"
#include "InspectorController.h"
#include "PlatformString.h"
+#include "ScriptState.h"
+#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
namespace WebCore {
@@ -55,6 +57,8 @@ public:
~InjectedScriptHost();
+ void setInjectedScriptSource(const String& source) { m_injectedScriptSource = source; }
+
InspectorController* inspectorController() { return m_inspectorController; }
void disconnectController() { m_inspectorController = 0; }
@@ -81,12 +85,20 @@ public:
#endif
void reportDidDispatchOnInjectedScript(long callId, const String& result, bool isException);
+ ScriptObject injectedScriptFor(ScriptState*);
+ ScriptObject injectedScriptForId(long);
+ void discardInjectedScripts();
+
private:
InjectedScriptHost(InspectorController* inspectorController);
InspectorDOMAgent* inspectorDOMAgent();
InspectorFrontend* inspectorFrontend();
InspectorController* m_inspectorController;
+ String m_injectedScriptSource;
+ long m_nextInjectedScriptId;
+ typedef HashMap<long, ScriptObject> IdToInjectedScriptMap;
+ IdToInjectedScriptMap m_idToInjectedScript;
};
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list