Changeset 243207 in webkit
- Timestamp:
- Mar 20, 2019, 9:21:37 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 14 edited
- 1 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/dom/dom-search-caseSensitive-expected.txt (copied) (copied from trunk/LayoutTests/inspector/dom/dom-search-expected.txt ) (3 diffs)
-
LayoutTests/inspector/dom/dom-search-caseSensitive.html (added)
-
LayoutTests/inspector/dom/dom-search-expected.txt (modified) (4 diffs)
-
LayoutTests/inspector/dom/resources/dom-search-queries.js (modified) (2 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/inspector/protocol/DOM.json (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/inspector/InspectorNodeFinder.cpp (modified) (6 diffs)
-
Source/WebCore/inspector/InspectorNodeFinder.h (modified) (2 diffs)
-
Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (modified) (1 diff)
-
Source/WebCore/inspector/agents/InspectorDOMAgent.h (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243201 r243207 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Search: allow DOM searches to be case sensitive 4 https://bugs.webkit.org/show_bug.cgi?id=194673 5 <rdar://problem/48087577> 6 7 Reviewed by Timothy Hatcher. 8 9 * inspector/dom/dom-search-caseSensitive.html: Copied from LayoutTests/inspector/dom/dom-search.html. 10 * inspector/dom/dom-search-caseSensitive-expected.txt: Copied from LayoutTests/inspector/dom/dom-search-expected.txt. 11 * inspector/dom/dom-search-expected.txt: 12 * inspector/dom/resources/dom-search-queries.js: 13 (TestPage.registerInitializer): 14 1 15 2019-03-20 Zalan Bujtas <zalan@apple.com> 2 16 -
trunk/LayoutTests/inspector/dom/dom-search-caseSensitive-expected.txt
r243206 r243207 7 7 body.inside-iframe 8 8 === Query: "<body" === 9 Count: 0 10 === Query: "body>" === 11 Count: 0 12 === Query: "<body>" === 13 Count: 0 14 === Query: "bOdY" === 9 15 Count: 2 10 16 body.main-frame 11 17 body.inside-iframe 12 === Query: "body>" === 18 === Query: "<bOdY" === 19 Count: 0 20 === Query: "bOdY>" === 21 Count: 0 22 === Query: "<bOdY>" === 23 Count: 0 24 === Query: "BODY" === 13 25 Count: 2 14 26 body.main-frame 15 27 body.inside-iframe 16 === Query: "<body>" === 28 === Query: "<BODY" === 29 Count: 2 30 body.main-frame 31 body.inside-iframe 32 === Query: "BODY>" === 17 33 Count: 2 18 34 body.main-frame … … 25 41 Count: 1 26 42 body.main-frame 43 === Query: "oNLoAd" === 44 Count: 0 27 45 === Query: "ONLOAD" === 28 Count: 1 29 body.main-frame 46 Count: 0 30 47 === Query: "runTest()" === 31 48 Count: 1 … … 34 51 Count: 1 35 52 body.main-frame 53 === Query: "runTest()\"" === 54 Count: 1 55 body.main-frame 36 56 === Query: "\"runTest()\"" === 37 57 Count: 1 38 58 body.main-frame 39 === Query: "runTest()\"" === 40 Count: 1 41 body.main-frame 59 === Query: "runtest()" === 60 Count: 0 61 === Query: "\"runtest()" === 62 Count: 0 63 === Query: "runtest()\"" === 64 Count: 0 65 === Query: "\"runtest()\"" === 66 Count: 0 67 === Query: "rUnTeSt()" === 68 Count: 0 69 === Query: "\"rUnTeSt()" === 70 Count: 0 71 === Query: "rUnTeSt()\"" === 72 Count: 0 73 === Query: "\"rUnTeSt()\"" === 74 Count: 0 42 75 === Query: "RUNTEST()" === 43 Count: 1 44 body.main-frame 45 === Query: "runtest()" === 46 Count: 1 47 body.main-frame 76 Count: 0 77 === Query: "\"RUNTEST()" === 78 Count: 0 79 === Query: "RUNTEST()\"" === 80 Count: 0 81 === Query: "\"RUNTEST()\"" === 82 Count: 0 48 83 === Query: ".body-inside-iframe" === 49 84 Count: 0 -
trunk/LayoutTests/inspector/dom/dom-search-expected.txt
r188598 r243207 18 18 body.main-frame 19 19 body.inside-iframe 20 === Query: "bOdY" === 21 Count: 2 22 body.main-frame 23 body.inside-iframe 24 === Query: "<bOdY" === 25 Count: 2 26 body.main-frame 27 body.inside-iframe 28 === Query: "bOdY>" === 29 Count: 2 30 body.main-frame 31 body.inside-iframe 32 === Query: "<bOdY>" === 33 Count: 2 34 body.main-frame 35 body.inside-iframe 36 === Query: "BODY" === 37 Count: 2 38 body.main-frame 39 body.inside-iframe 40 === Query: "<BODY" === 41 Count: 2 42 body.main-frame 43 body.inside-iframe 44 === Query: "BODY>" === 45 Count: 2 46 body.main-frame 47 body.inside-iframe 20 48 === Query: "<BODY>" === 21 49 Count: 2 … … 23 51 body.inside-iframe 24 52 === Query: "onload" === 53 Count: 1 54 body.main-frame 55 === Query: "oNLoAd" === 25 56 Count: 1 26 57 body.main-frame … … 34 65 Count: 1 35 66 body.main-frame 67 === Query: "runTest()\"" === 68 Count: 1 69 body.main-frame 36 70 === Query: "\"runTest()\"" === 37 71 Count: 1 38 72 body.main-frame 39 === Query: "runTest()\"" === 73 === Query: "runtest()" === 74 Count: 1 75 body.main-frame 76 === Query: "\"runtest()" === 77 Count: 1 78 body.main-frame 79 === Query: "runtest()\"" === 80 Count: 1 81 body.main-frame 82 === Query: "\"runtest()\"" === 83 Count: 1 84 body.main-frame 85 === Query: "rUnTeSt()" === 86 Count: 1 87 body.main-frame 88 === Query: "\"rUnTeSt()" === 89 Count: 1 90 body.main-frame 91 === Query: "rUnTeSt()\"" === 92 Count: 1 93 body.main-frame 94 === Query: "\"rUnTeSt()\"" === 40 95 Count: 1 41 96 body.main-frame … … 43 98 Count: 1 44 99 body.main-frame 45 === Query: "runtest()" === 100 === Query: "\"RUNTEST()" === 101 Count: 1 102 body.main-frame 103 === Query: "RUNTEST()\"" === 104 Count: 1 105 body.main-frame 106 === Query: "\"RUNTEST()\"" === 46 107 Count: 1 47 108 body.main-frame -
trunk/LayoutTests/inspector/dom/resources/dom-search-queries.js
r188639 r243207 4 4 5 5 window.domSearchQueries = [ 6 // Tag names 7 6 8 "body", 7 9 "<body", 8 10 "body>", 9 11 "<body>", 12 13 "bOdY", 14 "<bOdY", 15 "bOdY>", 16 "<bOdY>", 17 18 "BODY", 19 "<BODY", 20 "BODY>", 10 21 "<BODY>", 11 22 12 23 // Attribute names 24 13 25 "onload", 26 "oNLoAd", 14 27 "ONLOAD", 15 28 16 29 // Attribute values 30 17 31 "runTest()", 18 32 "\"runTest()", 33 "runTest()\"", 19 34 "\"runTest()\"", 20 "runTest()\"", 35 36 "runtest()", 37 "\"runtest()", 38 "runtest()\"", 39 "\"runtest()\"", 40 41 "rUnTeSt()", 42 "\"rUnTeSt()", 43 "rUnTeSt()\"", 44 "\"rUnTeSt()\"", 45 21 46 "RUNTEST()", 22 "runtest()", 47 "\"RUNTEST()", 48 "RUNTEST()\"", 49 "\"RUNTEST()\"", 23 50 24 51 // CSS selectors 52 25 53 ".body-inside-iframe", 26 54 "*", … … 28 56 29 57 // XPath query 58 30 59 "/html/body", 31 60 "/html/body/@onload", -
trunk/Source/JavaScriptCore/ChangeLog
r243206 r243207 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Search: allow DOM searches to be case sensitive 4 https://bugs.webkit.org/show_bug.cgi?id=194673 5 <rdar://problem/48087577> 6 7 Reviewed by Timothy Hatcher. 8 9 Since `DOM.performSearch` also searches by selector and XPath, some results may appear 10 as unexpected. As an example, searching for "BoDy" will still return the <body> as a result, 11 as although the literal node name ("BODY") didn't match, it did match via selector/XPath. 12 13 * inspector/protocol/DOM.json: 14 Allow `DOM.performSearch` to be case sensitive. 15 1 16 2019-03-20 Saam Barati <sbarati@apple.com> 2 17 -
trunk/Source/JavaScriptCore/inspector/protocol/DOM.json
r242386 r243207 360 360 "parameters": [ 361 361 { "name": "query", "type": "string", "description": "Plain text or query selector or XPath search query." }, 362 { "name": "nodeIds", "type": "array", "items": { "$ref": "NodeId" }, "optional": true, "description": "Ids of nodes to use as starting points for the search." } 362 { "name": "nodeIds", "type": "array", "items": { "$ref": "NodeId" }, "optional": true, "description": "Ids of nodes to use as starting points for the search." }, 363 { "name": "caseSensitive", "type": "boolean", "optional": true, "description": "If true, search is case sensitive." } 363 364 ], 364 365 "returns": [ -
trunk/Source/WebCore/ChangeLog
r243204 r243207 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Search: allow DOM searches to be case sensitive 4 https://bugs.webkit.org/show_bug.cgi?id=194673 5 <rdar://problem/48087577> 6 7 Reviewed by Timothy Hatcher. 8 9 Tests: inspector/dom/dom-search.html 10 inspector/dom/dom-search-caseSensitive.html 11 12 Since `DOM.performSearch` also searches by selector and XPath, some results may appear 13 as unexpected. As an example, searching for "BoDy" will still return the <body> as a result, 14 as although the literal node name ("BODY") didn't match, it did match via selector/XPath. 15 16 * inspector/agents/InspectorDOMAgent.h: 17 * inspector/agents/InspectorDOMAgent.cpp: 18 (WebCore::InspectorDOMAgent::performSearch): 19 20 * inspector/InspectorNodeFinder.h: 21 * inspector/InspectorNodeFinder.cpp: 22 (WebCore::InspectorNodeFinder::InspectorNodeFinder): 23 (WebCore::InspectorNodeFinder::searchUsingDOMTreeTraversal): 24 (WebCore::InspectorNodeFinder::checkEquals): Added. 25 (WebCore::InspectorNodeFinder::checkContains): Added. 26 (WebCore::InspectorNodeFinder::checkStartsWith): Added. 27 (WebCore::InspectorNodeFinder::checkEndsWith): Added. 28 (WebCore::InspectorNodeFinder::matchesAttribute): 29 (WebCore::InspectorNodeFinder::matchesElement): 30 (WebCore::InspectorNodeFinder::searchUsingXPath): 31 (WebCore::InspectorNodeFinder::searchUsingCSSSelectors): 32 1 33 2019-03-20 Michael Catanzaro <mcatanzaro@igalia.com> 2 34 -
trunk/Source/WebCore/inspector/InspectorNodeFinder.cpp
r225117 r243207 54 54 } 55 55 56 InspectorNodeFinder::InspectorNodeFinder(const String& whitespaceTrimmedQuery) 57 : m_whitespaceTrimmedQuery(whitespaceTrimmedQuery) 58 { 59 m_tagNameQuery = stripCharacters(whitespaceTrimmedQuery, '<', '>', m_startTagFound, m_endTagFound); 56 InspectorNodeFinder::InspectorNodeFinder(const String& query, bool caseSensitive) 57 : m_query(query) 58 , m_caseSensitive(caseSensitive) 59 { 60 m_tagNameQuery = stripCharacters(query, '<', '>', m_startTagFound, m_endTagFound); 60 61 61 62 bool startQuoteFound, endQuoteFound; 62 m_attributeQuery = stripCharacters( whitespaceTrimmedQuery, '"', '"', startQuoteFound, endQuoteFound);63 m_attributeQuery = stripCharacters(query, '"', '"', startQuoteFound, endQuoteFound); 63 64 m_exactAttributeMatch = startQuoteFound && endQuoteFound; 64 65 } … … 84 85 case Node::COMMENT_NODE: 85 86 case Node::CDATA_SECTION_NODE: 86 if ( node->nodeValue().containsIgnoringASCIICase(m_whitespaceTrimmedQuery))87 if (checkContains(node->nodeValue(), m_query)) 87 88 m_results.add(node); 88 89 break; … … 99 100 } 100 101 102 bool InspectorNodeFinder::checkEquals(const String& a, const String& b) 103 { 104 if (m_caseSensitive) 105 return a == b; 106 return equalIgnoringASCIICase(a, b); 107 } 108 109 bool InspectorNodeFinder::checkContains(const String& a, const String& b) 110 { 111 if (m_caseSensitive) 112 return a.contains(b); 113 return a.containsIgnoringASCIICase(b); 114 } 115 116 bool InspectorNodeFinder::checkStartsWith(const String& a, const String& b) 117 { 118 if (m_caseSensitive) 119 return a.startsWith(b); 120 return a.startsWithIgnoringASCIICase(b); 121 } 122 123 bool InspectorNodeFinder::checkEndsWith(const String& a, const String& b) 124 { 125 if (m_caseSensitive) 126 return a.endsWith(b); 127 return a.endsWithIgnoringASCIICase(b); 128 } 129 101 130 bool InspectorNodeFinder::matchesAttribute(const Attribute& attribute) 102 131 { 103 if ( attribute.localName().string().containsIgnoringASCIICase(m_whitespaceTrimmedQuery))132 if (checkContains(attribute.localName().string(), m_query)) 104 133 return true; 105 return m_exactAttributeMatch ? attribute.value() == m_attributeQuery : attribute.value().string().containsIgnoringASCIICase(m_attributeQuery); 134 135 auto value = attribute.value().string(); 136 return m_exactAttributeMatch ? checkEquals(value, m_attributeQuery) : checkContains(value, m_attributeQuery); 106 137 } 107 138 … … 109 140 { 110 141 String nodeName = element.nodeName(); 111 if ((!m_startTagFound && !m_endTagFound && nodeName.containsIgnoringASCIICase(m_tagNameQuery))112 || (m_startTagFound && m_endTagFound && equalIgnoringASCIICase(nodeName, m_tagNameQuery))113 || (m_startTagFound && !m_endTagFound && nodeName.startsWithIgnoringASCIICase(m_tagNameQuery))114 || (!m_startTagFound && m_endTagFound && nodeName.endsWithIgnoringASCIICase(m_tagNameQuery)))142 if ((!m_startTagFound && !m_endTagFound && checkContains(nodeName, m_tagNameQuery)) 143 || (m_startTagFound && m_endTagFound && checkEquals(nodeName, m_tagNameQuery)) 144 || (m_startTagFound && !m_endTagFound && checkStartsWith(nodeName, m_tagNameQuery)) 145 || (!m_startTagFound && m_endTagFound && checkEndsWith(nodeName, m_tagNameQuery))) 115 146 return true; 116 147 … … 128 159 void InspectorNodeFinder::searchUsingXPath(Node& parentNode) 129 160 { 130 auto evaluateResult = parentNode.document().evaluate(m_ whitespaceTrimmedQuery, &parentNode, nullptr, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE, nullptr);161 auto evaluateResult = parentNode.document().evaluate(m_query, &parentNode, nullptr, XPathResult::ORDERED_NODE_SNAPSHOT_TYPE, nullptr); 131 162 if (evaluateResult.hasException()) 132 163 return; … … 158 189 return; 159 190 160 auto queryResult = downcast<ContainerNode>(parentNode).querySelectorAll(m_ whitespaceTrimmedQuery);191 auto queryResult = downcast<ContainerNode>(parentNode).querySelectorAll(m_query); 161 192 if (queryResult.hasException()) 162 193 return; -
trunk/Source/WebCore/inspector/InspectorNodeFinder.h
r208145 r243207 42 42 class InspectorNodeFinder { 43 43 public: 44 InspectorNodeFinder(const String& whitespaceTrimmedQuery);44 InspectorNodeFinder(const String& query, bool caseSensitive); 45 45 void performSearch(Node*); 46 46 const ListHashSet<Node*>& results() const { return m_results; } 47 47 48 48 private: 49 bool checkEquals(const String&, const String&); 50 bool checkContains(const String&, const String&); 51 bool checkStartsWith(const String&, const String&); 52 bool checkEndsWith(const String&, const String&); 53 49 54 bool matchesAttribute(const Attribute&); 50 55 bool matchesElement(const Element&); … … 54 59 void searchUsingCSSSelectors(Node&); 55 60 61 String m_query; 62 String m_tagNameQuery; 63 String m_attributeQuery; 64 bool m_caseSensitive; 65 66 ListHashSet<Node*> m_results; 56 67 bool m_startTagFound; 57 68 bool m_endTagFound; 58 69 bool m_exactAttributeMatch; 59 60 String m_whitespaceTrimmedQuery;61 String m_tagNameQuery;62 String m_attributeQuery;63 64 ListHashSet<Node*> m_results;65 70 }; 66 71 -
trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
r243163 r243207 1006 1006 } 1007 1007 1008 void InspectorDOMAgent::performSearch(ErrorString& errorString, const String& whitespaceTrimmedQuery, const JSON::Array* nodeIds, String* searchId, int* resultCount)1008 void InspectorDOMAgent::performSearch(ErrorString& errorString, const String& query, const JSON::Array* nodeIds, const bool* caseSensitive, String* searchId, int* resultCount) 1009 1009 { 1010 1010 // FIXME: Search works with node granularity - number of matches within node is not calculated. 1011 InspectorNodeFinder finder( whitespaceTrimmedQuery);1011 InspectorNodeFinder finder(query, caseSensitive && *caseSensitive); 1012 1012 1013 1013 if (nodeIds) { -
trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h
r242386 r243207 135 135 void removeBreakpointForEventListener(ErrorString&, int eventListenerId) override; 136 136 void getAccessibilityPropertiesForNode(ErrorString&, int nodeId, RefPtr<Inspector::Protocol::DOM::AccessibilityProperties>& axProperties) override; 137 void performSearch(ErrorString&, const String& whitespaceTrimmedQuery, const JSON::Array* nodeIds, String* searchId, int* resultCount) override;137 void performSearch(ErrorString&, const String& query, const JSON::Array* nodeIds, const bool* caseSensitive, String* searchId, int* resultCount) override; 138 138 void getSearchResults(ErrorString&, const String& searchId, int fromIndex, int toIndex, RefPtr<JSON::ArrayOf<int>>&) override; 139 139 void discardSearchResults(ErrorString&, const String& searchId) override; -
trunk/Source/WebInspectorUI/ChangeLog
r243180 r243207 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Search: allow DOM searches to be case sensitive 4 https://bugs.webkit.org/show_bug.cgi?id=194673 5 <rdar://problem/48087577> 6 7 Reviewed by Timothy Hatcher. 8 9 * UserInterface/Views/SearchSidebarPanel.js: 10 (WI.SearchSidebarPanel.prototype.performSearch): 11 12 * UserInterface/Views/DOMTreeContentView.js: 13 (WI.DOMTreeContentView.prototype.performSearch.contextNodesReady): 14 15 * UserInterface/Controllers/DOMManager.js: 16 (WI.DOMManager.prototype.performSearch.callback): Deleted. 17 (WI.DOMManager.prototype.performSearch): Deleted. 18 (WI.DOMManager.prototype.searchResult.mycallback): Deleted. 19 (WI.DOMManager.prototype.searchResult): Deleted. 20 (WI.DOMManager.prototype.cancelSearch): Deleted. 21 Drive-by: remove unused code. 22 1 23 2019-03-19 Devin Rousso <drousso@apple.com> 2 24 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js
r241874 r243207 439 439 } 440 440 441 performSearch(query, searchCallback)442 {443 this.cancelSearch();444 445 function callback(error, searchId, resultsCount)446 {447 this._searchId = searchId;448 searchCallback(resultsCount);449 }450 DOMAgent.performSearch(query, callback.bind(this));451 }452 453 searchResult(index, callback)454 {455 function mycallback(error, nodeIds)456 {457 if (error) {458 console.error(error);459 callback(null);460 return;461 }462 if (nodeIds.length !== 1)463 return;464 465 callback(this._idToDOMNode[nodeIds[0]]);466 }467 468 if (this._searchId)469 DOMAgent.getSearchResults(this._searchId, index, index + 1, mycallback.bind(this));470 else471 callback(null);472 }473 474 cancelSearch()475 {476 if (this._searchId) {477 DOMAgent.discardSearchResults(this._searchId);478 this._searchId = undefined;479 }480 }481 482 441 querySelector(nodeOrNodeId, selector, callback) 483 442 { -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js
r242811 r243207 303 303 function contextNodesReady(nodeIds) 304 304 { 305 DOMAgent.performSearch(query, nodeIds, searchResultsReady.bind(this)); 305 if (this._searchQuery !== query) 306 return; 307 308 let commandArguments = { 309 query: this._searchQuery, 310 nodeIds, 311 caseSensitive: WI.SearchUtilities.defaultSettings.caseSensitive.value, 312 }; 313 DOMAgent.performSearch.invoke(commandArguments, searchResultsReady.bind(this)); 306 314 } 307 315 -
trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js
r242105 r243207 305 305 } 306 306 307 countPromise(DOMAgent.performSearch(searchQuery), domCallback); 307 let commandArguments = { 308 query: searchQuery, 309 caseSensitive: isCaseSensitive, 310 }; 311 countPromise(DOMAgent.performSearch.invoke(commandArguments), domCallback); 308 312 } 309 313
Note:
See TracChangeset
for help on using the changeset viewer.