Commit 601bdc52 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Move bounding boxes to SVGContentContainer

The |object_bounding_box_| and |stroke_bounding_box_| members of
LayoutSVGRoot and LayoutSVGContainer directly relate to the bounds of
the child (descendant) content. Move management of them to
SVGContentContainer.

Change-Id: If3b6803e46b789de40566fbc7c473467c232a627
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505872Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#822265}
parent 871a81a5
...@@ -189,10 +189,7 @@ void LayoutSVGContainer::Paint(const PaintInfo& paint_info) const { ...@@ -189,10 +189,7 @@ void LayoutSVGContainer::Paint(const PaintInfo& paint_info) const {
bool LayoutSVGContainer::UpdateCachedBoundaries() { bool LayoutSVGContainer::UpdateCachedBoundaries() {
NOT_DESTROYED(); NOT_DESTROYED();
auto old_object_bounding_box = object_bounding_box_; return content_.UpdateBoundingBoxes(object_bounding_box_valid_);
content_.ComputeBoundingBoxes(
object_bounding_box_, object_bounding_box_valid_, stroke_bounding_box_);
return old_object_bounding_box != object_bounding_box_;
} }
bool LayoutSVGContainer::NodeAtPoint(HitTestResult& result, bool LayoutSVGContainer::NodeAtPoint(HitTestResult& result,
...@@ -205,7 +202,7 @@ bool LayoutSVGContainer::NodeAtPoint(HitTestResult& result, ...@@ -205,7 +202,7 @@ bool LayoutSVGContainer::NodeAtPoint(HitTestResult& result,
LocalToSVGParentTransform()); LocalToSVGParentTransform());
if (!local_location) if (!local_location)
return false; return false;
if (!SVGLayoutSupport::IntersectsClipPath(*this, object_bounding_box_, if (!SVGLayoutSupport::IntersectsClipPath(*this, content_.ObjectBoundingBox(),
*local_location)) *local_location))
return false; return false;
......
...@@ -76,7 +76,7 @@ class LayoutSVGContainer : public LayoutSVGModelObject { ...@@ -76,7 +76,7 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
FloatRect ObjectBoundingBox() const final { FloatRect ObjectBoundingBox() const final {
NOT_DESTROYED(); NOT_DESTROYED();
return object_bounding_box_; return content_.ObjectBoundingBox();
} }
protected: protected:
...@@ -103,7 +103,7 @@ class LayoutSVGContainer : public LayoutSVGModelObject { ...@@ -103,7 +103,7 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
FloatRect StrokeBoundingBox() const final { FloatRect StrokeBoundingBox() const final {
NOT_DESTROYED(); NOT_DESTROYED();
return stroke_bounding_box_; return content_.StrokeBoundingBox();
} }
bool NodeAtPoint(HitTestResult&, bool NodeAtPoint(HitTestResult&,
...@@ -120,9 +120,6 @@ class LayoutSVGContainer : public LayoutSVGModelObject { ...@@ -120,9 +120,6 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
private: private:
SVGContentContainer content_; SVGContentContainer content_;
// TODO(fs): Some of this state can move to the "child list" object.
FloatRect object_bounding_box_;
FloatRect stroke_bounding_box_;
bool object_bounding_box_valid_; bool object_bounding_box_valid_;
bool needs_boundaries_update_ : 1; bool needs_boundaries_update_ : 1;
bool did_screen_scale_factor_change_ : 1; bool did_screen_scale_factor_change_ : 1;
......
...@@ -535,9 +535,7 @@ const LayoutObject* LayoutSVGRoot::PushMappingToContainer( ...@@ -535,9 +535,7 @@ const LayoutObject* LayoutSVGRoot::PushMappingToContainer(
void LayoutSVGRoot::UpdateCachedBoundaries() { void LayoutSVGRoot::UpdateCachedBoundaries() {
NOT_DESTROYED(); NOT_DESTROYED();
bool ignore; bool ignore;
content_.ComputeBoundingBoxes(object_bounding_box_, content_.UpdateBoundingBoxes(/* object_bounding_box_valid */ ignore);
/* object_bounding_box_valid */ ignore,
stroke_bounding_box_);
} }
bool LayoutSVGRoot::NodeAtPoint(HitTestResult& result, bool LayoutSVGRoot::NodeAtPoint(HitTestResult& result,
......
...@@ -161,15 +161,15 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { ...@@ -161,15 +161,15 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
FloatRect ObjectBoundingBox() const override { FloatRect ObjectBoundingBox() const override {
NOT_DESTROYED(); NOT_DESTROYED();
return object_bounding_box_; return content_.ObjectBoundingBox();
} }
FloatRect StrokeBoundingBox() const override { FloatRect StrokeBoundingBox() const override {
NOT_DESTROYED(); NOT_DESTROYED();
return stroke_bounding_box_; return content_.StrokeBoundingBox();
} }
FloatRect VisualRectInLocalSVGCoordinates() const override { FloatRect VisualRectInLocalSVGCoordinates() const override {
NOT_DESTROYED(); NOT_DESTROYED();
return stroke_bounding_box_; return content_.StrokeBoundingBox();
} }
bool NodeAtPoint(HitTestResult&, bool NodeAtPoint(HitTestResult&,
...@@ -213,9 +213,6 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced { ...@@ -213,9 +213,6 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
SVGContentContainer content_; SVGContentContainer content_;
LayoutSize container_size_; LayoutSize container_size_;
// TODO(fs): Some of this state can move to the "child list" object.
FloatRect object_bounding_box_;
FloatRect stroke_bounding_box_;
AffineTransform local_to_border_box_transform_; AffineTransform local_to_border_box_transform_;
bool is_layout_size_changed_ : 1; bool is_layout_size_changed_ : 1;
bool did_screen_scale_factor_change_ : 1; bool did_screen_scale_factor_change_ : 1;
......
...@@ -135,13 +135,8 @@ static bool HasValidBoundingBoxForContainer(const LayoutObject* object) { ...@@ -135,13 +135,8 @@ static bool HasValidBoundingBoxForContainer(const LayoutObject* object) {
return true; return true;
} }
void SVGContentContainer::ComputeBoundingBoxes( bool SVGContentContainer::UpdateBoundingBoxes(bool& object_bounding_box_valid) {
FloatRect& object_bounding_box,
bool& object_bounding_box_valid,
FloatRect& stroke_bounding_box) const {
object_bounding_box = FloatRect();
object_bounding_box_valid = false; object_bounding_box_valid = false;
stroke_bounding_box = FloatRect();
// When computing the strokeBoundingBox, we use the visualRects of // When computing the strokeBoundingBox, we use the visualRects of
// the container's children so that the container's stroke includes the // the container's children so that the container's stroke includes the
...@@ -149,6 +144,8 @@ void SVGContentContainer::ComputeBoundingBoxes( ...@@ -149,6 +144,8 @@ void SVGContentContainer::ComputeBoundingBoxes(
// filters applied to containers to correctly bound the children, and also // filters applied to containers to correctly bound the children, and also
// improves inlining of SVG content, as the stroke bound is used in that // improves inlining of SVG content, as the stroke bound is used in that
// situation also. // situation also.
FloatRect object_bounding_box;
FloatRect stroke_bounding_box;
for (LayoutObject* current = children_.FirstChild(); current; for (LayoutObject* current = children_.FirstChild(); current;
current = current->NextSibling()) { current = current->NextSibling()) {
// Don't include elements that are not rendered in the union. // Don't include elements that are not rendered in the union.
...@@ -162,6 +159,13 @@ void SVGContentContainer::ComputeBoundingBoxes( ...@@ -162,6 +159,13 @@ void SVGContentContainer::ComputeBoundingBoxes(
stroke_bounding_box.Unite( stroke_bounding_box.Unite(
transform.MapRect(current->VisualRectInLocalSVGCoordinates())); transform.MapRect(current->VisualRectInLocalSVGCoordinates()));
} }
bool changed = false;
changed |= object_bounding_box_ != object_bounding_box;
object_bounding_box_ = object_bounding_box;
changed |= stroke_bounding_box_ != stroke_bounding_box;
stroke_bounding_box_ = stroke_bounding_box;
return changed;
} }
bool SVGContentContainer::ComputeHasNonIsolatedBlendingDescendants() const { bool SVGContentContainer::ComputeHasNonIsolatedBlendingDescendants() const {
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include "third_party/blink/renderer/core/layout/api/hit_test_action.h" #include "third_party/blink/renderer/core/layout/api/hit_test_action.h"
#include "third_party/blink/renderer/core/layout/layout_object_child_list.h" #include "third_party/blink/renderer/core/layout/layout_object_child_list.h"
#include "third_party/blink/renderer/platform/geometry/float_rect.h"
namespace blink { namespace blink {
class FloatRect;
class HitTestLocation; class HitTestLocation;
class HitTestResult; class HitTestResult;
...@@ -28,9 +28,10 @@ class SVGContentContainer { ...@@ -28,9 +28,10 @@ class SVGContentContainer {
void Layout(const SVGContainerLayoutInfo&); void Layout(const SVGContainerLayoutInfo&);
bool HitTest(HitTestResult&, const HitTestLocation&, HitTestAction) const; bool HitTest(HitTestResult&, const HitTestLocation&, HitTestAction) const;
void ComputeBoundingBoxes(FloatRect& object_bounding_box, bool UpdateBoundingBoxes(bool& object_bounding_box_valid);
bool& object_bounding_box_valid, const FloatRect& ObjectBoundingBox() const { return object_bounding_box_; }
FloatRect& stroke_bounding_box) const; const FloatRect& StrokeBoundingBox() const { return stroke_bounding_box_; }
bool ComputeHasNonIsolatedBlendingDescendants() const; bool ComputeHasNonIsolatedBlendingDescendants() const;
LayoutObjectChildList& Children() { return children_; } LayoutObjectChildList& Children() { return children_; }
...@@ -38,6 +39,9 @@ class SVGContentContainer { ...@@ -38,6 +39,9 @@ class SVGContentContainer {
private: private:
LayoutObjectChildList children_; LayoutObjectChildList children_;
FloatRect object_bounding_box_;
FloatRect stroke_bounding_box_;
}; };
} // namespace blink } // namespace blink
......
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