Commit 4637dde4 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Pass property bag (struct) to SVGContentContainer::Layout

Rather than passing three bools, pass a SVGContainerLayoutInfo struct as
argument. Makes some of the callsites slightly more readable.

Change-Id: Ic71bb7d863de047bf8e20dfec02e30fee02a8d87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505754Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#822173}
parent 0e3bffb1
...@@ -59,13 +59,15 @@ void LayoutSVGContainer::UpdateLayout() { ...@@ -59,13 +59,15 @@ void LayoutSVGContainer::UpdateLayout() {
transform_change == SVGTransformChange::kFull || transform_change == SVGTransformChange::kFull ||
SVGLayoutSupport::ScreenScaleFactorChanged(Parent()); SVGLayoutSupport::ScreenScaleFactorChanged(Parent());
// When hasRelativeLengths() is false, no descendants have relative lengths SVGContainerLayoutInfo layout_info;
layout_info.scale_factor_changed = did_screen_scale_factor_change_;
// When HasRelativeLengths() is false, no descendants have relative lengths
// (hence no one is interested in viewport size changes). // (hence no one is interested in viewport size changes).
bool layout_size_changed = layout_info.viewport_changed =
GetElement()->HasRelativeLengths() && GetElement()->HasRelativeLengths() &&
SVGLayoutSupport::LayoutSizeOfNearestViewportChanged(this); SVGLayoutSupport::LayoutSizeOfNearestViewportChanged(this);
content_.Layout(false, did_screen_scale_factor_change_, layout_size_changed); content_.Layout(layout_info);
bool bbox_changed = false; bool bbox_changed = false;
if (needs_boundaries_update_) { if (needs_boundaries_update_) {
......
...@@ -32,13 +32,15 @@ void LayoutSVGHiddenContainer::UpdateLayout() { ...@@ -32,13 +32,15 @@ void LayoutSVGHiddenContainer::UpdateLayout() {
DCHECK(NeedsLayout()); DCHECK(NeedsLayout());
LayoutAnalyzer::Scope analyzer(*this); LayoutAnalyzer::Scope analyzer(*this);
// When hasRelativeLengths() is false, no descendants have relative lengths SVGContainerLayoutInfo layout_info;
layout_info.force_layout = SelfNeedsLayout();
// When HasRelativeLengths() is false, no descendants have relative lengths
// (hence no one is interested in viewport size changes). // (hence no one is interested in viewport size changes).
bool layout_size_changed = layout_info.viewport_changed =
GetElement()->HasRelativeLengths() && GetElement()->HasRelativeLengths() &&
SVGLayoutSupport::LayoutSizeOfNearestViewportChanged(this); SVGLayoutSupport::LayoutSizeOfNearestViewportChanged(this);
Content().Layout(SelfNeedsLayout(), false, layout_size_changed); Content().Layout(layout_info);
UpdateCachedBoundaries(); UpdateCachedBoundaries();
ClearNeedsLayout(); ClearNeedsLayout();
} }
......
...@@ -249,8 +249,11 @@ void LayoutSVGRoot::UpdateLayout() { ...@@ -249,8 +249,11 @@ void LayoutSVGRoot::UpdateLayout() {
is_layout_size_changed_ = is_layout_size_changed_ =
viewport_may_have_changed && svg->HasRelativeLengths(); viewport_may_have_changed && svg->HasRelativeLengths();
content_.Layout(false, did_screen_scale_factor_change_, SVGContainerLayoutInfo layout_info;
is_layout_size_changed_); layout_info.scale_factor_changed = did_screen_scale_factor_change_;
layout_info.viewport_changed = is_layout_size_changed_;
content_.Layout(layout_info);
if (needs_boundaries_or_transform_update_) { if (needs_boundaries_or_transform_update_) {
UpdateCachedBoundaries(); UpdateCachedBoundaries();
......
...@@ -14,14 +14,12 @@ ...@@ -14,14 +14,12 @@
namespace blink { namespace blink {
void SVGContentContainer::Layout(bool force_layout, void SVGContentContainer::Layout(const SVGContainerLayoutInfo& layout_info) {
bool screen_scaling_factor_changed,
bool layout_size_changed) {
for (LayoutObject* child = children_.FirstChild(); child; for (LayoutObject* child = children_.FirstChild(); child;
child = child->NextSibling()) { child = child->NextSibling()) {
bool force_child_layout = force_layout; bool force_child_layout = layout_info.force_layout;
if (screen_scaling_factor_changed) { if (layout_info.scale_factor_changed) {
// If the screen scaling factor changed we need to update the text // If the screen scaling factor changed we need to update the text
// metrics (note: this also happens for layoutSizeChanged=true). // metrics (note: this also happens for layoutSizeChanged=true).
if (child->IsSVGText()) if (child->IsSVGText())
...@@ -29,7 +27,7 @@ void SVGContentContainer::Layout(bool force_layout, ...@@ -29,7 +27,7 @@ void SVGContentContainer::Layout(bool force_layout,
force_child_layout = true; force_child_layout = true;
} }
if (layout_size_changed) { if (layout_info.viewport_changed) {
// When selfNeedsLayout is false and the layout size changed, we have to // When selfNeedsLayout is false and the layout size changed, we have to
// check whether this child uses relative lengths // check whether this child uses relative lengths
if (auto* element = DynamicTo<SVGElement>(child->GetNode())) { if (auto* element = DynamicTo<SVGElement>(child->GetNode())) {
......
...@@ -14,14 +14,18 @@ class FloatRect; ...@@ -14,14 +14,18 @@ class FloatRect;
class HitTestLocation; class HitTestLocation;
class HitTestResult; class HitTestResult;
struct SVGContainerLayoutInfo {
bool force_layout = false;
bool scale_factor_changed = false;
bool viewport_changed = false;
};
// Content representation for an SVG container. Wraps a LayoutObjectChildList // Content representation for an SVG container. Wraps a LayoutObjectChildList
// with additional state related to the children of the container. Used by // with additional state related to the children of the container. Used by
// <svg>, <g> etc. // <svg>, <g> etc.
class SVGContentContainer { class SVGContentContainer {
public: public:
void Layout(bool force_layout, void Layout(const SVGContainerLayoutInfo&);
bool screen_scaling_factor_changed,
bool layout_size_changed);
bool HitTest(HitTestResult&, const HitTestLocation&, HitTestAction) const; bool HitTest(HitTestResult&, const HitTestLocation&, HitTestAction) const;
void ComputeBoundingBoxes(FloatRect& object_bounding_box, void ComputeBoundingBoxes(FloatRect& object_bounding_box,
......
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