Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: Source/core/rendering/RenderInline.cpp

Issue 423173003: Incorrect Static Position of Absolute Positioned Elements inside Rel-Positioned Containers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css/abs-pos-child-inside-rel-pos-inline-offset-001-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderInline.cpp
diff --git a/Source/core/rendering/RenderInline.cpp b/Source/core/rendering/RenderInline.cpp
index e1501a8af492178a6757f6166143e778f45c9d1f..437f4e4a756734e4e72935f2011326cd8f02a310 100644
--- a/Source/core/rendering/RenderInline.cpp
+++ b/Source/core/rendering/RenderInline.cpp
@@ -1309,17 +1309,15 @@ LayoutSize RenderInline::offsetForInFlowPositionedInline(const RenderBox& child)
blockPosition = layer()->staticBlockPosition();
}
- if (!child.style()->hasStaticInlinePosition(style()->isHorizontalWritingMode()))
+ // 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.style()->hasStaticInlinePosition(style()->isHorizontalWritingMode()))
+ logicalOffset.setWidth(std::max(LayoutUnit(), -offsetForInFlowPosition().width()));
+ else
logicalOffset.setWidth(inlinePosition);
- // This is not terribly intuitive, but we have to match other browsers. Despite being a block display type inside
- // an inline, we still keep our x locked to the left of the relative positioned inline. Arguably the correct
- // behavior would be to go flush left to the block that contains the inline, but that isn't what other browsers
- // do.
- else if (!child.style()->isOriginalDisplayInlineType())
- // Avoid adding in the left border/padding of the containing block twice. Subtract it out.
- logicalOffset.setWidth(inlinePosition - child.containingBlock()->borderAndPaddingLogicalLeft());
-
if (!child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMode()))
logicalOffset.setHeight(blockPosition);
« no previous file with comments | « LayoutTests/fast/css/abs-pos-child-inside-rel-pos-inline-offset-001-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698