Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp

Issue 2394353003: Apply RuleSet changes for active stylesheet changes. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 addKeyframeRules(ruleSet); 97 addKeyframeRules(ruleSet);
98 addFontFaceRules(ruleSet); 98 addFontFaceRules(ruleSet);
99 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index); 99 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index);
100 treeScope().document().styleResolver()->addViewportDependentMediaQueries( 100 treeScope().document().styleResolver()->addViewportDependentMediaQueries(
101 ruleSet.viewportDependentMediaQueryResults()); 101 ruleSet.viewportDependentMediaQueryResults());
102 treeScope().document().styleResolver()->addDeviceDependentMediaQueries( 102 treeScope().document().styleResolver()->addDeviceDependentMediaQueries(
103 ruleSet.deviceDependentMediaQueryResults()); 103 ruleSet.deviceDependentMediaQueryResults());
104 } 104 }
105 105
106 void ScopedStyleResolver::appendActiveStyleSheets(
107 unsigned index,
108 const ActiveStyleSheetVector& activeSheets) {
109 for (auto activeIterator = activeSheets.begin() + index;
110 activeIterator != activeSheets.end(); activeIterator++) {
111 CSSStyleSheet* sheet = activeIterator->first;
112 if (!activeIterator->second)
113 continue;
114 const RuleSet& ruleSet = *activeIterator->second;
115 m_authorStyleSheets.append(sheet);
116 addKeyframeRules(ruleSet);
117 addFontFaceRules(ruleSet);
118 addTreeBoundaryCrossingRules(ruleSet, sheet, index++);
119 }
120 }
121
106 void ScopedStyleResolver::collectFeaturesTo( 122 void ScopedStyleResolver::collectFeaturesTo(
107 RuleFeatureSet& features, 123 RuleFeatureSet& features,
108 HeapHashSet<Member<const StyleSheetContents>>& 124 HeapHashSet<Member<const StyleSheetContents>>&
109 visitedSharedStyleSheetContents) const { 125 visitedSharedStyleSheetContents) const {
110 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 126 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
111 ASSERT(m_authorStyleSheets[i]->ownerNode()); 127 ASSERT(m_authorStyleSheets[i]->ownerNode());
112 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); 128 StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
113 if (contents->hasOneClient() || 129 if (contents->hasOneClient() ||
114 visitedSharedStyleSheetContents.add(contents).isNewEntry) 130 visitedSharedStyleSheetContents.add(contents).isNewEntry)
115 features.add(contents->ruleSet().features()); 131 features.add(contents->ruleSet().features());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); 164 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl());
149 if (it == m_keyframesRuleMap.end()) 165 if (it == m_keyframesRuleMap.end())
150 m_keyframesRuleMap.set(s.impl(), rule); 166 m_keyframesRuleMap.set(s.impl(), rule);
151 else if (it->value->isVendorPrefixed()) 167 else if (it->value->isVendorPrefixed())
152 m_keyframesRuleMap.set(s.impl(), rule); 168 m_keyframesRuleMap.set(s.impl(), rule);
153 } else { 169 } else {
154 m_keyframesRuleMap.set(s.impl(), rule); 170 m_keyframesRuleMap.set(s.impl(), rule);
155 } 171 }
156 } 172 }
157 173
158 static Node& invalidationRootFor(const TreeScope& treeScope) { 174 ContainerNode& ScopedStyleResolver::invalidationRootForTreeScope(
175 const TreeScope& treeScope) {
159 if (treeScope.rootNode() == treeScope.document()) 176 if (treeScope.rootNode() == treeScope.document())
160 return treeScope.document(); 177 return treeScope.document();
161 return toShadowRoot(treeScope.rootNode()).host(); 178 return toShadowRoot(treeScope.rootNode()).host();
162 } 179 }
163 180
164 void ScopedStyleResolver::keyframesRulesAdded(const TreeScope& treeScope) { 181 void ScopedStyleResolver::keyframesRulesAdded(const TreeScope& treeScope) {
165 // Called when @keyframes rules are about to be added/removed from a 182 // Called when @keyframes rules are about to be added/removed from a
166 // TreeScope. @keyframes rules may apply to animations on elements in the 183 // TreeScope. @keyframes rules may apply to animations on elements in the
167 // same TreeScope as the stylesheet, or the host element in the parent 184 // same TreeScope as the stylesheet, or the host element in the parent
168 // TreeScope if the TreeScope is a shadow tree. 185 // TreeScope if the TreeScope is a shadow tree.
(...skipping 12 matching lines...) Expand all
181 if (parentResolver && parentResolver->m_hasUnresolvedKeyframesRule) { 198 if (parentResolver && parentResolver->m_hasUnresolvedKeyframesRule) {
182 parentResolver->m_hasUnresolvedKeyframesRule = false; 199 parentResolver->m_hasUnresolvedKeyframesRule = false;
183 hadUnresolvedKeyframes = true; 200 hadUnresolvedKeyframes = true;
184 } 201 }
185 202
186 if (hadUnresolvedKeyframes) { 203 if (hadUnresolvedKeyframes) {
187 // If an animation ended up not being started because no @keyframes 204 // If an animation ended up not being started because no @keyframes
188 // rules were found for the animation-name, we need to recalculate style 205 // rules were found for the animation-name, we need to recalculate style
189 // for the elements in the scope, including its shadow host if 206 // for the elements in the scope, including its shadow host if
190 // applicable. 207 // applicable.
191 invalidationRootFor(treeScope).setNeedsStyleRecalc( 208 invalidationRootForTreeScope(treeScope).setNeedsStyleRecalc(
192 SubtreeStyleChange, StyleChangeReasonForTracing::create( 209 SubtreeStyleChange, StyleChangeReasonForTracing::create(
193 StyleChangeReason::StyleSheetChange)); 210 StyleChangeReason::StyleSheetChange));
194 return; 211 return;
195 } 212 }
196 213
197 // If we have animations running, added/removed @keyframes may affect these. 214 // If we have animations running, added/removed @keyframes may affect these.
198 treeScope.document().timeline().invalidateKeyframeEffects(treeScope); 215 treeScope.document().timeline().invalidateKeyframeEffects(treeScope);
199 } 216 }
200 217
201 void ScopedStyleResolver::collectMatchingAuthorRules( 218 void ScopedStyleResolver::collectMatchingAuthorRules(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 m_treeBoundaryCrossingRuleSet->append( 312 m_treeBoundaryCrossingRuleSet->append(
296 RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope)); 313 RuleSubSet::create(parentStyleSheet, sheetIndex, ruleSetForScope));
297 } 314 }
298 315
299 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) { 316 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) {
300 visitor->trace(m_parentStyleSheet); 317 visitor->trace(m_parentStyleSheet);
301 visitor->trace(m_ruleSet); 318 visitor->trace(m_ruleSet);
302 } 319 }
303 320
304 } // namespace blink 321 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.h ('k') | third_party/WebKit/Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698