Commit 3c9f4e09 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

[Squad] Get rid of mutable style access in list item markers.

Instead of modifying ComputedStyle in place for margins, clone the
style if necessary before setting the new margins.

UpdateMarginsAndContent() has been modified to call
ComputePreferredLogicalWidths() in the case of dirty preferred widths
because that method will call UpdateContent() and UpdateMargins(). We
had problems with UpdateMargins() being re-entered causing the style
member of LayoutObject to change multiple times during the process when
MinPreferredLogicalWidth() was called during UpdateMargins().

Bug: 813068
Change-Id: I902de039f6291ca56c47f88b1f69eee06afb18ca
Reviewed-on: https://chromium-review.googlesource.com/1051807
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarcathie chen <cathiechen@tencent.com>
Cr-Commit-Position: refs/heads/master@{#557483}
parent 4a4f739b
......@@ -266,10 +266,10 @@ bool LayoutListItem::UpdateMarkerLocation() {
if (marker_parent != line_box_parent) {
marker_->Remove();
line_box_parent->AddChild(marker_, FirstNonMarkerChild(line_box_parent));
// TODO(rhogan): lineBoxParent and markerParent may be deleted by addChild,
// so they are not safe to reference here.
// Once we have a safe way of referencing them delete markerParent if it is
// an empty anonymous block.
// TODO(rhogan): line_box_parent and marker_parent may be deleted by
// AddChild, so they are not safe to reference here. Once we have a safe way
// of referencing them delete marker_parent if it is an empty anonymous
// block.
marker_->UpdateMarginsAndContent();
return true;
}
......
......@@ -177,16 +177,14 @@ void LayoutListMarker::ImageChanged(WrappedImagePtr o,
}
void LayoutListMarker::UpdateMarginsAndContent() {
UpdateContent();
UpdateMargins();
if (PreferredLogicalWidthsDirty())
ComputePreferredLogicalWidths();
else
UpdateMargins();
}
void LayoutListMarker::UpdateContent() {
// FIXME: This if-statement is just a performance optimization, but it's messy
// to use the preferredLogicalWidths dirty bit for this.
// It's unclear if this is a premature optimization.
if (!PreferredLogicalWidthsDirty())
return;
DCHECK(PreferredLogicalWidthsDirty());
text_ = "";
......@@ -282,8 +280,16 @@ void LayoutListMarker::UpdateMargins() {
std::tie(margin_start, margin_end) =
InlineMarginsForOutside(style, IsImage(), MinPreferredLogicalWidth());
}
MutableStyleRef().SetMarginStart(Length(margin_start, kFixed));
MutableStyleRef().SetMarginEnd(Length(margin_end, kFixed));
Length start_length(margin_start, kFixed);
Length end_length(margin_end, kFixed);
if (start_length != style.MarginStart() || end_length != style.MarginEnd()) {
scoped_refptr<ComputedStyle> new_style = ComputedStyle::Clone(style);
new_style->SetMarginStart(start_length);
new_style->SetMarginEnd(end_length);
SetStyleInternal(std::move(new_style));
}
}
std::pair<LayoutUnit, LayoutUnit> LayoutListMarker::InlineMarginsForInside(
......
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