Changeset 54421 in webkit


Ignore:
Timestamp:
Feb 5, 2010 6:08:31 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2010-02-05 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

  • Use SerializedScriptValue for passing data between injected script and inspector frontend.
  • Remove custom JSON implementation from the instpector utility script.
  • Make sure that only objects created in the same ScriptState can be values of ScriptObject/Array properties and arguments to ScriptFunctionCall. We don't want ScriptObjects to leak between contexts.
  • Use ScriptState of the 'this' object in ScriptFunctionCall instead of passing it as additional parameter.

https://bugs.webkit.org/show_bug.cgi?id=33592

  • bindings/js/JSInjectedScriptHostCustom.cpp: (WebCore::JSInjectedScriptHost::reportDidDispatchOnInjectedScript):
  • bindings/js/ScriptArray.cpp: (WebCore::ScriptArray::set):
  • bindings/js/ScriptFunctionCall.cpp: (WebCore::ScriptFunctionCall::ScriptFunctionCall): (WebCore::ScriptFunctionCall::appendArgument):
  • bindings/js/ScriptFunctionCall.h:
  • bindings/js/ScriptObject.cpp: (WebCore::ScriptObject::set):
  • bindings/js/ScriptValue.cpp: (WebCore::ScriptValue::serialize): (WebCore::ScriptValue::deserialize):
  • bindings/js/ScriptValue.h:
  • bindings/v8/ScriptArray.cpp: (WebCore::ScriptArray::set):
  • bindings/v8/ScriptFunctionCall.cpp: (WebCore::ScriptFunctionCall::ScriptFunctionCall): (WebCore::ScriptFunctionCall::appendArgument):
  • bindings/v8/ScriptFunctionCall.h:
  • bindings/v8/ScriptObject.cpp: (WebCore::ScriptObject::set):
  • bindings/v8/ScriptState.h:
  • bindings/v8/ScriptValue.cpp: (WebCore::ScriptValue::serialize): (WebCore::deserialize):
  • bindings/v8/ScriptValue.h:
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp: (WebCore::V8InjectedScriptHost::reportDidDispatchOnInjectedScriptCallback):
  • inspector/InjectedScript.cpp: (WebCore::InjectedScript::dispatch): (WebCore::InjectedScript::callFrames): (WebCore::InjectedScript::wrapForConsole): (WebCore::InjectedScript::releaseWrapperObjectGroup):
  • inspector/InjectedScript.h:
  • inspector/InjectedScriptHost.cpp: (WebCore::InjectedScriptHost::reportDidDispatchOnInjectedScript):
  • inspector/InjectedScriptHost.h:
  • inspector/InjectedScriptHost.idl:
  • inspector/InspectorBackend.cpp: (WebCore::InspectorBackend::dispatchOnInjectedScript):
  • inspector/InspectorController.cpp: (WebCore::InspectorController::setFrontendProxyObject): (WebCore::InspectorController::didPause): (WebCore::InspectorController::didEvaluateForTestInFrontend):
  • inspector/InspectorFrontend.cpp: (WebCore::InspectorFrontend::InspectorFrontend): (WebCore::InspectorFrontend::newScriptArray): (WebCore::InspectorFrontend::newScriptObject): (WebCore::InspectorFrontend::populateFrontendSettings): (WebCore::InspectorFrontend::updateConsoleMessageExpiredCount): (WebCore::InspectorFrontend::addConsoleMessage): (WebCore::InspectorFrontend::updateConsoleMessageRepeatCount): (WebCore::InspectorFrontend::updateResource): (WebCore::InspectorFrontend::removeResource): (WebCore::InspectorFrontend::didGetResourceContent): (WebCore::InspectorFrontend::updateFocusedNode): (WebCore::InspectorFrontend::setAttachedWindow): (WebCore::InspectorFrontend::addRecordToTimeline): (WebCore::InspectorFrontend::parsedScriptSource): (WebCore::InspectorFrontend::failedToParseScriptSource): (WebCore::InspectorFrontend::addProfileHeader): (WebCore::InspectorFrontend::setRecordingProfile): (WebCore::InspectorFrontend::didGetProfileHeaders): (WebCore::InspectorFrontend::didGetProfile): (WebCore::InspectorFrontend::pausedScript): (WebCore::InspectorFrontend::setDocument): (WebCore::InspectorFrontend::setDetachedRoot): (WebCore::InspectorFrontend::setChildNodes): (WebCore::InspectorFrontend::childNodeCountUpdated): (WebCore::InspectorFrontend::childNodeInserted): (WebCore::InspectorFrontend::childNodeRemoved): (WebCore::InspectorFrontend::attributesUpdated): (WebCore::InspectorFrontend::didRemoveNode): (WebCore::InspectorFrontend::didGetChildNodes): (WebCore::InspectorFrontend::didApplyDomChange): (WebCore::InspectorFrontend::didGetEventListenersForNode): (WebCore::InspectorFrontend::didGetCookies): (WebCore::InspectorFrontend::didDispatchOnInjectedScript): (WebCore::InspectorFrontend::addDatabase): (WebCore::InspectorFrontend::selectDatabase): (WebCore::InspectorFrontend::didGetDatabaseTableNames): (WebCore::InspectorFrontend::addDOMStorage): (WebCore::InspectorFrontend::selectDOMStorage): (WebCore::InspectorFrontend::didGetDOMStorageEntries): (WebCore::InspectorFrontend::didSetDOMStorageItem): (WebCore::InspectorFrontend::didRemoveDOMStorageItem): (WebCore::InspectorFrontend::updateDOMStorage): (WebCore::InspectorFrontend::addNodesToSearchResult): (WebCore::InspectorFrontend::contextMenuItemSelected): (WebCore::InspectorFrontend::evaluateForTestInFrontend): (WebCore::InspectorFrontend::callSimpleFunction):
  • inspector/InspectorFrontend.h: (WebCore::InspectorFrontend::scriptState):
  • inspector/front-end/InjectedScript.js: (injectedScriptConstructor): (injectedScriptConstructor.):
  • inspector/front-end/InjectedScriptAccess.js: (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName.myCallback): (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName): (InjectedScriptAccess._installHandler):
  • inspector/front-end/inspector.js: (WebInspector.pausedScript): (WebInspector.addConsoleMessage):

2010-02-05 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Remove unused inmport of ScriptFunctionCall.h

https://bugs.webkit.org/show_bug.cgi?id=33592

  • Api/qwebelement.cpp:
