Commit 6d1df6cc authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Don't create CSSAnimationData to apply initial values.

ComputedStyle::Animations() are null if all values are initial. If we
apply initial we don't need to create the object.

The same applies to CSSTransitionData.

Change-Id: I4c529a9df1764ba04560554892a46c452734d26a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2489621Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819540}
parent 9d5ab21c
......@@ -218,6 +218,8 @@ To<Longhand>(resolved_property).{{apply_call}};
{% set animation = 'Animation' if property.style_builder_template == 'animation' else 'Transition' %}
{% set vector = attribute + "List()" %}
{% call(property) apply_initial(property) %}
if (!state.Style()->{{animation}}s())
return;
CSS{{animation}}Data& data = state.Style()->Access{{animation}}s();
data.{{vector}}.clear();
data.{{vector}}.push_back(CSS{{animation}}Data::Initial{{attribute}}());
......
......@@ -1096,4 +1096,24 @@ TEST(ComputedStyleTest, ClonedStyleTransitionsAreIndependent) {
EXPECT_EQ(1u, style->Transitions()->PropertyList().size());
}
TEST(ComputedStyleTest, ApplyInitialAnimationNameAndTransitionProperty) {
std::unique_ptr<DummyPageHolder> dummy_page_holder_ =
std::make_unique<DummyPageHolder>(IntSize(0, 0), nullptr);
const ComputedStyle* initial = &ComputedStyle::InitialStyle();
StyleResolverState state(dummy_page_holder_->GetDocument(),
*dummy_page_holder_->GetDocument().documentElement(),
initial, initial);
scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
state.SetStyle(style);
EXPECT_FALSE(style->Animations());
EXPECT_FALSE(style->Transitions());
To<Longhand>(GetCSSPropertyAnimationName()).ApplyInitial(state);
To<Longhand>(GetCSSPropertyTransitionProperty()).ApplyInitial(state);
EXPECT_FALSE(style->Animations());
EXPECT_FALSE(style->Transitions());
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment