Skip to content

Commit

Permalink
[StyleBuilder] Remove StyleResolver::CreateComputedStyle
Browse files Browse the repository at this point in the history
This was only used within tests now. There should be no behaviour
change.

Bug: 1377295
Change-Id: I5ea13303bd60af9a0914fae41a1d55e382192ee4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4216094
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1102712}
  • Loading branch information
bfgeek authored and Chromium LUCI CQ committed Feb 8, 2023
1 parent 887adbe commit a9e2056
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 142 deletions.
12 changes: 4 additions & 8 deletions third_party/blink/renderer/core/animation/animation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1735,8 +1735,7 @@ TEST_P(AnimationAnimationTestCompositing,
scroll_timeline, exception_state);

model->SnapshotAllCompositorKeyframesIfNecessary(
*element, *GetDocument().GetStyleResolver().CreateComputedStyle(),
nullptr);
*element, GetDocument().GetStyleResolver().InitialStyle(), nullptr);

UpdateAllLifecyclePhasesForTest();
scroll_animation->play();
Expand Down Expand Up @@ -1803,8 +1802,7 @@ TEST_P(AnimationAnimationTestCompositing,
Animation::Create(keyframe_effect, scroll_timeline, exception_state);

model->SnapshotAllCompositorKeyframesIfNecessary(
*element, *GetDocument().GetStyleResolver().CreateComputedStyle(),
nullptr);
*element, GetDocument().GetStyleResolver().InitialStyle(), nullptr);

UpdateAllLifecyclePhasesForTest();
const double TEST_START_PERCENT = 10;
Expand Down Expand Up @@ -1932,8 +1930,7 @@ TEST_P(AnimationAnimationTestCompositing,
Animation* scroll_animation =
Animation::Create(keyframe_effect, scroll_timeline, exception_state);
model->SnapshotAllCompositorKeyframesIfNecessary(
*element, *GetDocument().GetStyleResolver().CreateComputedStyle(),
nullptr);
*element, GetDocument().GetStyleResolver().InitialStyle(), nullptr);
UpdateAllLifecyclePhasesForTest();

scroll_animation->play();
Expand Down Expand Up @@ -2295,8 +2292,7 @@ TEST_P(AnimationAnimationTestCompositing,
scroll_timeline, exception_state);

model->SnapshotAllCompositorKeyframesIfNecessary(
*element, *GetDocument().GetStyleResolver().CreateComputedStyle(),
nullptr);
*element, GetDocument().GetStyleResolver().InitialStyle(), nullptr);

UpdateAllLifecyclePhasesForTest();
scroll_animation->play();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,9 +988,9 @@ TEST_P(AnimationCompositorAnimationsTest,
auto* keyframe_effect1 =
MakeGarbageCollected<KeyframeEffect>(element_, animation_effect, timing);
Animation* animation = timeline_->Play(keyframe_effect1);
auto style = GetDocument().GetStyleResolver().CreateComputedStyle();
const auto& style = GetDocument().GetStyleResolver().InitialStyle();
animation_effect->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(),
*style, nullptr);
style, nullptr);

