Commit 6bbbf532 authored by Robert Hogan's avatar Robert Hogan Committed by Commit Bot

Place list markers correctly when the line has shifted to avoid floats

Bug: 784793
Change-Id: Ib41a9a940acddf8737c261c3d14b39bf683aece4
Reviewed-on: https://chromium-review.googlesource.com/789930
Commit-Queue: Robert Hogan <robhogan@gmail.com>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520689}
parent 955ba583
<!DOCTYPE html>
<style>
.float {
float: left;
width: 100%;
background: lightgray;
}
</style>
<p>crbug.com/784793: The list marker should be to the left not the right.</p>
<div>
<div class="float">float</div>
<ul>
<li>
a
</li>
</ul>
</div>
<!DOCTYPE html>
<style>
.float {
float: left;
width: 100%;
background: lightgray;
}
</style>
<p>crbug.com/784793: The list marker should be to the left not the right.</p>
<div>
<div class="float">float</div>
<ul>
<li>
<script>
document.body.offsetTop;
</script>
a
</li>
</ul>
</div>
<!DOCTYPE html>
<style>
.float {
float: left;
width: 100%;
background: lightgray;
}
</style>
<p>crbug.com/784793: The list marker should be to the left not the right.</p>
<div style="direction:rtl">
<div class="float">float</div>
<ul>
<li>
a
</li>
</ul>
</div>
<!DOCTYPE html>
<style>
.float {
float: left;
width: 100%;
background: lightgray;
}
</style>
<p>crbug.com/784793: The list marker should be to the left not the right.</p>
<div style="direction:rtl">
<div class="float">float</div>
<ul>
<li>
<script>
document.body.offsetTop;
</script>
a
</li>
</ul>
</div>
......@@ -343,13 +343,22 @@ void LayoutListItem::PositionListMarker() {
if (need_block_direction_align_)
AlignMarkerInBlockDirection();
// We figured out the inline position of the marker before laying out the
// line so that floats later in the line don't interfere with it. However
// if the line has shifted down then that position will be too far out.
// So we always take the lowest value of (1) the position of the marker
// if we calculate it now and (2) the inline position we calculated before
// laying out the line.
// TODO(jchaffraix): Propagating the overflow to the line boxes seems
// pretty wrong (https://crbug.com/554160).
// FIXME: Need to account for relative positioning in the layout overflow.
if (Style()->IsLeftToRightDirection()) {
marker_logical_left = marker_->LineOffset() - line_offset -
PaddingStart() - BorderStart() +
marker_->MarginStart();
LayoutUnit marker_line_offset =
std::min(marker_->LineOffset(),
LogicalLeftOffsetForLine(marker_->LogicalTop(),
kDoNotIndentText, LayoutUnit()));
marker_logical_left = marker_line_offset - line_offset - PaddingStart() -
BorderStart() + marker_->MarginStart();
marker_->InlineBoxWrapper()->MoveInInlineDirection(
marker_logical_left - marker_old_logical_left);
for (InlineFlowBox* box = marker_->InlineBoxWrapper()->Parent(); box;
......@@ -380,9 +389,12 @@ void LayoutListItem::PositionListMarker() {
hit_self_painting_layer = true;
}
} else {
marker_logical_left = marker_->LineOffset() - line_offset +
PaddingStart() + BorderStart() +
marker_->MarginEnd();
LayoutUnit marker_line_offset =
std::max(marker_->LineOffset(),
LogicalRightOffsetForLine(marker_->LogicalTop(),
kDoNotIndentText, LayoutUnit()));
marker_logical_left = marker_line_offset - line_offset + PaddingStart() +
BorderStart() + marker_->MarginEnd();
marker_->InlineBoxWrapper()->MoveInInlineDirection(
marker_logical_left - marker_old_logical_left);
for (InlineFlowBox* box = marker_->InlineBoxWrapper()->Parent(); 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