|
Lines 73-84
static const StyleProperties& rightToLeftDeclaration()
a/Source/WebCore/style/ElementRuleCollector.cpp_sec1
|
| 73 |
|
73 |
|
| 74 |
class MatchRequest { |
74 |
class MatchRequest { |
| 75 |
public: |
75 |
public: |
| 76 |
MatchRequest(const RuleSet* ruleSet, ScopeOrdinal styleScopeOrdinal = ScopeOrdinal::Element) |
76 |
MatchRequest(const RuleSet& ruleSet, ScopeOrdinal styleScopeOrdinal = ScopeOrdinal::Element) |
| 77 |
: ruleSet(ruleSet) |
77 |
: ruleSet(ruleSet) |
| 78 |
, styleScopeOrdinal(styleScopeOrdinal) |
78 |
, styleScopeOrdinal(styleScopeOrdinal) |
| 79 |
{ |
79 |
{ |
| 80 |
} |
80 |
} |
| 81 |
const RuleSet* ruleSet; |
81 |
const RuleSet& ruleSet; |
| 82 |
ScopeOrdinal styleScopeOrdinal; |
82 |
ScopeOrdinal styleScopeOrdinal; |
| 83 |
}; |
83 |
}; |
| 84 |
|
84 |
|
|
Lines 114-120
const Vector<RefPtr<const StyleRule>>& ElementRuleCollector::matchedRuleList() c
a/Source/WebCore/style/ElementRuleCollector.cpp_sec2
|
| 114 |
|
114 |
|
| 115 |
inline void ElementRuleCollector::addMatchedRule(const RuleData& ruleData, unsigned specificity, const MatchRequest& matchRequest) |
115 |
inline void ElementRuleCollector::addMatchedRule(const RuleData& ruleData, unsigned specificity, const MatchRequest& matchRequest) |
| 116 |
{ |
116 |
{ |
| 117 |
auto cascadeLayerPriority = matchRequest.ruleSet ? matchRequest.ruleSet->cascadeLayerPriorityFor(ruleData) : RuleSet::cascadeLayerPriorityForUnlayered; |
117 |
auto cascadeLayerPriority = matchRequest.ruleSet.cascadeLayerPriorityFor(ruleData); |
| 118 |
m_matchedRules.append({ &ruleData, specificity, matchRequest.styleScopeOrdinal, cascadeLayerPriority }); |
118 |
m_matchedRules.append({ &ruleData, specificity, matchRequest.styleScopeOrdinal, cascadeLayerPriority }); |
| 119 |
} |
119 |
} |
| 120 |
|
120 |
|
|
Lines 139-145
inline void ElementRuleCollector::addElementStyleProperties(const StylePropertie
a/Source/WebCore/style/ElementRuleCollector.cpp_sec3
|
| 139 |
|
139 |
|
| 140 |
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest) |
140 |
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest) |
| 141 |
{ |
141 |
{ |
| 142 |
ASSERT(matchRequest.ruleSet); |
|
|
| 143 |
ASSERT_WITH_MESSAGE(!(m_mode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && m_pseudoElementRequest.pseudoId != PseudoId::None), "When in StyleInvalidation or SharingRules, SelectorChecker does not try to match the pseudo ID. While ElementRuleCollector supports matching a particular pseudoId in this case, this would indicate a error at the call site since matching a particular element should be unnecessary."); |
142 |
ASSERT_WITH_MESSAGE(!(m_mode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && m_pseudoElementRequest.pseudoId != PseudoId::None), "When in StyleInvalidation or SharingRules, SelectorChecker does not try to match the pseudo ID. While ElementRuleCollector supports matching a particular pseudoId in this case, this would indicate a error at the call site since matching a particular element should be unnecessary."); |
| 144 |
|
143 |
|
| 145 |
auto* shadowRoot = element().containingShadowRoot(); |
144 |
auto* shadowRoot = element().containingShadowRoot(); |
|
Lines 150-167
void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest
a/Source/WebCore/style/ElementRuleCollector.cpp_sec4
|
| 150 |
// then sort the buffer. |
149 |
// then sort the buffer. |
| 151 |
auto& id = element().idForStyleResolution(); |
150 |
auto& id = element().idForStyleResolution(); |
| 152 |
if (!id.isNull()) |
151 |
if (!id.isNull()) |
| 153 |
collectMatchingRulesForList(matchRequest.ruleSet->idRules(id), matchRequest); |
152 |
collectMatchingRulesForList(matchRequest.ruleSet.idRules(id), matchRequest); |
| 154 |
if (element().hasClass()) { |
153 |
if (element().hasClass()) { |
| 155 |
for (size_t i = 0; i < element().classNames().size(); ++i) |
154 |
for (size_t i = 0; i < element().classNames().size(); ++i) |
| 156 |
collectMatchingRulesForList(matchRequest.ruleSet->classRules(element().classNames()[i]), matchRequest); |
155 |
collectMatchingRulesForList(matchRequest.ruleSet.classRules(element().classNames()[i]), matchRequest); |
| 157 |
} |
156 |
} |
| 158 |
|
157 |
|
| 159 |
if (element().isLink()) |
158 |
if (element().isLink()) |
| 160 |
collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest); |
159 |
collectMatchingRulesForList(matchRequest.ruleSet.linkPseudoClassRules(), matchRequest); |
| 161 |
if (matchesFocusPseudoClass(element())) |
160 |
if (matchesFocusPseudoClass(element())) |
| 162 |
collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest); |
161 |
collectMatchingRulesForList(matchRequest.ruleSet.focusPseudoClassRules(), matchRequest); |
| 163 |
collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element().localName(), element().isHTMLElement() && element().document().isHTMLDocument()), matchRequest); |
162 |
collectMatchingRulesForList(matchRequest.ruleSet.tagRules(element().localName(), element().isHTMLElement() && element().document().isHTMLDocument()), matchRequest); |
| 164 |
collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest); |
163 |
collectMatchingRulesForList(matchRequest.ruleSet.universalRules(), matchRequest); |
| 165 |
} |
164 |
} |
| 166 |
|
165 |
|
| 167 |
|
166 |
|
|
Lines 234-240
bool ElementRuleCollector::matchesAnyAuthorRules()
a/Source/WebCore/style/ElementRuleCollector.cpp_sec5
|
| 234 |
void ElementRuleCollector::collectMatchingAuthorRules() |
233 |
void ElementRuleCollector::collectMatchingAuthorRules() |
| 235 |
{ |
234 |
{ |
| 236 |
{ |
235 |
{ |
| 237 |
MatchRequest matchRequest(m_authorStyle.ptr()); |
236 |
MatchRequest matchRequest(m_authorStyle); |
| 238 |
collectMatchingRules(matchRequest); |
237 |
collectMatchingRules(matchRequest); |
| 239 |
} |
238 |
} |
| 240 |
|
239 |
|
|
Lines 259-265
void ElementRuleCollector::matchAuthorShadowPseudoElementRules()
a/Source/WebCore/style/ElementRuleCollector.cpp_sec6
|
| 259 |
return; |
258 |
return; |
| 260 |
// Look up shadow pseudo elements also from the host scope author style as they are web-exposed. |
259 |
// Look up shadow pseudo elements also from the host scope author style as they are web-exposed. |
| 261 |
auto& hostAuthorRules = Scope::forNode(*shadowRoot.host()).resolver().ruleSets().authorStyle(); |
260 |
auto& hostAuthorRules = Scope::forNode(*shadowRoot.host()).resolver().ruleSets().authorStyle(); |
| 262 |
MatchRequest hostAuthorRequest { &hostAuthorRules, ScopeOrdinal::ContainingHost }; |
261 |
MatchRequest hostAuthorRequest { hostAuthorRules, ScopeOrdinal::ContainingHost }; |
| 263 |
collectMatchingShadowPseudoElementRules(hostAuthorRequest); |
262 |
collectMatchingShadowPseudoElementRules(hostAuthorRequest); |
| 264 |
} |
263 |
} |
| 265 |
|
264 |
|
|
Lines 272-278
void ElementRuleCollector::matchHostPseudoClassRules()
a/Source/WebCore/style/ElementRuleCollector.cpp_sec7
|
| 272 |
if (shadowHostRules.isEmpty()) |
271 |
if (shadowHostRules.isEmpty()) |
| 273 |
return; |
272 |
return; |
| 274 |
|
273 |
|
| 275 |
MatchRequest hostMatchRequest { nullptr, ScopeOrdinal::Shadow }; |
274 |
MatchRequest hostMatchRequest { shadowAuthorStyle, ScopeOrdinal::Shadow }; |
| 276 |
collectMatchingRulesForList(&shadowHostRules, hostMatchRequest); |
275 |
collectMatchingRulesForList(&shadowHostRules, hostMatchRequest); |
| 277 |
} |
276 |
} |
| 278 |
|
277 |
|
|
Lines 288-294
void ElementRuleCollector::matchSlottedPseudoElementRules()
a/Source/WebCore/style/ElementRuleCollector.cpp_sec8
|
| 288 |
|
287 |
|
| 289 |
auto& scopeAuthorRules = styleScope.resolver().ruleSets().authorStyle(); |
288 |
auto& scopeAuthorRules = styleScope.resolver().ruleSets().authorStyle(); |
| 290 |
|
289 |
|
| 291 |
MatchRequest scopeMatchRequest(&scopeAuthorRules, styleScopeOrdinal); |
290 |
MatchRequest scopeMatchRequest(scopeAuthorRules, styleScopeOrdinal); |
| 292 |
collectMatchingRulesForList(&scopeAuthorRules.slottedPseudoElementRules(), scopeMatchRequest); |
291 |
collectMatchingRulesForList(&scopeAuthorRules.slottedPseudoElementRules(), scopeMatchRequest); |
| 293 |
|
292 |
|
| 294 |
if (styleScopeOrdinal == ScopeOrdinal::SlotLimit) |
293 |
if (styleScopeOrdinal == ScopeOrdinal::SlotLimit) |
|
Lines 321-327
void ElementRuleCollector::matchPartPseudoElementRulesForScope(const Element& pa
a/Source/WebCore/style/ElementRuleCollector.cpp_sec9
|
| 321 |
|
320 |
|
| 322 |
auto& hostAuthorRules = styleScope.resolver().ruleSets().authorStyle(); |
321 |
auto& hostAuthorRules = styleScope.resolver().ruleSets().authorStyle(); |
| 323 |
|
322 |
|
| 324 |
MatchRequest scopeMatchRequest(&hostAuthorRules, styleScopeOrdinal); |
323 |
MatchRequest scopeMatchRequest(hostAuthorRules, styleScopeOrdinal); |
| 325 |
collectMatchingRulesForList(&hostAuthorRules.partPseudoElementRules(), scopeMatchRequest); |
324 |
collectMatchingRulesForList(&hostAuthorRules.partPseudoElementRules(), scopeMatchRequest); |
| 326 |
|
325 |
|
| 327 |
// Element may only be exposed to styling from enclosing scopes via exportparts attributes. |
326 |
// Element may only be exposed to styling from enclosing scopes via exportparts attributes. |
|
Lines 335-344
void ElementRuleCollector::matchPartPseudoElementRulesForScope(const Element& pa
a/Source/WebCore/style/ElementRuleCollector.cpp_sec10
|
| 335 |
|
334 |
|
| 336 |
void ElementRuleCollector::collectMatchingShadowPseudoElementRules(const MatchRequest& matchRequest) |
335 |
void ElementRuleCollector::collectMatchingShadowPseudoElementRules(const MatchRequest& matchRequest) |
| 337 |
{ |
336 |
{ |
| 338 |
ASSERT(matchRequest.ruleSet); |
|
|
| 339 |
ASSERT(element().containingShadowRoot()->mode() == ShadowRootMode::UserAgent); |
337 |
ASSERT(element().containingShadowRoot()->mode() == ShadowRootMode::UserAgent); |
| 340 |
|
338 |
|
| 341 |
auto& rules = *matchRequest.ruleSet; |
339 |
auto& rules = matchRequest.ruleSet; |
| 342 |
#if ENABLE(VIDEO) |
340 |
#if ENABLE(VIDEO) |
| 343 |
// FXIME: WebVTT should not be done by styling UA shadow trees like this. |
341 |
// FXIME: WebVTT should not be done by styling UA shadow trees like this. |
| 344 |
if (element().isWebVTTElement()) |
342 |
if (element().isWebVTTElement()) |
|
Lines 356-362
void ElementRuleCollector::matchUserRules()
a/Source/WebCore/style/ElementRuleCollector.cpp_sec11
|
| 356 |
|
354 |
|
| 357 |
clearMatchedRules(); |
355 |
clearMatchedRules(); |
| 358 |
|
356 |
|
| 359 |
MatchRequest matchRequest(m_userStyle.get()); |
357 |
MatchRequest matchRequest(*m_userStyle); |
| 360 |
collectMatchingRules(matchRequest); |
358 |
collectMatchingRules(matchRequest); |
| 361 |
|
359 |
|
| 362 |
sortAndTransferMatchedRules(DeclarationOrigin::User); |
360 |
sortAndTransferMatchedRules(DeclarationOrigin::User); |
|
Lines 381-387
void ElementRuleCollector::matchUARules(const RuleSet& rules)
a/Source/WebCore/style/ElementRuleCollector.cpp_sec12
|
| 381 |
{ |
379 |
{ |
| 382 |
clearMatchedRules(); |
380 |
clearMatchedRules(); |
| 383 |
|
381 |
|
| 384 |
collectMatchingRules(MatchRequest(&rules)); |
382 |
collectMatchingRules(MatchRequest(rules)); |
| 385 |
|
383 |
|
| 386 |
sortAndTransferMatchedRules(DeclarationOrigin::UserAgent); |
384 |
sortAndTransferMatchedRules(DeclarationOrigin::UserAgent); |
| 387 |
} |
385 |
} |
|
Lines 486-491
void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVe
a/Source/WebCore/style/ElementRuleCollector.cpp_sec13
|
| 486 |
if (m_selectorMatchingState && m_selectorMatchingState->selectorFilter.fastRejectSelector(ruleData.descendantSelectorIdentifierHashes())) |
484 |
if (m_selectorMatchingState && m_selectorMatchingState->selectorFilter.fastRejectSelector(ruleData.descendantSelectorIdentifierHashes())) |
| 487 |
continue; |
485 |
continue; |
| 488 |
|
486 |
|
|
|
487 |
if (auto* containerQuery = matchRequest.ruleSet.containerQueryFor(ruleData)) { |
| 488 |
if (!containerQueryMatches(*containerQuery)) |
| 489 |
continue; |
| 490 |
} |
| 491 |
|
| 489 |
auto& rule = ruleData.styleRule(); |
492 |
auto& rule = ruleData.styleRule(); |
| 490 |
|
493 |
|
| 491 |
// If the rule has no properties to apply, then ignore it in the non-debug mode. |
494 |
// If the rule has no properties to apply, then ignore it in the non-debug mode. |
|
Lines 501-506
void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVe
a/Source/WebCore/style/ElementRuleCollector.cpp_sec14
|
| 501 |
} |
504 |
} |
| 502 |
} |
505 |
} |
| 503 |
|
506 |
|
|
|
507 |
bool ElementRuleCollector::containerQueryMatches(const ContainerQuery&) |
| 508 |
{ |
| 509 |
if (!m_selectorMatchingState) |
| 510 |
return true; |
| 511 |
// FIXME: The actual matching. |
| 512 |
return !m_selectorMatchingState->queryContainers.isEmpty(); |
| 513 |
} |
| 514 |
|
| 504 |
static inline bool compareRules(MatchedRule r1, MatchedRule r2) |
515 |
static inline bool compareRules(MatchedRule r1, MatchedRule r2) |
| 505 |
{ |
516 |
{ |
| 506 |
// For normal properties the earlier scope wins. This may be reversed by !important which is handled when resolving cascade. |
517 |
// For normal properties the earlier scope wins. This may be reversed by !important which is handled when resolving cascade. |
|
Lines 578-584
void ElementRuleCollector::addElementInlineStyleProperties(bool includeSMILPrope
a/Source/WebCore/style/ElementRuleCollector.cpp_sec15
|
| 578 |
addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), false /* isCacheable */); |
589 |
addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), false /* isCacheable */); |
| 579 |
} |
590 |
} |
| 580 |
|
591 |
|
| 581 |
bool ElementRuleCollector::hasAnyMatchingRules(const RuleSet* ruleSet) |
592 |
bool ElementRuleCollector::hasAnyMatchingRules(const RuleSet& ruleSet) |
| 582 |
{ |
593 |
{ |
| 583 |
clearMatchedRules(); |
594 |
clearMatchedRules(); |
| 584 |
|
595 |
|