Changeset 190347 in webkit
- Timestamp:
- Sep 30, 2015, 8:39:15 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r190344 r190347 1 2015-09-29 Antti Koivisto <antti@apple.com> 2 3 Use separate style resolver for user agent shadow trees 4 https://bugs.webkit.org/show_bug.cgi?id=149626 5 6 Reviewed by Andreas Kling. 7 8 We now support separate style resolvers for shadow trees. Use this mechanism to have a separate 9 per-document style resolver for user agent shadow trees. This isolates user agent shadow trees 10 from author style better and simplifies the style resolver. It can also avoid some unnecessary style recalcs. 11 12 * css/DocumentRuleSets.cpp: 13 (WebCore::DocumentRuleSets::resetAuthorStyle): 14 (WebCore::DocumentRuleSets::appendAuthorStyleSheets): 15 16 Change interface so that only the new rules are provided. 17 18 * css/DocumentRuleSets.h: 19 * css/ElementRuleCollector.cpp: 20 (WebCore::ElementRuleCollector::addElementStyleProperties): 21 (WebCore::ElementRuleCollector::collectMatchingRules): 22 23 We can remove special bailout as shadow tree style resolver won't have other author style 24 25 (WebCore::ElementRuleCollector::sortAndTransferMatchedRules): 26 27 Remove the exception that disables property whitelists for UA stylesheets. We don't seem to use the feature. 28 29 (WebCore::ElementRuleCollector::matchUARules): 30 (WebCore::MatchingUARulesScope::MatchingUARulesScope): Deleted. 31 (WebCore::MatchingUARulesScope::~MatchingUARulesScope): Deleted. 32 (WebCore::MatchingUARulesScope::isMatchingUARules): Deleted. 33 34 Remove this unnecessary hack. 35 36 * css/ElementRuleCollector.h: 37 (WebCore::ElementRuleCollector::ElementRuleCollector): 38 * css/RuleSet.cpp: 39 (WebCore::RuleSet::addStyleRule): 40 (WebCore::RuleSet::copyShadowPseudoElementRulesFrom): 41 42 Also copy WebVTT rules. They are currently a sort of mixture of UA and author shadow tree. 43 44 (WebCore::shrinkMapVectorsToFit): 45 * css/RuleSet.h: 46 (WebCore::RuleData::containsUncommonAttributeSelector): 47 (WebCore::RuleData::linkMatchType): 48 (WebCore::RuleData::hasDocumentSecurityOrigin): 49 (WebCore::RuleData::propertyWhitelistType): 50 (WebCore::RuleData::descendantSelectorIdentifierHashes): 51 (WebCore::RuleSet::ruleCount): 52 (WebCore::RuleSet::hasShadowPseudoElementRules): 53 * css/StyleInvalidationAnalysis.cpp: 54 (WebCore::StyleInvalidationAnalysis::StyleInvalidationAnalysis): 55 (WebCore::StyleInvalidationAnalysis::invalidateIfNeeded): 56 57 Don't invalidate the whole tree when author shadow pseudo element rules change. Just invalidate the shadow trees. 58 59 (WebCore::StyleInvalidationAnalysis::invalidateStyleForTree): 60 (WebCore::StyleInvalidationAnalysis::invalidateStyle): 61 (WebCore::invalidateIfNeeded): Deleted. 62 (WebCore::invalidateStyleForTree): Deleted. 63 * css/StyleInvalidationAnalysis.h: 64 (WebCore::StyleInvalidationAnalysis::dirtiesAllStyle): 65 (WebCore::StyleInvalidationAnalysis::hasShadowPseudoElementRulesInAuthorSheet): 66 * css/StyleResolver.cpp: 67 (WebCore::StyleResolver::MatchResult::addMatchedProperties): 68 (WebCore::StyleResolver::StyleResolver): 69 (WebCore::StyleResolver::appendAuthorStyleSheets): 70 71 Simpler interface. 72 73 * css/StyleResolver.h: 74 (WebCore::StyleResolver::document): 75 (WebCore::StyleResolver::documentSettings): 76 (WebCore::StyleResolver::ruleSets): 77 * dom/AuthorStyleSheets.cpp: 78 (WebCore::AuthorStyleSheets::collectActiveStyleSheets): 79 (WebCore::AuthorStyleSheets::analyzeStyleSheetChange): 80 81 Cleanups. 82 83 (WebCore::filterEnabledNonemptyCSSStyleSheets): 84 (WebCore::AuthorStyleSheets::updateActiveStyleSheets): 85 (WebCore::AuthorStyleSheets::updateStyleResolver): 86 87 Factor to a function. 88 Copy any author shadow pseudo elements to user agent shadow tree resolver. 89 90 (WebCore::AuthorStyleSheets::activeStyleSheetsForInspector): 91 * dom/AuthorStyleSheets.h: 92 * dom/Document.cpp: 93 (WebCore::Document::createStyleResolver): 94 (WebCore::Document::userAgentShadowTreeStyleResolver): 95 96 Use separate resolver. 97 98 (WebCore::Document::fontsNeedUpdate): 99 (WebCore::Document::clearStyleResolver): 100 * dom/Document.h: 101 (WebCore::Document::ensureStyleResolver): 102 * dom/ShadowRoot.cpp: 103 (WebCore::ShadowRoot::styleResolver): 104 105 Return document-global shadow tree resolver for ua trees. 106 107 * style/StyleResolveTree.cpp: 108 (WebCore::Style::resolveShadowTree): 109 110 Take styleChange of shadow root into account. 111 1 112 2015-09-30 Gwang Yoon Hwang <yoon@igalia.com> 2 113 -
trunk/Source/WebCore/css/DocumentRuleSets.cpp
r190169 r190347 84 84 } 85 85 86 void DocumentRuleSets::appendAuthorStyleSheets( unsigned firstNew,const Vector<RefPtr<CSSStyleSheet>>& styleSheets, MediaQueryEvaluator* medium, InspectorCSSOMWrappers& inspectorCSSOMWrappers, StyleResolver* resolver)86 void DocumentRuleSets::appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>& styleSheets, MediaQueryEvaluator* medium, InspectorCSSOMWrappers& inspectorCSSOMWrappers, StyleResolver* resolver) 87 87 { 88 88 // This handles sheets added to the end of the stylesheet list only. In other cases the style resolver 89 89 // needs to be reconstructed. To handle insertions too the rule order numbers would need to be updated. 90 unsigned size = styleSheets.size(); 91 for (unsigned i = firstNew; i < size; ++i) { 92 CSSStyleSheet* cssSheet = styleSheets[i].get(); 90 for (auto& cssSheet : styleSheets) { 93 91 ASSERT(!cssSheet->disabled()); 94 92 if (cssSheet->mediaQueries() && !medium->eval(cssSheet->mediaQueries(), resolver)) 95 93 continue; 96 94 m_authorStyle->addRulesFromSheet(&cssSheet->contents(), *medium, resolver); 97 inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet );95 inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet.get()); 98 96 } 99 97 m_authorStyle->shrinkToFit(); -
trunk/Source/WebCore/css/DocumentRuleSets.h
r190171 r190347 52 52 void initUserStyle(ExtensionStyleSheets&, const MediaQueryEvaluator&, StyleResolver&); 53 53 void resetAuthorStyle(); 54 void appendAuthorStyleSheets( unsigned firstNew,const Vector<RefPtr<CSSStyleSheet>>&, MediaQueryEvaluator*, InspectorCSSOMWrappers&, StyleResolver*);54 void appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>&, MediaQueryEvaluator*, InspectorCSSOMWrappers&, StyleResolver*); 55 55 56 56 void collectFeatures(); -
trunk/Source/WebCore/css/ElementRuleCollector.cpp
r190256 r190347 114 114 } 115 115 116 class MatchingUARulesScope {117 public:118 MatchingUARulesScope();119 ~MatchingUARulesScope();120 121 static bool isMatchingUARules();122 123 private:124 static bool m_matchingUARules;125 };126 127 MatchingUARulesScope::MatchingUARulesScope()128 {129 ASSERT(!m_matchingUARules);130 m_matchingUARules = true;131 }132 133 MatchingUARulesScope::~MatchingUARulesScope()134 {135 m_matchingUARules = false;136 }137 138 inline bool MatchingUARulesScope::isMatchingUARules()139 {140 return m_matchingUARules;141 }142 143 bool MatchingUARulesScope::m_matchingUARules = false;144 145 116 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange) 146 117 { … … 159 130 if (!pseudoId.isEmpty()) 160 131 collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange); 161 162 // Only match UA rules in shadow tree.163 if (!MatchingUARulesScope::isMatchingUARules())164 return;165 132 } 166 133 … … 216 183 if (m_style && matchedRule.ruleData->containsUncommonAttributeSelector()) 217 184 m_style->setUnique(); 218 m_result.addMatchedProperties(matchedRule.ruleData->rule()->properties(), matchedRule.ruleData->rule(), matchedRule.ruleData->linkMatchType(), matchedRule.ruleData->propertyWhitelistType( MatchingUARulesScope::isMatchingUARules()));185 m_result.addMatchedProperties(matchedRule.ruleData->rule()->properties(), matchedRule.ruleData->rule(), matchedRule.ruleData->linkMatchType(), matchedRule.ruleData->propertyWhitelistType()); 219 186 } 220 187 } … … 252 219 void ElementRuleCollector::matchUARules() 253 220 { 254 MatchingUARulesScope scope;255 256 221 // First we match rules from the user agent sheet. 257 222 if (CSSDefaultStyleSheets::simpleDefaultStyleSheet) -
trunk/Source/WebCore/css/ElementRuleCollector.h
r178580 r190347 51 51 , m_ruleSets(ruleSets) 52 52 , m_selectorFilter(selectorFilter) 53 , m_isPrintStyle(false)54 , m_regionForStyling(nullptr)55 , m_pseudoStyleRequest(NOPSEUDO)56 , m_sameOriginOnly(false)57 , m_mode(SelectorChecker::Mode::ResolvingStyle)58 53 , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(element.parentNode())) 59 54 { … … 99 94 const SelectorFilter& m_selectorFilter; 100 95 101 bool m_isPrintStyle ;102 const RenderRegion* m_regionForStyling ;103 PseudoStyleRequest m_pseudoStyleRequest ;104 bool m_sameOriginOnly ;105 SelectorChecker::Mode m_mode ;96 bool m_isPrintStyle { false }; 97 const RenderRegion* m_regionForStyling { nullptr }; 98 PseudoStyleRequest m_pseudoStyleRequest { NOPSEUDO }; 99 bool m_sameOriginOnly { false }; 100 SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle }; 106 101 bool m_canUseFastReject; 107 102 -
trunk/Source/WebCore/css/RuleSet.cpp
r186388 r190347 378 378 } 379 379 380 bool RuleSet::hasShadowPseudoElementRules() const 381 { 382 if (!m_shadowPseudoElementRules.isEmpty()) 383 return true; 384 #if ENABLE(VIDEO_TRACK) 385 if (!m_cuePseudoRules.isEmpty()) 386 return true; 387 #endif 388 return false; 389 } 390 391 void RuleSet::copyShadowPseudoElementRulesFrom(const RuleSet& other) 392 { 393 for (auto& keyValuePair : other.m_shadowPseudoElementRules) 394 m_shadowPseudoElementRules.add(keyValuePair.key, std::make_unique<RuleDataVector>(*keyValuePair.value)); 395 396 #if ENABLE(VIDEO_TRACK) 397 // FIXME: We probably shouldn't treat WebVTT as author stylable user agent shadow tree. 398 for (auto& cue : other.m_cuePseudoRules) 399 m_cuePseudoRules.append(cue); 400 #endif 401 } 402 380 403 static inline void shrinkMapVectorsToFit(RuleSet::AtomRuleMap& map) 381 404 { -
trunk/Source/WebCore/css/RuleSet.h
r186388 r190347 80 80 unsigned linkMatchType() const { return m_linkMatchType; } 81 81 bool hasDocumentSecurityOrigin() const { return m_hasDocumentSecurityOrigin; } 82 PropertyWhitelistType propertyWhitelistType( bool isMatchingUARules = false) const { return isMatchingUARules ? PropertyWhitelistNone :static_cast<PropertyWhitelistType>(m_propertyWhitelistType); }82 PropertyWhitelistType propertyWhitelistType() const { return static_cast<PropertyWhitelistType>(m_propertyWhitelistType); } 83 83 // Try to balance between memory usage (there can be lots of RuleData objects) and good filtering performance. 84 84 static const unsigned maximumIdentifierCount = 4; … … 188 188 unsigned ruleCount() const { return m_ruleCount; } 189 189 190 bool hasShadowPseudoElementRules() const { return !m_shadowPseudoElementRules.isEmpty(); } 190 bool hasShadowPseudoElementRules() const; 191 void copyShadowPseudoElementRulesFrom(const RuleSet&); 191 192 192 193 private: -
trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp
r184615 r190347 32 32 #include "ElementRuleCollector.h" 33 33 #include "SelectorFilter.h" 34 #include "ShadowRoot.h" 34 35 #include "StyleRuleImport.h" 35 36 #include "StyleSheetContents.h" … … 84 85 m_ruleSets.authorStyle()->addRulesFromSheet(sheet, mediaQueryEvaluator); 85 86 86 // FIXME: We don't descent into shadow trees or otherwise handle shadow pseudo elements. 87 if (m_ruleSets.authorStyle()->hasShadowPseudoElementRules()) 88 m_dirtiesAllStyle = true; 87 m_hasShadowPseudoElementRulesInAuthorSheet = m_ruleSets.authorStyle()->hasShadowPseudoElementRules(); 89 88 } 90 89 91 enum class CheckDescendants { Yes, No }; 92 static CheckDescendants invalidateIfNeeded(Element& element, SelectorFilter& filter, const DocumentRuleSets& ruleSets) 90 StyleInvalidationAnalysis::CheckDescendants StyleInvalidationAnalysis::invalidateIfNeeded(Element& element, SelectorFilter& filter) 93 91 { 92 if (m_hasShadowPseudoElementRulesInAuthorSheet) { 93 // FIXME: This could do actual rule matching too. 94 if (auto* shadowRoot = element.shadowRoot()) 95 shadowRoot->setNeedsStyleRecalc(); 96 } 97 94 98 switch (element.styleChangeType()) { 95 99 case NoStyleChange: { 96 ElementRuleCollector ruleCollector(element, nullptr, ruleSets, filter);100 ElementRuleCollector ruleCollector(element, nullptr, m_ruleSets, filter); 97 101 ruleCollector.setMode(SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements); 98 102 ruleCollector.matchAuthorRules(false); … … 113 117 } 114 118 115 static void invalidateStyleForTree(Element& root, SelectorFilter& filter, const DocumentRuleSets& ruleSets)119 void StyleInvalidationAnalysis::invalidateStyleForTree(Element& root, SelectorFilter& filter) 116 120 { 117 if (invalidateIfNeeded(root, filter , ruleSets) == CheckDescendants::No)121 if (invalidateIfNeeded(root, filter) == CheckDescendants::No) 118 122 return; 119 123 … … 137 141 previousElement = &descendant; 138 142 139 if (invalidateIfNeeded(descendant, filter , ruleSets) == CheckDescendants::Yes)143 if (invalidateIfNeeded(descendant, filter) == CheckDescendants::Yes) 140 144 it.traverseNext(); 141 145 else … … 161 165 SelectorFilter filter; 162 166 filter.setupParentStack(documentElement); 163 invalidateStyleForTree(*documentElement, filter , m_ruleSets);167 invalidateStyleForTree(*documentElement, filter); 164 168 } 165 169 -
trunk/Source/WebCore/css/StyleInvalidationAnalysis.h
r165676 r190347 34 34 35 35 class Document; 36 class SelectorFilter; 36 37 class StyleSheetContents; 37 38 … … 41 42 42 43 bool dirtiesAllStyle() const { return m_dirtiesAllStyle; } 44 bool hasShadowPseudoElementRulesInAuthorSheet() const { return m_hasShadowPseudoElementRulesInAuthorSheet; } 43 45 void invalidateStyle(Document&); 44 46 45 47 private: 46 bool m_dirtiesAllStyle; 48 enum class CheckDescendants { Yes, No }; 49 CheckDescendants invalidateIfNeeded(Element&, SelectorFilter&); 50 void invalidateStyleForTree(Element&, SelectorFilter&); 51 52 bool m_dirtiesAllStyle { false }; 53 bool m_hasShadowPseudoElementRulesInAuthorSheet { false }; 47 54 DocumentRuleSets m_ruleSets; 48 55 }; -
trunk/Source/WebCore/css/StyleResolver.cpp
r190231 r190347 272 272 } 273 273 274 StyleResolver::StyleResolver(Document& document , bool matchAuthorAndUserStyles)274 StyleResolver::StyleResolver(Document& document) 275 275 : m_matchedPropertiesCacheAdditionsSinceLastSweep(0) 276 276 , m_matchedPropertiesCacheSweepTimer(*this, &StyleResolver::sweepMatchedPropertiesCache) 277 277 , m_document(document) 278 , m_matchAuthorAndUserStyles(m atchAuthorAndUserStyles)278 , m_matchAuthorAndUserStyles(m_document.settings() ? m_document.settings()->authorAndUserStylesEnabled() : true) 279 279 #if ENABLE(CSS_DEVICE_ADAPTATION) 280 280 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) … … 317 317 } 318 318 319 void StyleResolver::appendAuthorStyleSheets( unsigned firstNew,const Vector<RefPtr<CSSStyleSheet>>& styleSheets)320 { 321 m_ruleSets.appendAuthorStyleSheets( firstNew,styleSheets, m_medium.get(), m_inspectorCSSOMWrappers, this);319 void StyleResolver::appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>& styleSheets) 320 { 321 m_ruleSets.appendAuthorStyleSheets(styleSheets, m_medium.get(), m_inspectorCSSOMWrappers, this); 322 322 if (auto renderView = document().renderView()) 323 323 renderView->style().fontCascade().update(&document().fontSelector()); -
trunk/Source/WebCore/css/StyleResolver.h
r189987 r190347 139 139 WTF_MAKE_NONCOPYABLE(StyleResolver); WTF_MAKE_FAST_ALLOCATED; 140 140 public: 141 StyleResolver(Document& , bool matchAuthorAndUserStyles);141 StyleResolver(Document&); 142 142 ~StyleResolver(); 143 143 … … 163 163 Settings* documentSettings() { return m_document.settings(); } 164 164 165 // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() directly after we factor StyleRsolver further. 166 // https://bugs.webkit.org/show_bug.cgi?id=108890 167 void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet>>&); 165 void appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>&); 168 166 169 167 DocumentRuleSets& ruleSets() { return m_ruleSets; } -
trunk/Source/WebCore/dom/AuthorStyleSheets.cpp
r190256 r190347 212 212 } 213 213 214 void AuthorStyleSheets::analyzeStyleSheetChange(UpdateFlag updateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, StyleResolverUpdateType& styleResolverUpdateType, bool& requiresFullStyleRecalc) 215 { 216 styleResolverUpdateType = Reconstruct; 214 AuthorStyleSheets::StyleResolverUpdateType AuthorStyleSheets::analyzeStyleSheetChange(UpdateFlag updateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, bool& requiresFullStyleRecalc) 215 { 217 216 requiresFullStyleRecalc = true; 218 217 … … 226 225 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 227 226 m_hadActiveLoadingStylesheet = false; 228 return ;227 return Reconstruct; 229 228 } 230 229 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 231 230 232 231 if (updateFlag != OptimizedUpdate) 233 return ;232 return Reconstruct; 234 233 if (!m_document.styleResolverIfExists()) 235 return; 234 return Reconstruct; 235 236 236 StyleResolver& styleResolver = *m_document.styleResolverIfExists(); 237 237 … … 239 239 unsigned oldStylesheetCount = m_activeStyleSheets.size(); 240 240 if (newStylesheetCount < oldStylesheetCount) 241 return; 241 return Reconstruct; 242 242 243 Vector<StyleSheetContents*> addedSheets; 243 244 unsigned newIndex = 0; 244 245 for (unsigned oldIndex = 0; oldIndex < oldStylesheetCount; ++oldIndex) { 245 246 if (newIndex >= newStylesheetCount) 246 return ;247 return Reconstruct; 247 248 while (m_activeStyleSheets[oldIndex] != newStylesheets[newIndex]) { 248 249 addedSheets.append(&newStylesheets[newIndex]->contents()); 249 250 ++newIndex; 250 251 if (newIndex == newStylesheetCount) 251 return ;252 return Reconstruct; 252 253 } 253 254 ++newIndex; … … 260 261 // If all new sheets were added at the end of the list we can just add them to existing StyleResolver. 261 262 // If there were insertions we need to re-add all the stylesheets so rules are ordered correctly. 262 styleResolverUpdateType = hasInsertions ? Reset : Additive;263 auto styleResolverUpdateType = hasInsertions ? Reset : Additive; 263 264 264 265 // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs. 265 266 if (!m_document.bodyOrFrameset() || m_document.hasNodesWithPlaceholderStyle()) 266 return; 267 return styleResolverUpdateType; 268 267 269 StyleInvalidationAnalysis invalidationAnalysis(addedSheets, styleResolver.mediaQueryEvaluator()); 268 270 if (invalidationAnalysis.dirtiesAllStyle()) 269 return ;271 return styleResolverUpdateType; 270 272 invalidationAnalysis.invalidateStyle(m_document); 271 273 requiresFullStyleRecalc = false; 274 275 return styleResolverUpdateType; 272 276 } 273 277 … … 308 312 filterEnabledNonemptyCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets); 309 313 310 StyleResolverUpdateType styleResolverUpdateType;311 314 bool requiresFullStyleRecalc; 312 analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdateType, requiresFullStyleRecalc); 313 314 if (styleResolverUpdateType == Reconstruct) { 315 if (m_shadowRoot) 316 m_shadowRoot->resetStyleResolver(); 317 else 318 m_document.clearStyleResolver(); 319 } else { 320 StyleResolver& styleResolver = m_document.ensureStyleResolver(); 321 if (styleResolverUpdateType == Reset) { 322 styleResolver.ruleSets().resetAuthorStyle(); 323 styleResolver.appendAuthorStyleSheets(0, activeCSSStyleSheets); 324 } else { 325 ASSERT(styleResolverUpdateType == Additive); 326 styleResolver.appendAuthorStyleSheets(m_activeStyleSheets.size(), activeCSSStyleSheets); 327 } 328 } 315 auto styleResolverUpdateType = analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, requiresFullStyleRecalc); 316 317 updateStyleResolver(activeCSSStyleSheets, styleResolverUpdateType); 329 318 330 319 m_weakCopyOfActiveStyleSheetListForFastLookup = nullptr; … … 345 334 } 346 335 336 void AuthorStyleSheets::updateStyleResolver(Vector<RefPtr<CSSStyleSheet>>& activeStyleSheets, StyleResolverUpdateType updateType) 337 { 338 if (updateType == Reconstruct) { 339 if (m_shadowRoot) 340 m_shadowRoot->resetStyleResolver(); 341 else 342 m_document.clearStyleResolver(); 343 return; 344 } 345 auto& styleResolver = m_document.ensureStyleResolver(); 346 auto& userAgentShadowTreeStyleResolver = m_document.userAgentShadowTreeStyleResolver(); 347 348 if (updateType == Reset) { 349 styleResolver.ruleSets().resetAuthorStyle(); 350 styleResolver.appendAuthorStyleSheets(activeStyleSheets); 351 } else { 352 ASSERT(updateType == Additive); 353 unsigned firstNewIndex = m_activeStyleSheets.size(); 354 Vector<RefPtr<CSSStyleSheet>> newStyleSheets; 355 newStyleSheets.appendRange(activeStyleSheets.begin() + firstNewIndex, activeStyleSheets.end()); 356 styleResolver.appendAuthorStyleSheets(newStyleSheets); 357 } 358 359 userAgentShadowTreeStyleResolver.ruleSets().resetAuthorStyle(); 360 auto& authorRuleSet = *styleResolver.ruleSets().authorStyle(); 361 if (authorRuleSet.hasShadowPseudoElementRules()) 362 userAgentShadowTreeStyleResolver.ruleSets().authorStyle()->copyShadowPseudoElementRulesFrom(authorRuleSet); 363 } 364 347 365 const Vector<RefPtr<CSSStyleSheet>> AuthorStyleSheets::activeStyleSheetsForInspector() const 348 366 { -
trunk/Source/WebCore/dom/AuthorStyleSheets.h
r190256 r190347 107 107 Additive 108 108 }; 109 void analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, StyleResolverUpdateType&, bool& requiresFullStyleRecalc); 109 StyleResolverUpdateType analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, bool& requiresFullStyleRecalc); 110 void updateStyleResolver(Vector<RefPtr<CSSStyleSheet>>&, StyleResolverUpdateType); 110 111 111 112 Document& m_document; -
trunk/Source/WebCore/dom/Document.cpp
r190272 r190347 2112 2112 void Document::createStyleResolver() 2113 2113 { 2114 bool matchAuthorAndUserStyles = true; 2115 if (Settings* settings = this->settings()) 2116 matchAuthorAndUserStyles = settings->authorAndUserStylesEnabled(); 2117 m_styleResolver = std::make_unique<StyleResolver>(*this, matchAuthorAndUserStyles); 2118 m_styleResolver->appendAuthorStyleSheets(0, authorStyleSheets().activeStyleSheets()); 2114 m_styleResolver = std::make_unique<StyleResolver>(*this); 2115 m_styleResolver->appendAuthorStyleSheets(authorStyleSheets().activeStyleSheets()); 2116 } 2117 2118 StyleResolver& Document::userAgentShadowTreeStyleResolver() 2119 { 2120 if (!m_userAgentShadowTreeStyleResolver) { 2121 m_userAgentShadowTreeStyleResolver = std::make_unique<StyleResolver>(*this); 2122 2123 // FIXME: Filter out shadow pseudo elements we don't want to expose to authors. 2124 auto& documentAuthorStyle = *ensureStyleResolver().ruleSets().authorStyle(); 2125 if (documentAuthorStyle.hasShadowPseudoElementRules()) 2126 m_userAgentShadowTreeStyleResolver->ruleSets().authorStyle()->copyShadowPseudoElementRulesFrom(documentAuthorStyle); 2127 } 2128 2129 return *m_userAgentShadowTreeStyleResolver; 2119 2130 } 2120 2131 … … 2140 2151 { 2141 2152 m_styleResolver = nullptr; 2153 m_userAgentShadowTreeStyleResolver = nullptr; 2142 2154 2143 2155 // FIXME: It would be better if the FontSelector could survive this operation. -
trunk/Source/WebCore/dom/Document.h
r190272 r190347 496 496 return *m_styleResolver; 497 497 } 498 StyleResolver& userAgentShadowTreeStyleResolver(); 498 499 499 500 CSSFontSelector& fontSelector(); … … 1395 1396 1396 1397 std::unique_ptr<StyleResolver> m_styleResolver; 1398 std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver; 1397 1399 bool m_didCalculateStyleResolver; 1398 1400 bool m_hasNodesWithPlaceholderStyle; -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r190323 r190347 78 78 StyleResolver& ShadowRoot::styleResolver() 79 79 { 80 // FIXME: Use isolated style resolver for user agent shadow roots.81 80 if (m_type == Type::UserAgent) 82 return document(). ensureStyleResolver();81 return document().userAgentShadowTreeStyleResolver(); 83 82 84 83 if (!m_styleResolver) { 85 84 // FIXME: We could share style resolver with shadow roots that have identical style. 86 m_styleResolver = std::make_unique<StyleResolver>(document() , true);85 m_styleResolver = std::make_unique<StyleResolver>(document()); 87 86 if (m_authorStyleSheets) 88 m_styleResolver->appendAuthorStyleSheets( 0,m_authorStyleSheets->activeStyleSheets());87 m_styleResolver->appendAuthorStyleSheets(m_authorStyleSheets->activeStyleSheets()); 89 88 } 90 89 return *m_styleResolver; -
trunk/Source/WebCore/style/StyleResolveTree.cpp
r190169 r190347 726 726 ASSERT(shadowRoot.host() == &host); 727 727 ASSERT(host.renderer()); 728 if (shadowRoot.styleChangeType() >= FullStyleChange) 729 change = Force; 728 730 RenderTreePosition renderTreePosition(*host.renderer()); 729 731 for (Node* child = shadowRoot.firstChild(); child; child = child->nextSibling()) { -
trunk/Source/WebCore/svg/SVGElement.cpp
r189987 r190347 792 792 RefPtr<RenderStyle> SVGElement::customStyleForRenderer(RenderStyle& parentStyle) 793 793 { 794 if (!correspondingElement()) 795 return resolveStyle(&parentStyle); 796 797 return styleResolver().styleForElement(correspondingElement(), &parentStyle, DisallowStyleSharing); 794 // If the element is in a <use> tree we get the style from the definition tree. 795 if (auto* styleElement = this->correspondingElement()) 796 return styleElement->styleResolver().styleForElement(styleElement, &parentStyle, DisallowStyleSharing); 797 798 return resolveStyle(&parentStyle); 798 799 } 799 800
Note:
See TracChangeset
for help on using the changeset viewer.