Changeset 80338 in webkit
- Timestamp:
- Mar 4, 2011 1:40:47 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r80329 r80338 1 2011-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 1 21 2011-03-03 Adam Klein <adamk@chromium.org> 2 22 -
trunk/LayoutTests/http/tests/inspector/debugger-test.js
r79880 r80338 92 92 { 93 93 InspectorTest.captureStackTrace(callFrames); 94 InspectorTest.runAfterPendingDispatches(step2); 95 } 96 97 function step2() 98 { 94 99 InspectorTest.addResult(WebInspector.panels.scripts.sidebarPanes.callstack.bodyElement.lastChild.innerText); 95 100 InspectorTest.resumeExecution(InspectorTest.safeWrap(callback)); -
trunk/LayoutTests/http/tests/inspector/elements-test.js
r79205 r80338 31 31 } 32 32 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 } 34 39 }; 35 40 … … 195 200 InspectorTest.dumpDOMAgentTree = function() 196 201 { 202 if (!WebInspector.domAgent._document) 203 return; 204 197 205 function dump(node, prefix, startIndex) 198 206 { … … 202 210 dump(children[i], prefix + " ", startIndex); 203 211 } 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 28 28 InspectorTest.addResult("\n"); 29 29 InspectorTest.evaluateInConsoleAndDump(expression, next); 30 30 } 31 31 32 32 InspectorTest.runTestSuite([ -
trunk/LayoutTests/inspector/elements/dom-agent-query-selector.html
r79583 r80338 38 38 39 39 function dumpNodes(next, nodeIds) 40 41 42 40 { 41 if (!(nodeIds instanceof Array)) 42 nodeIds = [nodeIds]; 43 43 44 44 for (var i = 0; i < nodeIds.length; ++i) { … … 47 47 } 48 48 next(); 49 49 } 50 50 } 51 51 </script> -
trunk/LayoutTests/inspector/elements/mutate-unknown-node.html
r78831 r80338 32 32 } 33 33 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)); 38 35 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 } 40 44 41 45 function step1() -
trunk/LayoutTests/inspector/styles/styles-new-API.html
r78717 r80338 12 12 test_styles(); 13 13 14 var bodyId; 14 15 function test_styles(node) 15 16 { … … 48 49 function nodeCallback(node) 49 50 { 50 CSSAgent.getStylesForNode(node.id, callback); 51 bodyId = node.id; 52 CSSAgent.getStylesForNode(bodyId, callback); 51 53 } 52 54 InspectorTest.selectNodeWithId("mainBody", nodeCallback); … … 143 145 function didSetStyleText(style) 144 146 { 145 CSSAgent.getStylesForNode( WebInspector.domAgent.document.body.id, didGetStyles);147 CSSAgent.getStylesForNode(bodyId, didGetStyles); 146 148 } 147 149 … … 151 153 } 152 154 153 CSSAgent.addRule( WebInspector.domAgent.document.body.id, "body", ruleAdded);155 CSSAgent.addRule(bodyId, "body", ruleAdded); 154 156 } 155 157 -
trunk/Source/WebCore/ChangeLog
r80337 r80338 1 2011-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 1 51 2011-03-04 Andrey Kosyakov <caseq@chromium.org> 2 52 -
trunk/Source/WebCore/inspector/Inspector.idl
r80239 r80338 145 145 146 146 interface [Conditional=INSPECTOR] DOM { 147 void getDocument(out Object root); 147 148 void getChildNodes(in long nodeId); 148 149 void querySelector(in long nodeId, in String selectors, in boolean documentWide, out long elementId); … … 165 166 166 167 [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); 168 170 [event] void attributesUpdated(out long id, out Array attributes); 169 171 [event] void characterDataModified(out long id, out String newValue); 170 [event] void setChildNodes(out long parentId, out Array nodes);171 172 [event] void setDetachedRoot(out Object root); 172 173 [event] void childNodeCountUpdated(out long id, out int newValue); -
trunk/Source/WebCore/inspector/InspectorAgent.cpp
r80332 r80338 139 139 , m_instrumentingAgents(new InstrumentingAgents()) 140 140 , 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())) 142 143 , m_cssAgent(new InspectorCSSAgent(m_domAgent.get())) 143 144 #if ENABLE(DATABASE) … … 147 148 , m_domStorageAgent(InspectorDOMStorageAgent::create(m_instrumentingAgents.get())) 148 149 #endif 149 , m_state(new InspectorState(client))150 150 , m_timelineAgent(InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get())) 151 151 #if ENABLE(OFFLINE_WEB_APPLICATIONS) -
trunk/Source/WebCore/inspector/InspectorAgent.h
r80239 r80338 246 246 OwnPtr<InstrumentingAgents> m_instrumentingAgents; 247 247 RefPtr<InjectedScriptHost> m_injectedScriptHost; 248 OwnPtr<InspectorState> m_state; 248 249 OwnPtr<InspectorDOMAgent> m_domAgent; 249 250 OwnPtr<InspectorCSSAgent> m_cssAgent; … … 257 258 #endif 258 259 259 OwnPtr<InspectorState> m_state;260 260 OwnPtr<InspectorTimelineAgent> m_timelineAgent; 261 261 -
trunk/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp
r80239 r80338 302 302 // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint. 303 303 // 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); 307 306 308 307 // Find breakpoint owner node. … … 319 318 } 320 319 321 long breakpointOwnerNodeId = m_domAgent-> pushNodePathToFrontend(breakpointOwner);320 long breakpointOwnerNodeId = m_domAgent->boundNodeId(breakpointOwner); 322 321 ASSERT(breakpointOwnerNodeId); 323 322 description->setNumber("nodeId", breakpointOwnerNodeId); -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r80204 r80338 62 62 #include "InjectedScriptHost.h" 63 63 #include "InspectorFrontend.h" 64 #include "InspectorState.h" 64 65 #include "InstrumentingAgents.h" 65 66 #include "MutationEvent.h" … … 90 91 namespace WebCore { 91 92 93 namespace DOMAgentState { 94 static const char documentRequested[] = "documentRequested"; 95 }; 96 92 97 class MatchJob { 93 98 public: … … 244 249 } 245 250 246 InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, In jectedScriptHost* injectedScriptHost)251 InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptHost* injectedScriptHost) 247 252 : m_instrumentingAgents(instrumentingAgents) 253 , m_inspectorState(inspectorState) 248 254 , m_injectedScriptHost(injectedScriptHost) 249 255 , m_frontend(0) … … 271 277 m_frontend = 0; 272 278 m_instrumentingAgents->setInspectorDOMAgent(0); 279 m_inspectorState->setBoolean(DOMAgentState::documentRequested, false); 273 280 reset(); 274 281 } … … 310 317 m_document = doc; 311 318 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(); 317 321 } 318 322 … … 375 379 } 376 380 377 bool InspectorDOMAgent::pushDocumentToFrontend() 378 { 381 void InspectorDOMAgent::getDocument(ErrorString*, RefPtr<InspectorObject>* root) 382 { 383 m_inspectorState->setBoolean(DOMAgentState::documentRequested, true); 384 379 385 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 381 393 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); 384 395 } 385 396 … … 458 469 ASSERT(nodeToPush); // Invalid input 459 470 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)) 462 474 return 0; 463 475 … … 470 482 Vector<Node*> path; 471 483 NodeToIdMap* danglingMap = 0; 484 472 485 while (true) { 473 486 Node* parent = innerParentNode(node); … … 476 489 danglingMap = new NodeToIdMap(); 477 490 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); 479 494 break; 480 495 } else { … … 494 509 } 495 510 return map->get(nodeToPush); 511 } 512 513 long InspectorDOMAgent::boundNodeId(Node* node) 514 { 515 return m_documentNodeToIdMap.get(node); 496 516 } 497 517 … … 803 823 { 804 824 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); 808 830 } 809 831 … … 1005 1027 // Re-push document once it is loaded. 1006 1028 discardBindings(); 1007 pushDocumentToFrontend(); 1029 if (m_inspectorState->getBoolean(DOMAgentState::documentRequested)) 1030 m_frontend->documentUpdated(); 1008 1031 } 1009 1032 … … 1200 1223 } 1201 1224 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 1225 PassRefPtr<InspectorObject> InspectorDOMAgent::resolveNode(Node* node, const String& objectGroup) 1226 { 1209 1227 Document* document = node->ownerDocument(); 1210 Frame* frame = document->frame(); 1228 Frame* frame = document ? document->frame() : 0; 1229 if (!frame) 1230 return 0; 1211 1231 1212 1232 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); 1219 1237 } 1220 1238 -
trunk/Source/WebCore/inspector/InspectorDOMAgent.h
r80204 r80338 56 56 class InspectorFrontend; 57 57 class MatchJob; 58 class InspectorState; 58 59 class InstrumentingAgents; 59 60 class NameNodeMap; … … 91 92 }; 92 93 93 static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, In jectedScriptHost* injectedScriptHost)94 static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptHost* injectedScriptHost) 94 95 { 95 return adoptPtr(new InspectorDOMAgent(instrumentingAgents, in jectedScriptHost));96 return adoptPtr(new InspectorDOMAgent(instrumentingAgents, inspectorState, injectedScriptHost)); 96 97 } 97 98 … … 104 105 void reset(); 105 106 107 // Methods called from the frontend for DOM nodes inspection. 106 108 void querySelector(ErrorString*, long nodeId, const String& selectors, bool documentWide, long* elementId); 107 109 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); 109 111 void getChildNodes(ErrorString*, long nodeId); 110 112 void setAttribute(ErrorString*, long elementId, const String& name, const String& value, bool* success); … … 121 123 void resolveNode(ErrorString*, long nodeId, const String& objectGroup, RefPtr<InspectorValue>* result); 122 124 void pushNodeToFrontend(ErrorString*, PassRefPtr<InspectorObject> objectId, long* nodeId); 125 void pushNodeByPathToFrontend(ErrorString*, const String& path, long* nodeId); 123 126 124 127 // Methods called from the InspectorInstrumentation. … … 136 139 137 140 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*); 141 142 void copyNode(ErrorString*, long nodeId); 142 143 void setDOMListener(DOMListener*); 143 144 144 145 String documentURLString(Document*) const; 146 147 PassRefPtr<InspectorObject> resolveNode(Node*, const String& objectGroup); 145 148 146 149 // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently. … … 154 157 155 158 private: 156 InspectorDOMAgent(InstrumentingAgents*, In jectedScriptHost*);159 InspectorDOMAgent(InstrumentingAgents*, InspectorState*, InjectedScriptHost*); 157 160 158 161 // Node-related methods. … … 163 166 Node* nodeToSelectOn(long nodeId, bool documentWide); 164 167 165 bool pushDocumentToFrontend(); 168 long pushNodePathToFrontend(Node*); 169 void pushChildNodesToFrontend(long nodeId); 166 170 167 171 bool hasBreakpoint(Node*, long type); … … 182 186 void discardBindings(); 183 187 184 InjectedScript injectedScriptForNode(ErrorString*, Node*);185 186 188 InstrumentingAgents* m_instrumentingAgents; 189 InspectorState* m_inspectorState; 187 190 InjectedScriptHost* m_injectedScriptHost; 188 191 InspectorFrontend::DOM* m_frontend; -
trunk/Source/WebCore/inspector/front-end/BreakpointManager.js
r78717 r80338 217 217 function didPushNodeByPathToFrontend(path, nodeId) 218 218 { 219 if (!nodeId) 220 return; 221 219 222 pathToNodeId[path] = nodeId; 220 223 pendingCalls -= 1; … … 244 247 pathToNodeId[path] = 0; 245 248 pendingCalls += 1; 246 DOMAgent.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path));249 WebInspector.domAgent.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path)); 247 250 } 248 251 if (!pendingCalls) … … 491 494 } 492 495 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 } 501 513 } else 502 514 WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append); -
trunk/Source/WebCore/inspector/front-end/DOMAgent.js
r80204 r80338 224 224 } 225 225 226 WebInspector.DOMDocument = function(domAgent, defaultView,payload)226 WebInspector.DOMDocument = function(domAgent, payload) 227 227 { 228 228 WebInspector.DOMNode.call(this, this, payload); 229 229 this._listeners = {}; 230 230 this._domAgent = domAgent; 231 this.defaultView = defaultView;232 231 } 233 232 … … 270 269 WebInspector.DOMDocument.prototype.__proto__ = WebInspector.DOMNode.prototype; 271 270 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 299 271 WebInspector.DOMAgent = function() { 300 this._window = new WebInspector.DOMWindow(this);301 272 this._idToDOMNode = null; 302 this. document = null;273 this._document = null; 303 274 InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatcher(this)); 304 275 } 305 276 306 277 WebInspector.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)); 310 313 }, 311 314 … … 357 360 node._setAttributesPayload(attrsArray); 358 361 var event = {target: node}; 359 this. document._fireDomEvent("DOMAttrModified", event);362 this._document._fireDomEvent("DOMAttrModified", event); 360 363 }, 361 364 … … 366 369 node.textContent = newValue; 367 370 var event = { target : node }; 368 this. document._fireDomEvent("DOMCharacterDataModified", event);371 this._document._fireDomEvent("DOMCharacterDataModified", event); 369 372 }, 370 373 … … 372 375 { 373 376 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)); 374 388 }, 375 389 … … 378 392 this._idToDOMNode = {}; 379 393 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); 383 397 WebInspector.breakpointManager.restoreDOMBreakpoints(); 384 398 } else 385 this. document = null;386 WebInspector.panels.elements.setDocument(this. document);399 this._document = null; 400 WebInspector.panels.elements.setDocument(this._document); 387 401 }, 388 402 389 403 _setDetachedRoot: function(payload) 390 404 { 391 var root = new WebInspector.DOMNode(this. document, payload);405 var root = new WebInspector.DOMNode(this._document, payload); 392 406 this._idToDOMNode[payload.id] = root; 393 407 }, … … 395 409 _setChildNodes: function(parentId, payloads) 396 410 { 411 if (!parentId && payloads.length) { 412 this._setDetachedRoot(payloads[0]); 413 return; 414 } 415 397 416 var parent = this._idToDOMNode[parentId]; 398 417 parent._setChildrenPayload(payloads); … … 427 446 this._idToDOMNode[node.id] = node; 428 447 var event = { target : node, relatedNode : parent }; 429 this. document._fireDomEvent("DOMNodeInserted", event);448 this._document._fireDomEvent("DOMNodeInserted", event); 430 449 }, 431 450 … … 436 455 parent.removeChild_(node); 437 456 var event = { target : node, relatedNode : parent }; 438 this. document._fireDomEvent("DOMNodeRemoved", event);457 this._document._fireDomEvent("DOMNodeRemoved", event); 439 458 delete this._idToDOMNode[nodeId]; 440 459 this._removeBreakpoints(node); … … 458 477 459 478 WebInspector.DOMDispatcher.prototype = { 460 setDocument: function(payload)461 { 462 this._domAgent._ setDocument(payload);479 documentUpdated: function() 480 { 481 this._domAgent._documentUpdated(); 463 482 }, 464 483 … … 476 495 { 477 496 this._domAgent._setChildNodes(parentId, payloads); 478 },479 480 setDetachedRoot: function(payload)481 {482 this._domAgent._setDetachedRoot(payload);483 497 }, 484 498 -
trunk/Source/WebCore/inspector/front-end/ElementsPanel.js
r80102 r80338 142 142 if (this.recentlyModifiedNodes.length) 143 143 this.updateModifiedNodes(); 144 145 if (!this.rootDOMNode) 146 WebInspector.domAgent.requestDocument(); 144 147 }, 145 148 … … 212 215 213 216 if (this._selectedPathOnReset) 214 DOMAgent.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this));217 WebInspector.domAgent.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this)); 215 218 else 216 219 selectNode.call(this); -
trunk/Source/WebCore/inspector/front-end/MetricsSidebarPane.js
r73913 r80338 41 41 node = this.node; 42 42 43 if (!node || !node.ownerDocument.defaultView ||node.nodeType !== Node.ELEMENT_NODE) {43 if (!node || node.nodeType !== Node.ELEMENT_NODE) { 44 44 this.bodyElement.removeChildren(); 45 45 return; -
trunk/Source/WebCore/inspector/front-end/RemoteObject.js
r80141 r80338 134 134 { 135 135 if (this._objectId) 136 DOMAgent.pushNodeToFrontend(this._objectId, callback);136 WebInspector.domAgent.pushNodeToFrontend(this._objectId, callback); 137 137 else 138 138 callback(0);
Note: See TracChangeset
for help on using the changeset viewer.