Commit 1860545f authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[cascade] Respect filter when analyzing interpolations

The filter was accidentally unused when analyzing interpolations.
Everything still worked, because Apply-time filtering was honored. It
might be that we actually don't need Analyze-time filtering at all,
but we shouldn't remove it until the performance implication of such a
change has been investigated.

In the meantime, the filter should be respected.

Change-Id: Ib04e044ab4725940c17312e80206a75630bb8d80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106590Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751277}
parent 34c2914b
......@@ -112,7 +112,16 @@ void StyleCascade::Analyze(const CascadeInterpolations& interpolations,
uint32_t position = EncodeInterpolationPosition(
i, active_interpolation.key.IsPresentationAttribute());
CascadePriority priority(entries[i].origin, false, 0, position);
map_.Add(active_interpolation.key.GetCSSPropertyName(), priority);
auto name = active_interpolation.key.GetCSSPropertyName();
CSSPropertyRef ref(name, GetDocument());
DCHECK(ref.IsValid());
const CSSProperty& property = ref.GetProperty();
if (filter.Rejects(property))
continue;
map_.Add(name, priority);
}
}
}
......
......@@ -161,13 +161,13 @@ class TestCascade {
&GetDocument().EnsureStyleResolver());
}
void AnalyzeAnimations() {
void AnalyzeAnimations(CascadeFilter filter = CascadeFilter()) {
CalculateAnimationUpdate();
cascade_.Analyze(GetInterpolations(), CascadeFilter());
cascade_.Analyze(GetInterpolations(), filter);
}
void AnalyzeTransitions() {
void AnalyzeTransitions(CascadeFilter filter = CascadeFilter()) {
CalculateTransitionUpdate();
cascade_.Analyze(GetInterpolations(), CascadeFilter());
cascade_.Analyze(GetInterpolations(), filter);
}
private:
......@@ -1418,6 +1418,49 @@ TEST_F(StyleCascadeTest, ValidEnvInUsedFallback) {
EXPECT_EQ("rgb(255, 0, 0)", cascade.ComputedValue("background-color"));
}
TEST_F(StyleCascadeTest, AnimationAnalyzeFilter) {
AppendSheet(R"HTML(
@keyframes test {
from { color: white; background-color: white; }
to { color: gray; background-color: gray; }
}
)HTML");
TestCascade cascade(GetDocument());
cascade.Add("animation: test 1s");
cascade.Apply();
cascade.AnalyzeAnimations(CascadeFilter(CSSProperty::kInherited, true));
EXPECT_EQ(CascadeOrigin::kAnimation, cascade.GetOrigin("background-color"));
EXPECT_EQ(CascadeOrigin::kNone, cascade.GetOrigin("color"));
}
TEST_F(StyleCascadeTest, TransitionAnalyzeFilter) {
TestCascade cascade1(GetDocument());
cascade1.Add("background-color: white");
cascade1.Add("color: white");
cascade1.Add("transition: all 1s");
cascade1.Apply();
// Set the old style on the element, so that the transition
// update detects it.
GetDocument().body()->SetComputedStyle(cascade1.TakeStyle());
// Now simulate a new style, with new color values.
TestCascade cascade2(GetDocument());
cascade2.Add("background-color: gray");
cascade2.Add("color: gray");
cascade2.Add("transition: all 1s");
cascade2.Apply();
cascade2.AnalyzeTransitions(CascadeFilter(CSSProperty::kInherited, true));
EXPECT_EQ(CascadeOrigin::kTransition, cascade2.GetOrigin("background-color"));
EXPECT_EQ(CascadeOrigin::kAuthor, cascade2.GetOrigin("color"));
}
TEST_F(StyleCascadeTest, PendingKeyframeAnimation) {
RegisterProperty(GetDocument(), "--x", "<length>", "0px", false);
......
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