Changeset 29849 in webkit
- Timestamp:
- Jan 29, 2008, 1:35:07 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r29847 r29849 1 2008-01-29 Adam Roben <aroben@apple.com> 2 3 Fix Bug 16234: Inspector should support searching for elements by CSS selectors 4 5 <http://bugs.webkit.org/show_bugs.cgi?id=16234> 6 <rdar://5712862> 7 8 Reviewed by Tim. 9 10 * page/inspector/inspector.js: Use Document.querySelectorAll to search 11 for elements by CSS selector. Also store a custom property on nodes 12 being added to the search results to avoid showing the same node more 13 than once. 14 1 15 2008-01-29 Adam Roben <aroben@apple.com> 2 16 -
trunk/WebCore/page/inspector/inspector.js
r29179 r29849 870 870 871 871 var domResults = []; 872 const searchResultsProperty = "__includedInInspectorSearchResults"; 873 function addNodesToDOMResults(nodes, length, getItem) 874 { 875 for (var i = 0; i < length; ++i) { 876 var node = getItem(nodes, i); 877 if (searchResultsProperty in node) 878 continue; 879 node[searchResultsProperty] = true; 880 domResults.push(node); 881 } 882 } 883 884 function cleanUpDOMResultsNodes() 885 { 886 for (var i = 0; i < domResults.length; ++i) 887 delete domResults[i][searchResultsProperty]; 888 } 889 872 890 if (resource.category === this.resourceCategories.documents) { 891 var doc = resource.documentNode; 873 892 try { 874 var doc = resource.documentNode; 875 var nodeList = doc.evaluate(xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE); 876 for (var j = 0; j < nodeList.snapshotLength; ++j) 877 domResults.push(nodeList.snapshotItem(i)); 893 var result = doc.evaluate(xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE); 894 addNodesToDOMResults(result, result.snapshotLength, function(l, i) { return l.snapshotItem(i); }); 878 895 } catch(err) { 879 896 // ignore any exceptions. the query might be malformed, but we allow that. 880 897 } 898 899 var result = doc.querySelectorAll(query); 900 addNodesToDOMResults(result, result.length, function(l, i) { return l.item(i); }); 901 902 cleanUpDOMResultsNodes(); 881 903 } 882 904
Note:
See TracChangeset
for help on using the changeset viewer.