Changeset 80338 in webkit


Ignore:
Timestamp:
Mar 4, 2011 1:40:47 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2011-03-03 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: do not push document into front-end, make it request one.
https://bugs.webkit.org/show_bug.cgi?id=55664

  • inspector/Inspector.idl:
  • inspector/InspectorAgent.cpp: (WebCore::InspectorAgent::InspectorAgent):
  • inspector/InspectorAgent.h:
  • inspector/InspectorBrowserDebuggerAgent.cpp: (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent):
  • inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::InspectorDOMAgent): (WebCore::InspectorDOMAgent::clearFrontend): (WebCore::InspectorDOMAgent::setDocument): (WebCore::InspectorDOMAgent::getDocument): (WebCore::InspectorDOMAgent::pushNodePathToFrontend): (WebCore::InspectorDOMAgent::boundNodeId): (WebCore::InspectorDOMAgent::resolveNode): (WebCore::InspectorDOMAgent::mainFrameDOMContentLoaded):
  • inspector/InspectorDOMAgent.h: (WebCore::InspectorDOMAgent::create):
  • inspector/front-end/BreakpointManager.js: (WebInspector.BreakpointManager.prototype.restoreDOMBreakpoints): (WebInspector.DOMBreakpointView.prototype.populateStatusMessageElement.decorateNode): (WebInspector.DOMBreakpointView.prototype.populateStatusMessageElement):
  • inspector/front-end/DOMAgent.js: (WebInspector.DOMDocument): (WebInspector.DOMAgent): (WebInspector.DOMAgent.prototype.requestDocument): (WebInspector.DOMAgent.prototype.pushNodeToFrontend): (WebInspector.DOMAgent.prototype.pushNodeByPathToFrontend): (WebInspector.DOMAgent.prototype._attributesUpdated): (WebInspector.DOMAgent.prototype._characterDataModified): (WebInspector.DOMAgent.prototype._documentUpdated): (WebInspector.DOMAgent.prototype._setDocument): (WebInspector.DOMAgent.prototype._setDetachedRoot): (WebInspector.DOMAgent.prototype._setChildNodes): (WebInspector.DOMAgent.prototype._childNodeInserted): (WebInspector.DOMAgent.prototype._childNodeRemoved): (WebInspector.DOMDispatcher.prototype.documentUpdated):
  • inspector/front-end/ElementsPanel.js: (WebInspector.ElementsPanel.prototype.show): (WebInspector.ElementsPanel.prototype.setDocument):
  • inspector/front-end/MetricsSidebarPane.js:
  • inspector/front-end/RemoteObject.js: (WebInspector.RemoteObject.prototype.pushNodeToFrontend):

