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

Pass const references to SVGComputedStyle methods

Replace const SVGComputedStyle* with const SVGComputedStyle& as the
argument to the Diff*, InheritFrom and CopyNonInheritedFromCached
methods.

Change-Id: I79c14a39c09089882857fcbe61f4578c18cdd5ac
Reviewed-on: https://chromium-review.googlesource.com/c/1491655Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#636062}
parent 12004437
...@@ -396,7 +396,7 @@ void ComputedStyle::InheritFrom(const ComputedStyle& inherit_parent, ...@@ -396,7 +396,7 @@ void ComputedStyle::InheritFrom(const ComputedStyle& inherit_parent,
ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary); ComputedStyleBase::InheritFrom(inherit_parent, is_at_shadow_boundary);
if (svg_style_ != inherit_parent.svg_style_) if (svg_style_ != inherit_parent.svg_style_)
svg_style_.Access()->InheritFrom(inherit_parent.svg_style_.Get()); svg_style_.Access()->InheritFrom(*inherit_parent.svg_style_);
if (is_at_shadow_boundary == kAtShadowBoundary) { if (is_at_shadow_boundary == kAtShadowBoundary) {
// Even if surrounding content is user-editable, shadow DOM should act as a // Even if surrounding content is user-editable, shadow DOM should act as a
...@@ -441,7 +441,7 @@ void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) { ...@@ -441,7 +441,7 @@ void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
// m_isLink // m_isLink
if (svg_style_ != other.svg_style_) if (svg_style_ != other.svg_style_)
svg_style_.Access()->CopyNonInheritedFromCached(other.svg_style_.Get()); svg_style_.Access()->CopyNonInheritedFromCached(*other.svg_style_);
} }
bool ComputedStyle::operator==(const ComputedStyle& o) const { bool ComputedStyle::operator==(const ComputedStyle& o) const {
...@@ -529,7 +529,7 @@ StyleDifference ComputedStyle::VisualInvalidationDiff( ...@@ -529,7 +529,7 @@ StyleDifference ComputedStyle::VisualInvalidationDiff(
StyleDifference diff; StyleDifference diff;
if (svg_style_.Get() != other.svg_style_.Get()) if (svg_style_.Get() != other.svg_style_.Get())
diff = svg_style_->Diff(other.svg_style_.Get()); diff = svg_style_->Diff(*other.svg_style_);
if ((!diff.NeedsFullLayout() || !diff.NeedsFullPaintInvalidation()) && if ((!diff.NeedsFullLayout() || !diff.NeedsFullPaintInvalidation()) &&
DiffNeedsFullLayoutAndPaintInvalidation(other)) { DiffNeedsFullLayoutAndPaintInvalidation(other)) {
......
...@@ -92,24 +92,21 @@ bool SVGComputedStyle::NonInheritedEqual(const SVGComputedStyle& other) const { ...@@ -92,24 +92,21 @@ bool SVGComputedStyle::NonInheritedEqual(const SVGComputedStyle& other) const {
svg_noninherited_flags == other.svg_noninherited_flags; svg_noninherited_flags == other.svg_noninherited_flags;
} }
void SVGComputedStyle::InheritFrom(const SVGComputedStyle* svg_inherit_parent) { void SVGComputedStyle::InheritFrom(const SVGComputedStyle& svg_inherit_parent) {
if (!svg_inherit_parent) fill = svg_inherit_parent.fill;
return; stroke = svg_inherit_parent.stroke;
inherited_resources = svg_inherit_parent.inherited_resources;
fill = svg_inherit_parent->fill; svg_inherited_flags = svg_inherit_parent.svg_inherited_flags;
stroke = svg_inherit_parent->stroke;
inherited_resources = svg_inherit_parent->inherited_resources;
svg_inherited_flags = svg_inherit_parent->svg_inherited_flags;
} }
void SVGComputedStyle::CopyNonInheritedFromCached( void SVGComputedStyle::CopyNonInheritedFromCached(
const SVGComputedStyle* other) { const SVGComputedStyle& other) {
svg_noninherited_flags = other->svg_noninherited_flags; svg_noninherited_flags = other.svg_noninherited_flags;
stops = other->stops; stops = other.stops;
misc = other->misc; misc = other.misc;
geometry = other->geometry; geometry = other.geometry;
resources = other->resources; resources = other.resources;
} }
scoped_refptr<SVGDashArray> SVGComputedStyle::InitialStrokeDashArray() { scoped_refptr<SVGDashArray> SVGComputedStyle::InitialStrokeDashArray() {
...@@ -117,7 +114,7 @@ scoped_refptr<SVGDashArray> SVGComputedStyle::InitialStrokeDashArray() { ...@@ -117,7 +114,7 @@ scoped_refptr<SVGDashArray> SVGComputedStyle::InitialStrokeDashArray() {
return initial_dash_array; return initial_dash_array;
} }
StyleDifference SVGComputedStyle::Diff(const SVGComputedStyle* other) const { StyleDifference SVGComputedStyle::Diff(const SVGComputedStyle& other) const {
StyleDifference style_difference; StyleDifference style_difference;
if (DiffNeedsLayoutAndPaintInvalidation(other)) { if (DiffNeedsLayoutAndPaintInvalidation(other)) {
...@@ -131,126 +128,126 @@ StyleDifference SVGComputedStyle::Diff(const SVGComputedStyle* other) const { ...@@ -131,126 +128,126 @@ StyleDifference SVGComputedStyle::Diff(const SVGComputedStyle* other) const {
} }
bool SVGComputedStyle::DiffNeedsLayoutAndPaintInvalidation( bool SVGComputedStyle::DiffNeedsLayoutAndPaintInvalidation(
const SVGComputedStyle* other) const { const SVGComputedStyle& other) const {
// If resources change, we need a relayout, as the presence of resources // If resources change, we need a relayout, as the presence of resources
// influences the visual rect. // influences the visual rect.
if (resources != other->resources) if (resources != other.resources)
return true; return true;
// If markers change, we need a relayout, as marker boundaries are cached in // If markers change, we need a relayout, as marker boundaries are cached in
// LayoutSVGPath. // LayoutSVGPath.
if (inherited_resources != other->inherited_resources) if (inherited_resources != other.inherited_resources)
return true; return true;
// All text related properties influence layout. // All text related properties influence layout.
if (svg_inherited_flags.text_anchor != if (svg_inherited_flags.text_anchor !=
other->svg_inherited_flags.text_anchor || other.svg_inherited_flags.text_anchor ||
svg_inherited_flags.dominant_baseline != svg_inherited_flags.dominant_baseline !=
other->svg_inherited_flags.dominant_baseline || other.svg_inherited_flags.dominant_baseline ||
svg_noninherited_flags.f.alignment_baseline != svg_noninherited_flags.f.alignment_baseline !=
other->svg_noninherited_flags.f.alignment_baseline || other.svg_noninherited_flags.f.alignment_baseline ||
svg_noninherited_flags.f.baseline_shift != svg_noninherited_flags.f.baseline_shift !=
other->svg_noninherited_flags.f.baseline_shift) other.svg_noninherited_flags.f.baseline_shift)
return true; return true;
// Text related properties influence layout. // Text related properties influence layout.
if (misc->baseline_shift_value != other->misc->baseline_shift_value) if (misc->baseline_shift_value != other.misc->baseline_shift_value)
return true; return true;
// These properties affect the cached stroke bounding box rects. // These properties affect the cached stroke bounding box rects.
if (svg_inherited_flags.cap_style != other->svg_inherited_flags.cap_style || if (svg_inherited_flags.cap_style != other.svg_inherited_flags.cap_style ||
svg_inherited_flags.join_style != other->svg_inherited_flags.join_style) svg_inherited_flags.join_style != other.svg_inherited_flags.join_style)
return true; return true;
// vector-effect changes require a re-layout. // vector-effect changes require a re-layout.
if (svg_noninherited_flags.f.vector_effect != if (svg_noninherited_flags.f.vector_effect !=
other->svg_noninherited_flags.f.vector_effect) other.svg_noninherited_flags.f.vector_effect)
return true; return true;
// Some stroke properties require relayouts as the cached stroke boundaries // Some stroke properties require relayouts as the cached stroke boundaries
// need to be recalculated. // need to be recalculated.
if (stroke.Get() != other->stroke.Get()) { if (stroke.Get() != other.stroke.Get()) {
if (stroke->width != other->stroke->width || if (stroke->width != other.stroke->width ||
stroke->miter_limit != other->stroke->miter_limit) stroke->miter_limit != other.stroke->miter_limit)
return true; return true;
// If the stroke is toggled from/to 'none' we need to relayout, because the // If the stroke is toggled from/to 'none' we need to relayout, because the
// stroke shape will have changed. // stroke shape will have changed.
if (stroke->paint.IsNone() != other->stroke->paint.IsNone()) if (stroke->paint.IsNone() != other.stroke->paint.IsNone())
return true; return true;
// If the dash array is toggled from/to 'none' we need to relayout, because // 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 // some shapes will decide on which codepath to use based on the presence
// of a dash array. // of a dash array.
if (stroke->dash_array->IsEmpty() != other->stroke->dash_array->IsEmpty()) if (stroke->dash_array->IsEmpty() != other.stroke->dash_array->IsEmpty())
return true; return true;
} }
// The geometry properties require a re-layout. // The geometry properties require a re-layout.
if (geometry.Get() != other->geometry.Get() && *geometry != *other->geometry) if (geometry.Get() != other.geometry.Get() && *geometry != *other.geometry)
return true; return true;
return false; return false;
} }
bool SVGComputedStyle::DiffNeedsPaintInvalidation( bool SVGComputedStyle::DiffNeedsPaintInvalidation(
const SVGComputedStyle* other) const { const SVGComputedStyle& other) const {
if (stroke.Get() != other->stroke.Get()) { if (stroke.Get() != other.stroke.Get()) {
if (stroke->paint != other->stroke->paint || if (stroke->paint != other.stroke->paint ||
stroke->opacity != other->stroke->opacity || stroke->opacity != other.stroke->opacity ||
stroke->visited_link_paint != other->stroke->visited_link_paint) stroke->visited_link_paint != other.stroke->visited_link_paint)
return true; return true;
// Changes to the dash effect only require a repaint because we don't // Changes to the dash effect only require a repaint because we don't
// include it when computing (approximating) the stroke boundaries during // include it when computing (approximating) the stroke boundaries during
// layout. // layout.
if (stroke->dash_offset != other->stroke->dash_offset || if (stroke->dash_offset != other.stroke->dash_offset ||
*stroke->dash_array != *other->stroke->dash_array) *stroke->dash_array != *other.stroke->dash_array)
return true; return true;
} }
// Painting related properties only need paint invalidation. // Painting related properties only need paint invalidation.
if (misc.Get() != other->misc.Get()) { if (misc.Get() != other.misc.Get()) {
if (misc->flood_color != other->misc->flood_color || if (misc->flood_color != other.misc->flood_color ||
misc->flood_color_is_current_color != misc->flood_color_is_current_color !=
other->misc->flood_color_is_current_color || other.misc->flood_color_is_current_color ||
misc->flood_opacity != other->misc->flood_opacity || misc->flood_opacity != other.misc->flood_opacity ||
misc->lighting_color != other->misc->lighting_color || misc->lighting_color != other.misc->lighting_color ||
misc->lighting_color_is_current_color != misc->lighting_color_is_current_color !=
other->misc->lighting_color_is_current_color) other.misc->lighting_color_is_current_color)
return true; return true;
} }
// If fill changes, we just need to issue paint invalidations. Fill boundaries // If fill changes, we just need to issue paint invalidations. Fill boundaries
// are not influenced by this, only by the Path, that LayoutSVGPath contains. // are not influenced by this, only by the Path, that LayoutSVGPath contains.
if (fill.Get() != other->fill.Get()) { if (fill.Get() != other.fill.Get()) {
if (fill->paint != other->fill->paint || if (fill->paint != other.fill->paint ||
fill->opacity != other->fill->opacity) fill->opacity != other.fill->opacity)
return true; return true;
} }
// If gradient stops change, we just need to issue paint invalidations. Style // If gradient stops change, we just need to issue paint invalidations. Style
// updates are already handled through LayoutSVGGradientSTop. // updates are already handled through LayoutSVGGradientSTop.
if (stops != other->stops) if (stops != other.stops)
return true; return true;
// Changes of these flags only cause paint invalidations. // Changes of these flags only cause paint invalidations.
if (svg_inherited_flags.color_rendering != if (svg_inherited_flags.color_rendering !=
other->svg_inherited_flags.color_rendering || other.svg_inherited_flags.color_rendering ||
svg_inherited_flags.shape_rendering != svg_inherited_flags.shape_rendering !=
other->svg_inherited_flags.shape_rendering || other.svg_inherited_flags.shape_rendering ||
svg_inherited_flags.clip_rule != other->svg_inherited_flags.clip_rule || svg_inherited_flags.clip_rule != other.svg_inherited_flags.clip_rule ||
svg_inherited_flags.fill_rule != other->svg_inherited_flags.fill_rule || svg_inherited_flags.fill_rule != other.svg_inherited_flags.fill_rule ||
svg_inherited_flags.color_interpolation != svg_inherited_flags.color_interpolation !=
other->svg_inherited_flags.color_interpolation || other.svg_inherited_flags.color_interpolation ||
svg_inherited_flags.color_interpolation_filters != svg_inherited_flags.color_interpolation_filters !=
other->svg_inherited_flags.color_interpolation_filters || other.svg_inherited_flags.color_interpolation_filters ||
svg_inherited_flags.paint_order != other->svg_inherited_flags.paint_order) svg_inherited_flags.paint_order != other.svg_inherited_flags.paint_order)
return true; return true;
if (svg_noninherited_flags.f.buffered_rendering != if (svg_noninherited_flags.f.buffered_rendering !=
other->svg_noninherited_flags.f.buffered_rendering) other.svg_noninherited_flags.f.buffered_rendering)
return true; return true;
if (svg_noninherited_flags.f.mask_type != if (svg_noninherited_flags.f.mask_type !=
other->svg_noninherited_flags.f.mask_type) other.svg_noninherited_flags.f.mask_type)
return true; return true;
return false; return false;
......
...@@ -55,10 +55,10 @@ class SVGComputedStyle : public RefCounted<SVGComputedStyle> { ...@@ -55,10 +55,10 @@ class SVGComputedStyle : public RefCounted<SVGComputedStyle> {
bool InheritedEqual(const SVGComputedStyle&) const; bool InheritedEqual(const SVGComputedStyle&) const;
bool NonInheritedEqual(const SVGComputedStyle&) const; bool NonInheritedEqual(const SVGComputedStyle&) const;
void InheritFrom(const SVGComputedStyle*); void InheritFrom(const SVGComputedStyle&);
void CopyNonInheritedFromCached(const SVGComputedStyle*); void CopyNonInheritedFromCached(const SVGComputedStyle&);
CORE_EXPORT StyleDifference Diff(const SVGComputedStyle*) const; CORE_EXPORT StyleDifference Diff(const SVGComputedStyle&) const;
bool operator==(const SVGComputedStyle&) const; bool operator==(const SVGComputedStyle&) const;
bool operator!=(const SVGComputedStyle& o) const { return !(*this == o); } bool operator!=(const SVGComputedStyle& o) const { return !(*this == o); }
...@@ -468,8 +468,8 @@ class SVGComputedStyle : public RefCounted<SVGComputedStyle> { ...@@ -468,8 +468,8 @@ class SVGComputedStyle : public RefCounted<SVGComputedStyle> {
SVGComputedStyle( SVGComputedStyle(
CreateInitialType); // Used to create the initial style singleton. CreateInitialType); // Used to create the initial style singleton.
bool DiffNeedsLayoutAndPaintInvalidation(const SVGComputedStyle* other) const; bool DiffNeedsLayoutAndPaintInvalidation(const SVGComputedStyle& other) const;
bool DiffNeedsPaintInvalidation(const SVGComputedStyle* other) const; bool DiffNeedsPaintInvalidation(const SVGComputedStyle& other) const;
void SetBitDefaults() { void SetBitDefaults() {
svg_inherited_flags.clip_rule = InitialClipRule(); svg_inherited_flags.clip_rule = InitialClipRule();
......
...@@ -19,7 +19,7 @@ namespace blink { ...@@ -19,7 +19,7 @@ namespace blink {
scoped_refptr<type> value2 = value1->Copy(); \ scoped_refptr<type> value2 = value1->Copy(); \
svg1->Set##fieldName(value1); \ svg1->Set##fieldName(value1); \
svg2->Set##fieldName(value2); \ svg2->Set##fieldName(value2); \
EXPECT_FALSE(svg1->Diff(svg2.get()).HasDifference()); \ EXPECT_FALSE(svg1->Diff(*svg2).HasDifference()); \
} }
// This is not very useful for fields directly stored by values, because they // This is not very useful for fields directly stored by values, because they
...@@ -31,7 +31,7 @@ namespace blink { ...@@ -31,7 +31,7 @@ namespace blink {
scoped_refptr<SVGComputedStyle> svg2 = SVGComputedStyle::Create(); \ scoped_refptr<SVGComputedStyle> svg2 = SVGComputedStyle::Create(); \
svg1->Set##fieldName(SVGComputedStyle::Initial##fieldName()); \ svg1->Set##fieldName(SVGComputedStyle::Initial##fieldName()); \
svg2->Set##fieldName(SVGComputedStyle::Initial##fieldName()); \ svg2->Set##fieldName(SVGComputedStyle::Initial##fieldName()); \
EXPECT_FALSE(svg1->Diff(svg2.get()).HasDifference()); \ EXPECT_FALSE(svg1->Diff(*svg2).HasDifference()); \
} }
TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) { TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) {
...@@ -47,7 +47,7 @@ TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) { ...@@ -47,7 +47,7 @@ TEST(SVGComputedStyleTest, StrokeStyleShouldCompareValue) {
scoped_refptr<SVGComputedStyle> svg2 = SVGComputedStyle::Create(); scoped_refptr<SVGComputedStyle> svg2 = SVGComputedStyle::Create();
svg1->SetVisitedLinkStrokePaint(SVGComputedStyle::InitialStrokePaint()); svg1->SetVisitedLinkStrokePaint(SVGComputedStyle::InitialStrokePaint());
svg2->SetVisitedLinkStrokePaint(SVGComputedStyle::InitialStrokePaint()); svg2->SetVisitedLinkStrokePaint(SVGComputedStyle::InitialStrokePaint());
EXPECT_FALSE(svg1->Diff(svg2.get()).HasDifference()); EXPECT_FALSE(svg1->Diff(*svg2).HasDifference());
} }
} }
......
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