60
60
#include "TextIterator.h"
61
61
#include "VisiblePosition.h"
62
#include <parser/SourceCode.h>
62
63
#include <runtime/JSArray.h>
63
64
#include <runtime/JSLock.h>
64
65
#include <wtf/Vector.h>
74
75
namespace WebCore {
77
static ScriptObject createInjectedScript(const String& source, InjectedScriptHost* injectedScriptHost, ScriptState* scriptState, long id)
79
SourceCode sourceCode = makeSource(source);
80
JSLock lock(SilenceAssertionsOnly);
81
JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
82
JSValue globalThisValue = scriptState->globalThisValue();
83
Completion comp = JSC::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue);
84
if (comp.complType() != JSC::Normal && comp.complType() != JSC::ReturnValue)
85
return ScriptObject();
86
JSValue functionValue = comp.value();
88
CallType callType = functionValue.getCallData(callData);
89
if (callType == CallTypeNone)
90
return ScriptObject();
92
MarkedArgumentBuffer args;
93
args.append(toJS(scriptState, globalObject, injectedScriptHost));
94
args.append(globalThisValue);
95
args.append(jsNumber(scriptState, id));
96
JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args);
97
if (result.isObject())
98
return ScriptObject(scriptState, result.getObject());
99
return ScriptObject();
76
102
#if ENABLE(DATABASE)
77
103
JSValue JSInjectedScriptHost::databaseForId(ExecState* exec, const ArgList& args)
244
ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
246
JSLock lock(SilenceAssertionsOnly);
247
JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
248
JSObject* injectedScript = globalObject->injectedScript();
250
return ScriptObject(scriptState, injectedScript);
252
ASSERT(!m_injectedScriptSource.isEmpty());
253
ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId);
254
globalObject->setInjectedScript(injectedScriptObject.jsObject());
255
m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject);
256
m_nextInjectedScriptId++;
257
return injectedScriptObject;
218
260
} // namespace WebCore
220
262
#endif // ENABLE(INSPECTOR)