Changeset 116099 in webkit


Ignore:
Timestamp:
May 4, 2012 7:36:43 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: use single method for retrieving evaluation context in the runtime agent
https://bugs.webkit.org/show_bug.cgi?id=85621

Reviewed by Pavel Feldman.

Merged two script state retrieval methods into one. Moved Page specific logic
into PageRuntimeAgent.

  • inspector/InspectorRuntimeAgent.cpp:

(WebCore::InspectorRuntimeAgent::evaluate):

  • inspector/InspectorRuntimeAgent.h:

(InspectorRuntimeAgent):

  • inspector/PageRuntimeAgent.cpp:

(WebCore::PageRuntimeAgent::scriptStateForEval):

  • inspector/PageRuntimeAgent.h:

(PageRuntimeAgent):

  • inspector/WorkerRuntimeAgent.cpp:

(WebCore::WorkerRuntimeAgent::scriptStateForEval):

  • inspector/WorkerRuntimeAgent.h:

(WorkerRuntimeAgent):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116098 r116099  
     12012-05-04  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: use single method for retrieving evaluation context in the runtime agent
     4        https://bugs.webkit.org/show_bug.cgi?id=85621
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Merged two script state retrieval methods into one. Moved Page specific logic
     9        into PageRuntimeAgent.
     10
     11        * inspector/InspectorRuntimeAgent.cpp:
     12        (WebCore::InspectorRuntimeAgent::evaluate):
     13        * inspector/InspectorRuntimeAgent.h:
     14        (InspectorRuntimeAgent):
     15        * inspector/PageRuntimeAgent.cpp:
     16        (WebCore::PageRuntimeAgent::scriptStateForEval):
     17        * inspector/PageRuntimeAgent.h:
     18        (PageRuntimeAgent):
     19        * inspector/WorkerRuntimeAgent.cpp:
     20        (WebCore::WorkerRuntimeAgent::scriptStateForEval):
     21        * inspector/WorkerRuntimeAgent.h:
     22        (WorkerRuntimeAgent):
     23
    1242012-05-04  Jochen Eisinger  <jochen@chromium.org>
    225
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp

    r114632 r116099  
    8686void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const String* const frameId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
    8787{
    88     ScriptState* scriptState = 0;
    89     if (frameId) {
    90         scriptState = scriptStateForFrameId(*frameId);
    91         if (!scriptState) {
    92             *errorString = "Frame with given id not found.";
    93             return;
    94         }
    95     } else
    96         scriptState = getDefaultInspectedState();
     88    ScriptState* scriptState = scriptStateForEval(errorString, frameId);
     89    if (!scriptState)
     90        return;
    9791    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
    9892    if (injectedScript.hasNoValue()) {
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h

    r114632 r116099  
    8989protected:
    9090    InspectorRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
    91     virtual ScriptState* scriptStateForFrameId(const String& frameId) = 0;
    92     virtual ScriptState* getDefaultInspectedState() = 0;
     91    virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId) = 0;
     92
    9393    virtual void muteConsole() = 0;
    9494    virtual void unmuteConsole() = 0;
  • trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp

    r114632 r116099  
    5353}
    5454
    55 ScriptState* PageRuntimeAgent::scriptStateForFrameId(const String& frameId)
     55ScriptState* PageRuntimeAgent::scriptStateForEval(ErrorString* errorString, const String* frameId)
    5656{
    57     Frame* frame = m_pageAgent->frameForId(frameId);
    58     if (!frame)
     57    if (!frameId)
     58        return mainWorldScriptState(m_inspectedPage->mainFrame());
     59
     60    Frame* frame = m_pageAgent->frameForId(*frameId);
     61    if (!frame) {
     62        *errorString = "Frame with given id not found.";
    5963        return 0;
     64    }
    6065    return mainWorldScriptState(frame);
    61 }
    62 
    63 ScriptState* PageRuntimeAgent::getDefaultInspectedState()
    64 {
    65     return mainWorldScriptState(m_inspectedPage->mainFrame());
    6666}
    6767
  • trunk/Source/WebCore/inspector/PageRuntimeAgent.h

    r114632 r116099  
    5353    PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*);
    5454
    55     virtual ScriptState* scriptStateForFrameId(const String& frameId);
    56     virtual ScriptState* getDefaultInspectedState();
     55    virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId);
    5756    virtual void muteConsole();
    5857    virtual void unmuteConsole();
  • trunk/Source/WebCore/inspector/WorkerRuntimeAgent.cpp

    r114632 r116099  
    4949}
    5050
    51 ScriptState* WorkerRuntimeAgent::scriptStateForFrameId(const String&)
     51ScriptState* WorkerRuntimeAgent::scriptStateForEval(ErrorString* error, const String* frameId)
    5252{
    53     return 0;
    54 }
    55 
    56 ScriptState* WorkerRuntimeAgent::getDefaultInspectedState()
    57 {
     53    if (frameId) {
     54        *error = "Frame id is not supported for workers.";
     55        return 0;
     56    }
    5857    return scriptStateFromWorkerContext(m_workerContext);
    5958}
  • trunk/Source/WebCore/inspector/WorkerRuntimeAgent.h

    r114632 r116099  
    5151private:
    5252    WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
    53     virtual ScriptState* scriptStateForFrameId(const String& frameId);
    54     virtual ScriptState* getDefaultInspectedState();
     53    virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId);
    5554    virtual void muteConsole();
    5655    virtual void unmuteConsole();
Note: See TracChangeset for help on using the changeset viewer.