Commit 82c97746 authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Don't trigger re-layout when stroke-dash{array,offset} changes

Since we no longer include the dash-effect when computing
(appromixating) the stroke bounds, we don't need to trigger (re)layout
when they change.

This can help eliminate layouts for example for "line animations" like
the one on https://jakearchibald.com/2013/animated-line-drawing-svg/

Bug: 435097
Change-Id: Iaf5298620889b6ed0cb10437514bb8af3104cc35
Reviewed-on: https://chromium-review.googlesource.com/c/1489202Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#635931}
parent 3a9c5436
......@@ -167,16 +167,19 @@ bool SVGComputedStyle::DiffNeedsLayoutAndPaintInvalidation(
other->svg_noninherited_flags.f.vector_effect)
return true;
// Some stroke properties, requires relayouts, as the cached stroke boundaries
// Some stroke properties require relayouts as the cached stroke boundaries
// need to be recalculated.
if (stroke.Get() != other->stroke.Get()) {
if (stroke->width != other->stroke->width ||
stroke->paint != other->stroke->paint ||
stroke->miter_limit != other->stroke->miter_limit ||
*stroke->dash_array != *other->stroke->dash_array ||
stroke->dash_offset != other->stroke->dash_offset ||
stroke->visited_link_paint != other->stroke->visited_link_paint)
return true;
// If the dash array is toggled from/to 'none' we need to relayout, because
// some shapes will decide on which codepath to use based on the presence
// of a dash array.
if (stroke->dash_array->IsEmpty() != other->stroke->dash_array->IsEmpty())
return true;
}
// The geometry properties require a re-layout.
......@@ -188,8 +191,16 @@ bool SVGComputedStyle::DiffNeedsLayoutAndPaintInvalidation(
bool SVGComputedStyle::DiffNeedsPaintInvalidation(
const SVGComputedStyle* other) const {
if (stroke->opacity != other->stroke->opacity)
return true;
if (stroke.Get() != other->stroke.Get()) {
if (stroke->opacity != other->stroke->opacity)
return true;
// Changes to the dash effect only require a repaint because we don't
// include it when computing (approximating) the stroke boundaries during
// layout.
if (stroke->dash_offset != other->stroke->dash_offset ||
*stroke->dash_array != *other->stroke->dash_array)
return true;
}
// Painting related properties only need paint invalidation.
if (misc.Get() != other->misc.Get()) {
......
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