[go: up one dir, main page]

Set link highlight effect to target opacity.

When the link highlight animation finishes, there is a race to remove
the link highlight node before it is renderered at full opacity. If the
finished function is not called in time we see the highlight blink.
Avoid this by setting the effect node to the end opacity.

(cherry picked from commit d03ff4b86983089940d824c98fd11b002c54752b)

Bug: 974160
Change-Id: I597629ee7457cc3bd77493ea87ed29e2916855fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661159
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Robert Flack <flackr@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#669431}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661479
Reviewed-by: Robert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#359}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/third_party/blink/renderer/core/paint/link_highlight_impl.cc b/third_party/blink/renderer/core/paint/link_highlight_impl.cc
index 4fa0f54..9f0eecf 100644
--- a/third_party/blink/renderer/core/paint/link_highlight_impl.cc
+++ b/third_party/blink/renderer/core/paint/link_highlight_impl.cc
@@ -69,6 +69,15 @@
 
 static constexpr float kStartOpacity = 1;
 
+namespace {
+
+float HighlightTargetOpacity() {
+  // For web tests we don't fade out.
+  return WebTestSupport::IsRunningWebTest() ? kStartOpacity : 0;
+}
+
+}  // namespace
+
 static CompositorElementId NewElementId() {
   if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled() ||
       RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
@@ -103,7 +112,7 @@
   geometry_needs_update_ = true;
 
   EffectPaintPropertyNode::State state;
-  state.opacity = kStartOpacity;
+  state.opacity = HighlightTargetOpacity();
   state.local_transform_space = &TransformPaintPropertyNode::Root();
   state.compositor_element_id = element_id_;
   state.direct_compositing_reasons = CompositingReason::kActiveOpacityAnimation;
@@ -355,10 +364,9 @@
     curve->AddKeyframe(CompositorFloatKeyframe(
         extra_duration_required.InSecondsF(), kStartOpacity, timing_function));
   }
-  // For web tests we don't fade out.
   curve->AddKeyframe(CompositorFloatKeyframe(
       (kFadeDuration + extra_duration_required).InSecondsF(),
-      WebTestSupport::IsRunningWebTest() ? kStartOpacity : 0, timing_function));
+      HighlightTargetOpacity(), timing_function));
 
   auto keyframe_model = std::make_unique<CompositorKeyframeModel>(
       *curve, compositor_target_property::OPACITY, 0, 0);