Commit 176379b6 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Fix animation of stop-color on <stop>

We will not create LayoutObjects for <stop> elements, so when animating
stop-color on one of these elements we should access ComputedStyle via
Node::GetComputedStyle().

Fixed: 1097762
Change-Id: I9e5996b733cae97f813ab392f62f37a8aaa0e176
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2255366Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#780790}
parent 364ed5f7
......@@ -21,7 +21,7 @@
#include "third_party/blink/renderer/core/css/css_color_value.h"
#include "third_party/blink/renderer/core/css/parser/css_parser.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/svg/color_distance.h"
#include "third_party/blink/renderer/core/svg/svg_animate_element.h"
......@@ -49,8 +49,8 @@ SVGPropertyBase* SVGColorProperty::CloneForAnimation(const String&) const {
static inline Color FallbackColorForCurrentColor(SVGElement* target_element) {
DCHECK(target_element);
if (LayoutObject* target_layout_object = target_element->GetLayoutObject())
return target_layout_object->ResolveColor(GetCSSPropertyColor());
if (const ComputedStyle* target_style = target_element->GetComputedStyle())
return target_style->VisitedDependentColor(GetCSSPropertyColor());
return Color::kTransparent;
}
......
<!doctype html>
<title>Animating 'stop-color' from 'currentcolor'</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<svg>
<linearGradient id="lg" style="color: green">
<stop stop-color="red">
<animate attributeName="stop-color" from="currentcolor" to="green" dur="10s" fill="freeze"/>
</stop>
</linearGradient>
<rect width="100" height="100" fill="url(#lg)"/>
</svg>
<script>
async_test(t => {
let svg = document.querySelector("svg");
svg.pauseAnimations();
svg.setCurrentTime(5);
onload = t.step_func(() => {
requestAnimationFrame(t.step_func_done(() => {
let stop = document.querySelector("stop");
assert_equals(getComputedStyle(stop).getPropertyValue("stop-color"),
"rgb(0, 128, 0)");
}));
});
});
</script>
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