Changeset 252682 in webkit
- Timestamp:
- Nov 19, 2019 8:31:20 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r252366 r252682 1 2019-11-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM.highlightSelector should work for "div, div::before" 4 https://bugs.webkit.org/show_bug.cgi?id=204306 5 6 Reviewed by Brian Burg. 7 8 * ManualTests/inspector/overlay-selectors.html: Added. 9 1 10 2019-11-12 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 11 -
trunk/Source/WebCore/ChangeLog
r252681 r252682 1 2019-11-19 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM.highlightSelector should work for "div, div::before" 4 https://bugs.webkit.org/show_bug.cgi?id=204306 5 6 Reviewed by Brian Burg. 7 8 In r252436, the implementation of `DOM.highlightSelector` was changed from just calling 9 `document.querySelectorAll` to actually attempting to mimic what the CSS selector matching 10 engine does. Basically, this meant adding logic to walk the entire DOM tree and for each 11 node test each `CSSSelector` of the given `selector` string to see if it matched. 12 13 At the time, I had incorrectly assumed that once a selector was found that matched the 14 current node, it wouldn't need to be checked against ever again. This would be a fine 15 assumption if we didn't care about `:before`/`:after`, but since `DOM.highlightSelector` 16 also wants to match those, it is necessary to test every `CSSSelector` in case a later one 17 in the given `selector` string matches a pseudo-element (e.g. `div, div:before`). 18 19 The fix is simply to change `break` to `continue` and to ensure that every item in the 20 generated `NodeList` is unique (otherwise the overlay for a node may be drawn twice). 21 22 * inspector/agents/InspectorDOMAgent.cpp: 23 (WebCore::InspectorDOMAgent::highlightSelector): 24 1 25 2019-11-19 Youenn Fablet <youenn@apple.com> 2 26 -
trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
r252436 r252682 1261 1261 SelectorChecker selectorChecker(*document); 1262 1262 1263 Vector<Ref<Node>> nodes; 1263 Vector<Ref<Node>> nodeList; 1264 HashSet<Node*> seenNodes; 1264 1265 1265 1266 for (auto& descendant : composedTreeDescendants(*document)) { … … 1282 1283 unsigned ignoredSpecificity; 1283 1284 if (selectorChecker.match(*selector, descendantElement, context, ignoredSpecificity)) { 1284 nodes.append(descendantElement);1285 break;1285 if (seenNodes.add(&descendantElement)) 1286 nodeList.append(descendantElement); 1286 1287 } 1287 1288 … … 1291 1292 if (pseudoIDs.has(PseudoId::Before)) { 1292 1293 pseudoIDs.remove(PseudoId::Before); 1293 if (auto* beforePseudoElement = descendantElement.beforePseudoElement()) 1294 nodes.append(*beforePseudoElement); 1294 if (auto* beforePseudoElement = descendantElement.beforePseudoElement()) { 1295 if (seenNodes.add(beforePseudoElement)) 1296 nodeList.append(*beforePseudoElement); 1297 } 1295 1298 } 1296 1299 1297 1300 if (pseudoIDs.has(PseudoId::After)) { 1298 1301 pseudoIDs.remove(PseudoId::After); 1299 if (auto* afterPseudoElement = descendantElement.afterPseudoElement()) 1300 nodes.append(*afterPseudoElement); 1302 if (auto* afterPseudoElement = descendantElement.afterPseudoElement()) { 1303 if (seenNodes.add(afterPseudoElement)) 1304 nodeList.append(*afterPseudoElement); 1305 } 1301 1306 } 1302 1307 1303 1308 if (pseudoIDs) { 1304 nodes.append(descendantElement);1305 break;1309 if (seenNodes.add(&descendantElement)) 1310 nodeList.append(descendantElement); 1306 1311 } 1307 1312 } … … 1309 1314 } 1310 1315 1311 m_overlay->highlightNodeList(StaticNodeList::create(WTFMove(node s)), *highlightConfig);1316 m_overlay->highlightNodeList(StaticNodeList::create(WTFMove(nodeList)), *highlightConfig); 1312 1317 } 1313 1318
Note: See TracChangeset
for help on using the changeset viewer.