Commit 43795ee4 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Refactor/simplify bounding box update in LayoutSVGImage

The |needs_boundaries_update_| flag isn't really used for anything since
we always update the boundaries/object bounding box regardless. Hence it
doesn't add anything that the return value of UpdateBoundingBox()
doesn't already convey. In ImageChanged() only check if the image
dimensions changed without updating the oBB, but rather leave that to
the layout that will be triggered.

Bug: 1028061
Change-Id: I418e49952bbd808ceecc44bfa27b7ce07f8d698d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532459Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#826308}
parent 190f1302
...@@ -50,7 +50,6 @@ namespace blink { ...@@ -50,7 +50,6 @@ namespace blink {
LayoutSVGImage::LayoutSVGImage(SVGImageElement* impl) LayoutSVGImage::LayoutSVGImage(SVGImageElement* impl)
: LayoutSVGModelObject(impl), : LayoutSVGModelObject(impl),
needs_boundaries_update_(true),
needs_transform_update_(true), needs_transform_update_(true),
transform_uses_reference_box_(false), transform_uses_reference_box_(false),
image_resource_(MakeGarbageCollected<LayoutImageResource>()) { image_resource_(MakeGarbageCollected<LayoutImageResource>()) {
...@@ -152,11 +151,7 @@ bool LayoutSVGImage::UpdateBoundingBox() { ...@@ -152,11 +151,7 @@ bool LayoutSVGImage::UpdateBoundingBox() {
if (style.Width().IsAuto() || style.Height().IsAuto()) if (style.Width().IsAuto() || style.Height().IsAuto())
object_bounding_box_.SetSize(CalculateObjectSize()); object_bounding_box_.SetSize(CalculateObjectSize());
if (old_object_bounding_box != object_bounding_box_) { return old_object_bounding_box != object_bounding_box_;
SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kImage);
needs_boundaries_update_ = true;
}
return old_object_bounding_box.Size() != object_bounding_box_.Size();
} }
void LayoutSVGImage::UpdateLayout() { void LayoutSVGImage::UpdateLayout() {
...@@ -164,16 +159,14 @@ void LayoutSVGImage::UpdateLayout() { ...@@ -164,16 +159,14 @@ void LayoutSVGImage::UpdateLayout() {
DCHECK(NeedsLayout()); DCHECK(NeedsLayout());
LayoutAnalyzer::Scope analyzer(*this); LayoutAnalyzer::Scope analyzer(*this);
FloatPoint old_bbox_location = object_bounding_box_.Location(); const bool bbox_changed = UpdateBoundingBox();
bool bbox_changed = UpdateBoundingBox() || if (bbox_changed) {
old_bbox_location != object_bounding_box_.Location(); SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kImage);
// Invalidate all resources of this client if our reference box changed.
if (EverHadLayout() && bbox_changed)
SVGResourceInvalidator(*this).InvalidateEffects();
bool update_parent_boundaries = needs_boundaries_update_; // Invalidate all resources of this client if our reference box changed.
needs_boundaries_update_ = false; if (EverHadLayout())
SVGResourceInvalidator(*this).InvalidateEffects();
}
if (!needs_transform_update_ && transform_uses_reference_box_) { if (!needs_transform_update_ && transform_uses_reference_box_) {
needs_transform_update_ = CheckForImplicitTransformChange(bbox_changed); needs_transform_update_ = CheckForImplicitTransformChange(bbox_changed);
...@@ -181,6 +174,7 @@ void LayoutSVGImage::UpdateLayout() { ...@@ -181,6 +174,7 @@ void LayoutSVGImage::UpdateLayout() {
SetNeedsPaintPropertyUpdate(); SetNeedsPaintPropertyUpdate();
} }
bool update_parent_boundaries = bbox_changed;
if (needs_transform_update_) { if (needs_transform_update_) {
local_transform_ = CalculateLocalTransform(); local_transform_ = CalculateLocalTransform();
needs_transform_update_ = false; needs_transform_update_ = false;
...@@ -191,7 +185,6 @@ void LayoutSVGImage::UpdateLayout() { ...@@ -191,7 +185,6 @@ void LayoutSVGImage::UpdateLayout() {
if (update_parent_boundaries) if (update_parent_boundaries)
LayoutSVGModelObject::SetNeedsBoundariesUpdate(); LayoutSVGModelObject::SetNeedsBoundariesUpdate();
DCHECK(!needs_boundaries_update_);
DCHECK(!needs_transform_update_); DCHECK(!needs_transform_update_);
if (auto* svg_image_element = DynamicTo<SVGImageElement>(GetElement())) { if (auto* svg_image_element = DynamicTo<SVGImageElement>(GetElement())) {
...@@ -252,7 +245,7 @@ void LayoutSVGImage::ImageChanged(WrappedImagePtr, CanDeferInvalidation defer) { ...@@ -252,7 +245,7 @@ void LayoutSVGImage::ImageChanged(WrappedImagePtr, CanDeferInvalidation defer) {
false); false);
if (StyleRef().Width().IsAuto() || StyleRef().Height().IsAuto()) { if (StyleRef().Width().IsAuto() || StyleRef().Height().IsAuto()) {
if (UpdateBoundingBox()) if (CalculateObjectSize() != object_bounding_box_.Size())
SetNeedsLayout(layout_invalidation_reason::kSizeChanged); SetNeedsLayout(layout_invalidation_reason::kSizeChanged);
} }
......
...@@ -36,10 +36,7 @@ class LayoutSVGImage final : public LayoutSVGModelObject { ...@@ -36,10 +36,7 @@ class LayoutSVGImage final : public LayoutSVGModelObject {
explicit LayoutSVGImage(SVGImageElement*); explicit LayoutSVGImage(SVGImageElement*);
~LayoutSVGImage() override; ~LayoutSVGImage() override;
void SetNeedsBoundariesUpdate() override { void SetNeedsBoundariesUpdate() override { NOT_DESTROYED(); }
NOT_DESTROYED();
needs_boundaries_update_ = true;
}
void SetNeedsTransformUpdate() override { void SetNeedsTransformUpdate() override {
NOT_DESTROYED(); NOT_DESTROYED();
needs_transform_update_ = true; needs_transform_update_ = true;
...@@ -104,7 +101,6 @@ class LayoutSVGImage final : public LayoutSVGModelObject { ...@@ -104,7 +101,6 @@ class LayoutSVGImage final : public LayoutSVGModelObject {
FloatSize CalculateObjectSize() const; FloatSize CalculateObjectSize() const;
bool HasOverriddenIntrinsicSize() const; bool HasOverriddenIntrinsicSize() const;
bool needs_boundaries_update_ : 1;
bool needs_transform_update_ : 1; bool needs_transform_update_ : 1;
bool transform_uses_reference_box_ : 1; bool transform_uses_reference_box_ : 1;
AffineTransform local_transform_; AffineTransform local_transform_;
......
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