// Now we can check that we are set up correctly.
EXPECT_EQ(CheckCanStartEffectOnCompositor(timing, *element_.Get(), animation,
Expand Down Expand Up @@ -1143,7 +1143,7 @@ TEST_P(AnimationCompositorAnimationsTest, CheckCanStartForceReduceMotion) {

TEST_P(AnimationCompositorAnimationsTest,
CanStartElementOnCompositorEffectInvalid) {
auto style = GetDocument().GetStyleResolver().CreateComputedStyle();
const auto& style = GetDocument().GetStyleResolver().InitialStyle();

// Check that we notice the value is not animatable correctly.
const CSSProperty& target_property1(GetCSSPropertyOutlineStyle());
Expand All @@ -1156,7 +1156,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect1, timing_);

Animation* animation1 = timeline_->Play(keyframe_effect1);
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

const auto& keyframes1 =
Expand All @@ -1179,7 +1179,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(inline_.Get(), effect2, timing_);

Animation* animation2 = timeline_->Play(keyframe_effect2);
effect2->SnapshotAllCompositorKeyframesIfNecessary(*inline_.Get(), *style,
effect2->SnapshotAllCompositorKeyframesIfNecessary(*inline_.Get(), style,
nullptr);

const auto& keyframes2 =
Expand All @@ -1205,7 +1205,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect3, timing_);

Animation* animation3 = timeline_->Play(keyframe_effect3);
effect3->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect3->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

const auto& keyframes3 =
Expand All @@ -1229,8 +1229,8 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect1, timing_);

Animation* animation1 = timeline_->Play(keyframe_effect1);
auto style = GetDocument().GetStyleResolver().CreateComputedStyle();
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
const auto& style = GetDocument().GetStyleResolver().InitialStyle();
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

// Now we can check that we are set up correctly.
Expand All @@ -1247,7 +1247,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect2, timing_);

Animation* animation2 = timeline_->Play(keyframe_effect2);
effect2->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect2->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);
EXPECT_TRUE(CheckCanStartEffectOnCompositor(timing_, *element_.Get(),
animation2, *effect2) &
Expand All @@ -1261,7 +1261,7 @@ TEST_P(AnimationCompositorAnimationsTest,

TEST_P(AnimationCompositorAnimationsTest,
CanStartElementOnCompositorEffectTransform) {
auto style = GetDocument().GetStyleResolver().CreateComputedStyle();
const auto& style = GetDocument().GetStyleResolver().InitialStyle();

StringKeyframeEffectModel* effect1 = CreateKeyframeEffectModel(
CreateReplaceOpKeyframe(CSSPropertyID::kTransform, "none", 0),
Expand All @@ -1271,7 +1271,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect1, timing_);

Animation* animation1 = timeline_->Play(keyframe_effect1);
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

// Check if our layout object is not TransformApplicable
Expand All @@ -1283,7 +1283,7 @@ TEST_P(AnimationCompositorAnimationsTest,

TEST_P(AnimationCompositorAnimationsTest,
CheckCanStartEffectOnCompositorUnsupportedCSSProperties) {
auto style = GetDocument().GetStyleResolver().CreateComputedStyle();
const auto& style = GetDocument().GetStyleResolver().InitialStyle();

StringKeyframeEffectModel* effect1 = CreateKeyframeEffectModel(
CreateReplaceOpKeyframe(CSSPropertyID::kOpacity, "0", 0),
Expand All @@ -1293,7 +1293,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect1, timing_);

Animation* animation1 = timeline_->Play(keyframe_effect1);
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

// Make sure supported properties do not register a failure
Expand All @@ -1311,7 +1311,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect2, timing_);

Animation* animation2 = timeline_->Play(keyframe_effect2);
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

// Make sure unsupported properties are reported
Expand Down Expand Up @@ -1343,7 +1343,7 @@ TEST_P(AnimationCompositorAnimationsTest,
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect3, timing_);

Animation* animation3 = timeline_->Play(keyframe_effect3);
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);

// Make sure only the unsupported properties are reported
Expand Down Expand Up @@ -2002,9 +2002,9 @@ TEST_P(AnimationCompositorAnimationsTest,
auto* keyframe_effect1 = MakeGarbageCollected<KeyframeEffect>(
element_.Get(), animation_effect1, timing);
Animation* animation1 = timeline_->Play(keyframe_effect1);
auto style = GetDocument().GetStyleResolver().CreateComputedStyle();
const auto& style = GetDocument().GetStyleResolver().InitialStyle();
animation_effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(),
*style, nullptr);
style, nullptr);
EXPECT_EQ(CheckCanStartEffectOnCompositor(timing, *element_.Get(), animation1,
*animation_effect1),
CompositorAnimations::kNoFailure);
Expand All @@ -2014,7 +2014,7 @@ TEST_P(AnimationCompositorAnimationsTest,
element_.Get(), animation_effect2, timing);
Animation* animation2 = timeline_->Play(keyframe_effect2);
animation_effect2->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(),
*style, nullptr);
style, nullptr);
EXPECT_TRUE(CheckCanStartEffectOnCompositor(timing, *element_.Get(),
animation2, *animation_effect2) &
CompositorAnimations::kTargetHasIncompatibleAnimations);
Expand Down Expand Up @@ -2551,8 +2551,7 @@ TEST_P(AnimationCompositorAnimationsTest, Fragmented) {

TEST_P(AnimationCompositorAnimationsTest,
CancelIncompatibleTransformCompositorAnimation) {
scoped_refptr<ComputedStyle> style =
GetDocument().GetStyleResolver().CreateComputedStyle();
const auto& style = GetDocument().GetStyleResolver().InitialStyle();

// The first animation for transform is ok to run on the compositor.
StringKeyframeEffectModel* effect1 = CreateKeyframeEffectModel(
Expand All @@ -2561,7 +2560,7 @@ TEST_P(AnimationCompositorAnimationsTest,
auto* keyframe_effect1 =
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect1, timing_);
Animation* animation1 = timeline_->Play(keyframe_effect1);
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect1->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);
EXPECT_EQ(CheckCanStartEffectOnCompositor(timing_, *element_.Get(),
animation1, *effect1),
Expand All @@ -2577,7 +2576,7 @@ TEST_P(AnimationCompositorAnimationsTest,
KeyframeEffect* keyframe_effect2 =
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect2, timing_);
Animation* animation2 = timeline_->Play(keyframe_effect2);
effect2->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect2->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);
EXPECT_EQ(CheckCanStartEffectOnCompositor(timing_, *element_.Get(),
animation2, *effect2),
Expand All @@ -2594,7 +2593,7 @@ TEST_P(AnimationCompositorAnimationsTest,
KeyframeEffect* keyframe_effect3 =
MakeGarbageCollected<KeyframeEffect>(element_.Get(), effect3, timing_);
Animation* animation3 = timeline_->Play(keyframe_effect3);
effect3->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), *style,
effect3->SnapshotAllCompositorKeyframesIfNecessary(*element_.Get(), style,
nullptr);
EXPECT_EQ(CheckCanStartEffectOnCompositor(timing_, *element_.Get(),
animation3, *effect3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ TEST_F(CSSPropertyTest, InternalFontSizeDeltaNotWebExposed) {
}

TEST_F(CSSPropertyTest, VisitedPropertiesCanParseValues) {
scoped_refptr<ComputedStyle> initial_style =
GetDocument().GetStyleResolver().CreateComputedStyle();
const ComputedStyle& initial_style =
GetDocument().GetStyleResolver().InitialStyle();

// Count the number of 'visited' properties seen.
size_t num_visited = 0;
Expand All @@ -105,7 +105,7 @@ TEST_F(CSSPropertyTest, VisitedPropertiesCanParseValues) {

// Get any value compatible with 'property'. The initial value will do.
const CSSValue* initial_value = property.CSSValueFromComputedStyle(
*initial_style, nullptr /* layout_object */,
initial_style, nullptr /* layout_object */,
false /* allow_visited_style */);
ASSERT_TRUE(initial_value);
String css_text = initial_value->CssText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class FontBuilderAdditiveTest : public FontBuilderTest,
public testing::TestWithParam<FunctionPair> {};

TEST_F(FontBuilderInitTest, InitialFontSizeNotScaled) {
scoped_refptr<const ComputedStyle> parent_style =
GetDocument().GetStyleResolver().CreateComputedStyle();
const ComputedStyle& parent_style =
GetDocument().GetStyleResolver().InitialStyle();
ComputedStyleBuilder style_builder =
GetDocument().GetStyleResolver().CreateComputedStyleBuilder();

FontBuilder font_builder(&GetDocument());
font_builder.SetSize(FontBuilder::InitialSize());
font_builder.CreateFont(style_builder, parent_style.get());
font_builder.CreateFont(style_builder, &parent_style);

EXPECT_EQ(16.0f, style_builder.GetFontDescription().ComputedSize());
}
Expand Down

0 comments on commit a9e2056

Please sign in to comment.