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

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

Issue 2808673004: WIP Support var() references in registered custom property keyframes (Closed)
Patch Set: Created 3 years, 8 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 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
10 * (http://www.torchmobile.com/) 10 * (http://www.torchmobile.com/)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // Inline style is immutable as long as there is no CSSOM wrapper. 299 // Inline style is immutable as long as there is no CSSOM wrapper.
300 bool is_inline_style_cacheable = !element.InlineStyle()->IsMutable(); 300 bool is_inline_style_cacheable = !element.InlineStyle()->IsMutable();
301 collector.AddElementStyleProperties(element.InlineStyle(), 301 collector.AddElementStyleProperties(element.InlineStyle(),
302 is_inline_style_cacheable); 302 is_inline_style_cacheable);
303 } 303 }
304 304
305 collector.FinishAddingAuthorRulesForTreeScope(); 305 collector.FinishAddingAuthorRulesForTreeScope();
306 } 306 }
307 307
308 static bool ShouldCheckScope(const Element& element, 308 static bool ShouldCheckScope(const Element& element,
309 const Node& scoping_node, 309 const Node& scopingNode,
310 bool is_inner_tree_scope) { 310 bool isInnerTreeScope) {
311 if (is_inner_tree_scope && 311 if (isInnerTreeScope &&
312 element.GetTreeScope() != scoping_node.GetTreeScope()) { 312 element.GetTreeScope() != scopingNode.GetTreeScope()) {
313 // Check if |element| may be affected by a ::content rule in |scopingNode|'s 313 // Check if |element| may be affected by a ::content rule in |scopingNode|'s
314 // style. If |element| is a descendant of a shadow host which is ancestral 314 // style. If |element| is a descendant of a shadow host which is ancestral
315 // to |scopingNode|, the |element| should be included for rule collection. 315 // to |scopingNode|, the |element| should be included for rule collection.
316 // Skip otherwise. 316 // Skip otherwise.
317 const TreeScope* scope = &scoping_node.GetTreeScope(); 317 const TreeScope* scope = &scopingNode.GetTreeScope();
318 while (scope && scope->ParentTreeScope() != &element.GetTreeScope()) 318 while (scope && scope->ParentTreeScope() != &element.GetTreeScope())
319 scope = scope->ParentTreeScope(); 319 scope = scope->ParentTreeScope();
320 Element* shadow_host = 320 Element* shadow_host =
321 scope ? scope->RootNode().OwnerShadowHost() : nullptr; 321 scope ? scope->RootNode().OwnerShadowHost() : nullptr;
322 return shadow_host && element.IsDescendantOf(shadow_host); 322 return shadow_host && element.IsDescendantOf(shadow_host);
323 } 323 }
324 324
325 // When |element| can be distributed to |scopingNode| via <shadow>, ::content 325 // When |element| can be distributed to |scopingNode| via <shadow>, ::content
326 // rule can match, thus the case should be included. 326 // rule can match, thus the case should be included.
327 if (!is_inner_tree_scope && 327 if (!isInnerTreeScope &&
328 scoping_node.ParentOrShadowHostNode() == 328 scopingNode.ParentOrShadowHostNode() ==
329 element.GetTreeScope().RootNode().ParentOrShadowHostNode()) 329 element.GetTreeScope().RootNode().ParentOrShadowHostNode())
330 return true; 330 return true;
331 331
332 // Obviously cases when ancestor scope has /deep/ or ::shadow rule should be 332 // Obviously cases when ancestor scope has /deep/ or ::shadow rule should be
333 // included. Skip otherwise. 333 // included. Skip otherwise.
334 return scoping_node.GetTreeScope() 334 return scopingNode.GetTreeScope()
335 .GetScopedStyleResolver() 335 .GetScopedStyleResolver()
336 ->HasDeepOrShadowSelector(); 336 ->HasDeepOrShadowSelector();
337 } 337 }
338 338
339 void StyleResolver::MatchScopedRules(const Element& element, 339 void StyleResolver::MatchScopedRules(const Element& element,
340 ElementRuleCollector& collector) { 340 ElementRuleCollector& collector) {
341 // Match rules from treeScopes in the reverse tree-of-trees order, since the 341 // Match rules from treeScopes in the reverse tree-of-trees order, since the
342 // cascading order for normal rules is such that when comparing rules from 342 // cascading order for normal rules is such that when comparing rules from
343 // different shadow trees, the rule from the tree which comes first in the 343 // different shadow trees, the rule from the tree which comes first in the
344 // tree-of-trees order wins. From other treeScopes than the element's own 344 // tree-of-trees order wins. From other treeScopes than the element's own
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 PseudoElement* pseudo = CreatePseudoElement(&parent, pseudo_id); 896 PseudoElement* pseudo = CreatePseudoElement(&parent, pseudo_id);
897 897
898 SetAnimationUpdateIfNeeded(state, *pseudo); 898 SetAnimationUpdateIfNeeded(state, *pseudo);
899 if (ElementAnimations* element_animations = pseudo->GetElementAnimations()) 899 if (ElementAnimations* element_animations = pseudo->GetElementAnimations())
900 element_animations->CssAnimations().MaybeApplyPendingUpdate(pseudo); 900 element_animations->CssAnimations().MaybeApplyPendingUpdate(pseudo);
901 return pseudo; 901 return pseudo;
902 } 902 }
903 903
904 bool StyleResolver::PseudoStyleForElementInternal( 904 bool StyleResolver::PseudoStyleForElementInternal(
905 Element& element, 905 Element& element,
906 const PseudoStyleRequest& pseudo_style_request, 906 const PseudoStyleRequest& pseudoStyleRequest,
907 const ComputedStyle* parent_style, 907 const ComputedStyle* parentStyle,
908 StyleResolverState& state) { 908 StyleResolverState& state) {
909 DCHECK(GetDocument().GetFrame()); 909 DCHECK(GetDocument().GetFrame());
910 DCHECK(GetDocument().GetSettings()); 910 DCHECK(GetDocument().GetSettings());
911 DCHECK(pseudo_style_request.pseudo_id != kPseudoIdFirstLineInherited); 911 DCHECK(pseudoStyleRequest.pseudo_id != kPseudoIdFirstLineInherited);
912 DCHECK(state.ParentStyle()); 912 DCHECK(state.ParentStyle());
913 913
914 SelectorFilterParentScope::EnsureParentStackIsPushed(); 914 SelectorFilterParentScope::EnsureParentStackIsPushed();
915 915
916 Element* pseudo_element = 916 Element* pseudo_element =
917 element.GetPseudoElement(pseudo_style_request.pseudo_id); 917 element.GetPseudoElement(pseudoStyleRequest.pseudo_id);
918 918
919 const ComputedStyle* base_computed_style = 919 const ComputedStyle* base_computed_style =
920 CalculateBaseComputedStyle(state, pseudo_element); 920 CalculateBaseComputedStyle(state, pseudo_element);
921 921
922 if (base_computed_style) { 922 if (base_computed_style) {
923 state.SetStyle(ComputedStyle::Clone(*base_computed_style)); 923 state.SetStyle(ComputedStyle::Clone(*base_computed_style));
924 } else if (pseudo_style_request.AllowsInheritance(state.ParentStyle())) { 924 } else if (pseudoStyleRequest.AllowsInheritance(state.ParentStyle())) {
925 RefPtr<ComputedStyle> style = ComputedStyle::Create(); 925 RefPtr<ComputedStyle> style = ComputedStyle::Create();
926 style->InheritFrom(*state.ParentStyle()); 926 style->InheritFrom(*state.ParentStyle());
927 state.SetStyle(std::move(style)); 927 state.SetStyle(std::move(style));
928 } else { 928 } else {
929 state.SetStyle(InitialStyleForElement()); 929 state.SetStyle(InitialStyleForElement());
930 state.SetParentStyle(ComputedStyle::Clone(*state.Style())); 930 state.SetParentStyle(ComputedStyle::Clone(*state.Style()));
931 } 931 }
932 932
933 state.Style()->SetStyleType(pseudo_style_request.pseudo_id); 933 state.Style()->SetStyleType(pseudoStyleRequest.pseudo_id);
934 934
935 // Since we don't use pseudo-elements in any of our quirk/print 935 // Since we don't use pseudo-elements in any of our quirk/print
936 // user agent rules, don't waste time walking those rules. 936 // user agent rules, don't waste time walking those rules.
937 937
938 if (!base_computed_style) { 938 if (!base_computed_style) {
939 // Check UA, user and author rules. 939 // Check UA, user and author rules.
940 ElementRuleCollector collector(state.ElementContext(), selector_filter_, 940 ElementRuleCollector collector(state.ElementContext(), selector_filter_,
941 state.Style()); 941 state.Style());
942 collector.SetPseudoStyleRequest(pseudo_style_request); 942 collector.SetPseudoStyleRequest(pseudoStyleRequest);
943 943
944 MatchUARules(collector); 944 MatchUARules(collector);
945 MatchAuthorRules(*state.GetElement(), collector); 945 MatchAuthorRules(*state.GetElement(), collector);
946 collector.FinishAddingAuthorRulesForTreeScope(); 946 collector.FinishAddingAuthorRulesForTreeScope();
947 947
948 if (tracker_) 948 if (tracker_)
949 AddMatchedRulesToTracker(collector); 949 AddMatchedRulesToTracker(collector);
950 950
951 if (!collector.MatchedResult().HasMatchedProperties()) 951 if (!collector.MatchedResult().HasMatchedProperties())
952 return false; 952 return false;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 if (rules_to_include & kUAAndUserCSSRules) 1125 if (rules_to_include & kUAAndUserCSSRules)
1126 MatchUARules(collector); 1126 MatchUARules(collector);
1127 1127
1128 if (rules_to_include & kAuthorCSSRules) { 1128 if (rules_to_include & kAuthorCSSRules) {
1129 collector.SetSameOriginOnly(!(rules_to_include & kCrossOriginCSSRules)); 1129 collector.SetSameOriginOnly(!(rules_to_include & kCrossOriginCSSRules));
1130 collector.SetIncludeEmptyRules(rules_to_include & kEmptyCSSRules); 1130 collector.SetIncludeEmptyRules(rules_to_include & kEmptyCSSRules);
1131 MatchAuthorRules(element, collector); 1131 MatchAuthorRules(element, collector);
1132 } 1132 }
1133 } 1133 }
1134 1134
1135 void StyleResolver::ApplyAnimatedCustomProperties(StyleResolverState& state) {
1136 if (!state.IsAnimatingCustomProperties()) {
1137 return;
1138 }
1139 HashSet<PropertyHandle>& pending =
1140 state.CustomPropertiesPendingAnimationApplication();
1141 pending.Clear();
1142 for (const auto& interpolations_map :
1143 {state.AnimationUpdate().ActiveInterpolationsForCustomAnimations(),
1144 state.AnimationUpdate().ActiveInterpolationsForCustomTransitions()}) {
1145 for (const auto& entry : interpolations_map) {
1146 pending.insert(entry.key);
1147 }
1148 }
1149 while (!pending.IsEmpty()) {
1150 ApplyAnimatedCustomProperty(state, pending.TakeAny());
1151 }
1152 }
1153
1154 static const ActiveInterpolations& ActiveInterpolationsForCustomProperty(
1155 const StyleResolverState& state,
1156 const PropertyHandle& property) {
1157 const ActiveInterpolationsMap& animations_map =
1158 state.AnimationUpdate().ActiveInterpolationsForCustomAnimations();
1159 const auto& find_result = animations_map.Find(property);
1160 if (find_result != animations_map.end()) {
1161 return find_result->value;
1162 }
1163 return state.AnimationUpdate()
1164 .ActiveInterpolationsForCustomAnimations()
1165 .Find(property)
1166 ->value;
1167 }
1168
1169 void StyleResolver::ApplyAnimatedCustomProperty(
1170 StyleResolverState& state,
1171 const PropertyHandle& property) {
1172 DCHECK(property.IsCSSCustomProperty());
1173 const ActiveInterpolations& interpolations =
1174 ActiveInterpolationsForCustomProperty(state, property);
1175 const Interpolation& interpolation = *interpolations.front();
1176 if (interpolation.IsInvalidatableInterpolation()) {
1177 CSSInterpolationTypesMap map(state.GetDocument().GetPropertyRegistry());
1178 InterpolationEnvironment environment(map, state);
1179 InvalidatableInterpolation::ApplyStack(interpolations, environment);
1180 } else {
1181 ToTransitionInterpolation(interpolation).Apply(state);
1182 }
1183 }
1184
1135 bool StyleResolver::ApplyAnimatedStandardProperties( 1185 bool StyleResolver::ApplyAnimatedStandardProperties(
1136 StyleResolverState& state, 1186 StyleResolverState& state,
1137 const Element* animating_element) { 1187 const Element* animatingElement) {
1138 Element* element = state.GetElement(); 1188 Element* element = state.GetElement();
1139 DCHECK(element); 1189 DCHECK(element);
1140 1190
1141 // The animating element may be this element, or its pseudo element. It is 1191 // The animating element may be this element, or its pseudo element. It is
1142 // null when calculating the style for a potential pseudo element that has 1192 // null when calculating the style for a potential pseudo element that has
1143 // yet to be created. 1193 // yet to be created.
1144 DCHECK(animating_element == element || !animating_element || 1194 DCHECK(animatingElement == element || !animatingElement ||
1145 animating_element->ParentOrShadowHostElement() == element); 1195 animatingElement->ParentOrShadowHostElement() == element);
1146 1196
1147 if (state.Style()->Animations() || 1197 if (state.Style()->Animations() ||
1148 (animating_element && animating_element->HasAnimations())) { 1198 (animatingElement && animatingElement->HasAnimations())) {
1149 if (!state.IsAnimationInterpolationMapReady()) 1199 if (!state.IsAnimationInterpolationMapReady())
1150 CalculateAnimationUpdate(state, animating_element); 1200 CalculateAnimationUpdate(state, animatingElement);
1151 } else if (!state.Style()->Transitions()) { 1201 } else if (!state.Style()->Transitions()) {
1152 return false; 1202 return false;
1153 } 1203 }
1154 1204
1155 CSSAnimations::CalculateCompositorAnimationUpdate( 1205 CSSAnimations::CalculateCompositorAnimationUpdate(
1156 state.AnimationUpdate(), animating_element, *element, *state.Style(), 1206 state.AnimationUpdate(), animatingElement, *element, *state.Style(),
1157 state.ParentStyle(), WasViewportResized()); 1207 state.ParentStyle(), WasViewportResized());
1158 CSSAnimations::CalculateTransitionUpdate( 1208 CSSAnimations::CalculateTransitionUpdate(
1159 state.AnimationUpdate(), CSSAnimations::PropertyPass::kStandard, 1209 state.AnimationUpdate(), CSSAnimations::PropertyPass::kStandard,
1160 animating_element, *state.Style()); 1210 animatingElement, *state.Style());
1161 1211
1162 CSSAnimations::SnapshotCompositorKeyframes( 1212 CSSAnimations::SnapshotCompositorKeyframes(
1163 *element, state.AnimationUpdate(), *state.Style(), state.ParentStyle()); 1213 *element, state.AnimationUpdate(), *state.Style(), state.ParentStyle());
1164 1214
1165 if (state.AnimationUpdate().IsEmpty()) 1215 if (state.AnimationUpdate().IsEmpty())
1166 return false; 1216 return false;
1167 1217
1168 if (state.Style()->InsideLink() != EInsideLink::kNotInsideLink) { 1218 if (state.Style()->InsideLink() != EInsideLink::kNotInsideLink) {
1169 DCHECK(state.ApplyPropertyToRegularStyle()); 1219 DCHECK(state.ApplyPropertyToRegularStyle());
1170 state.SetApplyPropertyToVisitedLinkStyle(true); 1220 state.SetApplyPropertyToVisitedLinkStyle(true);
1171 } 1221 }
1172 1222
1173 const ActiveInterpolationsMap& active_interpolations_map_for_animations = 1223 const ActiveInterpolationsMap& animations_map =
1174 state.AnimationUpdate().ActiveInterpolationsForAnimations(); 1224 state.AnimationUpdate().ActiveInterpolationsForStandardAnimations();
1175 const ActiveInterpolationsMap& 1225 const ActiveInterpolationsMap& transitions_map =
1176 active_interpolations_map_for_standard_transitions = 1226 state.AnimationUpdate().ActiveInterpolationsForStandardTransitions();
1177 state.AnimationUpdate().ActiveInterpolationsForStandardTransitions(); 1227 ApplyAnimatedStandardProperties<kHighPropertyPriority>(state, animations_map);
1178 // TODO(crbug.com/644148): Apply animations on custom properties. 1228 ApplyAnimatedStandardProperties<kHighPropertyPriority>(state,
1179 ApplyAnimatedProperties<kHighPropertyPriority>( 1229 transitions_map);
1180 state, active_interpolations_map_for_animations);
1181 ApplyAnimatedProperties<kHighPropertyPriority>(
1182 state, active_interpolations_map_for_standard_transitions);
1183 1230
1184 UpdateFont(state); 1231 UpdateFont(state);
1185 1232
1186 ApplyAnimatedProperties<kLowPropertyPriority>( 1233 ApplyAnimatedStandardProperties<kLowPropertyPriority>(state, animations_map);
1187 state, active_interpolations_map_for_animations); 1234 ApplyAnimatedStandardProperties<kLowPropertyPriority>(state, transitions_map);
1188 ApplyAnimatedProperties<kLowPropertyPriority>(
1189 state, active_interpolations_map_for_standard_transitions);
1190 1235
1191 // Start loading resources used by animations. 1236 // Start loading resources used by animations.
1192 LoadPendingResources(state); 1237 LoadPendingResources(state);
1193 1238
1194 DCHECK(!state.GetFontBuilder().FontDirty()); 1239 DCHECK(!state.GetFontBuilder().FontDirty());
1195 1240
1196 state.SetApplyPropertyToVisitedLinkStyle(false); 1241 state.SetApplyPropertyToVisitedLinkStyle(false);
1197 1242
1198 return true; 1243 return true;
1199 } 1244 }
(...skipping 12 matching lines...) Expand all
1212 resolver->KeyframeStylesForAnimation(animation_name.Impl())) 1257 resolver->KeyframeStylesForAnimation(animation_name.Impl()))
1213 return keyframes_rule; 1258 return keyframes_rule;
1214 } 1259 }
1215 1260
1216 for (auto& resolver : resolvers) 1261 for (auto& resolver : resolvers)
1217 resolver->SetHasUnresolvedKeyframesRule(); 1262 resolver->SetHasUnresolvedKeyframesRule();
1218 return nullptr; 1263 return nullptr;
1219 } 1264 }
1220 1265
1221 template <CSSPropertyPriority priority> 1266 template <CSSPropertyPriority priority>
1222 void StyleResolver::ApplyAnimatedProperties( 1267 void StyleResolver::ApplyAnimatedStandardProperties(
1223 StyleResolverState& state, 1268 StyleResolverState& state,
1224 const ActiveInterpolationsMap& active_interpolations_map) { 1269 const ActiveInterpolationsMap& active_interpolations_map) {
1270 static_assert(
1271 priority != kResolveVariables,
1272 "Use applyAnimatedCustomProperty() for custom property animations");
1225 // TODO(alancutter): Don't apply presentation attribute animations here, 1273 // TODO(alancutter): Don't apply presentation attribute animations here,
1226 // they should instead apply in 1274 // they should instead apply in
1227 // SVGElement::collectStyleForPresentationAttribute(). 1275 // SVGElement::collectStyleForPresentationAttribute().
1228 for (const auto& entry : active_interpolations_map) { 1276 for (const auto& entry : active_interpolations_map) {
1229 CSSPropertyID property = entry.key.IsCSSProperty() 1277 CSSPropertyID property = entry.key.IsCSSProperty()
1230 ? entry.key.CssProperty() 1278 ? entry.key.CssProperty()
1231 : entry.key.PresentationAttribute(); 1279 : entry.key.PresentationAttribute();
1232 if (!CSSPropertyPriorityData<priority>::PropertyHasPriority(property)) 1280 if (!CSSPropertyPriorityData<priority>::PropertyHasPriority(property))
1233 continue; 1281 continue;
1234 const Interpolation& interpolation = *entry.value.front(); 1282 const Interpolation& interpolation = *entry.value.front();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 !settings->GetTextTrackFontStyle().IsEmpty() || 1481 !settings->GetTextTrackFontStyle().IsEmpty() ||
1434 !settings->GetTextTrackFontVariant().IsEmpty() || 1482 !settings->GetTextTrackFontVariant().IsEmpty() ||
1435 !settings->GetTextTrackTextColor().IsEmpty() || 1483 !settings->GetTextTrackTextColor().IsEmpty() ||
1436 !settings->GetTextTrackTextShadow().IsEmpty() || 1484 !settings->GetTextTrackTextShadow().IsEmpty() ||
1437 !settings->GetTextTrackTextSize().IsEmpty()) 1485 !settings->GetTextTrackTextSize().IsEmpty())
1438 return true; 1486 return true;
1439 return false; 1487 return false;
1440 } 1488 }
1441 1489
1442 static inline bool IsPropertyInWhitelist( 1490 static inline bool IsPropertyInWhitelist(
1443 PropertyWhitelistType property_whitelist_type, 1491 PropertyWhitelistType propertyWhitelistType,
1444 CSSPropertyID property, 1492 CSSPropertyID property,
1445 const Document& document) { 1493 const Document& document) {
1446 if (property_whitelist_type == kPropertyWhitelistNone) 1494 if (propertyWhitelistType == kPropertyWhitelistNone)
1447 return true; // Early bail for the by far most common case. 1495 return true; // Early bail for the by far most common case.
1448 1496
1449 if (property_whitelist_type == kPropertyWhitelistFirstLetter) 1497 if (propertyWhitelistType == kPropertyWhitelistFirstLetter)
1450 return IsValidFirstLetterStyleProperty(property); 1498 return IsValidFirstLetterStyleProperty(property);
1451 1499
1452 if (property_whitelist_type == kPropertyWhitelistCue) 1500 if (propertyWhitelistType == kPropertyWhitelistCue)
1453 return IsValidCueStyleProperty(property) && 1501 return IsValidCueStyleProperty(property) &&
1454 !ShouldIgnoreTextTrackAuthorStyle(document); 1502 !ShouldIgnoreTextTrackAuthorStyle(document);
1455 1503
1456 NOTREACHED(); 1504 NOTREACHED();
1457 return true; 1505 return true;
1458 } 1506 }
1459 1507
1460 // This method expands the 'all' shorthand property to longhand properties 1508 // This method expands the 'all' shorthand property to longhand properties
1461 // and applies the expanded longhand properties. 1509 // and applies the expanded longhand properties.
1462 template <CSSPropertyPriority priority> 1510 template <CSSPropertyPriority priority>
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 1791
1744 // TODO(leviw): We need the proper bit for tracking whether we need to do 1792 // TODO(leviw): We need the proper bit for tracking whether we need to do
1745 // this work. 1793 // this work.
1746 ApplyMatchedProperties<kResolveVariables, kUpdateNeedsApplyPass>( 1794 ApplyMatchedProperties<kResolveVariables, kUpdateNeedsApplyPass>(
1747 state, match_result.AuthorRules(), false, apply_inherited_only, 1795 state, match_result.AuthorRules(), false, apply_inherited_only,
1748 needs_apply_pass); 1796 needs_apply_pass);
1749 ApplyMatchedProperties<kResolveVariables, kCheckNeedsApplyPass>( 1797 ApplyMatchedProperties<kResolveVariables, kCheckNeedsApplyPass>(
1750 state, match_result.AuthorRules(), true, apply_inherited_only, 1798 state, match_result.AuthorRules(), true, apply_inherited_only,
1751 needs_apply_pass); 1799 needs_apply_pass);
1752 if (apply_animations == kIncludeAnimations) { 1800 if (apply_animations == kIncludeAnimations) {
1753 ApplyAnimatedProperties<kResolveVariables>( 1801 ApplyAnimatedCustomProperties(state);
1754 state, state.AnimationUpdate().ActiveInterpolationsForAnimations());
1755 ApplyAnimatedProperties<kResolveVariables>(
1756 state,
1757 state.AnimationUpdate().ActiveInterpolationsForCustomTransitions());
1758 } 1802 }
1759 // TODO(leviw): stop recalculating every time 1803 // TODO(leviw): stop recalculating every time
1760 CSSVariableResolver::ResolveVariableDefinitions(state); 1804 CSSVariableResolver::ResolveVariableDefinitions(state);
1761 1805
1762 if (RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { 1806 if (RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) {
1763 if (CacheCustomPropertiesForApplyAtRules(state, 1807 if (CacheCustomPropertiesForApplyAtRules(state,
1764 match_result.AuthorRules())) { 1808 match_result.AuthorRules())) {
1765 ApplyMatchedProperties<kResolveVariables, kUpdateNeedsApplyPass>( 1809 ApplyMatchedProperties<kResolveVariables, kUpdateNeedsApplyPass>(
1766 state, match_result.AuthorRules(), false, apply_inherited_only, 1810 state, match_result.AuthorRules(), false, apply_inherited_only,
1767 needs_apply_pass); 1811 needs_apply_pass);
1768 ApplyMatchedProperties<kResolveVariables, kCheckNeedsApplyPass>( 1812 ApplyMatchedProperties<kResolveVariables, kCheckNeedsApplyPass>(
1769 state, match_result.AuthorRules(), true, apply_inherited_only, 1813 state, match_result.AuthorRules(), true, apply_inherited_only,
1770 needs_apply_pass); 1814 needs_apply_pass);
1771 if (apply_animations == kIncludeAnimations) { 1815 if (apply_animations == kIncludeAnimations) {
1772 ApplyAnimatedProperties<kResolveVariables>( 1816 ApplyAnimatedCustomProperties(state);
1773 state, state.AnimationUpdate().ActiveInterpolationsForAnimations());
1774 ApplyAnimatedProperties<kResolveVariables>(
1775 state,
1776 state.AnimationUpdate().ActiveInterpolationsForCustomTransitions());
1777 } 1817 }
1778 CSSVariableResolver::ResolveVariableDefinitions(state); 1818 CSSVariableResolver::ResolveVariableDefinitions(state);
1779 } 1819 }
1780 } 1820 }
1781 } 1821 }
1782 1822
1783 void StyleResolver::ApplyMatchedAnimationProperties( 1823 void StyleResolver::ApplyMatchedAnimationProperties(
1784 StyleResolverState& state, 1824 StyleResolverState& state,
1785 const MatchResult& match_result, 1825 const MatchResult& match_result,
1786 const CacheSuccess& cache_success, 1826 const CacheSuccess& cache_success,
(...skipping 21 matching lines...) Expand all
1808 CSSAnimations::CalculateTransitionUpdate(state.AnimationUpdate(), 1848 CSSAnimations::CalculateTransitionUpdate(state.AnimationUpdate(),
1809 CSSAnimations::PropertyPass::kCustom, 1849 CSSAnimations::PropertyPass::kCustom,
1810 animating_element, *state.Style()); 1850 animating_element, *state.Style());
1811 1851
1812 state.SetIsAnimationInterpolationMapReady(); 1852 state.SetIsAnimationInterpolationMapReady();
1813 1853
1814 if (state.IsAnimatingCustomProperties()) { 1854 if (state.IsAnimatingCustomProperties()) {
1815 return; 1855 return;
1816 } 1856 }
1817 if (!state.AnimationUpdate() 1857 if (!state.AnimationUpdate()
1858 .ActiveInterpolationsForCustomAnimations()
1859 .IsEmpty() ||
1860 !state.AnimationUpdate()
1818 .ActiveInterpolationsForCustomTransitions() 1861 .ActiveInterpolationsForCustomTransitions()
1819 .IsEmpty()) { 1862 .IsEmpty()) {
1820 state.SetIsAnimatingCustomProperties(true); 1863 state.SetIsAnimatingCustomProperties(true);
1821 return;
1822 }
1823 for (const auto& property_handle :
1824 state.AnimationUpdate().ActiveInterpolationsForAnimations().Keys()) {
1825 if (CSSAnimations::IsCustomPropertyHandle(property_handle)) {
1826 state.SetIsAnimatingCustomProperties(true);
1827 return;
1828 }
1829 } 1864 }
1830 } 1865 }
1831 1866
1832 void StyleResolver::ApplyMatchedStandardProperties( 1867 void StyleResolver::ApplyMatchedStandardProperties(
1833 StyleResolverState& state, 1868 StyleResolverState& state,
1834 const MatchResult& match_result, 1869 const MatchResult& match_result,
1835 const CacheSuccess& cache_success, 1870 const CacheSuccess& cache_success,
1836 NeedsApplyPass& needs_apply_pass) { 1871 NeedsApplyPass& needs_apply_pass) {
1837 INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(), 1872 INCREMENT_STYLE_STATS_COUNTER(GetDocument().GetStyleEngine(),
1838 matched_property_apply, 1); 1873 matched_property_apply, 1);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 2052
2018 DEFINE_TRACE(StyleResolver) { 2053 DEFINE_TRACE(StyleResolver) {
2019 visitor->Trace(matched_properties_cache_); 2054 visitor->Trace(matched_properties_cache_);
2020 visitor->Trace(selector_filter_); 2055 visitor->Trace(selector_filter_);
2021 visitor->Trace(style_sharing_lists_); 2056 visitor->Trace(style_sharing_lists_);
2022 visitor->Trace(document_); 2057 visitor->Trace(document_);
2023 visitor->Trace(tracker_); 2058 visitor->Trace(tracker_);
2024 } 2059 }
2025 2060
2026 } // namespace blink 2061 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698