Chromium Code Reviews| 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 var originalCallback = callback; | |
|
vsevik
2013/06/07 08:41:00
Unused.
pfeldman
2013/06/07 08:53:49
Done.
| |
| 5 callback = InspectorTest.safeWrap(callback); | 6 callback = InspectorTest.safeWrap(callback); |
| 6 var result = null; | 7 var result = null; |
| 7 var topLevelChildrenRequested = false; | |
| 8 var pendingRequests = 0; | 8 var pendingRequests = 0; |
| 9 function processChildren(topLevel, children) | 9 function processChildren(children) |
| 10 { | 10 { |
| 11 pendingRequests--; | 11 try { |
| 12 if (result) | 12 if (result) |
| 13 return; | 13 return; |
| 14 | 14 |
| 15 for (var i = 0; children && i < children.length; ++i) { | 15 for (var i = 0; children && i < children.length; ++i) { |
| 16 var childNode = children[i]; | 16 var childNode = children[i]; |
| 17 if (matchFunction(childNode)) { | 17 if (matchFunction(childNode)) { |
| 18 result = childNode; | 18 result = childNode; |
| 19 callback(result); | 19 callback(result); |
| 20 return; | 20 pendingRequests--; |
|
vsevik
2013/06/07 08:41:00
remove
pfeldman
2013/06/07 08:53:49
Done.
| |
| 21 return; | |
| 22 } | |
| 23 pendingRequests++; | |
| 24 childNode.getChildNodes(processChildren); | |
| 21 } | 25 } |
| 22 pendingRequests++; | 26 } finally { |
|
apavlov
2013/06/06 16:18:59
Curlies not necessary here? The new styleguide is
| |
| 23 childNode.getChildNodes(processChildren.bind(null, false)); | 27 pendingRequests--; |
| 24 } | 28 } |
| 25 | 29 |
| 26 if (topLevel) | 30 if (!result && !pendingRequests) { |
|
apavlov
2013/06/06 16:18:59
ditto
pfeldman
2013/06/07 08:53:49
Done.
| |
| 27 topLevelChildrenRequested = true; | |
| 28 if (topLevelChildrenRequested && !result && !pendingRequests) | |
| 29 callback(null); | 31 callback(null); |
| 32 } | |
| 30 } | 33 } |
| 31 pendingRequests++; | |
| 32 | 34 |
| 33 WebInspector.domAgent.requestDocument(documentRequested.bind(this)); | 35 WebInspector.domAgent.requestDocument(documentRequested.bind(this)); |
| 34 function documentRequested(doc) | 36 function documentRequested(doc) |
| 35 { | 37 { |
| 36 doc.getChildNodes(processChildren.bind(this, true)); | 38 pendingRequests++; |
| 39 doc.getChildNodes(processChildren); | |
| 37 } | 40 } |
| 38 }; | 41 }; |
| 39 | 42 |
| 40 InspectorTest.nodeWithId = function(idValue, callback) | 43 InspectorTest.nodeWithId = function(idValue, callback) |
| 41 { | 44 { |
| 42 function nodeIdMatches(node) | 45 function nodeIdMatches(node) |
| 43 { | 46 { |
| 44 return node.getAttribute("id") === idValue; | 47 return node.getAttribute("id") === idValue; |
| 45 } | 48 } |
| 46 InspectorTest.findNode(nodeIdMatches, callback); | 49 InspectorTest.findNode(nodeIdMatches, callback); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 { | 613 { |
| 611 var rectNames = ["margin", "border", "padding", "content"]; | 614 var rectNames = ["margin", "border", "padding", "content"]; |
| 612 var rects = window.internals.inspectorHighlightRects(document); | 615 var rects = window.internals.inspectorHighlightRects(document); |
| 613 for (var i = 0; i < rects.length; i++) | 616 for (var i = 0; i < rects.length; i++) |
| 614 { | 617 { |
| 615 var rectName = (i < rectNames.length ? rectNames[i] : "untitled"); | 618 var rectName = (i < rectNames.length ? rectNames[i] : "untitled"); |
| 616 var rect = rects.item(i); | 619 var rect = rects.item(i); |
| 617 output(rectName + " rect is " + rect.width + " x " + rect.height + " at (" + rect.left + ", " + rect.top + ")"); | 620 output(rectName + " rect is " + rect.width + " x " + rect.height + " at (" + rect.left + ", " + rect.top + ")"); |
| 618 } | 621 } |
| 619 } | 622 } |
| OLD | NEW |