Changeset 207077 in webkit
- Timestamp:
- Oct 11, 2016, 3:24:07 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207058 r207077 1 2016-10-10 Antti Koivisto <antti@apple.com> 2 3 Stop copying author shadow pseudo rules into shadow tree style resolver 4 https://bugs.webkit.org/show_bug.cgi?id=163232 5 6 Reviewed by Darin Adler. 7 8 * css/ElementRuleCollector.cpp: 9 (WebCore::ElementRuleCollector::collectMatchingRules): 10 (WebCore::ElementRuleCollector::matchAuthorRules): 11 (WebCore::ElementRuleCollector::matchAuthorShadowPseudoElementRules): 12 13 If we are resolving a user agent shadow tree also look up pseudo element rules from the host scope author sheet. 14 This is needed to keep web exposed ::-webkit-foo pseudo elements working. 15 16 (WebCore::ElementRuleCollector::collectMatchingShadowPseudoElementRules): 17 18 Factor to a function. 19 20 * css/ElementRuleCollector.h: 21 * css/RuleSet.cpp: 22 (WebCore::RuleSet::copyShadowPseudoElementRulesFrom): Deleted. 23 * css/RuleSet.h: 24 * dom/Document.cpp: 25 (WebCore::Document::userAgentShadowTreeStyleResolver): 26 * style/StyleScope.cpp: 27 (WebCore::Style::Scope::updateStyleResolver): 28 29 No need to awkwardly copy these rules anymore. 30 1 31 2016-10-11 Chris Dumez <cdumez@apple.com> 2 32 -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r206951 r207077 144 144 ASSERT_WITH_MESSAGE(!(m_mode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && m_pseudoStyleRequest.pseudoId != NOPSEUDO), "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."); 145 145 146 #if ENABLE(VIDEO_TRACK)147 if (m_element.isWebVTTElement())148 collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange);149 #endif150 151 146 auto* shadowRoot = m_element.containingShadowRoot(); 152 if (shadowRoot && shadowRoot->mode() == ShadowRoot::Mode::UserAgent) { 153 const AtomicString& pseudoId = m_element.shadowPseudoId(); 154 if (!pseudoId.isEmpty()) 155 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); 156 } 147 if (shadowRoot && shadowRoot->mode() == ShadowRoot::Mode::UserAgent) 148 collectMatchingShadowPseudoElementRules(matchRequest, ruleRange); 157 149 158 150 // We need to collect the rules for id, class, tag, and everything else into a buffer and … … 227 219 matchHostPseudoClassRules(matchRequest, ruleRange); 228 220 221 if (m_element.isInShadowTree()) 222 matchAuthorShadowPseudoElementRules(matchRequest, ruleRange); 223 229 224 sortAndTransferMatchedRules(); 225 } 226 227 void ElementRuleCollector::matchAuthorShadowPseudoElementRules(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) 228 { 229 ASSERT(m_element.isInShadowTree()); 230 auto& shadowRoot = *m_element.containingShadowRoot(); 231 if (shadowRoot.mode() != ShadowRoot::Mode::UserAgent) 232 return; 233 // Look up shadow pseudo elements also from the host scope author style as they are web-exposed. 234 auto& hostAuthorRules = Style::Scope::forNode(*shadowRoot.host()).resolver().ruleSets().authorStyle(); 235 MatchRequest hostAuthorRequest { &hostAuthorRules, matchRequest.includeEmptyRules }; 236 collectMatchingShadowPseudoElementRules(hostAuthorRequest, ruleRange); 230 237 } 231 238 … … 283 290 m_keepAliveSlottedPseudoElementRules.append(WTFMove(slottedPseudoElementRules)); 284 291 } 292 } 293 294 void ElementRuleCollector::collectMatchingShadowPseudoElementRules(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) 295 { 296 ASSERT(matchRequest.ruleSet); 297 ASSERT(m_element.containingShadowRoot()->mode() == ShadowRoot::Mode::UserAgent); 298 299 auto& rules = *matchRequest.ruleSet; 300 #if ENABLE(VIDEO_TRACK) 301 // FXIME: WebVTT should not be done by styling UA shadow trees like this. 302 if (m_element.isWebVTTElement()) 303 collectMatchingRulesForList(rules.cuePseudoRules(), matchRequest, ruleRange); 304 #endif 305 auto& pseudoId = m_element.shadowPseudoId(); 306 if (!pseudoId.isEmpty()) 307 collectMatchingRulesForList(rules.shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); 285 308 } 286 309 -
trunk/Source/WebCore/css/ElementRuleCollector.h
r202091 r207077 77 77 78 78 void matchUARules(RuleSet*); 79 void matchAuthorShadowPseudoElementRules(const MatchRequest&, StyleResolver::RuleRange&); 79 80 void matchHostPseudoClassRules(MatchRequest&, StyleResolver::RuleRange&); 80 81 void matchSlottedPseudoElementRules(MatchRequest&, StyleResolver::RuleRange&); 82 83 void collectMatchingShadowPseudoElementRules(const MatchRequest&, StyleResolver::RuleRange&); 81 84 std::unique_ptr<RuleSet::RuleDataVector> collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules); 82 85 -
trunk/Source/WebCore/css/RuleSet.cpp
r202091 r207077 395 395 } 396 396 397 void RuleSet::copyShadowPseudoElementRulesFrom(const RuleSet& other)398 {399 for (auto& keyValuePair : other.m_shadowPseudoElementRules)400 m_shadowPseudoElementRules.add(keyValuePair.key, std::make_unique<RuleDataVector>(*keyValuePair.value));401 402 #if ENABLE(VIDEO_TRACK)403 // FIXME: We probably shouldn't treat WebVTT as author stylable user agent shadow tree.404 for (auto& cue : other.m_cuePseudoRules)405 m_cuePseudoRules.append(cue);406 #endif407 }408 409 397 static inline void shrinkMapVectorsToFit(RuleSet::AtomRuleMap& map) 410 398 { -
trunk/Source/WebCore/css/RuleSet.h
r204466 r207077 193 193 194 194 bool hasShadowPseudoElementRules() const; 195 void copyShadowPseudoElementRulesFrom(const RuleSet&);196 195 197 196 private: -
trunk/Source/WebCore/dom/Document.cpp
r206990 r207077 2145 2145 StyleResolver& Document::userAgentShadowTreeStyleResolver() 2146 2146 { 2147 if (!m_userAgentShadowTreeStyleResolver) {2147 if (!m_userAgentShadowTreeStyleResolver) 2148 2148 m_userAgentShadowTreeStyleResolver = std::make_unique<StyleResolver>(*this); 2149 2150 // FIXME: Filter out shadow pseudo elements we don't want to expose to authors.2151 auto& documentAuthorStyle = styleScope().resolver().ruleSets().authorStyle();2152 if (documentAuthorStyle.hasShadowPseudoElementRules())2153 m_userAgentShadowTreeStyleResolver->ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(documentAuthorStyle);2154 }2155 2156 2149 return *m_userAgentShadowTreeStyleResolver; 2157 2150 } -
trunk/Source/WebCore/style/StyleScope.cpp
r206990 r207077 405 405 styleResolver.appendAuthorStyleSheets(newStyleSheets); 406 406 } 407 408 if (!m_shadowRoot) {409 auto& userAgentShadowTreeStyleResolver = m_document.userAgentShadowTreeStyleResolver();410 userAgentShadowTreeStyleResolver.ruleSets().resetAuthorStyle();411 auto& authorRuleSet = styleResolver.ruleSets().authorStyle();412 if (authorRuleSet.hasShadowPseudoElementRules())413 userAgentShadowTreeStyleResolver.ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(authorRuleSet);414 }415 407 } 416 408
Note:
See TracChangeset
for help on using the changeset viewer.