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 {
bool LayoutSVGContainer::UpdateCachedBoundaries() {
NOT_DESTROYED();
auto old_object_bounding_box = object_bounding_box_;
content_.ComputeBoundingBoxes(
object_bounding_box_, object_bounding_box_valid_, stroke_bounding_box_);
return old_object_bounding_box != object_bounding_box_;
return content_.UpdateBoundingBoxes(object_bounding_box_valid_);
}
bool LayoutSVGContainer::NodeAtPoint(HitTestResult& result,
......@@ -205,7 +202,7 @@ bool LayoutSVGContainer::NodeAtPoint(HitTestResult& result,
LocalToSVGParentTransform());
if (!local_location)
return false;
if (!SVGLayoutSupport::IntersectsClipPath(*this, object_bounding_box_,
if (!SVGLayoutSupport::IntersectsClipPath(*this, content_.ObjectBoundingBox(),
*local_location))
return false;
......
......@@ -76,7 +76,7 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
FloatRect ObjectBoundingBox() const final {
NOT_DESTROYED();
return object_bounding_box_;
return content_.ObjectBoundingBox();
}
protected:
......@@ -103,7 +103,7 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
FloatRect StrokeBoundingBox() const final {
NOT_DESTROYED();
return stroke_bounding_box_;
return content_.StrokeBoundingBox();
}
bool NodeAtPoint(HitTestResult&,
......@@ -120,9 +120,6 @@ class LayoutSVGContainer : public LayoutSVGModelObject {
private:
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 needs_boundaries_update_ : 1;
bool did_screen_scale_factor_change_ : 1;
......
......@@ -535,9 +535,7 @@ const LayoutObject* LayoutSVGRoot::PushMappingToContainer(
void LayoutSVGRoot::UpdateCachedBoundaries() {
NOT_DESTROYED();
bool ignore;
content_.ComputeBoundingBoxes(object_bounding_box_,
/* object_bounding_box_valid */ ignore,
stroke_bounding_box_);
content_.UpdateBoundingBoxes(/* object_bounding_box_valid */ ignore);
}
bool LayoutSVGRoot::NodeAtPoint(HitTestResult& result,
......
......@@ -161,15 +161,15 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
FloatRect ObjectBoundingBox() const override {
NOT_DESTROYED();
return object_bounding_box_;
return content_.ObjectBoundingBox();
}
FloatRect StrokeBoundingBox() const override {
NOT_DESTROYED();
return stroke_bounding_box_;
return content_.StrokeBoundingBox();
}
FloatRect VisualRectInLocalSVGCoordinates() const override {
NOT_DESTROYED();
return stroke_bounding_box_;
return content_.StrokeBoundingBox();
}
bool NodeAtPoint(HitTestResult&,
......@@ -213,9 +213,6 @@ class CORE_EXPORT LayoutSVGRoot final : public LayoutReplaced {
SVGContentContainer content_;
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_;
bool is_layout_size_changed_ : 1;
bool did_screen_scale_factor_change_ : 1;
......
......@@ -135,13 +135,8 @@ static bool HasValidBoundingBoxForContainer(const LayoutObject* object) {
return true;
}
void SVGContentContainer::ComputeBoundingBoxes(
FloatRect& object_bounding_box,
bool& object_bounding_box_valid,
FloatRect& stroke_bounding_box) const {
object_bounding_box = FloatRect();
bool SVGContentContainer::UpdateBoundingBoxes(bool& object_bounding_box_valid) {
object_bounding_box_valid = false;
stroke_bounding_box = FloatRect();
// When computing the strokeBoundingBox, we use the visualRects of
// the container's children so that the container's stroke includes the
......@@ -149,6 +144,8 @@ void SVGContentContainer::ComputeBoundingBoxes(
// filters applied to containers to correctly bound the children, and also
// improves inlining of SVG content, as the stroke bound is used in that
// situation also.
FloatRect object_bounding_box;
FloatRect stroke_bounding_box;
for (LayoutObject* current = children_.FirstChild(); current;
current = current->NextSibling()) {
// Don't include elements that are not rendered in the union.
......@@ -162,6 +159,13 @@ void SVGContentContainer::ComputeBoundingBoxes(
stroke_bounding_box.Unite(
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 {
......
......@@ -7,10 +7,10 @@
#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/platform/geometry/float_rect.h"
namespace blink {
class FloatRect;
class HitTestLocation;
class HitTestResult;
......@@ -28,9 +28,10 @@ class SVGContentContainer {
void Layout(const SVGContainerLayoutInfo&);
bool HitTest(HitTestResult&, const HitTestLocation&, HitTestAction) const;
void ComputeBoundingBoxes(FloatRect& object_bounding_box,
bool& object_bounding_box_valid,
FloatRect& stroke_bounding_box) const;
bool UpdateBoundingBoxes(bool& object_bounding_box_valid);
const FloatRect& ObjectBoundingBox() const { return object_bounding_box_; }
const FloatRect& StrokeBoundingBox() const { return stroke_bounding_box_; }
bool ComputeHasNonIsolatedBlendingDescendants() const;
LayoutObjectChildList& Children() { return children_; }
......@@ -38,6 +39,9 @@ class SVGContentContainer {
private:
LayoutObjectChildList children_;
FloatRect object_bounding_box_;
FloatRect stroke_bounding_box_;
};
} // 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