| OLD | NEW |
| 1 var initialize_ElementTest = function() { | 1 var initialize_ElementTest = function() { |
| 2 | 2 |
| 3 InspectorTest.findNode = function(matchFunction, callback) | 3 InspectorTest.findNode = function(matchFunction, callback) |
| 4 { | 4 { |
| 5 callback = InspectorTest.safeWrap(callback); | 5 callback = InspectorTest.safeWrap(callback); |
| 6 var result = null; | 6 var result = null; |
| 7 var topLevelChildrenRequested = false; | |
| 8 var pendingRequests = 0; | 7 var pendingRequests = 0; |
| 9 function processChildren(topLevel, children) | 8 function processChildren(node) |
| 10 { | 9 { |
| 11 pendingRequests--; | 10 try { |
| 12 if (result) | 11 if (result) |
| 13 return; | 12 return; |
| 14 | 13 |
| 15 for (var i = 0; children && i < children.length; ++i) { | 14 var children = (node.children() || []).concat(node.shadowRoots()); |
| 16 var childNode = children[i]; | 15 if (node.templateContent()) |
| 17 if (matchFunction(childNode)) { | 16 children.push(node.templateContent()); |
| 18 result = childNode; | 17 |
| 19 callback(result); | 18 for (var i = 0; i < children.length; ++i) { |
| 20 return; | 19 var childNode = children[i]; |
| 20 if (matchFunction(childNode)) { |
| 21 result = childNode; |
| 22 callback(result); |
| 23 return; |
| 24 } |
| 25 pendingRequests++; |
| 26 childNode.getChildNodes(processChildren.bind(null, childNode)); |
| 21 } | 27 } |
| 22 pendingRequests++; | 28 } finally { |
| 23 childNode.getChildNodes(processChildren.bind(null, false)); | 29 pendingRequests--; |
| 24 } | 30 } |
| 25 | 31 |
| 26 if (topLevel) | 32 if (!result && !pendingRequests) |
| 27 topLevelChildrenRequested = true; | |
| 28 if (topLevelChildrenRequested && !result && !pendingRequests) | |
| 29 callback(null); | 33 callback(null); |
| 30 } | 34 } |
| 31 pendingRequests++; | |
| 32 | 35 |
| 33 WebInspector.domAgent.requestDocument(documentRequested.bind(this)); | 36 WebInspector.domAgent.requestDocument(documentRequested.bind(this)); |
| 34 function documentRequested(doc) | 37 function documentRequested(doc) |
| 35 { | 38 { |
| 36 doc.getChildNodes(processChildren.bind(this, true)); | 39 pendingRequests++; |
| 40 doc.getChildNodes(processChildren.bind(null, doc)); |
| 37 } | 41 } |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 InspectorTest.nodeWithId = function(idValue, callback) | 44 InspectorTest.nodeWithId = function(idValue, callback) |
| 41 { | 45 { |
| 42 function nodeIdMatches(node) | 46 function nodeIdMatches(node) |
| 43 { | 47 { |
| 44 return node.getAttribute("id") === idValue; | 48 return node.getAttribute("id") === idValue; |
| 45 } | 49 } |
| 46 InspectorTest.findNode(nodeIdMatches, callback); | 50 InspectorTest.findNode(nodeIdMatches, callback); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 { | 614 { |
| 611 var rectNames = ["margin", "border", "padding", "content"]; | 615 var rectNames = ["margin", "border", "padding", "content"]; |
| 612 var rects = window.internals.inspectorHighlightRects(document); | 616 var rects = window.internals.inspectorHighlightRects(document); |
| 613 for (var i = 0; i < rects.length; i++) | 617 for (var i = 0; i < rects.length; i++) |
| 614 { | 618 { |
| 615 var rectName = (i < rectNames.length ? rectNames[i] : "untitled"); | 619 var rectName = (i < rectNames.length ? rectNames[i] : "untitled"); |
| 616 var rect = rects.item(i); | 620 var rect = rects.item(i); |
| 617 output(rectName + " rect is " + rect.width + " x " + rect.height + " at
(" + rect.left + ", " + rect.top + ")"); | 621 output(rectName + " rect is " + rect.width + " x " + rect.height + " at
(" + rect.left + ", " + rect.top + ")"); |
| 618 } | 622 } |
| 619 } | 623 } |
| OLD | NEW |