|
Lines 36-41
Source/WebCore/css/ElementRuleCollector.cpp_sec1
|
| 36 |
#include "CSSSelectorList.h" |
36 |
#include "CSSSelectorList.h" |
| 37 |
#include "CSSValueKeywords.h" |
37 |
#include "CSSValueKeywords.h" |
| 38 |
#include "HTMLElement.h" |
38 |
#include "HTMLElement.h" |
|
|
39 |
#include "HTMLSlotElement.h" |
| 39 |
#include "InspectorInstrumentation.h" |
40 |
#include "InspectorInstrumentation.h" |
| 40 |
#include "NodeRenderStyle.h" |
41 |
#include "NodeRenderStyle.h" |
| 41 |
#include "RenderRegion.h" |
42 |
#include "RenderRegion.h" |
|
Lines 206-211
void ElementRuleCollector::matchAuthorRu
Source/WebCore/css/ElementRuleCollector.cpp_sec2
|
| 206 |
#if ENABLE(SHADOW_DOM) |
207 |
#if ENABLE(SHADOW_DOM) |
| 207 |
if (m_element.shadowRoot()) |
208 |
if (m_element.shadowRoot()) |
| 208 |
matchHostPseudoClassRules(includeEmptyRules); |
209 |
matchHostPseudoClassRules(includeEmptyRules); |
|
|
210 |
|
| 211 |
if (m_element.parentNode()->shadowRoot()) |
| 212 |
matchSlottedPseudoElementRules(includeEmptyRules); |
| 209 |
#endif |
213 |
#endif |
| 210 |
|
214 |
|
| 211 |
clearMatchedRules(); |
215 |
clearMatchedRules(); |
|
Lines 241-246
void ElementRuleCollector::matchHostPseu
Source/WebCore/css/ElementRuleCollector.cpp_sec3
|
| 241 |
// FIXME: Match the spec when it is finalized. |
245 |
// FIXME: Match the spec when it is finalized. |
| 242 |
sortAndTransferMatchedRules(); |
246 |
sortAndTransferMatchedRules(); |
| 243 |
} |
247 |
} |
|
|
248 |
|
| 249 |
void ElementRuleCollector::matchSlottedPseudoElementRules(bool includeEmptyRules) |
| 250 |
{ |
| 251 |
auto* hostShadowRoot = m_element.parentNode()->shadowRoot(); |
| 252 |
ASSERT(hostShadowRoot); |
| 253 |
auto* slot = hostShadowRoot->findAssignedSlot(m_element); |
| 254 |
if (!slot) |
| 255 |
return; |
| 256 |
auto* shadowAuthorStyle = hostShadowRoot->styleResolver().ruleSets().authorStyle(); |
| 257 |
if (!shadowAuthorStyle) |
| 258 |
return; |
| 259 |
// Find out if there are any ::slotted rules in the shadow tree matching the current slot. |
| 260 |
// FIXME: This is really part of the slot style and could be cached when resolving it. |
| 261 |
ElementRuleCollector collector(*slot, *shadowAuthorStyle, nullptr); |
| 262 |
auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(includeEmptyRules); |
| 263 |
if (slottedPseudoElementRules.isEmpty()) |
| 264 |
return; |
| 265 |
|
| 266 |
TemporaryChange<bool> change(m_isMatchindSlottedPseudoElement, true); |
| 267 |
|
| 268 |
clearMatchedRules(); |
| 269 |
m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; |
| 270 |
auto ruleRange = m_result.ranges.authorRuleRange(); |
| 271 |
|
| 272 |
// Match in the current scope. |
| 273 |
MatchRequest matchRequest(nullptr, includeEmptyRules); |
| 274 |
collectMatchingRulesForList(&slottedPseudoElementRules, matchRequest, ruleRange); |
| 275 |
|
| 276 |
// FIXME: What is the correct order? |
| 277 |
sortAndTransferMatchedRules(); |
| 278 |
} |
| 279 |
|
| 280 |
RuleSet::RuleDataVector ElementRuleCollector::collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules) |
| 281 |
{ |
| 282 |
ASSERT(is<HTMLSlotElement>(m_element)); |
| 283 |
|
| 284 |
clearMatchedRules(); |
| 285 |
|
| 286 |
m_mode = SelectorChecker::Mode::CollectingRules; |
| 287 |
|
| 288 |
// Match global author rules. |
| 289 |
MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); |
| 290 |
StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); |
| 291 |
collectMatchingRulesForList(&m_authorStyle.slottedPseudoElementRules(), matchRequest, ruleRange); |
| 292 |
|
| 293 |
if (m_matchedRules.isEmpty()) |
| 294 |
return { }; |
| 295 |
|
| 296 |
RuleSet::RuleDataVector ruleDataVector; |
| 297 |
for (auto& matchedRule : m_matchedRules) |
| 298 |
ruleDataVector.append(*matchedRule.ruleData); |
| 299 |
return ruleDataVector; |
| 300 |
} |
| 244 |
#endif |
301 |
#endif |
| 245 |
|
302 |
|
| 246 |
void ElementRuleCollector::matchUserRules(bool includeEmptyRules) |
303 |
void ElementRuleCollector::matchUserRules(bool includeEmptyRules) |
|
Lines 284-289
void ElementRuleCollector::matchUARules(
Source/WebCore/css/ElementRuleCollector.cpp_sec4
|
| 284 |
sortAndTransferMatchedRules(); |
341 |
sortAndTransferMatchedRules(); |
| 285 |
} |
342 |
} |
| 286 |
|
343 |
|
|
|
344 |
#if ENABLE(SHADOW_DOM) |
| 345 |
static const CSSSelector* findSlottedPseudoElementSelector(const CSSSelector* selector) |
| 346 |
{ |
| 347 |
for (; selector; selector = selector->tagHistory()) { |
| 348 |
if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) { |
| 349 |
if (auto* list = selector->selectorList()) |
| 350 |
return list->first(); |
| 351 |
break; |
| 352 |
} |
| 353 |
}; |
| 354 |
return nullptr; |
| 355 |
} |
| 356 |
#endif |
| 357 |
|
| 287 |
inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, unsigned& specificity) |
358 |
inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, unsigned& specificity) |
| 288 |
{ |
359 |
{ |
| 289 |
// We know a sufficiently simple single part selector matches simply because we found it from the rule hash when filtering the RuleSet. |
360 |
// We know a sufficiently simple single part selector matches simply because we found it from the rule hash when filtering the RuleSet. |
|
Lines 356-364
inline bool ElementRuleCollector::ruleMa
Source/WebCore/css/ElementRuleCollector.cpp_sec5
|
| 356 |
} else |
427 |
} else |
| 357 |
#endif // ENABLE(CSS_SELECTOR_JIT) |
428 |
#endif // ENABLE(CSS_SELECTOR_JIT) |
| 358 |
{ |
429 |
{ |
|
|
430 |
auto* selector = ruleData.selector(); |
| 431 |
#if ENABLE(SHADOW_DOM) |
| 432 |
if (m_isMatchindSlottedPseudoElement) { |
| 433 |
selector = findSlottedPseudoElementSelector(ruleData.selector()); |
| 434 |
if (!selector) |
| 435 |
return false; |
| 436 |
} |
| 437 |
|
| 438 |
#endif |
| 359 |
// Slow path. |
439 |
// Slow path. |
| 360 |
SelectorChecker selectorChecker(m_element.document()); |
440 |
SelectorChecker selectorChecker(m_element.document()); |
| 361 |
selectorMatches = selectorChecker.match(*ruleData.selector(), m_element, context, specificity); |
441 |
selectorMatches = selectorChecker.match(*selector, m_element, context, specificity); |
| 362 |
} |
442 |
} |
| 363 |
|
443 |
|
| 364 |
commitStyleRelations(context.styleRelations); |
444 |
commitStyleRelations(context.styleRelations); |