2011-03-03 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: do not push document into front-end, make it request one.
https://bugs.webkit.org/show_bug.cgi?id=55664

  • http/tests/inspector/debugger-test.js: (initialize_DebuggerTest.): (initialize_DebuggerTest):
  • http/tests/inspector/elements-test.js: (initialize_ElementTest.InspectorTest.nodeWithId.documentRequested): (initialize_ElementTest.InspectorTest.nodeWithId): (initialize_ElementTest.InspectorTest.dumpDOMAgentTree): (initialize_ElementTest):
  • inspector/console/command-line-api-inspect.html:
  • inspector/elements/dom-agent-query-selector.html:
  • inspector/elements/mutate-unknown-node.html:
  • inspector/styles/styles-new-API.html:
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80329 r80338  
     12011-03-03  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: do not push document into front-end, make it request one.
     6        https://bugs.webkit.org/show_bug.cgi?id=55664
     7
     8        * http/tests/inspector/debugger-test.js:
     9        (initialize_DebuggerTest.):
     10        (initialize_DebuggerTest):
     11        * http/tests/inspector/elements-test.js:
     12        (initialize_ElementTest.InspectorTest.nodeWithId.documentRequested):
     13        (initialize_ElementTest.InspectorTest.nodeWithId):
     14        (initialize_ElementTest.InspectorTest.dumpDOMAgentTree):
     15        (initialize_ElementTest):
     16        * inspector/console/command-line-api-inspect.html:
     17        * inspector/elements/dom-agent-query-selector.html:
     18        * inspector/elements/mutate-unknown-node.html:
     19        * inspector/styles/styles-new-API.html:
     20
    1212011-03-03  Adam Klein  <adamk@chromium.org>
    222
  • trunk/LayoutTests/http/tests/inspector/debugger-test.js

    r79880 r80338  
    9292    {
    9393        InspectorTest.captureStackTrace(callFrames);
     94        InspectorTest.runAfterPendingDispatches(step2);
     95    }
     96
     97    function step2()
     98    {
    9499        InspectorTest.addResult(WebInspector.panels.scripts.sidebarPanes.callstack.bodyElement.lastChild.innerText);
    95100        InspectorTest.resumeExecution(InspectorTest.safeWrap(callback));
  • trunk/LayoutTests/http/tests/inspector/elements-test.js

    r79205 r80338  
    3131    }
    3232    pendingRequests++;
    33     WebInspector.domAgent.getChildNodesAsync(WebInspector.domAgent.document, processChildren.bind(this, true));
     33
     34    WebInspector.domAgent.requestDocument(documentRequested.bind(this));
     35    function documentRequested(doc)
     36    {
     37        WebInspector.domAgent.getChildNodesAsync(doc, processChildren.bind(this, true));
     38    }
    3439};
    3540
     
    195200InspectorTest.dumpDOMAgentTree = function()
    196201{
     202    if (!WebInspector.domAgent._document)
     203        return;
     204
    197205    function dump(node, prefix, startIndex)
    198206    {
     
    202210            dump(children[i], prefix + "    ", startIndex);
    203211    }
    204     dump(WebInspector.domAgent.document, "", WebInspector.domAgent.document.id - 1);
    205 };
    206 
    207 };
     212    dump(WebInspector.domAgent._document, "", WebInspector.domAgent._document.id - 1);
     213};
     214
     215};
  • trunk/LayoutTests/inspector/console/command-line-api-inspect.html

    r79556 r80338  
    2828        InspectorTest.addResult("\n");
    2929        InspectorTest.evaluateInConsoleAndDump(expression, next);
    30         }
     30    }
    3131
    3232    InspectorTest.runTestSuite([
  • trunk/LayoutTests/inspector/elements/dom-agent-query-selector.html

    r79583 r80338  
    3838
    3939    function dumpNodes(next, nodeIds)
    40         {
    41                 if (!(nodeIds instanceof Array))
    42                     nodeIds = [nodeIds];
     40    {
     41        if (!(nodeIds instanceof Array))
     42            nodeIds = [nodeIds];
    4343
    4444        for (var i = 0; i < nodeIds.length; ++i) {
     
    4747        }
    4848        next();
    49         }
     49    }
    5050}
    5151</script>
  • trunk/LayoutTests/inspector/elements/mutate-unknown-node.html

    r78831 r80338  
    3232    }
    3333
    34     WebInspector.domAgent.document.addEventListener("DOMAttrModified", listener.bind(this, "DOMAttrModified"));
    35     WebInspector.domAgent.document.addEventListener("DOMCharacterDataModified", listener.bind(this, "DOMCharacterDataModified"));
    36     WebInspector.domAgent.document.addEventListener("DOMNodeInserted", listener.bind(this, "DOMNodeInserted"));
    37     WebInspector.domAgent.document.addEventListener("DOMNodeRemoved", listener.bind(this, "DOMNodeRemoved"));
     34    WebInspector.domAgent.requestDocument(step0.bind(this));
    3835
    39     InspectorTest.evaluateInPage("appendChild()", step1);
     36    function step0(doc)
     37    {
     38        doc.addEventListener("DOMAttrModified", listener.bind(this, "DOMAttrModified"));
     39        doc.addEventListener("DOMCharacterDataModified", listener.bind(this, "DOMCharacterDataModified"));
     40        doc.addEventListener("DOMNodeInserted", listener.bind(this, "DOMNodeInserted"));
     41        doc.addEventListener("DOMNodeRemoved", listener.bind(this, "DOMNodeRemoved"));
     42        InspectorTest.evaluateInPage("appendChild()", step1);
     43    }
    4044
    4145    function step1()
  • trunk/LayoutTests/inspector/styles/styles-new-API.html

    r78717 r80338  
    1212    test_styles();
    1313
     14    var bodyId;
    1415    function test_styles(node)
    1516    {
     
    4849        function nodeCallback(node)
    4950        {
    50             CSSAgent.getStylesForNode(node.id, callback);
     51            bodyId = node.id;
     52            CSSAgent.getStylesForNode(bodyId, callback);
    5153        }
    5254        InspectorTest.selectNodeWithId("mainBody", nodeCallback);
     
    143145        function didSetStyleText(style)
    144146        {
    145             CSSAgent.getStylesForNode(WebInspector.domAgent.document.body.id, didGetStyles);
     147            CSSAgent.getStylesForNode(bodyId, didGetStyles);
    146148        }
    147149
     
    151153        }
    152154
    153         CSSAgent.addRule(WebInspector.domAgent.document.body.id, "body", ruleAdded);
     155        CSSAgent.addRule(bodyId, "body", ruleAdded);
    154156    }
    155157
  • trunk/Source/WebCore/ChangeLog

    r80337 r80338  
     12011-03-03  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: do not push document into front-end, make it request one.
     6        https://bugs.webkit.org/show_bug.cgi?id=55664
     7
     8        * inspector/Inspector.idl:
     9        * inspector/InspectorAgent.cpp:
     10        (WebCore::InspectorAgent::InspectorAgent):
     11        * inspector/InspectorAgent.h:
     12        * inspector/InspectorBrowserDebuggerAgent.cpp:
     13        (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent):
     14        * inspector/InspectorDOMAgent.cpp:
     15        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
     16        (WebCore::InspectorDOMAgent::clearFrontend):
     17        (WebCore::InspectorDOMAgent::setDocument):
     18        (WebCore::InspectorDOMAgent::getDocument):
     19        (WebCore::InspectorDOMAgent::pushNodePathToFrontend):
     20        (WebCore::InspectorDOMAgent::boundNodeId):
     21        (WebCore::InspectorDOMAgent::resolveNode):
     22        (WebCore::InspectorDOMAgent::mainFrameDOMContentLoaded):
     23        * inspector/InspectorDOMAgent.h:
     24        (WebCore::InspectorDOMAgent::create):
     25        * inspector/front-end/BreakpointManager.js:
     26        (WebInspector.BreakpointManager.prototype.restoreDOMBreakpoints):
     27        (WebInspector.DOMBreakpointView.prototype.populateStatusMessageElement.decorateNode):
     28        (WebInspector.DOMBreakpointView.prototype.populateStatusMessageElement):
     29        * inspector/front-end/DOMAgent.js:
     30        (WebInspector.DOMDocument):
     31        (WebInspector.DOMAgent):
     32        (WebInspector.DOMAgent.prototype.requestDocument):
     33        (WebInspector.DOMAgent.prototype.pushNodeToFrontend):
     34        (WebInspector.DOMAgent.prototype.pushNodeByPathToFrontend):
     35        (WebInspector.DOMAgent.prototype._attributesUpdated):
     36        (WebInspector.DOMAgent.prototype._characterDataModified):
     37        (WebInspector.DOMAgent.prototype._documentUpdated):
     38        (WebInspector.DOMAgent.prototype._setDocument):
     39        (WebInspector.DOMAgent.prototype._setDetachedRoot):
     40        (WebInspector.DOMAgent.prototype._setChildNodes):
     41        (WebInspector.DOMAgent.prototype._childNodeInserted):
     42        (WebInspector.DOMAgent.prototype._childNodeRemoved):
     43        (WebInspector.DOMDispatcher.prototype.documentUpdated):
     44        * inspector/front-end/ElementsPanel.js:
     45        (WebInspector.ElementsPanel.prototype.show):
     46        (WebInspector.ElementsPanel.prototype.setDocument):
     47        * inspector/front-end/MetricsSidebarPane.js:
     48        * inspector/front-end/RemoteObject.js:
     49        (WebInspector.RemoteObject.prototype.pushNodeToFrontend):
     50
    1512011-03-04  Andrey Kosyakov  <caseq@chromium.org>
    252
  • trunk/Source/WebCore/inspector/Inspector.idl

    r80239 r80338  
    145145
    146146    interface [Conditional=INSPECTOR] DOM {
     147        void getDocument(out Object root);
    147148        void getChildNodes(in long nodeId);
    148149        void querySelector(in long nodeId, in String selectors, in boolean documentWide, out long elementId);
     
    165166
    166167        [event] void addNodesToSearchResult(out Array nodeIds);
    167         [event] void setDocument(out Value root); // FIXME: should be requested from the front-end as getDocument.
     168        [event] void documentUpdated();
     169        [event] void setChildNodes(out long parentId, out Array nodes);
    168170        [event] void attributesUpdated(out long id, out Array attributes);
    169171        [event] void characterDataModified(out long id, out String newValue);
    170         [event] void setChildNodes(out long parentId, out Array nodes);
    171172        [event] void setDetachedRoot(out Object root);
    172173        [event] void childNodeCountUpdated(out long id, out int newValue);
  • trunk/Source/WebCore/inspector/InspectorAgent.cpp

    r80332 r80338  
    139139    , m_instrumentingAgents(new InstrumentingAgents())
    140140    , m_injectedScriptHost(InjectedScriptHost::create(this))
    141     , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), m_injectedScriptHost.get()))
     141    , m_state(new InspectorState(client))
     142    , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptHost.get()))
    142143    , m_cssAgent(new InspectorCSSAgent(m_domAgent.get()))
    143144#if ENABLE(DATABASE)
     
    147148    , m_domStorageAgent(InspectorDOMStorageAgent::create(m_instrumentingAgents.get()))
    148149#endif
    149     , m_state(new InspectorState(client))
    150150    , m_timelineAgent(InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get()))
    151151#if ENABLE(OFFLINE_WEB_APPLICATIONS)
  • trunk/Source/WebCore/inspector/InspectorAgent.h

    r80239 r80338  
    246246    OwnPtr<InstrumentingAgents> m_instrumentingAgents;
    247247    RefPtr<InjectedScriptHost> m_injectedScriptHost;
     248    OwnPtr<InspectorState> m_state;
    248249    OwnPtr<InspectorDOMAgent> m_domAgent;
    249250    OwnPtr<InspectorCSSAgent> m_cssAgent;
     
    257258#endif
    258259
    259     OwnPtr<InspectorState> m_state;
    260260    OwnPtr<InspectorTimelineAgent> m_timelineAgent;
    261261
  • trunk/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp

    r80239 r80338  
    302302        // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint.
    303303        // Target node may be unknown to frontend, so we need to push it first.
    304         long targetNodeId = m_domAgent->pushNodePathToFrontend(target);
    305         ASSERT(targetNodeId);
    306         description->setNumber("targetNodeId", targetNodeId);
     304        RefPtr<InspectorObject> targetNodeObject = m_domAgent->resolveNode(target, "");
     305        description->setObject("targetNode", targetNodeObject);
    307306
    308307        // Find breakpoint owner node.
     
    319318    }
    320319
    321     long breakpointOwnerNodeId = m_domAgent->pushNodePathToFrontend(breakpointOwner);
     320    long breakpointOwnerNodeId = m_domAgent->boundNodeId(breakpointOwner);
    322321    ASSERT(breakpointOwnerNodeId);
    323322    description->setNumber("nodeId", breakpointOwnerNodeId);
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r80204 r80338  
    6262#include "InjectedScriptHost.h"
    6363#include "InspectorFrontend.h"
     64#include "InspectorState.h"
    6465#include "InstrumentingAgents.h"
    6566#include "MutationEvent.h"
     
    9091namespace WebCore {
    9192
     93namespace DOMAgentState {
     94static const char documentRequested[] = "documentRequested";
     95};
     96
    9297class MatchJob {
    9398public:
     
    244249}
    245250
    246 InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InjectedScriptHost* injectedScriptHost)
     251InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptHost* injectedScriptHost)
    247252    : m_instrumentingAgents(instrumentingAgents)
     253    , m_inspectorState(inspectorState)
    248254    , m_injectedScriptHost(injectedScriptHost)
    249255    , m_frontend(0)
     
    271277    m_frontend = 0;
    272278    m_instrumentingAgents->setInspectorDOMAgent(0);
     279    m_inspectorState->setBoolean(DOMAgentState::documentRequested, false);
    273280    reset();
    274281}
     
    310317    m_document = doc;
    311318
    312     if (doc) {
    313         if (doc->documentElement())
    314             pushDocumentToFrontend();
    315     } else
    316         m_frontend->setDocument(InspectorValue::null());
     319    if (!doc && m_inspectorState->getBoolean(DOMAgentState::documentRequested))
     320        m_frontend->documentUpdated();
    317321}
    318322
     
    375379}
    376380
    377 bool InspectorDOMAgent::pushDocumentToFrontend()
    378 {
     381void InspectorDOMAgent::getDocument(ErrorString*, RefPtr<InspectorObject>* root)
     382{
     383    m_inspectorState->setBoolean(DOMAgentState::documentRequested, true);
     384
    379385    if (!m_document)
    380         return false;
     386        return;
     387
     388    // Reset backend state.
     389    RefPtr<Document> doc = m_document;
     390    reset();
     391    m_document = doc;
     392
    381393    if (!m_documentNodeToIdMap.contains(m_document))
    382         m_frontend->setDocument(buildObjectForNode(m_document.get(), 2, &m_documentNodeToIdMap));
    383     return true;
     394        *root = buildObjectForNode(m_document.get(), 2, &m_documentNodeToIdMap);
    384395}
    385396
     
    458469    ASSERT(nodeToPush);  // Invalid input
    459470
    460     // If we are sending information to the client that is currently being created. Send root node first.
    461     if (!pushDocumentToFrontend())
     471    if (!m_document)
     472        return 0;
     473    if (!m_documentNodeToIdMap.contains(m_document))
    462474        return 0;
    463475
     
    470482    Vector<Node*> path;
    471483    NodeToIdMap* danglingMap = 0;
     484
    472485    while (true) {
    473486        Node* parent = innerParentNode(node);
     
    476489            danglingMap = new NodeToIdMap();
    477490            m_danglingNodeToIdMaps.append(danglingMap);
    478             m_frontend->setDetachedRoot(buildObjectForNode(node, 0, danglingMap));
     491            RefPtr<InspectorArray> children = InspectorArray::create();
     492            children->pushObject(buildObjectForNode(node, 0, danglingMap));
     493            m_frontend->setChildNodes(0, children);
    479494            break;
    480495        } else {
     
    494509    }
    495510    return map->get(nodeToPush);
     511}
     512
     513long InspectorDOMAgent::boundNodeId(Node* node)
     514{
     515    return m_documentNodeToIdMap.get(node);
    496516}
    497517
     
    803823{
    804824    Node* node = nodeForId(nodeId);
    805     InjectedScript injectedScript = injectedScriptForNode(error, node);
    806     if (error->isEmpty())
    807         *result = injectedScript.wrapNode(node, objectGroup);
     825    if (!node) {
     826        *error = "No node with given id found.";
     827        return;
     828    }
     829    *result = resolveNode(node, objectGroup);
    808830}
    809831
     
    10051027    // Re-push document once it is loaded.
    10061028    discardBindings();
    1007     pushDocumentToFrontend();
     1029    if (m_inspectorState->getBoolean(DOMAgentState::documentRequested))
     1030        m_frontend->documentUpdated();
    10081031}
    10091032
     
    12001223}
    12011224
    1202 InjectedScript InspectorDOMAgent::injectedScriptForNode(ErrorString* error, Node* node)
    1203 {
    1204     if (!node) {
    1205         *error = "No node with given id found.";
    1206         return InjectedScript();
    1207     }
    1208 
     1225PassRefPtr<InspectorObject> InspectorDOMAgent::resolveNode(Node* node, const String& objectGroup)
     1226{
    12091227    Document* document = node->ownerDocument();
    1210     Frame* frame = document->frame();
     1228    Frame* frame = document ? document->frame() : 0;
     1229    if (!frame)
     1230        return 0;
    12111231
    12121232    InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(mainWorldScriptState(frame));
    1213     if (injectedScript.hasNoValue()) {
    1214         *error = "No JavaScript world found for node with given id.";
    1215         return InjectedScript();
    1216     }
    1217 
    1218     return injectedScript;
     1233    if (injectedScript.hasNoValue())
     1234        return 0;
     1235
     1236    return injectedScript.wrapNode(node, objectGroup);
    12191237}
    12201238
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.h

    r80204 r80338  
    5656class InspectorFrontend;
    5757class MatchJob;
     58class InspectorState;
    5859class InstrumentingAgents;
    5960class NameNodeMap;
     
    9192    };
    9293
    93     static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InjectedScriptHost* injectedScriptHost)
     94    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptHost* injectedScriptHost)
    9495    {
    95         return adoptPtr(new InspectorDOMAgent(instrumentingAgents, injectedScriptHost));
     96        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, inspectorState, injectedScriptHost));
    9697    }
    9798
     
    104105    void reset();
    105106
     107    // Methods called from the frontend for DOM nodes inspection.
    106108    void querySelector(ErrorString*, long nodeId, const String& selectors, bool documentWide, long* elementId);
    107109    void querySelectorAll(ErrorString*, long nodeId, const String& selectors, bool documentWide, RefPtr<InspectorArray>* result);
    108     // Methods called from the frontend for DOM nodes inspection.
     110    void getDocument(ErrorString*, RefPtr<InspectorObject>* root);
    109111    void getChildNodes(ErrorString*, long nodeId);
    110112    void setAttribute(ErrorString*, long elementId, const String& name, const String& value, bool* success);
     
    121123    void resolveNode(ErrorString*, long nodeId, const String& objectGroup, RefPtr<InspectorValue>* result);
    122124    void pushNodeToFrontend(ErrorString*, PassRefPtr<InspectorObject> objectId, long* nodeId);
     125    void pushNodeByPathToFrontend(ErrorString*, const String& path, long* nodeId);
    123126
    124127    // Methods called from the InspectorInstrumentation.
     
    136139
    137140    Node* nodeForId(long nodeId);
    138     long pushNodePathToFrontend(Node*);
    139     void pushChildNodesToFrontend(long nodeId);
    140     void pushNodeByPathToFrontend(ErrorString*, const String& path, long* nodeId);
     141    long boundNodeId(Node*);
    141142    void copyNode(ErrorString*, long nodeId);
    142143    void setDOMListener(DOMListener*);
    143144
    144145    String documentURLString(Document*) const;
     146
     147    PassRefPtr<InspectorObject> resolveNode(Node*, const String& objectGroup);
    145148
    146149    // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently.
     
    154157
    155158private:
    156     InspectorDOMAgent(InstrumentingAgents*, InjectedScriptHost*);
     159    InspectorDOMAgent(InstrumentingAgents*, InspectorState*, InjectedScriptHost*);
    157160
    158161    // Node-related methods.
     
    163166    Node* nodeToSelectOn(long nodeId, bool documentWide);
    164167
    165     bool pushDocumentToFrontend();
     168    long pushNodePathToFrontend(Node*);
     169    void pushChildNodesToFrontend(long nodeId);
    166170
    167171    bool hasBreakpoint(Node*, long type);
     
    182186    void discardBindings();
    183187
    184     InjectedScript injectedScriptForNode(ErrorString*, Node*);
    185 
    186188    InstrumentingAgents* m_instrumentingAgents;
     189    InspectorState* m_inspectorState;
    187190    InjectedScriptHost* m_injectedScriptHost;
    188191    InspectorFrontend::DOM* m_frontend;
  • trunk/Source/WebCore/inspector/front-end/BreakpointManager.js

    r78717 r80338  
    217217        function didPushNodeByPathToFrontend(path, nodeId)
    218218        {
     219            if (!nodeId)
     220                return;
     221
    219222            pathToNodeId[path] = nodeId;
    220223            pendingCalls -= 1;
     
    244247            pathToNodeId[path] = 0;
    245248            pendingCalls += 1;
    246             DOMAgent.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path));
     249            WebInspector.domAgent.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path));
    247250        }
    248251        if (!pendingCalls)
     
    491494        }
    492495        if (this._type === WebInspector.DOMBreakpointTypes.SubtreeModified) {
    493             var targetNode = WebInspector.panels.elements.linkifyNodeById(eventData.targetNodeId);
    494             if (eventData.insertion) {
    495                 if (eventData.targetNodeId !== this._nodeId)
    496                     WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to its descendant %s.", substitutions.concat(targetNode), formatters, "", append);
    497                 else
    498                     WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to that node.", substitutions, formatters, "", append);
    499             } else
    500                 WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because its descendant %s was removed.", substitutions.concat(targetNode), formatters, "", append);
     496            var targetNodeObject = WebInspector.RemoteObject.fromPayload(eventData.targetNode);
     497            targetNodeObject.pushNodeToFrontend(decorateNode.bind(this));
     498            function decorateNode(targetNodeId)
     499            {
     500                if (!targetNodeId)
     501                    return;
     502
     503                RuntimeAgent.releaseObject(eventData.targetNode);
     504                var targetNode = WebInspector.panels.elements.linkifyNodeById(targetNodeId);
     505                if (eventData.insertion) {
     506                    if (targetNodeId !== this._nodeId)
     507                        WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to its descendant %s.", substitutions.concat(targetNode), formatters, "", append);
     508                    else
     509                        WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to that node.", substitutions, formatters, "", append);
     510                } else
     511                    WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because its descendant %s was removed.", substitutions.concat(targetNode), formatters, "", append);
     512            }
    501513        } else
    502514            WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append);
  • trunk/Source/WebCore/inspector/front-end/DOMAgent.js

    r80204 r80338  
    224224}
    225225
    226 WebInspector.DOMDocument = function(domAgent, defaultView, payload)
     226WebInspector.DOMDocument = function(domAgent, payload)
    227227{
    228228    WebInspector.DOMNode.call(this, this, payload);
    229229    this._listeners = {};
    230230    this._domAgent = domAgent;
    231     this.defaultView = defaultView;
    232231}
    233232
     
    270269WebInspector.DOMDocument.prototype.__proto__ = WebInspector.DOMNode.prototype;
    271270
    272 
    273 WebInspector.DOMWindow = function(domAgent)
    274 {
    275     this._domAgent = domAgent;
    276 }
    277 
    278 WebInspector.DOMWindow.prototype = {
    279     get document()
    280     {
    281         return this._domAgent.document;
    282     },
    283 
    284     get Node()
    285     {
    286         return WebInspector.DOMNode;
    287     },
    288 
    289     get Element()
    290     {
    291         return WebInspector.DOMNode;
    292     },
    293 
    294     Object: function()
    295     {
    296     }
    297 }
    298 
    299271WebInspector.DOMAgent = function() {
    300     this._window = new WebInspector.DOMWindow(this);
    301272    this._idToDOMNode = null;
    302     this.document = null;
     273    this._document = null;
    303274    InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatcher(this));
    304275}
    305276
    306277WebInspector.DOMAgent.prototype = {
    307     get domWindow()
    308     {
    309         return this._window;
     278    requestDocument: function(callback)
     279    {
     280        if (this._document) {
     281            if (callback)
     282                callback(this._document);
     283        } else
     284            this._documentUpdated(callback);
     285    },
     286
     287    pushNodeToFrontend: function(objectId, callback)
     288    {
     289        function mycallback()
     290        {
     291            if (this._document)
     292                DOMAgent.pushNodeToFrontend(objectId, callback);
     293            else {
     294                if (callback)
     295                    callback(0);
     296            }
     297        }
     298        this.requestDocument(mycallback.bind(this));
     299    },
     300
     301    pushNodeByPathToFrontend: function(path, callback)
     302    {
     303        function mycallback()
     304        {
     305            if (this._document)
     306                DOMAgent.pushNodeByPathToFrontend(path, callback);
     307            else {
     308                if (callback)
     309                    callback(0);
     310            }
     311        }
     312        this.requestDocument(mycallback.bind(this));
    310313    },
    311314
     
    357360        node._setAttributesPayload(attrsArray);
    358361        var event = {target: node};
    359         this.document._fireDomEvent("DOMAttrModified", event);
     362        this._document._fireDomEvent("DOMAttrModified", event);
    360363    },
    361364
     
    366369        node.textContent = newValue;
    367370        var event = { target : node };
    368         this.document._fireDomEvent("DOMCharacterDataModified", event);
     371        this._document._fireDomEvent("DOMCharacterDataModified", event);
    369372    },
    370373
     
    372375    {
    373376        return this._idToDOMNode[nodeId];
     377    },
     378
     379    _documentUpdated: function(callback)
     380    {
     381        function mycallback(root)
     382        {
     383            this._setDocument(root);
     384            if (callback)
     385                callback(this._document);
     386        }
     387        DOMAgent.getDocument(mycallback.bind(this));
    374388    },
    375389
     
    378392        this._idToDOMNode = {};
    379393        if (payload && "id" in payload) {
    380             this.document = new WebInspector.DOMDocument(this, this._window, payload);
    381             this._idToDOMNode[payload.id] = this.document;
    382             this._bindNodes(this.document.children);
     394            this._document = new WebInspector.DOMDocument(this, payload);
     395            this._idToDOMNode[payload.id] = this._document;
     396            this._bindNodes(this._document.children);
    383397            WebInspector.breakpointManager.restoreDOMBreakpoints();
    384398        } else
    385             this.document = null;
    386         WebInspector.panels.elements.setDocument(this.document);
     399            this._document = null;
     400        WebInspector.panels.elements.setDocument(this._document);
    387401    },
    388402
    389403    _setDetachedRoot: function(payload)
    390404    {
    391         var root = new WebInspector.DOMNode(this.document, payload);
     405        var root = new WebInspector.DOMNode(this._document, payload);
    392406        this._idToDOMNode[payload.id] = root;
    393407    },
     
    395409    _setChildNodes: function(parentId, payloads)
    396410    {
     411        if (!parentId && payloads.length) {
     412            this._setDetachedRoot(payloads[0]);
     413            return;
     414        }
     415
    397416        var parent = this._idToDOMNode[parentId];
    398417        parent._setChildrenPayload(payloads);
     
    427446        this._idToDOMNode[node.id] = node;
    428447        var event = { target : node, relatedNode : parent };
    429         this.document._fireDomEvent("DOMNodeInserted", event);
     448        this._document._fireDomEvent("DOMNodeInserted", event);
    430449    },
    431450
     
    436455        parent.removeChild_(node);
    437456        var event = { target : node, relatedNode : parent };
    438         this.document._fireDomEvent("DOMNodeRemoved", event);
     457        this._document._fireDomEvent("DOMNodeRemoved", event);
    439458        delete this._idToDOMNode[nodeId];
    440459        this._removeBreakpoints(node);
     
    458477
    459478WebInspector.DOMDispatcher.prototype = {
    460     setDocument: function(payload)
    461     {
    462         this._domAgent._setDocument(payload);
     479    documentUpdated: function()
     480    {
     481        this._domAgent._documentUpdated();
    463482    },
    464483
     
    476495    {
    477496        this._domAgent._setChildNodes(parentId, payloads);
    478     },
    479 
    480     setDetachedRoot: function(payload)
    481     {
    482         this._domAgent._setDetachedRoot(payload);
    483497    },
    484498
  • trunk/Source/WebCore/inspector/front-end/ElementsPanel.js

    r80102 r80338  
    142142        if (this.recentlyModifiedNodes.length)
    143143            this.updateModifiedNodes();
     144
     145        if (!this.rootDOMNode)
     146            WebInspector.domAgent.requestDocument();
    144147    },
    145148
     
    212215
    213216        if (this._selectedPathOnReset)
    214             DOMAgent.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this));
     217            WebInspector.domAgent.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this));
    215218        else
    216219            selectNode.call(this);
  • trunk/Source/WebCore/inspector/front-end/MetricsSidebarPane.js

    r73913 r80338  
    4141            node = this.node;
    4242
    43         if (!node || !node.ownerDocument.defaultView || node.nodeType !== Node.ELEMENT_NODE) {
     43        if (!node || node.nodeType !== Node.ELEMENT_NODE) {
    4444            this.bodyElement.removeChildren();
    4545            return;
  • trunk/Source/WebCore/inspector/front-end/RemoteObject.js

    r80141 r80338  
    134134    {
    135135        if (this._objectId)
    136             DOMAgent.pushNodeToFrontend(this._objectId, callback);
     136            WebInspector.domAgent.pushNodeToFrontend(this._objectId, callback);
    137137        else
    138138            callback(0);
Note: See TracChangeset for help on using the changeset viewer.