Changeset 252436 in webkit
- Timestamp:
- Nov 13, 2019 3:56:36 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252435 r252436 1 2019-11-13 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: DOM.highlightSelector should work for "a:visited" 4 https://bugs.webkit.org/show_bug.cgi?id=146161 5 <rdar://problem/21467303> 6 7 Reviewed by Antti Koivisto. 8 9 * inspector/agents/InspectorDOMAgent.cpp: 10 (WebCore::InspectorDOMAgent::highlightSelector): 11 Rather than use `document.querySelectorAll`, which doesn't match pseudo-selectors, attempt 12 to mimic how CSS actually matches nodes. 13 14 * rendering/style/RenderStyleConstants.h: 15 (WebCore::PseudoIdSet::remove): Added. 16 1 17 2019-11-13 Myles C. Maxfield <mmaxfield@apple.com> 2 18 -
trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp
r251871 r252436 36 36 #include "Attr.h" 37 37 #include "CSSComputedStyleDeclaration.h" 38 #include "CSSParser.h" 38 39 #include "CSSPropertyNames.h" 39 40 #include "CSSPropertySourceData.h" 40 41 #include "CSSRule.h" 41 42 #include "CSSRuleList.h" 43 #include "CSSSelector.h" 44 #include "CSSSelectorList.h" 42 45 #include "CSSStyleRule.h" 43 46 #include "CSSStyleSheet.h" 44 47 #include "CharacterData.h" 45 48 #include "CommandLineAPIHost.h" 49 #include "ComposedTreeIterator.h" 46 50 #include "ContainerNode.h" 47 51 #include "Cookie.h" … … 93 97 #include "RenderStyleConstants.h" 94 98 #include "ScriptState.h" 99 #include "SelectorChecker.h" 95 100 #include "ShadowRoot.h" 96 101 #include "StaticNodeList.h" … … 110 115 #include <JavaScriptCore/JSCInlines.h> 111 116 #include <pal/crypto/CryptoDigest.h> 117 #include <wtf/Function.h> 112 118 #include <wtf/text/Base64.h> 113 119 #include <wtf/text/CString.h> … … 1223 1229 void InspectorDOMAgent::highlightSelector(ErrorString& errorString, const JSON::Object& highlightInspectorObject, const String& selectorString, const String* frameId) 1224 1230 { 1231 auto highlightConfig = highlightConfigFromInspectorObject(errorString, &highlightInspectorObject); 1232 if (!highlightConfig) 1233 return; 1234 1225 1235 RefPtr<Document> document; 1226 1236 … … 1245 1255 } 1246 1256 1247 auto queryResult = document->querySelectorAll(selectorString); 1248 // FIXME: <https://webkit.org/b/146161> Web Inspector: DOM.highlightSelector should work for "a:visited" 1249 if (queryResult.hasException()) { 1250 errorString = "DOM Error while querying with given selectorString"_s; 1251 return; 1252 } 1253 1254 auto highlightConfig = highlightConfigFromInspectorObject(errorString, &highlightInspectorObject); 1255 if (!highlightConfig) 1256 return; 1257 1258 m_overlay->highlightNodeList(queryResult.releaseReturnValue(), *highlightConfig); 1257 CSSParser parser(*document); 1258 CSSSelectorList selectorList; 1259 parser.parseSelector(selectorString, selectorList); 1260 1261 SelectorChecker selectorChecker(*document); 1262 1263 Vector<Ref<Node>> nodes; 1264 1265 for (auto& descendant : composedTreeDescendants(*document)) { 1266 if (!is<Element>(descendant)) 1267 continue; 1268 1269 auto& descendantElement = downcast<Element>(descendant); 1270 1271 auto isInUserAgentShadowTree = descendantElement.isInUserAgentShadowTree(); 1272 auto pseudoId = descendantElement.pseudoId(); 1273 auto& pseudo = descendantElement.pseudo(); 1274 1275 for (const auto* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) { 1276 if (isInUserAgentShadowTree && (selector->match() != CSSSelector::PseudoElement || selector->value() != pseudo)) 1277 continue; 1278 1279 SelectorChecker::CheckingContext context(SelectorChecker::Mode::ResolvingStyle); 1280 context.pseudoId = pseudoId; 1281 1282 unsigned ignoredSpecificity; 1283 if (selectorChecker.match(*selector, descendantElement, context, ignoredSpecificity)) { 1284 nodes.append(descendantElement); 1285 break; 1286 } 1287 1288 if (context.pseudoIDSet) { 1289 auto pseudoIDs = PseudoIdSet::fromMask(context.pseudoIDSet.data()); 1290 1291 if (pseudoIDs.has(PseudoId::Before)) { 1292 pseudoIDs.remove(PseudoId::Before); 1293 if (auto* beforePseudoElement = descendantElement.beforePseudoElement()) 1294 nodes.append(*beforePseudoElement); 1295 } 1296 1297 if (pseudoIDs.has(PseudoId::After)) { 1298 pseudoIDs.remove(PseudoId::After); 1299 if (auto* afterPseudoElement = descendantElement.afterPseudoElement()) 1300 nodes.append(*afterPseudoElement); 1301 } 1302 1303 if (pseudoIDs) { 1304 nodes.append(descendantElement); 1305 break; 1306 } 1307 } 1308 } 1309 } 1310 1311 m_overlay->highlightNodeList(StaticNodeList::create(WTFMove(nodes)), *highlightConfig); 1259 1312 } 1260 1313 -
trunk/Source/WebCore/rendering/style/RenderStyleConstants.h
r252336 r252436 140 140 ASSERT((sizeof(m_data) * 8) > static_cast<unsigned>(pseudoId)); 141 141 m_data |= (1U << static_cast<unsigned>(pseudoId)); 142 } 143 144 void remove(PseudoId pseudoId) 145 { 146 ASSERT((sizeof(m_data) * 8) > static_cast<unsigned>(pseudoId)); 147 m_data &= ~(1U << static_cast<unsigned>(pseudoId)); 142 148 } 143 149
Note: See TracChangeset
for help on using the changeset viewer.