Changeset 51601 in webkit
- Timestamp:
- Dec 2, 2009 10:32:08 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r51597 r51601 1 2009-12-02 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: DOM tree selection disappears upon page refresh. 6 7 https://bugs.webkit.org/show_bug.cgi?id=31142 8 9 * inspector/elements-panel-selection-on-refresh-expected.txt: Added. 10 * inspector/elements-panel-selection-on-refresh.html: Added. 11 1 12 2009-12-02 Csaba Osztrogonác <ossy@webkit.org> 2 13 -
trunk/WebCore/ChangeLog
r51600 r51601 1 2009-12-02 Pavel Feldman <pfeldman@dhcp-172-28-174-220.spb.corp.google.com> 2 3 Reviewed by Timothy Hatcher. 4 5 Web Inspector: DOM tree selection disappears upon page refresh. 6 7 https://bugs.webkit.org/show_bug.cgi?id=31142 8 9 Test: inspector/elements-panel-selection-on-refresh.html 10 11 * inspector/InjectedScriptHost.cpp: 12 (WebCore::InjectedScriptHost::pushNodeByPathToFrontend): 13 * inspector/InjectedScriptHost.h: 14 * inspector/InjectedScriptHost.idl: 15 * inspector/InspectorBackend.h: 16 * inspector/InspectorController.cpp: 17 (WebCore::InspectorController::close): 18 (WebCore::InspectorController::releaseDOMAgent): 19 (WebCore::InspectorController::resetScriptObjects): 20 * inspector/InspectorDOMAgent.cpp: 21 (WebCore::InspectorDOMAgent::~InspectorDOMAgent): 22 (WebCore::InspectorDOMAgent::reset): 23 (WebCore::InspectorDOMAgent::setDocument): 24 (WebCore::InspectorDOMAgent::pushDocumentToFrontend): 25 (WebCore::InspectorDOMAgent::nodeForPath): 26 (WebCore::InspectorDOMAgent::pushNodePathToFrontend): 27 * inspector/InspectorDOMAgent.h: 28 * inspector/front-end/DOMAgent.js: 29 (WebInspector.DOMNode.prototype._renumber): 30 (WebInspector.DOMAgent.prototype._setDocument): 31 * inspector/front-end/ElementsPanel.js: 32 (WebInspector.ElementsPanel.prototype.reset): 33 (WebInspector.ElementsPanel.prototype.setDocument.selectDefaultNode): 34 (WebInspector.ElementsPanel.prototype.setDocument.selectLastSelectedNode): 35 (WebInspector.ElementsPanel.prototype.setDocument): 36 * inspector/front-end/InjectedScript.js: 37 (InjectedScript.pushNodeByPathToFrontend): 38 * inspector/front-end/InjectedScriptAccess.js: 39 1 40 2009-12-01 Dave Hyatt <hyatt@apple.com> 2 41 -
trunk/WebCore/inspector/InjectedScriptHost.cpp
r51528 r51601 124 124 } 125 125 126 long InjectedScriptHost::pushNodeByPathToFrontend(const String& path) 127 { 128 InspectorDOMAgent* domAgent = inspectorDOMAgent(); 129 if (!domAgent) 130 return 0; 131 132 Node* node = domAgent->nodeForPath(path); 133 if (!node) 134 return 0; 135 136 return domAgent->pushNodePathToFrontend(node); 137 } 138 126 139 #if ENABLE(JAVASCRIPT_DEBUGGER) 127 140 JavaScriptCallFrame* InjectedScriptHost::currentCallFrame() const -
trunk/WebCore/inspector/InjectedScriptHost.h
r51528 r51601 64 64 ScriptValue unwrapObject(const String& objectId); 65 65 long pushNodePathToFrontend(Node* node, bool selectInUI); 66 66 67 void addNodesToSearchResult(const String& nodeIds); 68 long pushNodeByPathToFrontend(const String& path); 69 67 70 #if ENABLE(JAVASCRIPT_DEBUGGER) 68 71 JavaScriptCallFrame* currentCallFrame() const; -
trunk/WebCore/inspector/InjectedScriptHost.idl
r51528 r51601 42 42 [Custom] DOMObject unwrapObject(in long objectId); 43 43 [Custom] int pushNodePathToFrontend(in DOMObject node, in boolean selectInUI); 44 44 45 void addNodesToSearchResult(in DOMString nodeIds); 46 long pushNodeByPathToFrontend(in DOMString path); 45 47 46 48 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER -
trunk/WebCore/inspector/InspectorController.cpp
r51598 r51601 625 625 closeWindow(); 626 626 627 m_frontend.set(0);628 627 m_injectedScriptObj = ScriptObject(); 629 628 releaseDOMAgent(); 629 m_frontend.set(0); 630 630 m_timelineAgent = 0; 631 631 m_scriptState = 0; … … 665 665 // no references to the DOM agent from the DOM tree. 666 666 if (m_domAgent) 667 m_domAgent-> setDocument(0);667 m_domAgent->reset(); 668 668 m_domAgent = 0; 669 669 } … … 728 728 729 729 m_frontend->reset(); 730 m_domAgent-> setDocument(0);730 m_domAgent->reset(); 731 731 m_objectGroups.clear(); 732 732 m_idToWrappedObject.clear(); -
trunk/WebCore/inspector/InspectorDOMAgent.cpp
r51439 r51601 69 69 InspectorDOMAgent::~InspectorDOMAgent() 70 70 { 71 setDocument(0); 72 } 73 74 void InspectorDOMAgent::setDocument(Document* doc) 75 { 76 if (doc == mainFrameDocument()) 77 return; 71 reset(); 72 } 73 74 void InspectorDOMAgent::reset() 75 { 78 76 discardBindings(); 79 77 … … 83 81 84 82 ASSERT(!m_documents.size()); 83 } 84 85 void InspectorDOMAgent::setDocument(Document* doc) 86 { 87 if (doc == mainFrameDocument()) 88 return; 89 90 reset(); 85 91 86 92 if (doc) { 87 93 startListening(doc); 88 if (doc->documentElement()) {94 if (doc->documentElement()) 89 95 pushDocumentToFrontend(); 90 }91 }96 } else 97 m_frontend->setDocument(ScriptObject()); 92 98 } 93 99 … … 240 246 } 241 247 242 voidInspectorDOMAgent::pushDocumentToFrontend()248 bool InspectorDOMAgent::pushDocumentToFrontend() 243 249 { 244 250 Document* document = mainFrameDocument(); 251 if (!document) 252 return false; 245 253 if (!m_documentNodeToIdMap.contains(document)) 246 254 m_frontend->setDocument(buildObjectForNode(document, 2, &m_documentNodeToIdMap)); 255 return true; 247 256 } 248 257 … … 280 289 } 281 290 291 Node* InspectorDOMAgent::nodeForPath(const String& path) 292 { 293 // The path is of form "1,HTML,2,BODY,1,DIV" 294 Node* node = mainFrameDocument(); 295 if (!node) 296 return 0; 297 298 Vector<String> pathTokens; 299 path.split(",", false, pathTokens); 300 for (size_t i = 0; i < pathTokens.size() - 1; i += 2) { 301 bool success = true; 302 unsigned childNumber = pathTokens[i].toUInt(&success); 303 if (!success) 304 return 0; 305 if (childNumber >= innerChildNodeCount(node)) 306 return 0; 307 308 Node* child = innerFirstChild(node); 309 String childName = pathTokens[i + 1]; 310 for (size_t j = 0; child && j < childNumber; ++j) 311 child = innerNextSibling(child); 312 313 if (!child || child->nodeName() != childName) 314 return 0; 315 node = child; 316 } 317 return node; 318 } 319 282 320 void InspectorDOMAgent::getChildNodes(long callId, long nodeId) 283 321 { … … 291 329 292 330 // If we are sending information to the client that is currently being created. Send root node first. 293 pushDocumentToFrontend(); 331 if (!pushDocumentToFrontend()) 332 return 0; 294 333 295 334 // Return id in case the node is known. … … 571 610 } 572 611 573 intInspectorDOMAgent::innerChildNodeCount(Node* node)574 { 575 intcount = 0;612 unsigned InspectorDOMAgent::innerChildNodeCount(Node* node) 613 { 614 unsigned count = 0; 576 615 Node* child = innerFirstChild(node); 577 616 while (child) { -
trunk/WebCore/inspector/InspectorDOMAgent.h
r49950 r51601 84 84 ~InspectorDOMAgent(); 85 85 86 void reset(); 87 86 88 virtual bool operator==(const EventListener& other); 87 89 … … 98 100 99 101 Node* nodeForId(long nodeId); 102 Node* nodeForPath(const String& path); 100 103 long pushNodePathToFrontend(Node* node); 101 104 … … 110 113 void unbind(Node* node, NodeToIdMap* nodesMap); 111 114 112 voidpushDocumentToFrontend();115 bool pushDocumentToFrontend(); 113 116 void pushChildNodesToFrontend(long nodeId); 114 117 … … 124 127 Node* innerNextSibling(Node* node); 125 128 Node* innerPreviousSibling(Node* node); 126 intinnerChildNodeCount(Node* node);129 unsigned innerChildNodeCount(Node* node); 127 130 Node* innerParentNode(Node* node); 128 131 bool isWhitespace(Node* node); -
trunk/WebCore/inspector/front-end/DOMAgent.js
r51528 r51601 180 180 for (var i = 0; i < this._childNodeCount; ++i) { 181 181 var child = this.children[i]; 182 child.index = i; 182 183 child.nextSibling = i + 1 < this._childNodeCount ? this.children[i + 1] : null; 183 184 child.prevSibling = i - 1 >= 0 ? this.children[i - 1] : null; … … 374 375 { 375 376 this._idToDOMNode = {}; 376 if (payload ) {377 if (payload && "id" in payload) { 377 378 this.document = new WebInspector.DOMDocument(this, this._window, payload); 378 379 this._idToDOMNode[payload.id] = this.document; … … 380 381 } else 381 382 this.document = null; 382 WebInspector.panels.elements. reset();383 WebInspector.panels.elements.setDocument(this.document); 383 384 }, 384 385 -
trunk/WebCore/inspector/front-end/ElementsPanel.js
r51528 r51601 165 165 reset: function() 166 166 { 167 if (this.focusedDOMNode) { 168 this._selectedPathOnReset = []; 169 var node = this.focusedDOMNode; 170 while ("index" in node) { 171 this._selectedPathOnReset.push(node.nodeName); 172 this._selectedPathOnReset.push(node.index); 173 node = node.parentNode; 174 } 175 this._selectedPathOnReset.reverse(); 176 } 177 167 178 this.rootDOMNode = null; 168 179 this.focusedDOMNode = null; … … 179 190 delete this.currentQuery; 180 191 this.searchCanceled(); 181 182 var domWindow = WebInspector.domAgent.domWindow; 183 if (!domWindow || !domWindow.document || !domWindow.document.firstChild) 184 return; 185 186 var inspectedRootDocument = domWindow.document; 192 }, 193 194 setDocument: function(inspectedRootDocument) 195 { 196 this.reset(); 197 198 if (!inspectedRootDocument) 199 return; 200 187 201 inspectedRootDocument.addEventListener("DOMNodeInserted", this._nodeInserted.bind(this)); 188 202 inspectedRootDocument.addEventListener("DOMNodeRemoved", this._nodeRemoved.bind(this)); … … 190 204 this.treeOutline.suppressSelectHighlight = true; 191 205 this.rootDOMNode = inspectedRootDocument; 192 193 var canidateFocusNode = inspectedRootDocument.body || inspectedRootDocument.documentElement;194 if (canidateFocusNode) {195 this.focusedDOMNode = canidateFocusNode;196 197 if (this.treeOutline.selectedTreeElement)198 this.treeOutline.selectedTreeElement.expand();199 }200 206 this.treeOutline.suppressSelectHighlight = false; 207 208 function selectDefaultNode() 209 { 210 this.treeOutline.suppressSelectHighlight = true; 211 var candidateFocusNode = inspectedRootDocument.body || inspectedRootDocument.documentElement; 212 if (candidateFocusNode) { 213 this.focusedDOMNode = candidateFocusNode; 214 215 if (this.treeOutline.selectedTreeElement) 216 this.treeOutline.selectedTreeElement.expand(); 217 } 218 } 219 220 function selectLastSelectedNode(nodeId) 221 { 222 var node = nodeId ? WebInspector.domAgent.nodeForId(nodeId) : 0; 223 if (!node) { 224 selectDefaultNode.call(this); 225 return; 226 } 227 228 this.treeOutline.suppressSelectHighlight = true; 229 this.focusedDOMNode = node; 230 this.treeOutline.suppressSelectHighlight = false; 231 } 232 233 if (this._selectedPathOnReset) 234 InjectedScriptAccess.nodeByPath(this._selectedPathOnReset, selectLastSelectedNode.bind(this)); 235 else 236 selectDefaultNode.call(this); 237 delete this._selectedPathOnReset; 201 238 }, 202 239 -
trunk/WebCore/inspector/front-end/InjectedScript.js
r51528 r51601 1051 1051 } 1052 1052 1053 InjectedScript.nodeByPath = function(path) 1054 { 1055 // We make this call through the injected script only to get a nice 1056 // callback for it. 1057 return InjectedScriptHost.pushNodeByPathToFrontend(path.join(",")); 1058 } 1059 1053 1060 // Called from within InspectorController on the 'inspected page' side. 1054 1061 InjectedScript.createProxyObject = function(object, objectId, abbreviate) -
trunk/WebCore/inspector/front-end/InjectedScriptAccess.js
r51528 r51601 71 71 InjectedScriptAccess._installHandler("performSearch"); 72 72 InjectedScriptAccess._installHandler("pushNodeToFrontend"); 73 InjectedScriptAccess._installHandler("nodeByPath"); 73 74 InjectedScriptAccess._installHandler("searchCanceled"); 74 75 InjectedScriptAccess._installHandler("setPropertyValue");
Note: See TracChangeset
for help on using the changeset viewer.