Commit 116b2f29 authored by Tien-Ren Chen's avatar Tien-Ren Chen Committed by Commit Bot

[Blink] Remove negative offset compensation for rel-pos inline

Consider the following case:
<span style="position:relative; left:-100px;">
  <div style="display:inline-block; position:absolute;"></div>
</span>

In our implementation the absolute positioned element will have a
counter offset applied, to ignore the negative offset on its rel-pos
parent.

The compensation was added in https://codereview.chromium.org/423173003/
which wasn't covered by the added test, and isn't consistent with other
browser implementations. (Checked with Safari, IE, and Firefox.)

BUG=398164

Change-Id: I44127ff42446a7483d7e4ebb3197ecdc915db39d
Reviewed-on: https://chromium-review.googlesource.com/1195084Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587745}
parent 5d36a4bb
<!DOCTYPE HTML>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Test: Absolutely positioned descendant under relative positioned inline with negative offset</title>
<link rel="author" title="Tien-Ren Chen" href="mailto:trchen@chromium.org"/>
<link rel="help" href="https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width"/>
<link rel="match" href="../../reference/ref-filled-green-100px-square-only.html"/>
</head>
<body>
<p>Test passes if there is a filled green square.</p>
<div style="position:relative; left:100px; width:100px;">
<span style="position:relative; left:-100px;">
<div style="position:absolute; display:inline-block; width:100px; height:100px; background:green;"></div>
</span>
</div>
</body>
</html>
\ No newline at end of file
......@@ -14,6 +14,7 @@
width: 100px;
height: 100px;
background: green;
margin-left: 100px;
}
</style>
<script src="resources/text-based-repaint.js" type="text/javascript"></script>
......
......@@ -1541,15 +1541,9 @@ LayoutSize LayoutInline::OffsetForInFlowPositionedInline(
// Per http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width an
// absolute positioned box with a static position should locate itself as
// though it is a normal flow box in relation to its containing block. If this
// relative-positioned inline has a negative offset we need to compensate for
// it so that we align the positioned object with the edge of its containing
// block.
if (child.StyleRef().HasStaticInlinePosition(
// though it is a normal flow box in relation to its containing block.
if (!child.StyleRef().HasStaticInlinePosition(
StyleRef().IsHorizontalWritingMode()))
logical_offset.SetWidth(
std::max(LayoutUnit(), -OffsetForInFlowPosition().Width()));
else
logical_offset.SetWidth(inline_position);
if (!child.StyleRef().HasStaticBlockPosition(
......
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