| Index: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
|
| index 3d8ea3d2d68bc195809332385b570621b420f48f..84b8a4066f30e70a31e1ddff975ecb64ccc15333 100644
|
| --- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
|
| +++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
|
| @@ -306,15 +306,15 @@ static void MatchElementScopeRules(const Element& element,
|
| }
|
|
|
| static bool ShouldCheckScope(const Element& element,
|
| - const Node& scoping_node,
|
| - bool is_inner_tree_scope) {
|
| - if (is_inner_tree_scope &&
|
| - element.GetTreeScope() != scoping_node.GetTreeScope()) {
|
| + const Node& scopingNode,
|
| + bool isInnerTreeScope) {
|
| + if (isInnerTreeScope &&
|
| + element.GetTreeScope() != scopingNode.GetTreeScope()) {
|
| // Check if |element| may be affected by a ::content rule in |scopingNode|'s
|
| // style. If |element| is a descendant of a shadow host which is ancestral
|
| // to |scopingNode|, the |element| should be included for rule collection.
|
| // Skip otherwise.
|
| - const TreeScope* scope = &scoping_node.GetTreeScope();
|
| + const TreeScope* scope = &scopingNode.GetTreeScope();
|
| while (scope && scope->ParentTreeScope() != &element.GetTreeScope())
|
| scope = scope->ParentTreeScope();
|
| Element* shadow_host =
|
| @@ -324,14 +324,14 @@ static bool ShouldCheckScope(const Element& element,
|
|
|
| // When |element| can be distributed to |scopingNode| via <shadow>, ::content
|
| // rule can match, thus the case should be included.
|
| - if (!is_inner_tree_scope &&
|
| - scoping_node.ParentOrShadowHostNode() ==
|
| + if (!isInnerTreeScope &&
|
| + scopingNode.ParentOrShadowHostNode() ==
|
| element.GetTreeScope().RootNode().ParentOrShadowHostNode())
|
| return true;
|
|
|
| // Obviously cases when ancestor scope has /deep/ or ::shadow rule should be
|
| // included. Skip otherwise.
|
| - return scoping_node.GetTreeScope()
|
| + return scopingNode.GetTreeScope()
|
| .GetScopedStyleResolver()
|
| ->HasDeepOrShadowSelector();
|
| }
|
| @@ -903,25 +903,25 @@ PseudoElement* StyleResolver::CreatePseudoElementIfNeeded(Element& parent,
|
|
|
| bool StyleResolver::PseudoStyleForElementInternal(
|
| Element& element,
|
| - const PseudoStyleRequest& pseudo_style_request,
|
| - const ComputedStyle* parent_style,
|
| + const PseudoStyleRequest& pseudoStyleRequest,
|
| + const ComputedStyle* parentStyle,
|
| StyleResolverState& state) {
|
| DCHECK(GetDocument().GetFrame());
|
| DCHECK(GetDocument().GetSettings());
|
| - DCHECK(pseudo_style_request.pseudo_id != kPseudoIdFirstLineInherited);
|
| + DCHECK(pseudoStyleRequest.pseudo_id != kPseudoIdFirstLineInherited);
|
| DCHECK(state.ParentStyle());
|
|
|
| SelectorFilterParentScope::EnsureParentStackIsPushed();
|
|
|
| Element* pseudo_element =
|
| - element.GetPseudoElement(pseudo_style_request.pseudo_id);
|
| + element.GetPseudoElement(pseudoStyleRequest.pseudo_id);
|
|
|
| const ComputedStyle* base_computed_style =
|
| CalculateBaseComputedStyle(state, pseudo_element);
|
|
|
| if (base_computed_style) {
|
| state.SetStyle(ComputedStyle::Clone(*base_computed_style));
|
| - } else if (pseudo_style_request.AllowsInheritance(state.ParentStyle())) {
|
| + } else if (pseudoStyleRequest.AllowsInheritance(state.ParentStyle())) {
|
| RefPtr<ComputedStyle> style = ComputedStyle::Create();
|
| style->InheritFrom(*state.ParentStyle());
|
| state.SetStyle(std::move(style));
|
| @@ -930,7 +930,7 @@ bool StyleResolver::PseudoStyleForElementInternal(
|
| state.SetParentStyle(ComputedStyle::Clone(*state.Style()));
|
| }
|
|
|
| - state.Style()->SetStyleType(pseudo_style_request.pseudo_id);
|
| + state.Style()->SetStyleType(pseudoStyleRequest.pseudo_id);
|
|
|
| // Since we don't use pseudo-elements in any of our quirk/print
|
| // user agent rules, don't waste time walking those rules.
|
| @@ -939,7 +939,7 @@ bool StyleResolver::PseudoStyleForElementInternal(
|
| // Check UA, user and author rules.
|
| ElementRuleCollector collector(state.ElementContext(), selector_filter_,
|
| state.Style());
|
| - collector.SetPseudoStyleRequest(pseudo_style_request);
|
| + collector.SetPseudoStyleRequest(pseudoStyleRequest);
|
|
|
| MatchUARules(collector);
|
| MatchAuthorRules(*state.GetElement(), collector);
|
| @@ -1132,32 +1132,82 @@ void StyleResolver::CollectPseudoRulesForElement(
|
| }
|
| }
|
|
|
| +void StyleResolver::ApplyAnimatedCustomProperties(StyleResolverState& state) {
|
| + if (!state.IsAnimatingCustomProperties()) {
|
| + return;
|
| + }
|
| + HashSet<PropertyHandle>& pending =
|
| + state.CustomPropertiesPendingAnimationApplication();
|
| + pending.Clear();
|
| + for (const auto& interpolations_map :
|
| + {state.AnimationUpdate().ActiveInterpolationsForCustomAnimations(),
|
| + state.AnimationUpdate().ActiveInterpolationsForCustomTransitions()}) {
|
| + for (const auto& entry : interpolations_map) {
|
| + pending.insert(entry.key);
|
| + }
|
| + }
|
| + while (!pending.IsEmpty()) {
|
| + ApplyAnimatedCustomProperty(state, pending.TakeAny());
|
| + }
|
| +}
|
| +
|
| +static const ActiveInterpolations& ActiveInterpolationsForCustomProperty(
|
| + const StyleResolverState& state,
|
| + const PropertyHandle& property) {
|
| + const ActiveInterpolationsMap& animations_map =
|
| + state.AnimationUpdate().ActiveInterpolationsForCustomAnimations();
|
| + const auto& find_result = animations_map.Find(property);
|
| + if (find_result != animations_map.end()) {
|
| + return find_result->value;
|
| + }
|
| + return state.AnimationUpdate()
|
| + .ActiveInterpolationsForCustomAnimations()
|
| + .Find(property)
|
| + ->value;
|
| +}
|
| +
|
| +void StyleResolver::ApplyAnimatedCustomProperty(
|
| + StyleResolverState& state,
|
| + const PropertyHandle& property) {
|
| + DCHECK(property.IsCSSCustomProperty());
|
| + const ActiveInterpolations& interpolations =
|
| + ActiveInterpolationsForCustomProperty(state, property);
|
| + const Interpolation& interpolation = *interpolations.front();
|
| + if (interpolation.IsInvalidatableInterpolation()) {
|
| + CSSInterpolationTypesMap map(state.GetDocument().GetPropertyRegistry());
|
| + InterpolationEnvironment environment(map, state);
|
| + InvalidatableInterpolation::ApplyStack(interpolations, environment);
|
| + } else {
|
| + ToTransitionInterpolation(interpolation).Apply(state);
|
| + }
|
| +}
|
| +
|
| bool StyleResolver::ApplyAnimatedStandardProperties(
|
| StyleResolverState& state,
|
| - const Element* animating_element) {
|
| + const Element* animatingElement) {
|
| Element* element = state.GetElement();
|
| DCHECK(element);
|
|
|
| // The animating element may be this element, or its pseudo element. It is
|
| // null when calculating the style for a potential pseudo element that has
|
| // yet to be created.
|
| - DCHECK(animating_element == element || !animating_element ||
|
| - animating_element->ParentOrShadowHostElement() == element);
|
| + DCHECK(animatingElement == element || !animatingElement ||
|
| + animatingElement->ParentOrShadowHostElement() == element);
|
|
|
| if (state.Style()->Animations() ||
|
| - (animating_element && animating_element->HasAnimations())) {
|
| + (animatingElement && animatingElement->HasAnimations())) {
|
| if (!state.IsAnimationInterpolationMapReady())
|
| - CalculateAnimationUpdate(state, animating_element);
|
| + CalculateAnimationUpdate(state, animatingElement);
|
| } else if (!state.Style()->Transitions()) {
|
| return false;
|
| }
|
|
|
| CSSAnimations::CalculateCompositorAnimationUpdate(
|
| - state.AnimationUpdate(), animating_element, *element, *state.Style(),
|
| + state.AnimationUpdate(), animatingElement, *element, *state.Style(),
|
| state.ParentStyle(), WasViewportResized());
|
| CSSAnimations::CalculateTransitionUpdate(
|
| state.AnimationUpdate(), CSSAnimations::PropertyPass::kStandard,
|
| - animating_element, *state.Style());
|
| + animatingElement, *state.Style());
|
|
|
| CSSAnimations::SnapshotCompositorKeyframes(
|
| *element, state.AnimationUpdate(), *state.Style(), state.ParentStyle());
|
| @@ -1170,23 +1220,18 @@ bool StyleResolver::ApplyAnimatedStandardProperties(
|
| state.SetApplyPropertyToVisitedLinkStyle(true);
|
| }
|
|
|
| - const ActiveInterpolationsMap& active_interpolations_map_for_animations =
|
| - state.AnimationUpdate().ActiveInterpolationsForAnimations();
|
| - const ActiveInterpolationsMap&
|
| - active_interpolations_map_for_standard_transitions =
|
| - state.AnimationUpdate().ActiveInterpolationsForStandardTransitions();
|
| - // TODO(crbug.com/644148): Apply animations on custom properties.
|
| - ApplyAnimatedProperties<kHighPropertyPriority>(
|
| - state, active_interpolations_map_for_animations);
|
| - ApplyAnimatedProperties<kHighPropertyPriority>(
|
| - state, active_interpolations_map_for_standard_transitions);
|
| + const ActiveInterpolationsMap& animations_map =
|
| + state.AnimationUpdate().ActiveInterpolationsForStandardAnimations();
|
| + const ActiveInterpolationsMap& transitions_map =
|
| + state.AnimationUpdate().ActiveInterpolationsForStandardTransitions();
|
| + ApplyAnimatedStandardProperties<kHighPropertyPriority>(state, animations_map);
|
| + ApplyAnimatedStandardProperties<kHighPropertyPriority>(state,
|
| + transitions_map);
|
|
|
| UpdateFont(state);
|
|
|
| - ApplyAnimatedProperties<kLowPropertyPriority>(
|
| - state, active_interpolations_map_for_animations);
|
| - ApplyAnimatedProperties<kLowPropertyPriority>(
|
| - state, active_interpolations_map_for_standard_transitions);
|
| + ApplyAnimatedStandardProperties<kLowPropertyPriority>(state, animations_map);
|
| + ApplyAnimatedStandardProperties<kLowPropertyPriority>(state, transitions_map);
|
|
|
| // Start loading resources used by animations.
|
| LoadPendingResources(state);
|
| @@ -1219,9 +1264,12 @@ StyleRuleKeyframes* StyleResolver::FindKeyframesRule(
|
| }
|
|
|
| template <CSSPropertyPriority priority>
|
| -void StyleResolver::ApplyAnimatedProperties(
|
| +void StyleResolver::ApplyAnimatedStandardProperties(
|
| StyleResolverState& state,
|
| const ActiveInterpolationsMap& active_interpolations_map) {
|
| + static_assert(
|
| + priority != kResolveVariables,
|
| + "Use applyAnimatedCustomProperty() for custom property animations");
|
| // TODO(alancutter): Don't apply presentation attribute animations here,
|
| // they should instead apply in
|
| // SVGElement::collectStyleForPresentationAttribute().
|
| @@ -1440,16 +1488,16 @@ static bool ShouldIgnoreTextTrackAuthorStyle(const Document& document) {
|
| }
|
|
|
| static inline bool IsPropertyInWhitelist(
|
| - PropertyWhitelistType property_whitelist_type,
|
| + PropertyWhitelistType propertyWhitelistType,
|
| CSSPropertyID property,
|
| const Document& document) {
|
| - if (property_whitelist_type == kPropertyWhitelistNone)
|
| + if (propertyWhitelistType == kPropertyWhitelistNone)
|
| return true; // Early bail for the by far most common case.
|
|
|
| - if (property_whitelist_type == kPropertyWhitelistFirstLetter)
|
| + if (propertyWhitelistType == kPropertyWhitelistFirstLetter)
|
| return IsValidFirstLetterStyleProperty(property);
|
|
|
| - if (property_whitelist_type == kPropertyWhitelistCue)
|
| + if (propertyWhitelistType == kPropertyWhitelistCue)
|
| return IsValidCueStyleProperty(property) &&
|
| !ShouldIgnoreTextTrackAuthorStyle(document);
|
|
|
| @@ -1750,11 +1798,7 @@ void StyleResolver::ApplyCustomProperties(StyleResolverState& state,
|
| state, match_result.AuthorRules(), true, apply_inherited_only,
|
| needs_apply_pass);
|
| if (apply_animations == kIncludeAnimations) {
|
| - ApplyAnimatedProperties<kResolveVariables>(
|
| - state, state.AnimationUpdate().ActiveInterpolationsForAnimations());
|
| - ApplyAnimatedProperties<kResolveVariables>(
|
| - state,
|
| - state.AnimationUpdate().ActiveInterpolationsForCustomTransitions());
|
| + ApplyAnimatedCustomProperties(state);
|
| }
|
| // TODO(leviw): stop recalculating every time
|
| CSSVariableResolver::ResolveVariableDefinitions(state);
|
| @@ -1769,11 +1813,7 @@ void StyleResolver::ApplyCustomProperties(StyleResolverState& state,
|
| state, match_result.AuthorRules(), true, apply_inherited_only,
|
| needs_apply_pass);
|
| if (apply_animations == kIncludeAnimations) {
|
| - ApplyAnimatedProperties<kResolveVariables>(
|
| - state, state.AnimationUpdate().ActiveInterpolationsForAnimations());
|
| - ApplyAnimatedProperties<kResolveVariables>(
|
| - state,
|
| - state.AnimationUpdate().ActiveInterpolationsForCustomTransitions());
|
| + ApplyAnimatedCustomProperties(state);
|
| }
|
| CSSVariableResolver::ResolveVariableDefinitions(state);
|
| }
|
| @@ -1815,17 +1855,12 @@ void StyleResolver::CalculateAnimationUpdate(StyleResolverState& state,
|
| return;
|
| }
|
| if (!state.AnimationUpdate()
|
| + .ActiveInterpolationsForCustomAnimations()
|
| + .IsEmpty() ||
|
| + !state.AnimationUpdate()
|
| .ActiveInterpolationsForCustomTransitions()
|
| .IsEmpty()) {
|
| state.SetIsAnimatingCustomProperties(true);
|
| - return;
|
| - }
|
| - for (const auto& property_handle :
|
| - state.AnimationUpdate().ActiveInterpolationsForAnimations().Keys()) {
|
| - if (CSSAnimations::IsCustomPropertyHandle(property_handle)) {
|
| - state.SetIsAnimatingCustomProperties(true);
|
| - return;
|
| - }
|
| }
|
| }
|
|
|
|
|