Changeset 35315 in webkit
- Timestamp:
- Jul 23, 2008 7:48:01 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r35314 r35315 1 2008-07-22 Timothy Hatcher <timothy@apple.com> 2 3 Fix a regression where elements in subframes would not be revealed 4 or selected when inspected from the context menu. This was caused by 5 JavaScript equality is not being true for JSInspectedObjectWrappers 6 of the same node wrapped with different global ExecStates. This change 7 adds a helper function that uses isSameNode to compare wrapped nodes. 8 9 https://bugs.webkit.org/show_bug.cgi?id=19377 10 11 Reviewed by Adam Roben. 12 13 * page/inspector/ElementsPanel.js: 14 (WebInspector.ElementsPanel.prototype.set rootDOMNode): Use objectsAreSame 15 to compare nodes. 16 (WebInspector.ElementsPanel.prototype.set focusedDOMNode): Ditto. 17 (WebInspector.ElementsPanel.prototype.set hoveredDOMNode): Ditto. 18 (WebInspector.ElementsPanel.prototype._updateModifiedNodes): Ditto. 19 (WebInspector.ElementsPanel.prototype.revealNode): Ditto. 20 (WebInspector.ElementsPanel.prototype.updateBreadcrumb): Ditto. 21 (WebInspector.DOMNodeTreeElement.prototype.updateChildren): Ditto. 22 * page/inspector/treeoutline.js: 23 (TreeOutline.prototype.findTreeElement): Add an equal argument 24 to accept a functions to compare two representedObjects. Defaults 25 to strict equal if not supplied. All current clients pass objectsAreSame. 26 * page/inspector/utilities.js: 27 (Node.prototype.enclosingNodeOrSelfWithNodeNameInArray): Use objectsAreSame 28 to compare nodes. 29 (Node.prototype.enclosingNodeOrSelfWithClass): Ditto. 30 (Element.prototype.query): Use the ownerDocument of the node, not document. 31 (objectsAreSame): Added. Compares strict equal first, then uses isSameNode if 32 it exists on both objects. 33 (isAncestorNode): Use objectsAreSame to compare nodes. 34 (firstCommonNodeAncestor): Ditto. 35 (traverseNextNode): Ditto. 36 1 37 2008-07-21 Timothy Hatcher <timothy@apple.com> 2 38 -
trunk/WebCore/page/inspector/ElementsPanel.js
r34104 r35315 173 173 set rootDOMNode(x) 174 174 { 175 if ( this._rootDOMNode === x)175 if (objectsAreSame(this._rootDOMNode, x)) 176 176 return; 177 177 … … 189 189 set focusedDOMNode(x) 190 190 { 191 if ( this._focusedDOMNode === x) {191 if (objectsAreSame(this._focusedDOMNode, x)) { 192 192 var nodeItem = this.revealNode(x); 193 193 if (nodeItem) … … 212 212 set hoveredDOMNode(x) 213 213 { 214 if ( this._hoveredDOMNode === x)214 if (objectsAreSame(this._hoveredDOMNode, x)) 215 215 return; 216 216 … … 293 293 revealNode: function(node) 294 294 { 295 var nodeItem = this.treeOutline.findTreeElement(node, this._isAncestorIncludingParentFrames.bind(this), this._parentNodeOrFrameElement.bind(this) );295 var nodeItem = this.treeOutline.findTreeElement(node, this._isAncestorIncludingParentFrames.bind(this), this._parentNodeOrFrameElement.bind(this), objectsAreSame); 296 296 if (!nodeItem) 297 297 return; … … 329 329 var crumb = crumbs.firstChild; 330 330 while (crumb) { 331 if ( crumb.representedObject === this.rootDOMNode)331 if (objectsAreSame(crumb.representedObject, this.rootDOMNode)) 332 332 foundRoot = true; 333 333 … … 337 337 crumb.removeStyleClass("dimmed"); 338 338 339 if ( crumb.representedObject === this.focusedDOMNode) {339 if (objectsAreSame(crumb.representedObject, this.focusedDOMNode)) { 340 340 crumb.addStyleClass("selected"); 341 341 handled = true; … … 429 429 continue; 430 430 431 if ( current === this.rootDOMNode)431 if (objectsAreSame(current, this.rootDOMNode)) 432 432 foundRoot = true; 433 433 … … 514 514 if (foundRoot) 515 515 crumb.addStyleClass("dimmed"); 516 if ( current === this.focusedDOMNode)516 if (objectsAreSame(current, this.focusedDOMNode)) 517 517 crumb.addStyleClass("selected"); 518 518 if (!crumbs.childNodes.length) -
trunk/WebCore/page/inspector/treeoutline.js
r35313 r35315 246 246 } 247 247 248 TreeOutline.prototype.findTreeElement = function(representedObject, isAncestor, getParent )248 TreeOutline.prototype.findTreeElement = function(representedObject, isAncestor, getParent, equal) 249 249 { 250 250 if (!representedObject) 251 251 return null; 252 253 if (!equal) 254 equal = function(a, b) { return a === b }; 252 255 253 256 if ("__treeElementIdentifier" in representedObject) { … … 257 260 if (elements) { 258 261 for (var i = 0; i < elements.length; ++i) 259 if (e lements[i].representedObject === representedObject)262 if (equal(elements[i].representedObject, representedObject)) 260 263 return elements[i]; 261 264 } … … 271 274 for (var i = 0; i < this.children.length; ++i) { 272 275 item = this.children[i]; 273 if ( item.representedObject === representedObject|| isAncestor(item.representedObject, representedObject)) {276 if (equal(item.representedObject, representedObject) || isAncestor(item.representedObject, representedObject)) { 274 277 found = true; 275 278 break; … … 286 289 while (currentObject) { 287 290 ancestors.unshift(currentObject); 288 if ( currentObject === item.representedObject)291 if (equal(currentObject, item.representedObject)) 289 292 break; 290 293 currentObject = getParent(currentObject); … … 295 298 // Make sure we don't call findTreeElement with the same representedObject 296 299 // again, to prevent infinite recursion. 297 if ( ancestors[i] === representedObject)300 if (equal(ancestors[i], representedObject)) 298 301 continue; 299 302 // FIXME: we could do something faster than findTreeElement since we will know the next 300 303 // ancestor exists in the tree. 301 item = this.findTreeElement(ancestors[i], isAncestor, getParent );304 item = this.findTreeElement(ancestors[i], isAncestor, getParent, equal); 302 305 if (item && item.onpopulate) 303 306 item.onpopulate(item); … … 306 309 // Now that all the ancestors are populated, try to find the representedObject again. This time 307 310 // without the isAncestor and getParent functions to prevent an infinite recursion if it isn't found. 308 return this.findTreeElement(representedObject );311 return this.findTreeElement(representedObject, null, null, equal); 309 312 } 310 313 -
trunk/WebCore/page/inspector/utilities.js
r34211 r35315 136 136 Node.prototype.enclosingNodeOrSelfWithNodeNameInArray = function(nameArray) 137 137 { 138 for (var node = this; node && (node !== document); node = node.parentNode)138 for (var node = this; node && !objectsAreSame(node, this.ownerDocument); node = node.parentNode) 139 139 for (var i = 0; i < nameArray.length; ++i) 140 140 if (node.nodeName.toLowerCase() === nameArray[i].toLowerCase()) … … 150 150 Node.prototype.enclosingNodeOrSelfWithClass = function(className) 151 151 { 152 for (var node = this; node && (node !== document); node = node.parentNode)152 for (var node = this; node && !objectsAreSame(node, this.ownerDocument); node = node.parentNode) 153 153 if (node.nodeType === Node.ELEMENT_NODE && node.hasStyleClass(className)) 154 154 return node; … … 165 165 Element.prototype.query = function(query) 166 166 { 167 return document.evaluate(query, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;167 return this.ownerDocument.evaluate(query, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; 168 168 } 169 169 … … 492 492 } 493 493 494 function objectsAreSame(a, b) 495 { 496 // FIXME: Make this more generic so is works with any wrapped object, not just nodes. 497 // This function is used to compare nodes that might be JSInspectedObjectWrappers, since 498 // JavaScript equality is not true for JSInspectedObjectWrappers of the same node wrapped 499 // with different global ExecStates, we use isSameNode to compare them. 500 if (a === b) 501 return true; 502 if (!a || !b) 503 return false; 504 if (a.isSameNode && b.isSameNode) 505 return a.isSameNode(b); 506 return false; 507 } 508 494 509 function isAncestorNode(ancestor) 495 510 { … … 499 514 var currentNode = ancestor.parentNode; 500 515 while (currentNode) { 501 if ( this === currentNode)516 if (objectsAreSame(this, currentNode)) 502 517 return true; 503 518 currentNode = currentNode.parentNode; … … 520 535 var node2 = node.parentNode; 521 536 522 if ((!node1 || !node2) || node1 !== node2)537 if ((!node1 || !node2) || !objectsAreSame(node1, node2)) 523 538 return null; 524 539 … … 526 541 if (!node1.parentNode || !node2.parentNode) 527 542 break; 528 if ( node1 !== node2)543 if (!objectsAreSame(node1, node2)) 529 544 break; 530 545 … … 585 600 return node; 586 601 587 if (stayWithin && this === stayWithin)602 if (stayWithin && objectsAreSame(this, stayWithin)) 588 603 return null; 589 604 … … 593 608 594 609 node = this; 595 while (node && !(skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling) && (!stayWithin || !node.parentNode || node.parentNode !== stayWithin))610 while (node && !(skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling) && (!stayWithin || !node.parentNode || !objectsAreSame(node.parentNode, stayWithin))) 596 611 node = node.parentNode; 597 612 if (!node)
Note: See TracChangeset
for help on using the changeset viewer.