An inline element with an absolutely positioned child does not correctly calculate/render padding and margin
https://bugs.webkit.org/show_bug.cgi?id=47554

Reviewed by David Hyatt.

Source/WebCore:

When looking for padding/margin to add from the start of a child's parent skip past any leading positioned siblings as
we don't add the padding/margin of the common parent when skipping past them in |skipLeadingWhitespace|. We
don't need to worry about the case of trailing positioned objects as we will account for their parent's
border/margin/padding when we encounter them in |nextSegmentBreak|.

Test: fast/inline/padding-before-leading-positioned-element-contributes-width.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::previousInFlowSibling):
(WebCore):
(WebCore::inlineLogicalWidth):

LayoutTests:

* fast/inline/padding-before-leading-positioned-element-contributes-width-expected.txt: Added.
* fast/inline/padding-before-leading-positioned-element-contributes-width.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148453 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
index 34ce89a..c7afd73 100644
--- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -350,6 +350,14 @@
     return checkSide;
 }
 
+static RenderObject* previousInFlowSibling(RenderObject* child)
+{
+    child = child->previousSibling();
+    while (child && child->isOutOfFlowPositioned())
+        child = child->previousSibling();
+    return child;
+}
+
 static LayoutUnit inlineLogicalWidth(RenderObject* child, bool start = true, bool end = true)
 {
     unsigned lineDepth = 1;
@@ -358,7 +366,7 @@
     while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) {
         RenderInline* parentAsRenderInline = toRenderInline(parent);
         if (!isEmptyInline(parentAsRenderInline)) {
-            if (start && shouldAddBorderPaddingMargin(child->previousSibling(), start))
+            if (start && shouldAddBorderPaddingMargin(previousInFlowSibling(child), start))
                 extraWidth += borderPaddingMarginStart(parentAsRenderInline);
             if (end && shouldAddBorderPaddingMargin(child->nextSibling(), end))
                 extraWidth += borderPaddingMarginEnd(parentAsRenderInline);