Commit c896e79e authored by robhogan's avatar robhogan Committed by Commit bot

Establish a list marker's offset before floats have been added to its line

Computing the offset for a list marker after the rest of the objects on the line
it is on have been laid out means it will avoid floats it ought not to.

Instead, compute the offset when laying out the marker and cache it for use later.

BUG=548616
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2553793003
Cr-Commit-Position: refs/heads/master@{#437798}
parent 73ac3ff0
...@@ -649,6 +649,11 @@ crbug.com/538697 [ Win7 Debug ] printing/webgl-oversized-printing.html [ Failure ...@@ -649,6 +649,11 @@ crbug.com/538697 [ Win7 Debug ] printing/webgl-oversized-printing.html [ Failure
crbug.com/617152 imported/wpt/mediacapture-streams/GUM-impossible-constraint.https.html [ Skip ] crbug.com/617152 imported/wpt/mediacapture-streams/GUM-impossible-constraint.https.html [ Skip ]
crbug.com/548616 [ Mac Win ] fast/lists/list-marker-before-float-nested-rtl.html [ NeedsRebaseline ]
crbug.com/548616 [ Mac Win ] fast/lists/list-marker-before-float-nested.html [ NeedsRebaseline ]
crbug.com/548616 [ Mac Win ] fast/lists/list-marker-before-float-rtl.html [ NeedsRebaseline ]
crbug.com/548616 [ Mac Win ] fast/lists/list-marker-before-float.html [ NeedsRebaseline ]
crbug.com/417782 [ Linux Win ] virtual/rootlayerscrolls/fast/scrolling/fractional-scroll-offset-fixed-position-non-composited.html [ Failure ] crbug.com/417782 [ Linux Win ] virtual/rootlayerscrolls/fast/scrolling/fractional-scroll-offset-fixed-position-non-composited.html [ Failure ]
crbug.com/492664 [ Linux ] imported/csswg-test/css-writing-modes-3/box-offsets-rel-pos-vlr-005.xht [ Failure ] crbug.com/492664 [ Linux ] imported/csswg-test/css-writing-modes-3/box-offsets-rel-pos-vlr-005.xht [ Failure ]
crbug.com/492664 [ Linux ] imported/csswg-test/css-writing-modes-3/box-offsets-rel-pos-vrl-004.xht [ Failure ] crbug.com/492664 [ Linux ] imported/csswg-test/css-writing-modes-3/box-offsets-rel-pos-vrl-004.xht [ Failure ]
......
<!DOCTYPE html>
<p>crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line.</p>
<ol dir=rtl>
<li>
<img width=20 height=20 style="float: right; background-color:black;">
<li>
<img width=20 height=20 style="float: right; background-color:black;">
</li>
</li>
<li>
<img width=20 height=20 style="float: right; background-color:black;">
</li>
</ol>
<!DOCTYPE html>
<p>crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line.</p>
<ol>
<li>
<img width=20 height=20 style="float: left; background-color:black;">
<li>
<img width=20 height=20 style="float: left; background-color:black;">
</li>
</li>
<li>
<img width=20 height=20 style="float: left; background-color:black;">
</li>
</ol>
<!DOCTYPE html>
<p>crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line.</p>
<ol dir=rtl>
<li>
<img width=20 height=20 style="float: right; background-color:black;">
</li>
</ol>
<!DOCTYPE html>
<p>crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line.</p>
<ol>
<li>
<img width=20 height=20 style="float: left; background-color:black;">
</li>
</ol>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x88
LayoutBlockFlow {HTML} at (0,0) size 800x88
LayoutBlockFlow {BODY} at (8,16) size 784x56
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 557x19
text run at (0,0) width 557: "crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line."
LayoutBlockFlow {OL} at (0,36) size 784x20
LayoutListItem {LI} at (40,0) size 744x20
LayoutListMarker (anonymous) at (-16,0) size 16x19: "1"
LayoutImage (floating) {IMG} at (0,0) size 20x20 [bgcolor=#000000]
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x128
LayoutBlockFlow {HTML} at (0,0) size 800x128
LayoutBlockFlow {BODY} at (8,16) size 784x96
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 557x19
text run at (0,0) width 557: "crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line."
LayoutBlockFlow {OL} at (0,36) size 784x60
LayoutListItem {LI} at (40,0) size 744x20
LayoutListMarker (anonymous) at (-16,0) size 16x19: "1"
LayoutImage (floating) {IMG} at (0,0) size 20x20 [bgcolor=#000000]
LayoutListItem {LI} at (40,20) size 744x20
LayoutListMarker (anonymous) at (-16,0) size 16x19: "2"
LayoutImage (floating) {IMG} at (0,0) size 20x20 [bgcolor=#000000]
LayoutListItem {LI} at (40,40) size 744x20
LayoutListMarker (anonymous) at (-16,0) size 16x19: "3"
LayoutImage (floating) {IMG} at (0,0) size 20x20 [bgcolor=#000000]
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x128
LayoutBlockFlow {HTML} at (0,0) size 800x128
LayoutBlockFlow {BODY} at (8,16) size 784x96
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 557x19
text run at (0,0) width 557: "crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line."
LayoutBlockFlow {OL} at (0,36) size 784x60
LayoutListItem {LI} at (0,0) size 744x20
LayoutListMarker (anonymous) at (744,0) size 16x19: "1"
LayoutImage (floating) {IMG} at (724,0) size 20x20 [bgcolor=#000000]
LayoutListItem {LI} at (0,20) size 744x20
LayoutListMarker (anonymous) at (744,0) size 16x19: "2"
LayoutImage (floating) {IMG} at (724,0) size 20x20 [bgcolor=#000000]
LayoutListItem {LI} at (0,40) size 744x20
LayoutListMarker (anonymous) at (744,0) size 16x19: "3"
LayoutImage (floating) {IMG} at (724,0) size 20x20 [bgcolor=#000000]
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x88
LayoutBlockFlow {HTML} at (0,0) size 800x88
LayoutBlockFlow {BODY} at (8,16) size 784x56
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 557x19
text run at (0,0) width 557: "crbug.com/548616: List markers shouldn't shift to avoid floats that come after them on a line."
LayoutBlockFlow {OL} at (0,36) size 784x20
LayoutListItem {LI} at (0,0) size 744x20
LayoutListMarker (anonymous) at (744,0) size 16x19: "1"
LayoutImage (floating) {IMG} at (724,0) size 20x20 [bgcolor=#000000]
...@@ -358,10 +358,7 @@ void LayoutListItem::positionListMarker() { ...@@ -358,10 +358,7 @@ void LayoutListItem::positionListMarker() {
// pretty wrong (https://crbug.com/554160). // pretty wrong (https://crbug.com/554160).
// FIXME: Need to account for relative positioning in the layout overflow. // FIXME: Need to account for relative positioning in the layout overflow.
if (style()->isLeftToRightDirection()) { if (style()->isLeftToRightDirection()) {
LayoutUnit leftLineOffset = logicalLeftOffsetForLine( markerLogicalLeft = m_marker->lineOffset() - lineOffset - paddingStart() -
blockOffset, logicalLeftOffsetForLine(blockOffset, DoNotIndentText),
DoNotIndentText);
markerLogicalLeft = leftLineOffset - lineOffset - paddingStart() -
borderStart() + m_marker->marginStart(); borderStart() + m_marker->marginStart();
m_marker->inlineBoxWrapper()->moveInInlineDirection(markerLogicalLeft - m_marker->inlineBoxWrapper()->moveInInlineDirection(markerLogicalLeft -
markerOldLogicalLeft); markerOldLogicalLeft);
...@@ -393,10 +390,7 @@ void LayoutListItem::positionListMarker() { ...@@ -393,10 +390,7 @@ void LayoutListItem::positionListMarker() {
hitSelfPaintingLayer = true; hitSelfPaintingLayer = true;
} }
} else { } else {
LayoutUnit rightLineOffset = logicalRightOffsetForLine( markerLogicalLeft = m_marker->lineOffset() - lineOffset + paddingStart() +
blockOffset, logicalRightOffsetForLine(blockOffset, DoNotIndentText),
DoNotIndentText);
markerLogicalLeft = rightLineOffset - lineOffset + paddingStart() +
borderStart() + m_marker->marginEnd(); borderStart() + m_marker->marginEnd();
m_marker->inlineBoxWrapper()->moveInInlineDirection(markerLogicalLeft - m_marker->inlineBoxWrapper()->moveInInlineDirection(markerLogicalLeft -
markerOldLogicalLeft); markerOldLogicalLeft);
......
...@@ -43,7 +43,7 @@ const int cMarkerPaddingPx = 7; ...@@ -43,7 +43,7 @@ const int cMarkerPaddingPx = 7;
const int cUAMarkerMarginEm = 1; const int cUAMarkerMarginEm = 1;
LayoutListMarker::LayoutListMarker(LayoutListItem* item) LayoutListMarker::LayoutListMarker(LayoutListItem* item)
: LayoutBox(nullptr), m_listItem(item) { : LayoutBox(nullptr), m_listItem(item), m_lineOffset() {
setInline(true); setInline(true);
setIsAtomicInlineLevel(true); setIsAtomicInlineLevel(true);
} }
...@@ -139,6 +139,17 @@ void LayoutListMarker::layout() { ...@@ -139,6 +139,17 @@ void LayoutListMarker::layout() {
ASSERT(needsLayout()); ASSERT(needsLayout());
LayoutAnalyzer::Scope analyzer(*this); LayoutAnalyzer::Scope analyzer(*this);
LayoutUnit blockOffset;
for (LayoutBox* o = parentBox(); o && o != listItem(); o = o->parentBox()) {
blockOffset += o->logicalTop();
}
if (listItem()->style()->isLeftToRightDirection()) {
m_lineOffset = listItem()->logicalLeftOffsetForLine(
blockOffset, DoNotIndentText, LayoutUnit());
} else {
m_lineOffset = listItem()->logicalRightOffsetForLine(
blockOffset, DoNotIndentText, LayoutUnit());
}
if (isImage()) { if (isImage()) {
updateMarginsAndContent(); updateMarginsAndContent();
LayoutSize imageSize(imageBulletSize()); LayoutSize imageSize(imageBulletSize());
......
...@@ -62,6 +62,8 @@ class LayoutListMarker final : public LayoutBox { ...@@ -62,6 +62,8 @@ class LayoutListMarker final : public LayoutBox {
const char* name() const override { return "LayoutListMarker"; } const char* name() const override { return "LayoutListMarker"; }
LayoutUnit lineOffset() const { return m_lineOffset; }
protected: protected:
void willBeDestroyed() override; void willBeDestroyed() override;
...@@ -112,6 +114,7 @@ class LayoutListMarker final : public LayoutBox { ...@@ -112,6 +114,7 @@ class LayoutListMarker final : public LayoutBox {
String m_text; String m_text;
Persistent<StyleImage> m_image; Persistent<StyleImage> m_image;
LayoutListItem* m_listItem; LayoutListItem* m_listItem;
LayoutUnit m_lineOffset;
}; };
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutListMarker, isListMarker()); DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutListMarker, isListMarker());
......
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