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() {
transform_change == SVGTransformChange::kFull ||
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).
bool layout_size_changed =
layout_info.viewport_changed =
GetElement()->HasRelativeLengths() &&
SVGLayoutSupport::LayoutSizeOfNearestViewportChanged(this);
content_.Layout(false, did_screen_scale_factor_change_, layout_size_changed);
content_.Layout(layout_info);
bool bbox_changed = false;
if (needs_boundaries_update_) {
......
......@@ -32,13 +32,15 @@ void LayoutSVGHiddenContainer::UpdateLayout() {
DCHECK(NeedsLayout());
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).
bool layout_size_changed =
layout_info.viewport_changed =
GetElement()->HasRelativeLengths() &&
SVGLayoutSupport::LayoutSizeOfNearestViewportChanged(this);
Content().Layout(SelfNeedsLayout(), false, layout_size_changed);
Content().Layout(layout_info);
UpdateCachedBoundaries();
ClearNeedsLayout();
}
......
......@@ -249,8 +249,11 @@ void LayoutSVGRoot::UpdateLayout() {
is_layout_size_changed_ =
viewport_may_have_changed && svg->HasRelativeLengths();
content_.Layout(false, did_screen_scale_factor_change_,
is_layout_size_changed_);
SVGContainerLayoutInfo layout_info;
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_) {
UpdateCachedBoundaries();
......
......@@ -14,14 +14,12 @@
namespace blink {
void SVGContentContainer::Layout(bool force_layout,
bool screen_scaling_factor_changed,
bool layout_size_changed) {
void SVGContentContainer::Layout(const SVGContainerLayoutInfo& layout_info) {
for (LayoutObject* child = children_.FirstChild(); child;
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
// metrics (note: this also happens for layoutSizeChanged=true).
if (child->IsSVGText())
......@@ -29,7 +27,7 @@ void SVGContentContainer::Layout(bool force_layout,
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
// check whether this child uses relative lengths
if (auto* element = DynamicTo<SVGElement>(child->GetNode())) {
......
......@@ -14,14 +14,18 @@ class FloatRect;
class HitTestLocation;
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
// with additional state related to the children of the container. Used by
// <svg>, <g> etc.
class SVGContentContainer {
public:
void Layout(bool force_layout,
bool screen_scaling_factor_changed,
bool layout_size_changed);
void Layout(const SVGContainerLayoutInfo&);
bool HitTest(HitTestResult&, const HitTestLocation&, HitTestAction) const;
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