Location:
trunk
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54420 r54421  
     12010-02-05  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        - Use SerializedScriptValue for passing data between injected script and
     6        inspector frontend.
     7        - Remove custom JSON implementation from the instpector utility script.
     8        - Make sure that only objects created in the same ScriptState can be values
     9        of ScriptObject/Array properties and arguments to ScriptFunctionCall. We don't
     10        want ScriptObjects to leak between contexts.
     11        - Use ScriptState of the 'this' object in ScriptFunctionCall instead of passing
     12        it as additional parameter.
     13
     14        https://bugs.webkit.org/show_bug.cgi?id=33592
     15
     16        * bindings/js/JSInjectedScriptHostCustom.cpp:
     17        (WebCore::JSInjectedScriptHost::reportDidDispatchOnInjectedScript):
     18        * bindings/js/ScriptArray.cpp:
     19        (WebCore::ScriptArray::set):
     20        * bindings/js/ScriptFunctionCall.cpp:
     21        (WebCore::ScriptFunctionCall::ScriptFunctionCall):
     22        (WebCore::ScriptFunctionCall::appendArgument):
     23        * bindings/js/ScriptFunctionCall.h:
     24        * bindings/js/ScriptObject.cpp:
     25        (WebCore::ScriptObject::set):
     26        * bindings/js/ScriptValue.cpp:
     27        (WebCore::ScriptValue::serialize):
     28        (WebCore::ScriptValue::deserialize):
     29        * bindings/js/ScriptValue.h:
     30        * bindings/v8/ScriptArray.cpp:
     31        (WebCore::ScriptArray::set):
     32        * bindings/v8/ScriptFunctionCall.cpp:
     33        (WebCore::ScriptFunctionCall::ScriptFunctionCall):
     34        (WebCore::ScriptFunctionCall::appendArgument):
     35        * bindings/v8/ScriptFunctionCall.h:
     36        * bindings/v8/ScriptObject.cpp:
     37        (WebCore::ScriptObject::set):
     38        * bindings/v8/ScriptState.h:
     39        * bindings/v8/ScriptValue.cpp:
     40        (WebCore::ScriptValue::serialize):
     41        (WebCore::deserialize):
     42        * bindings/v8/ScriptValue.h:
     43        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     44        (WebCore::V8InjectedScriptHost::reportDidDispatchOnInjectedScriptCallback):
     45        * inspector/InjectedScript.cpp:
     46        (WebCore::InjectedScript::dispatch):
     47        (WebCore::InjectedScript::callFrames):
     48        (WebCore::InjectedScript::wrapForConsole):
     49        (WebCore::InjectedScript::releaseWrapperObjectGroup):
     50        * inspector/InjectedScript.h:
     51        * inspector/InjectedScriptHost.cpp:
     52        (WebCore::InjectedScriptHost::reportDidDispatchOnInjectedScript):
     53        * inspector/InjectedScriptHost.h:
     54        * inspector/InjectedScriptHost.idl:
     55        * inspector/InspectorBackend.cpp:
     56        (WebCore::InspectorBackend::dispatchOnInjectedScript):
     57        * inspector/InspectorController.cpp:
     58        (WebCore::InspectorController::setFrontendProxyObject):
     59        (WebCore::InspectorController::didPause):
     60        (WebCore::InspectorController::didEvaluateForTestInFrontend):
     61        * inspector/InspectorFrontend.cpp:
     62        (WebCore::InspectorFrontend::InspectorFrontend):
     63        (WebCore::InspectorFrontend::newScriptArray):
     64        (WebCore::InspectorFrontend::newScriptObject):
     65        (WebCore::InspectorFrontend::populateFrontendSettings):
     66        (WebCore::InspectorFrontend::updateConsoleMessageExpiredCount):
     67        (WebCore::InspectorFrontend::addConsoleMessage):
     68        (WebCore::InspectorFrontend::updateConsoleMessageRepeatCount):
     69        (WebCore::InspectorFrontend::updateResource):
     70        (WebCore::InspectorFrontend::removeResource):
     71        (WebCore::InspectorFrontend::didGetResourceContent):
     72        (WebCore::InspectorFrontend::updateFocusedNode):
     73        (WebCore::InspectorFrontend::setAttachedWindow):
     74        (WebCore::InspectorFrontend::addRecordToTimeline):
     75        (WebCore::InspectorFrontend::parsedScriptSource):
     76        (WebCore::InspectorFrontend::failedToParseScriptSource):
     77        (WebCore::InspectorFrontend::addProfileHeader):
     78        (WebCore::InspectorFrontend::setRecordingProfile):
     79        (WebCore::InspectorFrontend::didGetProfileHeaders):
     80        (WebCore::InspectorFrontend::didGetProfile):
     81        (WebCore::InspectorFrontend::pausedScript):
     82        (WebCore::InspectorFrontend::setDocument):
     83        (WebCore::InspectorFrontend::setDetachedRoot):
     84        (WebCore::InspectorFrontend::setChildNodes):
     85        (WebCore::InspectorFrontend::childNodeCountUpdated):
     86        (WebCore::InspectorFrontend::childNodeInserted):
     87        (WebCore::InspectorFrontend::childNodeRemoved):
     88        (WebCore::InspectorFrontend::attributesUpdated):
     89        (WebCore::InspectorFrontend::didRemoveNode):
     90        (WebCore::InspectorFrontend::didGetChildNodes):
     91        (WebCore::InspectorFrontend::didApplyDomChange):
     92        (WebCore::InspectorFrontend::didGetEventListenersForNode):
     93        (WebCore::InspectorFrontend::didGetCookies):
     94        (WebCore::InspectorFrontend::didDispatchOnInjectedScript):
     95        (WebCore::InspectorFrontend::addDatabase):
     96        (WebCore::InspectorFrontend::selectDatabase):
     97        (WebCore::InspectorFrontend::didGetDatabaseTableNames):
     98        (WebCore::InspectorFrontend::addDOMStorage):
     99        (WebCore::InspectorFrontend::selectDOMStorage):
     100        (WebCore::InspectorFrontend::didGetDOMStorageEntries):
     101        (WebCore::InspectorFrontend::didSetDOMStorageItem):
     102        (WebCore::InspectorFrontend::didRemoveDOMStorageItem):
     103        (WebCore::InspectorFrontend::updateDOMStorage):
     104        (WebCore::InspectorFrontend::addNodesToSearchResult):
     105        (WebCore::InspectorFrontend::contextMenuItemSelected):
     106        (WebCore::InspectorFrontend::evaluateForTestInFrontend):
     107        (WebCore::InspectorFrontend::callSimpleFunction):
     108        * inspector/InspectorFrontend.h:
     109        (WebCore::InspectorFrontend::scriptState):
     110        * inspector/front-end/InjectedScript.js:
     111        (injectedScriptConstructor):
     112        (injectedScriptConstructor.):
     113        * inspector/front-end/InjectedScriptAccess.js:
     114        (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName.myCallback):
     115        (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName):
     116        (InjectedScriptAccess._installHandler):
     117        * inspector/front-end/inspector.js:
     118        (WebInspector.pausedScript):
     119        (WebInspector.addConsoleMessage):
     120
    11212010-02-05  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    2122
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r54334 r54421  
    5454#include "Page.h"
    5555#if ENABLE(DOM_STORAGE)
     56#include "SerializedScriptValue.h"
    5657#include "Storage.h"
    5758#include "JSStorage.h"
     
    6263#include <runtime/JSArray.h>
    6364#include <runtime/JSLock.h>
     65#include <wtf/RefPtr.h>
    6466#include <wtf/Vector.h>
    6567
     
    196198#endif
    197199
     200JSValue JSInjectedScriptHost::reportDidDispatchOnInjectedScript(ExecState* exec, const ArgList& args)
     201{
     202    if (args.size() < 3)
     203        return jsUndefined();
     204   
     205    if (!args.at(0).isInt32())
     206        return jsUndefined();
     207    int callId = args.at(0).asInt32();
     208   
     209    RefPtr<SerializedScriptValue> result(SerializedScriptValue::create(exec, args.at(1)));
     210   
     211    bool isException;
     212    if (!args.at(2).getBoolean(isException))
     213        return jsUndefined();
     214    impl()->reportDidDispatchOnInjectedScript(callId, result.get(), isException);
     215    return jsUndefined();
     216}
     217
    198218InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
    199219{
  • trunk/WebCore/bindings/js/ScriptArray.cpp

    r46490 r54421  
    5454bool ScriptArray::set(unsigned index, const ScriptObject& value)
    5555{
     56    if (value.scriptState() != m_scriptState) {
     57        ASSERT_NOT_REACHED();
     58        return false;
     59    }
    5660    JSLock lock(SilenceAssertionsOnly);
    5761    jsArray()->put(m_scriptState, index, value.jsObject());
  • trunk/WebCore/bindings/js/ScriptFunctionCall.cpp

    r53371 r54421  
    4343namespace WebCore {
    4444
    45 ScriptFunctionCall::ScriptFunctionCall(ScriptState* exec, const ScriptObject& thisObject, const String& name)
    46     : m_exec(exec)
     45ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name)
     46    : m_exec(thisObject.scriptState())
    4747    , m_thisObject(thisObject)
    4848    , m_name(name)
     
    5252void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
    5353{
     54    if (argument.scriptState() != m_exec) {
     55        ASSERT_NOT_REACHED();
     56        return;
     57    }
    5458    m_arguments.append(argument.jsObject());
    5559}
  • trunk/WebCore/bindings/js/ScriptFunctionCall.h

    r51621 r54421  
    4949    class ScriptFunctionCall {
    5050    public:
    51         ScriptFunctionCall(ScriptState* exec, const ScriptObject& thisObject, const String& name);
     51        ScriptFunctionCall(const ScriptObject& thisObject, const String& name);
    5252        virtual ~ScriptFunctionCall() {};
    5353
  • trunk/WebCore/bindings/js/ScriptObject.cpp

    r51528 r54421  
    7171bool ScriptObject::set(const char* name, const ScriptObject& value)
    7272{
     73    if (value.scriptState() != m_scriptState) {
     74        ASSERT_NOT_REACHED();
     75        return false;
     76    }
    7377    JSLock lock(SilenceAssertionsOnly);
    7478    PutPropertySlot slot;
  • trunk/WebCore/bindings/js/ScriptValue.cpp

    r53766 r54421  
    2929#include "config.h"
    3030#include "ScriptValue.h"
     31
     32#include "SerializedScriptValue.h"
    3133
    3234#include <JavaScriptCore/APICast.h>
     
    8284}
    8385
     86PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState)
     87{
     88    return SerializedScriptValue::create(scriptState, jsValue());
     89}
     90
     91ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value)
     92{
     93    return ScriptValue(value->deserialize(scriptState, scriptState->lexicalGlobalObject()));
     94}
     95
    8496} // namespace WebCore
  • trunk/WebCore/bindings/js/ScriptValue.h

    r53766 r54421  
    3535#include "ScriptState.h"
    3636#include <runtime/Protect.h>
     37#include <wtf/PassRefPtr.h>
    3738
    3839namespace WebCore {
    3940
    4041class String;
     42class SerializedScriptValue;
    4143
    4244class ScriptValue {
     
    5456    bool hasNoValue() const { return m_value == JSC::JSValue(); }
    5557
     58    PassRefPtr<SerializedScriptValue> serialize(ScriptState*);
     59    static ScriptValue deserialize(ScriptState*, SerializedScriptValue*);
     60
    5661private:
    5762    JSC::ProtectedJSValue m_value;
  • trunk/WebCore/bindings/v8/ScriptArray.cpp

    r46490 r54421  
    5151bool ScriptArray::set(unsigned index, const ScriptObject& value)
    5252{
     53    if (value.scriptState() != m_scriptState) {
     54        ASSERT_NOT_REACHED();
     55        return false;
     56    }
    5357    ScriptScope scope(m_scriptState);
    5458    v8Object()->Set(v8::Integer::New(index), value.v8Value());
  • trunk/WebCore/bindings/v8/ScriptFunctionCall.cpp

    r51642 r54421  
    4646namespace WebCore {
    4747
    48 ScriptFunctionCall::ScriptFunctionCall(ScriptState* scriptState, const ScriptObject& thisObject, const String& name)
    49     : m_scriptState(scriptState)
     48ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name)
     49    : m_scriptState(thisObject.scriptState())
    5050    , m_thisObject(thisObject)
    5151    , m_name(name)
     
    5555void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
    5656{
     57    if (argument.scriptState() != m_scriptState) {
     58        ASSERT_NOT_REACHED();
     59        return;
     60    }
    5761    m_arguments.append(argument);
    5862}
  • trunk/WebCore/bindings/v8/ScriptFunctionCall.h

    r51642 r54421  
    4444    class ScriptFunctionCall {
    4545    public:
    46         ScriptFunctionCall(ScriptState* scriptState, const ScriptObject& thisObject, const String& name);
     46        ScriptFunctionCall(const ScriptObject& thisObject, const String& name);
    4747        virtual ~ScriptFunctionCall() {};
    4848
  • trunk/WebCore/bindings/v8/ScriptObject.cpp

    r54305 r54421  
    6868bool ScriptObject::set(const char* name, const ScriptObject& value)
    6969{
     70    if (value.scriptState() != m_scriptState) {
     71        ASSERT_NOT_REACHED();
     72        return false;
     73    }
    7074    ScriptScope scope(m_scriptState);
    7175    v8Object()->Set(v8::String::New(name), value.v8Value());
  • trunk/WebCore/bindings/v8/ScriptState.h

    r54108 r54421  
    3939namespace WebCore {
    4040    class DOMWrapperWorld;
     41    class Frame;
    4142    class Node;
    4243    class Page;
    43     class Frame;
    4444
    4545    class ScriptState : public Noncopyable {
  • trunk/WebCore/bindings/v8/ScriptValue.cpp

    • Property svn:executable set to *
    r41649 r54421  
    3232#include "ScriptValue.h"
    3333
     34#include "ScriptScope.h"
     35#include "SerializedScriptValue.h"
    3436#include "V8Binding.h"
    3537
    3638namespace WebCore {
     39
     40PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState)
     41{
     42    ScriptScope scope(scriptState);
     43    return SerializedScriptValue::create(v8Value());
     44}
     45
     46ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value)
     47{
     48    ScriptScope scope(scriptState);
     49    return ScriptValue(value->deserialize());
     50}
    3751
    3852bool ScriptValue::getString(String& result) const
  • trunk/WebCore/bindings/v8/ScriptValue.h

    r53766 r54421  
    3636
    3737#include <v8.h>
     38#include <wtf/PassRefPtr.h>
    3839
    3940#ifndef NDEBUG
     
    4243
    4344namespace WebCore {
     45
     46class SerializedScriptValue;
    4447
    4548class ScriptValue {
     
    122125    }
    123126
     127    PassRefPtr<SerializedScriptValue> serialize(ScriptState*);
     128    static ScriptValue deserialize(ScriptState*, SerializedScriptValue*);
     129
    124130    void clear()
    125131    {
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r54334 r54421  
    4040#include "Node.h"
    4141#include "Page.h"
     42#include "SerializedScriptValue.h"
    4243
    4344#include "V8Binding.h"
     
    4647#include "V8Proxy.h"
    4748#include "V8Storage.h"
     49#include <wtf/RefPtr.h>
    4850
    4951namespace WebCore {
     
    195197#endif
    196198
     199v8::Handle<v8::Value> V8InjectedScriptHost::reportDidDispatchOnInjectedScriptCallback(const v8::Arguments& args)
     200{
     201    INC_STATS("InjectedScriptHost.reportDidDispatchOnInjectedScript()");
     202    if (args.Length() < 3)
     203        return v8::Undefined();
     204    InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
     205    int callId = args[0]->ToInt32()->Value();
     206    RefPtr<SerializedScriptValue> result(SerializedScriptValue::create(args[1]));
     207    bool isException = args[2]->ToBoolean()->Value();
     208    host->reportDidDispatchOnInjectedScript(callId, result.get(), isException);
     209    return v8::Undefined();
     210}
     211
    197212InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState)
    198213{
  • trunk/WebCore/inspector/InjectedScript.cpp

    r54334 r54421  
    3535
    3636#include "PlatformString.h"
     37#include "SerializedScriptValue.h"
    3738#include "ScriptFunctionCall.h"
    3839
     
    4445}
    4546
    46 void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException)
     47void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<SerializedScriptValue>* result, bool* hadException)
    4748{
    4849    ASSERT(!hasNoValue());
    49     ScriptState* scriptState = m_injectedScriptObject.scriptState();
    50     ScriptFunctionCall function(scriptState, m_injectedScriptObject, "dispatch");
     50    ScriptFunctionCall function(m_injectedScriptObject, "dispatch");
    5151    function.appendArgument(methodName);
    5252    function.appendArgument(arguments);
     
    5656    ScriptValue resultValue = function.call(*hadException);
    5757    if (!*hadException)
    58         *result = resultValue.toString(scriptState);
     58        *result = resultValue.serialize(m_injectedScriptObject.scriptState());
    5959}
    6060
    6161#if ENABLE(JAVASCRIPT_DEBUGGER)
    62 String InjectedScript::callFrames()
     62PassRefPtr<SerializedScriptValue> InjectedScript::callFrames()
    6363{
    6464    ASSERT(!hasNoValue());
    65     ScriptState* scriptState = m_injectedScriptObject.scriptState();
    66     ScriptFunctionCall function(scriptState, m_injectedScriptObject, "callFrames");
     65    ScriptFunctionCall function(m_injectedScriptObject, "callFrames");
    6766    ScriptValue callFramesValue = function.call();
    68     return callFramesValue.toString(scriptState);
     67    return callFramesValue.serialize(m_injectedScriptObject.scriptState());
    6968}
    7069#endif
    7170
    72 String InjectedScript::wrapAndStringifyForConsole(ScriptValue value)
     71PassRefPtr<SerializedScriptValue> InjectedScript::wrapForConsole(ScriptValue value)
    7372{
    7473    ASSERT(!hasNoValue());
    75     ScriptState* scriptState = m_injectedScriptObject.scriptState();
    76     ScriptFunctionCall wrapFunction(scriptState, m_injectedScriptObject, "wrapAndStringifyObject");
     74    ScriptFunctionCall wrapFunction(m_injectedScriptObject, "wrapObject");
    7775    wrapFunction.appendArgument(value);
    7876    wrapFunction.appendArgument("console");
    7977    ScriptValue r = wrapFunction.call();
    80     if (r.hasNoValue())
    81         return "";
    82     return r.toString(scriptState);
     78    return r.serialize(m_injectedScriptObject.scriptState());
    8379}
    8480
     
    8682{
    8783    ASSERT(!hasNoValue());
    88     ScriptState* scriptState = m_injectedScriptObject.scriptState();
    89     ScriptFunctionCall releaseFunction(scriptState, m_injectedScriptObject, "releaseWrapperObjectGroup");
     84    ScriptFunctionCall releaseFunction(m_injectedScriptObject, "releaseWrapperObjectGroup");
    9085    releaseFunction.appendArgument(objectGroup);
    9186    releaseFunction.call();
  • trunk/WebCore/inspector/InjectedScript.h

    r54334 r54421  
    3535#include "ScriptObject.h"
    3636#include <wtf/Noncopyable.h>
     37#include <wtf/PassRefPtr.h>
    3738
    3839namespace WebCore {
    3940
     41class SerializedScriptValue;
    4042class String;
    4143
     
    4749    bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
    4850
    49     void dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException);
     51    void dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<SerializedScriptValue>* result, bool* hadException);
    5052#if ENABLE(JAVASCRIPT_DEBUGGER)
    51     String callFrames();
     53    PassRefPtr<SerializedScriptValue> callFrames();
    5254#endif
    53     String wrapAndStringifyForConsole(ScriptValue);
     55    PassRefPtr<SerializedScriptValue> wrapForConsole(ScriptValue);
    5456    void releaseWrapperObjectGroup(const String&);
    5557
  • trunk/WebCore/inspector/InjectedScriptHost.cpp

    r54334 r54421  
    4646#include "InspectorResource.h"
    4747#include "Pasteboard.h"
    48 #include "ScriptArray.h"
    49 #include "ScriptFunctionCall.h"
    5048
    5149#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
     
    163161#endif
    164162
    165 void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, const String& result, bool isException)
     163void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException)
    166164{
    167165    if (InspectorFrontend* frontend = inspectorFrontend())
  • trunk/WebCore/inspector/InjectedScriptHost.h

    r54334 r54421  
    4747class JavaScriptCallFrame;
    4848class Node;
     49class SerializedScriptValue;
    4950class Storage;
    5051
     
    8384    void selectDOMStorage(Storage* storage);
    8485#endif
    85     void reportDidDispatchOnInjectedScript(long callId, const String& result, bool isException);
     86    void reportDidDispatchOnInjectedScript(long callId, SerializedScriptValue* result, bool isException);
    8687
    8788    InjectedScript injectedScriptFor(ScriptState*);
  • trunk/WebCore/inspector/InjectedScriptHost.idl

    r53945 r54421  
    5656#endif
    5757
    58         void reportDidDispatchOnInjectedScript(in long callId, in DOMString result, in boolean isException);
     58        [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException);
    5959    };
    6060}
  • trunk/WebCore/inspector/InspectorBackend.cpp

    r54334 r54421  
    5050#include "Pasteboard.h"
    5151#include "ScriptArray.h"
    52 #include "ScriptFunctionCall.h"
     52#include "SerializedScriptValue.h"
    5353
    5454#if ENABLE(DOM_STORAGE)
     
    296296        return;
    297297
    298     String result;
     298    RefPtr<SerializedScriptValue> result;
    299299    bool hadException = false;
    300300    injectedScript.dispatch(callId, methodName, arguments, async, &result, &hadException);
    301301    if (async)
    302302        return;  // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript.
    303     frontend->didDispatchOnInjectedScript(callId, result, hadException);
     303    frontend->didDispatchOnInjectedScript(callId, result.get(), hadException);
    304304}
    305305
  • trunk/WebCore/inspector/InspectorController.cpp

    r54343 r54421  
    543543{
    544544    m_frontendScriptState = scriptState;
    545     m_frontend.set(new InspectorFrontend(this, scriptState, webInspectorObj));
     545    m_frontend.set(new InspectorFrontend(this, webInspectorObj));
    546546    releaseDOMAgent();
    547547    m_domAgent = InspectorDOMAgent::create(m_frontend.get());
     
    15701570    ASSERT(scriptState);
    15711571    InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(scriptState);
    1572     String callFrames = injectedScript.callFrames();
    1573     m_frontend->pausedScript(callFrames);
     1572    RefPtr<SerializedScriptValue> callFrames = injectedScript.callFrames();
     1573    m_frontend->pausedScript(callFrames.get());
    15741574}
    15751575
     
    15941594    ScriptObject window;
    15951595    ScriptGlobalObject::get(scriptState, "window", window);
    1596     ScriptFunctionCall function(scriptState, window, "didEvaluateForTestInFrontend");
     1596    ScriptFunctionCall function(window, "didEvaluateForTestInFrontend");
    15971597    function.appendArgument(callId);
    15981598    function.appendArgument(jsonResult);
  • trunk/WebCore/inspector/InspectorFrontend.cpp

    • Property svn:executable set to *
    r54334 r54421  
    4343#include "ScriptState.h"
    4444#include "ScriptString.h"
     45#include "ScriptValue.h"
     46#include "SerializedScriptValue.h"
    4547#include <wtf/OwnPtr.h>
    4648
     
    5355namespace WebCore {
    5456
    55 InspectorFrontend::InspectorFrontend(InspectorController* inspectorController, ScriptState* scriptState, ScriptObject webInspector)
     57InspectorFrontend::InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector)
    5658    : m_inspectorController(inspectorController)
    57     , m_scriptState(scriptState)
    5859    , m_webInspector(webInspector)
    5960{
     
    6768ScriptArray InspectorFrontend::newScriptArray()
    6869{
    69     return ScriptArray::createNew(m_scriptState);
     70    return ScriptArray::createNew(scriptState());
    7071}
    7172
    7273ScriptObject InspectorFrontend::newScriptObject()
    7374{
    74     return ScriptObject::createNew(m_scriptState);
     75    return ScriptObject::createNew(scriptState());
    7576}
    7677
     
    8283void InspectorFrontend::populateFrontendSettings(const String& settings)
    8384{
    84     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     85    ScriptFunctionCall function(m_webInspector, "dispatch");
    8586    function.appendArgument("populateFrontendSettings");
    8687    function.appendArgument(settings);
     
    9091void InspectorFrontend::updateConsoleMessageExpiredCount(unsigned count)
    9192{
    92     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     93    ScriptFunctionCall function(m_webInspector, "dispatch");
    9394    function.appendArgument("updateConsoleMessageExpiredCount");
    9495    function.appendArgument(count);
     
    9899void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector<ScriptString>& frames, ScriptState* scriptState, const Vector<ScriptValue> arguments, const String& message)
    99100{
    100     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     101    ScriptFunctionCall function(m_webInspector, "dispatch");
    101102    function.appendArgument("addConsoleMessage");
    102103    function.appendArgument(messageObj);
    103104    if (!frames.isEmpty()) {
    104         function.appendArgument(false);
    105105        for (unsigned i = 0; i < frames.size(); ++i)
    106106            function.appendArgument(frames[i]);
    107107    } else if (!arguments.isEmpty()) {
    108         function.appendArgument(true);
    109108        InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState);
    110109        for (unsigned i = 0; i < arguments.size(); ++i) {
    111             String s = injectedScript.wrapAndStringifyForConsole(arguments[i]);
    112             function.appendArgument(s);
     110            RefPtr<SerializedScriptValue> serializedValue = injectedScript.wrapForConsole(arguments[i]);
     111            ScriptValue scriptValue = ScriptValue::deserialize(this->scriptState(), serializedValue.get());
     112            if (scriptValue.hasNoValue()) {
     113                ASSERT_NOT_REACHED();
     114                return;
     115            }
     116            function.appendArgument(scriptValue);
    113117        }
    114118    } else {
    115         function.appendArgument(false);
    116119        function.appendArgument(message);
    117120    }
     
    121124void InspectorFrontend::updateConsoleMessageRepeatCount(unsigned count)
    122125{
    123     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     126    ScriptFunctionCall function(m_webInspector, "dispatch");
    124127    function.appendArgument("updateConsoleMessageRepeatCount");
    125128    function.appendArgument(count);
     
    134137bool InspectorFrontend::updateResource(unsigned long identifier, const ScriptObject& resourceObj)
    135138{
    136     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     139    ScriptFunctionCall function(m_webInspector, "dispatch");
    137140    function.appendArgument("updateResource");
    138141    function.appendArgument(identifier);
     
    145148void InspectorFrontend::removeResource(unsigned long identifier)
    146149{
    147     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     150    ScriptFunctionCall function(m_webInspector, "dispatch");
    148151    function.appendArgument("removeResource");
    149152    function.appendArgument(identifier);
     
    153156void InspectorFrontend::didGetResourceContent(int callId, const String& content)
    154157{
    155     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     158    ScriptFunctionCall function(m_webInspector, "dispatch");
    156159    function.appendArgument("didGetResourceContent");
    157160    function.appendArgument(callId);
     
    162165void InspectorFrontend::updateFocusedNode(long nodeId)
    163166{
    164     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     167    ScriptFunctionCall function(m_webInspector, "dispatch");
    165168    function.appendArgument("updateFocusedNode");
    166169    function.appendArgument(nodeId);
     
    170173void InspectorFrontend::setAttachedWindow(bool attached)
    171174{
    172     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     175    ScriptFunctionCall function(m_webInspector, "dispatch");
    173176    function.appendArgument("setAttachedWindow");
    174177    function.appendArgument(attached);
     
    242245void InspectorFrontend::addRecordToTimeline(const ScriptObject& record)
    243246{
    244     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     247    ScriptFunctionCall function(m_webInspector, "dispatch");
    245248    function.appendArgument("addRecordToTimeline");
    246249    function.appendArgument(record);
     
    276279void InspectorFrontend::parsedScriptSource(const JSC::SourceCode& source)
    277280{
    278     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     281    ScriptFunctionCall function(m_webInspector, "dispatch");
    279282    function.appendArgument("parsedScriptSource");
    280283    function.appendArgument(JSC::UString(JSC::UString::from(source.provider()->asID())));
     
    287290void InspectorFrontend::failedToParseScriptSource(const JSC::SourceCode& source, int errorLine, const JSC::UString& errorMessage)
    288291{
    289     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     292    ScriptFunctionCall function(m_webInspector, "dispatch");
    290293    function.appendArgument("failedToParseScriptSource");
    291294    function.appendArgument(source.provider()->url());
     
    299302void InspectorFrontend::addProfileHeader(const ScriptValue& profile)
    300303{
    301     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     304    ScriptFunctionCall function(m_webInspector, "dispatch");
    302305    function.appendArgument("addProfileHeader");
    303306    function.appendArgument(profile);
     
    307310void InspectorFrontend::setRecordingProfile(bool isProfiling)
    308311{
    309     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     312    ScriptFunctionCall function(m_webInspector, "dispatch");
    310313    function.appendArgument("setRecordingProfile");
    311314    function.appendArgument(isProfiling);
     
    315318void InspectorFrontend::didGetProfileHeaders(int callId, const ScriptArray& headers)
    316319{
    317     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     320    ScriptFunctionCall function(m_webInspector, "dispatch");
    318321    function.appendArgument("didGetProfileHeaders");
    319322    function.appendArgument(callId);
     
    324327void InspectorFrontend::didGetProfile(int callId, const ScriptValue& profile)
    325328{
    326     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     329    ScriptFunctionCall function(m_webInspector, "dispatch");
    327330    function.appendArgument("didGetProfile");
    328331    function.appendArgument(callId);
     
    331334}
    332335
    333 void InspectorFrontend::pausedScript(const String& callFrames)
    334 {
    335     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     336void InspectorFrontend::pausedScript(SerializedScriptValue* callFrames)
     337{
     338    ScriptValue callFramesValue = ScriptValue::deserialize(scriptState(), callFrames);
     339    ScriptFunctionCall function(m_webInspector, "dispatch");
    336340    function.appendArgument("pausedScript");
    337     function.appendArgument(callFrames);
     341    function.appendArgument(callFramesValue);
    338342    function.call();
    339343}
     
    347351void InspectorFrontend::setDocument(const ScriptObject& root)
    348352{
    349     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     353    ScriptFunctionCall function(m_webInspector, "dispatch");
    350354    function.appendArgument("setDocument");
    351355    function.appendArgument(root);
     
    355359void InspectorFrontend::setDetachedRoot(const ScriptObject& root)
    356360{
    357     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     361    ScriptFunctionCall function(m_webInspector, "dispatch");
    358362    function.appendArgument("setDetachedRoot");
    359363    function.appendArgument(root);
     
    363367void InspectorFrontend::setChildNodes(int parentId, const ScriptArray& nodes)
    364368{
    365     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     369    ScriptFunctionCall function(m_webInspector, "dispatch");
    366370    function.appendArgument("setChildNodes");
    367371    function.appendArgument(parentId);
     
    372376void InspectorFrontend::childNodeCountUpdated(int id, int newValue)
    373377{
    374     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     378    ScriptFunctionCall function(m_webInspector, "dispatch");
    375379    function.appendArgument("childNodeCountUpdated");
    376380    function.appendArgument(id);
     
    381385void InspectorFrontend::childNodeInserted(int parentId, int prevId, const ScriptObject& node)
    382386{
    383     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     387    ScriptFunctionCall function(m_webInspector, "dispatch");
    384388    function.appendArgument("childNodeInserted");
    385389    function.appendArgument(parentId);
     
    391395void InspectorFrontend::childNodeRemoved(int parentId, int id)
    392396{
    393     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     397    ScriptFunctionCall function(m_webInspector, "dispatch");
    394398    function.appendArgument("childNodeRemoved");
    395399    function.appendArgument(parentId);
     
    400404void InspectorFrontend::attributesUpdated(int id, const ScriptArray& attributes)
    401405{
    402     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     406    ScriptFunctionCall function(m_webInspector, "dispatch");
    403407    function.appendArgument("attributesUpdated");
    404408    function.appendArgument(id);
     
    409413void InspectorFrontend::didRemoveNode(int callId, int nodeId)
    410414{
    411     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     415    ScriptFunctionCall function(m_webInspector, "dispatch");
    412416    function.appendArgument("didRemoveNode");
    413417    function.appendArgument(callId);
     
    418422void InspectorFrontend::didGetChildNodes(int callId)
    419423{
    420     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     424    ScriptFunctionCall function(m_webInspector, "dispatch");
    421425    function.appendArgument("didGetChildNodes");
    422426    function.appendArgument(callId);
     
    426430void InspectorFrontend::didApplyDomChange(int callId, bool success)
    427431{
    428     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     432    ScriptFunctionCall function(m_webInspector, "dispatch");
    429433    function.appendArgument("didApplyDomChange");
    430434    function.appendArgument(callId);
     
    435439void InspectorFrontend::didGetEventListenersForNode(int callId, int nodeId, ScriptArray& listenersArray)
    436440{
    437     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     441    ScriptFunctionCall function(m_webInspector, "dispatch");
    438442    function.appendArgument("didGetEventListenersForNode");
    439443    function.appendArgument(callId);
     
    445449void InspectorFrontend::didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString)
    446450{
    447     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     451    ScriptFunctionCall function(m_webInspector, "dispatch");
    448452    function.appendArgument("didGetCookies");
    449453    function.appendArgument(callId);
     
    453457}
    454458
    455 void InspectorFrontend::didDispatchOnInjectedScript(int callId, const String& result, bool isException)
    456 {
    457     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     459void InspectorFrontend::didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException)
     460{
     461    ScriptFunctionCall function(m_webInspector, "dispatch");
    458462    function.appendArgument("didDispatchOnInjectedScript");
    459463    function.appendArgument(callId);
    460     function.appendArgument(result);
     464    if (isException)
     465        function.appendArgument("");
     466    else {
     467        ScriptValue resultValue = ScriptValue::deserialize(scriptState(), result);
     468        function.appendArgument(resultValue);
     469    }
    461470    function.appendArgument(isException);
    462471    function.call();
     
    466475bool InspectorFrontend::addDatabase(const ScriptObject& dbObject)
    467476{
    468     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     477    ScriptFunctionCall function(m_webInspector, "dispatch");
    469478    function.appendArgument("addDatabase");
    470479    function.appendArgument(dbObject);
     
    476485void InspectorFrontend::selectDatabase(int databaseId)
    477486{
    478     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     487    ScriptFunctionCall function(m_webInspector, "dispatch");
    479488    function.appendArgument("selectDatabase");
    480489    function.appendArgument(databaseId);
     
    483492void InspectorFrontend::didGetDatabaseTableNames(int callId, const ScriptArray& tableNames)
    484493{
    485     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     494    ScriptFunctionCall function(m_webInspector, "dispatch");
    486495    function.appendArgument("didGetDatabaseTableNames");
    487496    function.appendArgument(callId);
     
    494503bool InspectorFrontend::addDOMStorage(const ScriptObject& domStorageObj)
    495504{
    496     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     505    ScriptFunctionCall function(m_webInspector, "dispatch");
    497506    function.appendArgument("addDOMStorage");
    498507    function.appendArgument(domStorageObj);
     
    504513void InspectorFrontend::selectDOMStorage(int storageId)
    505514{
    506     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     515    ScriptFunctionCall function(m_webInspector, "dispatch");
    507516    function.appendArgument("selectDOMStorage");
    508517    function.appendArgument(storageId);
     
    512521void InspectorFrontend::didGetDOMStorageEntries(int callId, const ScriptArray& entries)
    513522{
    514     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     523    ScriptFunctionCall function(m_webInspector, "dispatch");
    515524    function.appendArgument("didGetDOMStorageEntries");
    516525    function.appendArgument(callId);
     
    521530void InspectorFrontend::didSetDOMStorageItem(int callId, bool success)
    522531{
    523     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     532    ScriptFunctionCall function(m_webInspector, "dispatch");
    524533    function.appendArgument("didSetDOMStorageItem");
    525534    function.appendArgument(callId);
     
    530539void InspectorFrontend::didRemoveDOMStorageItem(int callId, bool success)
    531540{
    532     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     541    ScriptFunctionCall function(m_webInspector, "dispatch");
    533542    function.appendArgument("didRemoveDOMStorageItem");
    534543    function.appendArgument(callId);
     
    539548void InspectorFrontend::updateDOMStorage(int storageId)
    540549{
    541     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     550    ScriptFunctionCall function(m_webInspector, "dispatch");
    542551    function.appendArgument("updateDOMStorage");
    543552    function.appendArgument(storageId);
     
    548557void InspectorFrontend::addNodesToSearchResult(const String& nodeIds)
    549558{
    550     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     559    ScriptFunctionCall function(m_webInspector, "dispatch");
    551560    function.appendArgument("addNodesToSearchResult");
    552561    function.appendArgument(nodeIds);
     
    556565void InspectorFrontend::contextMenuItemSelected(int itemId)
    557566{
    558     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     567    ScriptFunctionCall function(m_webInspector, "dispatch");
    559568    function.appendArgument("contextMenuItemSelected");
    560569    function.appendArgument(itemId);
     
    569578void InspectorFrontend::evaluateForTestInFrontend(int callId, const String& script)
    570579{
    571     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     580    ScriptFunctionCall function(m_webInspector, "dispatch");
    572581    function.appendArgument("evaluateForTestInFrontend");
    573582    function.appendArgument(callId);
     
    578587void InspectorFrontend::callSimpleFunction(const String& functionName)
    579588{
    580     ScriptFunctionCall function(m_scriptState, m_webInspector, "dispatch");
     589    ScriptFunctionCall function(m_webInspector, "dispatch");
    581590    function.appendArgument(functionName);
    582591    function.call();
  • trunk/WebCore/inspector/InspectorFrontend.h

    r54329 r54421  
    5151    class InspectorResource;
    5252    class Node;
    53     class ScriptFunctionCall;
    5453    class ScriptString;
     54    class SerializedScriptValue;
    5555    class Storage;
    5656
    5757    class InspectorFrontend : public Noncopyable {
    5858    public:
    59         InspectorFrontend(InspectorController* inspectorController, ScriptState*, ScriptObject webInspector);
     59        InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector);
    6060        ~InspectorFrontend();
    6161
     
    9797        void didGetProfileHeaders(int callId, const ScriptArray& headers);
    9898        void didGetProfile(int callId, const ScriptValue& profile);
    99         void pausedScript(const String& callFrames);
     99        void pausedScript(SerializedScriptValue* callFrames);
    100100        void resumedScript();
    101101#endif
     
    133133
    134134        void didGetCookies(int callId, const ScriptArray& cookies, const String& cookiesString);
    135         void didDispatchOnInjectedScript(int callId, const String& result, bool isException);
     135        void didDispatchOnInjectedScript(int callId, SerializedScriptValue* result, bool isException);
    136136
    137137        void addNodesToSearchResult(const String& nodeIds);
     
    140140        void contextMenuCleared();
    141141
    142         ScriptState* scriptState() const { return m_scriptState; }
     142        ScriptState* scriptState() const { return m_webInspector.scriptState(); }
    143143
    144144        void evaluateForTestInFrontend(int callId, const String& script);
     
    146146        void callSimpleFunction(const String& functionName);
    147147        InspectorController* m_inspectorController;
    148         ScriptState* m_scriptState;
    149148        ScriptObject m_webInspector;
    150149    };
  • trunk/WebCore/inspector/front-end/InjectedScript.js

    r54334 r54421  
    5353};
    5454
    55 InjectedScript.wrapAndStringifyObject = function(object, objectGroupName) {
    56     var r = InjectedScript.wrapObject(object, objectGroupName);
    57     return InjectedScript.JSON.stringify(r);
    58 };
    59 
    6055InjectedScript.unwrapObject = function(objectId) {
    6156    return InjectedScript.idToWrappedObject[objectId];
     
    8681InjectedScript.dispatch = function(methodName, args, callId)
    8782{
    88     var argsArray = InjectedScript.JSON.parse(args);
     83    var argsArray = eval("(" + args + ")");
    8984    if (callId)
    9085        argsArray.splice(0, 0, callId);  // Methods that run asynchronously have a call back id parameter.
     
    9489        result = null;
    9590    }
    96     return InjectedScript.JSON.stringify(result);
     91    return result;
    9792}
    9893
     
    936931        callFrame = callFrame.caller;
    937932    } while (callFrame);
    938     return InjectedScript.JSON.stringify(result);
     933    return result;
    939934}
    940935
     
    12211216            }
    12221217        }
    1223         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(result), false);
     1218        InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, result, false);
    12241219    }
    12251220
    12261221    function errorCallback(tx, error)
    12271222    {
    1228         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, InjectedScript.JSON.stringify(error), false);
     1223        InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, error, false);
    12291224    }
    12301225
     
    13401335}
    13411336
    1342 InjectedScript.JSON = {};
    1343 
    1344 // The following code is a slightly modified version of http://www.json.org/json2.js last modified on 2009-09-29.
    1345 // Compared to the original version it ignores toJSON method on objects it serializes.
    1346 // It's done to avoid weird behaviour when inspected application provides it's own implementation
    1347 // of toJSON methods to the Object and other intrinsic types. We use InjectedScript.JSON implementation
    1348 // instead of global JSON object since it can have been modified by the inspected code.
    1349 (function() {
    1350 
    1351     function f(n) {
    1352         // Format integers to have at least two digits.
    1353         return n < 10 ? '0' + n : n;
    1354     }
    1355 
    1356     var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
    1357         escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
    1358         gap,
    1359         indent,
    1360         meta = {    // table of character substitutions
    1361             '\b': '\\b',
    1362             '\t': '\\t',
    1363             '\n': '\\n',
    1364             '\f': '\\f',
    1365             '\r': '\\r',
    1366             '"' : '\\"',
    1367             '\\': '\\\\'
    1368         },
    1369         rep;
    1370 
    1371 
    1372     function quote(string) {
    1373 
    1374 // If the string contains no control characters, no quote characters, and no
    1375 // backslash characters, then we can safely slap some quotes around it.
    1376 // Otherwise we must also replace the offending characters with safe escape
    1377 // sequences.
    1378 
    1379         escapable.lastIndex = 0;
    1380         return escapable.test(string) ?
    1381             '"' + string.replace(escapable, function (a) {
    1382                 var c = meta[a];
    1383                 return typeof c === 'string' ? c :
    1384                     '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
    1385             }) + '"' :
    1386             '"' + string + '"';
    1387     }
    1388 
    1389 
    1390     function str(key, holder) {
    1391 
    1392 // Produce a string from holder[key].
    1393 
    1394         var i,          // The loop counter.
    1395             k,          // The member key.
    1396             v,          // The member value.
    1397             length,
    1398             mind = gap,
    1399             partial,
    1400             value = holder[key];
    1401 
    1402 // If we were called with a replacer function, then call the replacer to
    1403 // obtain a replacement value.
    1404 
    1405         if (typeof rep === 'function') {
    1406             value = rep.call(holder, key, value);
    1407         }
    1408 
    1409 // What happens next depends on the value's type.
    1410 
    1411         switch (typeof value) {
    1412         case 'string':
    1413             return quote(value);
    1414 
    1415         case 'number':
    1416 
    1417 // JSON numbers must be finite. Encode non-finite numbers as null.
    1418 
    1419             return isFinite(value) ? String(value) : 'null';
    1420 
    1421         case 'boolean':
    1422         case 'null':
    1423 
    1424 // If the value is a boolean or null, convert it to a string. Note:
    1425 // typeof null does not produce 'null'. The case is included here in
    1426 // the remote chance that this gets fixed someday.
    1427 
    1428             return String(value);
    1429 
    1430 // If the type is 'object', we might be dealing with an object or an array or
    1431 // null.
    1432 
    1433         case 'object':
    1434 
    1435 // Due to a specification blunder in ECMAScript, typeof null is 'object',
    1436 // so watch out for that case.
    1437 
    1438             if (!value) {
    1439                 return 'null';
    1440             }
    1441 
    1442 // Make an array to hold the partial results of stringifying this object value.
    1443 
    1444             gap += indent;
    1445             partial = [];
    1446 
    1447 // Is the value an array?
    1448 
    1449             if (Object.prototype.toString.apply(value) === '[object Array]') {
    1450 
    1451 // The value is an array. Stringify every element. Use null as a placeholder
    1452 // for non-JSON values.
    1453 
    1454                 length = value.length;
    1455                 for (i = 0; i < length; i += 1) {
    1456                     partial[i] = str(i, value) || 'null';
    1457                 }
    1458 
    1459 // Join all of the elements together, separated with commas, and wrap them in
    1460 // brackets.
    1461 
    1462                 v = partial.length === 0 ? '[]' :
    1463                     gap ? '[\n' + gap +
    1464                             partial.join(',\n' + gap) + '\n' +
    1465                                 mind + ']' :
    1466                           '[' + partial.join(',') + ']';
    1467                 gap = mind;
    1468                 return v;
    1469             }
    1470 
    1471 // If the replacer is an array, use it to select the members to be stringified.
    1472 
    1473             if (rep && typeof rep === 'object') {
    1474                 length = rep.length;
    1475                 for (i = 0; i < length; i += 1) {
    1476                     k = rep[i];
    1477                     if (typeof k === 'string') {
    1478                         v = str(k, value);
    1479                         if (v) {
    1480                             partial.push(quote(k) + (gap ? ': ' : ':') + v);
    1481                         }
    1482                     }
    1483                 }
    1484             } else {
    1485 
    1486 // Otherwise, iterate through all of the keys in the object.
    1487 
    1488                 for (k in value) {
    1489                     if (Object.hasOwnProperty.call(value, k)) {
    1490                         v = str(k, value);
    1491                         if (v) {
    1492                             partial.push(quote(k) + (gap ? ': ' : ':') + v);
    1493                         }
    1494                     }
    1495                 }
    1496             }
    1497 
    1498 // Join all of the member texts together, separated with commas,
    1499 // and wrap them in braces.
    1500 
    1501             v = partial.length === 0 ? '{}' :
    1502                 gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
    1503                         mind + '}' : '{' + partial.join(',') + '}';
    1504             gap = mind;
    1505             return v;
    1506         }
    1507     }
    1508 
    1509         InjectedScript.JSON.stringify = function (value, replacer, space) {
    1510 
    1511 // The stringify method takes a value and an optional replacer, and an optional
    1512 // space parameter, and returns a JSON text. The replacer can be a function
    1513 // that can replace values, or an array of strings that will select the keys.
    1514 // A default replacer method can be provided. Use of the space parameter can
    1515 // produce text that is more easily readable.
    1516 
    1517             var i;
    1518             gap = '';
    1519             indent = '';
    1520 
    1521 // If the space parameter is a number, make an indent string containing that
    1522 // many spaces.
    1523 
    1524             if (typeof space === 'number') {
    1525                 for (i = 0; i < space; i += 1) {
    1526                     indent += ' ';
    1527                 }
    1528 
    1529 // If the space parameter is a string, it will be used as the indent string.
    1530 
    1531             } else if (typeof space === 'string') {
    1532                 indent = space;
    1533             }
    1534 
    1535 // If there is a replacer, it must be a function or an array.
    1536 // Otherwise, throw an error.
    1537 
    1538             rep = replacer;
    1539             if (replacer && typeof replacer !== 'function' &&
    1540                     (typeof replacer !== 'object' ||
    1541                      typeof replacer.length !== 'number')) {
    1542                 throw new Error('JSON.stringify');
    1543             }
    1544 
    1545 // Make a fake root object containing our value under the key of ''.
    1546 // Return the result of stringifying the value.
    1547 
    1548             return str('', {'': value});
    1549         };
    1550 
    1551 
    1552 // If the JSON object does not yet have a parse method, give it one.
    1553 
    1554     InjectedScript.JSON.parse = function (text, reviver) {
    1555 
    1556 // The parse method takes a text and an optional reviver function, and returns
    1557 // a JavaScript value if the text is a valid JSON text.
    1558 
    1559             var j;
    1560 
    1561             function walk(holder, key) {
    1562 
    1563 // The walk method is used to recursively walk the resulting structure so
    1564 // that modifications can be made.
    1565 
    1566                 var k, v, value = holder[key];
    1567                 if (value && typeof value === 'object') {
    1568                     for (k in value) {
    1569                         if (Object.hasOwnProperty.call(value, k)) {
    1570                             v = walk(value, k);
    1571                             if (v !== undefined) {
    1572                                 value[k] = v;
    1573                             } else {
    1574                                 delete value[k];
    1575                             }
    1576                         }
    1577                     }
    1578                 }
    1579                 return reviver.call(holder, key, value);
    1580             }
    1581 
    1582 
    1583 // Parsing happens in four stages. In the first stage, we replace certain
    1584 // Unicode characters with escape sequences. JavaScript handles many characters
    1585 // incorrectly, either silently deleting them, or treating them as line endings.
    1586 
    1587             cx.lastIndex = 0;
    1588             if (cx.test(text)) {
    1589                 text = text.replace(cx, function (a) {
    1590                     return '\\u' +
    1591                         ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
    1592                 });
    1593             }
    1594 
    1595 // In the second stage, we run the text against regular expressions that look
    1596 // for non-JSON patterns. We are especially concerned with '()' and 'new'
    1597 // because they can cause invocation, and '=' because it can cause mutation.
    1598 // But just to be safe, we want to reject all unexpected forms.
    1599 
    1600 // We split the second stage into 4 regexp operations in order to work around
    1601 // crippling inefficiencies in IE's and Safari's regexp engines. First we
    1602 // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
    1603 // replace all simple value tokens with ']' characters. Third, we delete all
    1604 // open brackets that follow a colon or comma or that begin the text. Finally,
    1605 // we look to see that the remaining characters are only whitespace or ']' or
    1606 // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
    1607 
    1608             if (/^[\],:{}\s]*$/.
    1609 test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
    1610 replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
    1611 replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
    1612 
    1613 // In the third stage we use the eval function to compile the text into a
    1614 // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
    1615 // in JavaScript: it can begin a block or an object literal. We wrap the text
    1616 // in parens to eliminate the ambiguity.
    1617 
    1618                 j = eval('(' + text + ')');
    1619 
    1620 // In the optional fourth stage, we recursively walk the new structure, passing
    1621 // each name/value pair to a reviver function for possible transformation.
    1622 
    1623                 return typeof reviver === 'function' ?
    1624                     walk({'': j}, '') : j;
    1625             }
    1626 
    1627 // If the text is not JSON parseable, then a SyntaxError is thrown.
    1628 
    1629             throw new SyntaxError('JSON.parse');
    1630         };
    1631 }());
    1632 
    16331337return InjectedScript;
    16341338});
  • trunk/WebCore/inspector/front-end/InjectedScriptAccess.js

    r53766 r54421  
    5757        {
    5858            if (!isException)
    59                 callback(JSON.parse(result));
     59                callback(result);
    6060            else
    6161                WebInspector.console.addMessage(new WebInspector.ConsoleTextMessage("Error dispatching: " + methodName));
  • trunk/WebCore/inspector/front-end/inspector.js

    r54351 r54421  
    12041204WebInspector.pausedScript = function(callFrames)
    12051205{
    1206     callFrames = JSON.parse(callFrames);
    12071206    this.panels.scripts.debuggerPaused(callFrames);
    12081207}
     
    12611260}
    12621261
    1263 WebInspector.addConsoleMessage = function(payload, argumentsStringified, opt_args)
     1262WebInspector.addConsoleMessage = function(payload, opt_args)
    12641263{
    12651264    var consoleMessage = new WebInspector.ConsoleMessage(
     
    12711270        payload.groupLevel,
    12721271        payload.repeatCount);
    1273     var parsedArguments = [];
    1274     for (var i = 2; i < arguments.length; i++) {
    1275         if (argumentsStringified)
    1276             parsedArguments.push(JSON.parse(arguments[i]));
    1277         else
    1278             parsedArguments.push(arguments[i]);
    1279     }
    1280     consoleMessage.setMessageBody(parsedArguments);
     1272    consoleMessage.setMessageBody(Array.prototype.slice.call(arguments, 1));
    12811273    this.console.addMessage(consoleMessage);
    12821274}
  • trunk/WebKit/qt/Api/qwebelement.cpp

    r51308 r54421  
    3939#include "PropertyNameArray.h"
    4040#include "RenderImage.h"
    41 #include "ScriptFunctionCall.h"
    4241#include "StaticNodeList.h"
    4342#include "qt_runtime.h"
  • trunk/WebKit/qt/ChangeLog

    r54420 r54421  
     12010-02-05  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Remove unused inmport of ScriptFunctionCall.h
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=33592
     8
     9        * Api/qwebelement.cpp:
     10
    1112010-02-05  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    212
Note: See TracChangeset for help on using the changeset viewer.