Title: [116446] trunk
Revision
116446
Author
[email protected]
Date
2012-05-08 12:11:14 -0700 (Tue, 08 May 2012)

Log Message

offsetLeft broken within CSS3 columns
https://bugs.webkit.org/show_bug.cgi?id=34875

Patch by Shezan Baig <[email protected]> on 2012-05-08
Reviewed by Julien Chaffraix.

Source/WebCore:

Reimplement offsetLeft and offsetTop in terms of a new method called
'offsetTopLeft'. The new method starts from a reference point (the
top-left coordinate of a box or inline) and adjusts this reference
point for columns as we traverse each parent. Note that the reference
point needs to be adjusted in both dimensions, even though offsetLeft
and offsetTop return only one of them.

A new method called 'offsetForColumns' was added to RenderObject. This
method is similar to adjustForColumns, except that it returns the
offset instead of modifying a reference. This method is necessary to
simplify the implementation of offsetTopLeft.

Tests: fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt
       fast/block/positioning/offsetLeft-offsetTop-multicolumn.html

* rendering/RenderBox.h:
(RenderBox):
Override offsetLeft and offsetTop.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::offsetLeft):
Implemented in terms of RenderBoxModelObject::offsetTopLeft, using
topLeftLocation as startPoint.
(WebCore::RenderBox::offsetTop):
Implemented in terms of RenderBoxModelObject::offsetTopLeft, using
topLeftLocation as startPoint.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::offsetTopLeft):
New method to compute offsetLeft and offsetTop simultaneously, and
adjusting for columns at each parent.
(WebCore::RenderBoxModelObject::offsetLeft):
Reimplemented in terms of offsetTopLeft.
(WebCore::RenderBoxModelObject::offsetTop):
Reimplemented in terms of offsetTopLeft.
* rendering/RenderBoxModelObject.h:
(RenderBoxModelObject):
Declare new offsetTopLeft method.
* rendering/RenderInline.cpp:
(WebCore::RenderInline::offsetLeft):
Reimplemented in terms of RenderBoxModelObject::offsetTopLeft.
(WebCore::RenderInline::offsetTop):
Reimplemented in terms of RenderBoxModelObject::offsetTopLeft.
* rendering/RenderObject.h:
(RenderObject):
(WebCore::RenderObject::offsetForColumns):
New helper method to simplify implementation of offsetTopLeft.

LayoutTests:

Add test for offsetLeft and offsetTop within multi-columns.

* fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt: Added.
* fast/block/positioning/offsetLeft-offsetTop-multicolumn.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116445 => 116446)


--- trunk/LayoutTests/ChangeLog	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/LayoutTests/ChangeLog	2012-05-08 19:11:14 UTC (rev 116446)
@@ -1,3 +1,15 @@
+2012-05-08  Shezan Baig  <[email protected]>
+
+        offsetLeft broken within CSS3 columns
+        https://bugs.webkit.org/show_bug.cgi?id=34875
+
+        Reviewed by Julien Chaffraix.
+
+        Add test for offsetLeft and offsetTop within multi-columns.
+
+        * fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt: Added.
+        * fast/block/positioning/offsetLeft-offsetTop-multicolumn.html: Added.
+
 2012-05-08  Christophe Dumez  <[email protected]>
 
         [EFL] media/video-play-require-user-gesture.html test is failing

Added: trunk/LayoutTests/fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt (0 => 116446)


--- trunk/LayoutTests/fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt	2012-05-08 19:11:14 UTC (rev 116446)
@@ -0,0 +1,138 @@
+This test checks that offsetLeft and offsetTop return correct values when used on elements contained in multiple columns. We put a number of spans (of arbitrary size) in a multi-column div. The script at the end verifies the offsetLeft and offsetTop result of each span against pre-calculated values.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS multicol.offsetParent.id is offsetParent.id
+PASS spans[0].offsetLeft is 0
+PASS spans[0].offsetTop is 0
+PASS spans[1].offsetLeft is 14
+PASS spans[1].offsetTop is 0
+PASS spans[2].offsetLeft is 38
+PASS spans[2].offsetTop is 0
+PASS spans[3].offsetLeft is 62
+PASS spans[3].offsetTop is 0
+PASS spans[4].offsetLeft is 0
+PASS spans[4].offsetTop is 23
+PASS spans[5].offsetLeft is 24
+PASS spans[5].offsetTop is 23
+PASS spans[6].offsetLeft is 0
+PASS spans[6].offsetTop is 46
+PASS spans[7].offsetLeft is 24
+PASS spans[7].offsetTop is 46
+PASS spans[8].offsetLeft is 38
+PASS spans[8].offsetTop is 46
+PASS spans[9].offsetLeft is 0
+PASS spans[9].offsetTop is 69
+PASS spans[10].offsetLeft is 44
+PASS spans[10].offsetTop is 69
+PASS spans[11].offsetLeft is 0
+PASS spans[11].offsetTop is 92
+PASS spans[12].offsetLeft is 44
+PASS spans[12].offsetTop is 92
+PASS spans[13].offsetLeft is 58
+PASS spans[13].offsetTop is 92
+PASS spans[14].offsetLeft is 82
+PASS spans[14].offsetTop is 92
+PASS spans[15].offsetLeft is 0
+PASS spans[15].offsetTop is 115
+PASS spans[16].offsetLeft is 24
+PASS spans[16].offsetTop is 115
+PASS spans[17].offsetLeft is 68
+PASS spans[17].offsetTop is 115
+PASS spans[18].offsetLeft is 0
+PASS spans[18].offsetTop is 138
+PASS spans[19].offsetLeft is 44
+PASS spans[19].offsetTop is 138
+PASS spans[20].offsetLeft is 58
+PASS spans[20].offsetTop is 138
+PASS spans[21].offsetLeft is 0
+PASS spans[21].offsetTop is 161
+PASS spans[22].offsetLeft is 44
+PASS spans[22].offsetTop is 161
+PASS spans[23].offsetLeft is 123
+PASS spans[23].offsetTop is 0
+PASS spans[24].offsetLeft is 147
+PASS spans[24].offsetTop is 0
+PASS spans[25].offsetLeft is 123
+PASS spans[25].offsetTop is 23
+PASS spans[26].offsetLeft is 167
+PASS spans[26].offsetTop is 23
+PASS spans[27].offsetLeft is 191
+PASS spans[27].offsetTop is 23
+PASS spans[28].offsetLeft is 205
+PASS spans[28].offsetTop is 23
+PASS spans[29].offsetLeft is 123
+PASS spans[29].offsetTop is 46
+PASS spans[30].offsetLeft is 147
+PASS spans[30].offsetTop is 46
+PASS spans[31].offsetLeft is 123
+PASS spans[31].offsetTop is 69
+PASS spans[32].offsetLeft is 147
+PASS spans[32].offsetTop is 69
+PASS spans[33].offsetLeft is 161
+PASS spans[33].offsetTop is 69
+PASS spans[34].offsetLeft is 123
+PASS spans[34].offsetTop is 92
+PASS spans[35].offsetLeft is 167
+PASS spans[35].offsetTop is 92
+PASS spans[36].offsetLeft is 181
+PASS spans[36].offsetTop is 92
+PASS spans[37].offsetLeft is 123
+PASS spans[37].offsetTop is 115
+PASS spans[38].offsetLeft is 167
+PASS spans[38].offsetTop is 115
+PASS spans[39].offsetLeft is 123
+PASS spans[39].offsetTop is 138
+PASS spans[40].offsetLeft is 147
+PASS spans[40].offsetTop is 138
+PASS spans[41].offsetLeft is 191
+PASS spans[41].offsetTop is 138
+PASS spans[42].offsetLeft is 123
+PASS spans[42].offsetTop is 161
+PASS spans[43].offsetLeft is 167
+PASS spans[43].offsetTop is 161
+PASS spans[44].offsetLeft is 246
+PASS spans[44].offsetTop is 0
+PASS spans[45].offsetLeft is 270
+PASS spans[45].offsetTop is 0
+PASS spans[46].offsetLeft is 284
+PASS spans[46].offsetTop is 0
+PASS spans[47].offsetLeft is 298
+PASS spans[47].offsetTop is 0
+PASS spans[48].offsetLeft is 322
+PASS spans[48].offsetTop is 0
+PASS spans[49].offsetLeft is 246
+PASS spans[49].offsetTop is 23
+PASS spans[50].offsetLeft is 270
+PASS spans[50].offsetTop is 23
+PASS spans[51].offsetLeft is 284
+PASS spans[51].offsetTop is 23
+PASS spans[52].offsetLeft is 246
+PASS spans[52].offsetTop is 46
+PASS spans[53].offsetLeft is 290
+PASS spans[53].offsetTop is 46
+PASS spans[54].offsetLeft is 304
+PASS spans[54].offsetTop is 46
+PASS spans[55].offsetLeft is 246
+PASS spans[55].offsetTop is 69
+PASS spans[56].offsetLeft is 290
+PASS spans[56].offsetTop is 69
+PASS spans[57].offsetLeft is 314
+PASS spans[57].offsetTop is 69
+PASS spans[58].offsetLeft is 246
+PASS spans[58].offsetTop is 92
+PASS spans[59].offsetLeft is 290
+PASS spans[59].offsetTop is 92
+PASS spans[60].offsetLeft is 304
+PASS spans[60].offsetTop is 92
+PASS successfullyParsed is true
+
+TEST COMPLETE
+    
+            
+    
+     
+         
+    
+  

Added: trunk/LayoutTests/fast/block/positioning/offsetLeft-offsetTop-multicolumn.html (0 => 116446)


--- trunk/LayoutTests/fast/block/positioning/offsetLeft-offsetTop-multicolumn.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/positioning/offsetLeft-offsetTop-multicolumn.html	2012-05-08 19:11:14 UTC (rev 116446)
@@ -0,0 +1,156 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+    description("This test checks that offsetLeft and offsetTop return " +
+                "correct values when used on elements contained in multiple " +
+                "columns. We put a number of spans (of arbitrary size) in a " +
+                "multi-column div. The script at the end verifies the " +
+                "offsetLeft and offsetTop result of each span against " +
+                "pre-calculated values.");
+
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<style>
+    body {
+        font: Ahem;
+    }
+
+    #parent {
+        position: absolute;
+    }
+
+    #multicol {
+        -webkit-column-width: 100px;
+        -moz-column-width: 100px;
+        column-width: 100px;
+        height: 200px;
+        line-height: 18px;
+    }
+
+    #multicol span {
+        display: inline-block;
+        height: 20px;
+        background: #000;
+    }
+
+    .size1 {
+        width: 10px;
+    }
+
+    .size2 {
+        width: 20px;
+    }
+
+    .size3 {
+        width: 40px;
+    }
+</style>
+</head>
+<body>
+<div id="parent">
+    <div id="multicol">
+        <div>
+            <span class="size1"></span>
+            <span class="size2"></span>
+            <span class="size2"></span>
+            <span class="size3"></span>
+            <span class="size2"></span>
+            <span class="size1"></span>
+        </div>
+        <div>
+            <span class="size2"></span>
+            <span class="size1"></span>
+            <span class="size3"></span>
+            <span class="size3"></span>
+            <span class="size2"></span>
+            <span class="size3"></span>
+            <span class="size1"></span>
+            <span class="size2"></span>
+            <span class="size2"></span>
+            <span class="size2"></span>
+            <span class="size3"></span>
+            <span class="size2"></span>
+            <span class="size3"></span>
+            <span class="size1"></span>
+            <span class="size3"></span>
+            <span class="size3"></span>
+            <span class="size3"></span>
+            <span class="size2"></span>
+            <span class="size3"></span>
+        </div>
+        <div>
+            <span class="size3"></span>
+            <span class="size2"></span>
+            <span class="size1"></span>
+            <span class="size1"></span>
+            <span class="size2"></span>
+            <span class="size2"></span>
+            <div>
+                <span class="size2"></span>
+                <span class="size1"></span>
+                <span class="size3"></span>
+                <span class="size3"></span>
+                <span class="size1"></span>
+                <span class="size3"></span>
+                <span class="size3"></span>
+                <span class="size2"></span>
+                <div>
+                    <span class="size2"></span>
+                    <span class="size3"></span>
+                    <span class="size1"></span>
+                    <span class="size3"></span>
+                    <span class="size3"></span>
+                    <span class="size2"></span>
+                    <span class="size1"></span>
+                    <span class="size1"></span>
+                    <span class="size2"></span>
+                    <span class="size2"></span>
+                    <span class="size2"></span>
+                    <span class="size1"></span>
+                    <span class="size3"></span>
+                </div>
+                <span class="size3"></span>
+                <span class="size1"></span>
+                <span class="size3"></span>
+                <span class="size3"></span>
+                <span class="size2"></span>
+                <span class="size2"></span>
+            </div>
+            <span class="size3"></span>
+            <span class="size1"></span>
+            <span class="size3"></span>
+        </div>
+    </div>
+</div>
+<script>
+    var body = document.getElementsByTagName("body")[0];
+    var multicol = document.getElementById("multicol");
+    var offsetParent = document.getElementById("parent");
+    var spans = multicol.getElementsByTagName("span");
+
+    shouldBe("multicol.offsetParent.id", "offsetParent.id");
+
+    var expectedResults = [
+        [0,0],[14,0],[38,0],[62,0],[0,23],[24,23],[0,46],[24,46],[38,46],
+        [0,69],[44,69],[0,92],[44,92],[58,92],[82,92],[0,115],[24,115],
+        [68,115],[0,138],[44,138],[58,138],[0,161],[44,161],[123,0],[147,0],
+        [123,23],[167,23],[191,23],[205,23],[123,46],[147,46],[123,69],[147,69],
+        [161,69],[123,92],[167,92],[181,92],[123,115],[167,115],[123,138],[147,138],
+        [191,138],[123,161],[167,161],[246,0],[270,0],[284,0],[298,0],[322,0],
+        [246,23],[270,23],[284,23],[246,46],[290,46],[304,46],[246,69],[290,69],
+        [314,69],[246,92],[290,92],[304,92],
+    ];
+
+    for (var i = 0; i < spans.length; ++i) {
+        var expected = expectedResults[i];
+        shouldBe("spans[" + i + "].offsetLeft", expected[0].toString());
+        shouldBe("spans[" + i + "].offsetTop", expected[1].toString());
+    }
+</script>
+</body>
+<script src=""
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (116445 => 116446)


--- trunk/Source/WebCore/ChangeLog	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/ChangeLog	2012-05-08 19:11:14 UTC (rev 116446)
@@ -1,3 +1,56 @@
+2012-05-08  Shezan Baig  <[email protected]>
+
+        offsetLeft broken within CSS3 columns
+        https://bugs.webkit.org/show_bug.cgi?id=34875
+
+        Reviewed by Julien Chaffraix.
+
+        Reimplement offsetLeft and offsetTop in terms of a new method called
+        'offsetTopLeft'. The new method starts from a reference point (the
+        top-left coordinate of a box or inline) and adjusts this reference
+        point for columns as we traverse each parent. Note that the reference
+        point needs to be adjusted in both dimensions, even though offsetLeft
+        and offsetTop return only one of them.
+
+        A new method called 'offsetForColumns' was added to RenderObject. This
+        method is similar to adjustForColumns, except that it returns the
+        offset instead of modifying a reference. This method is necessary to
+        simplify the implementation of offsetTopLeft.
+
+        Tests: fast/block/positioning/offsetLeft-offsetTop-multicolumn-expected.txt
+               fast/block/positioning/offsetLeft-offsetTop-multicolumn.html
+
+        * rendering/RenderBox.h:
+        (RenderBox):
+        Override offsetLeft and offsetTop.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::offsetLeft):
+        Implemented in terms of RenderBoxModelObject::offsetTopLeft, using
+        topLeftLocation as startPoint.
+        (WebCore::RenderBox::offsetTop):
+        Implemented in terms of RenderBoxModelObject::offsetTopLeft, using
+        topLeftLocation as startPoint.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::offsetTopLeft):
+        New method to compute offsetLeft and offsetTop simultaneously, and
+        adjusting for columns at each parent.
+        (WebCore::RenderBoxModelObject::offsetLeft):
+        Reimplemented in terms of offsetTopLeft.
+        (WebCore::RenderBoxModelObject::offsetTop):
+        Reimplemented in terms of offsetTopLeft.
+        * rendering/RenderBoxModelObject.h:
+        (RenderBoxModelObject):
+        Declare new offsetTopLeft method.
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::offsetLeft):
+        Reimplemented in terms of RenderBoxModelObject::offsetTopLeft.
+        (WebCore::RenderInline::offsetTop):
+        Reimplemented in terms of RenderBoxModelObject::offsetTopLeft.
+        * rendering/RenderObject.h:
+        (RenderObject):
+        (WebCore::RenderObject::offsetForColumns):
+        New helper method to simplify implementation of offsetTopLeft.
+
 2012-03-31  Robert Hogan  <[email protected]>
 
         CSS 2.1 failure: first-letter-nested-004.htm fails

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (116445 => 116446)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-05-08 19:11:14 UTC (rev 116446)
@@ -3912,6 +3912,16 @@
     return rect;
 }
 
+LayoutUnit RenderBox::offsetLeft() const
+{
+    return offsetTopLeft(topLeftLocation()).x();
+}
+
+LayoutUnit RenderBox::offsetTop() const
+{
+    return offsetTopLeft(topLeftLocation()).y();
+}
+
 LayoutPoint RenderBox::flipForWritingModeForChild(const RenderBox* child, const LayoutPoint& point) const
 {
     if (!style()->isFlippedBlocksWritingMode())

Modified: trunk/Source/WebCore/rendering/RenderBox.h (116445 => 116446)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-05-08 19:11:14 UTC (rev 116446)
@@ -433,6 +433,9 @@
     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
     virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
 
+    virtual LayoutUnit offsetLeft() const OVERRIDE;
+    virtual LayoutUnit offsetTop() const OVERRIDE;
+
     LayoutPoint flipForWritingModeForChild(const RenderBox* child, const LayoutPoint&) const;
     LayoutUnit flipForWritingMode(LayoutUnit position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
     LayoutPoint flipForWritingMode(const LayoutPoint&) const;

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (116445 => 116446)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-05-08 19:11:14 UTC (rev 116446)
@@ -535,71 +535,53 @@
     return offset;
 }
 
-LayoutUnit RenderBoxModelObject::offsetLeft() const
+LayoutPoint RenderBoxModelObject::offsetTopLeft(const LayoutPoint& startPoint) const
 {
     // If the element is the HTML body element or does not have an associated box
     // return 0 and stop this algorithm.
     if (isBody())
-        return ZERO_LAYOUT_UNIT;
+        return LayoutPoint();
     
-    RenderBoxModelObject* offsetPar = offsetParent();
-    LayoutUnit xPos = (isBox() ? toRenderBox(this)->left() : ZERO_LAYOUT_UNIT);
+    LayoutPoint referencePoint = startPoint;
+    referencePoint.move(parent()->offsetForColumns(referencePoint));
     
     // If the offsetParent of the element is null, or is the HTML body element,
     // return the distance between the canvas origin and the left border edge 
     // of the element and stop this algorithm.
-    if (offsetPar) {
-        if (offsetPar->isBox() && !offsetPar->isBody())
-            xPos -= toRenderBox(offsetPar)->borderLeft();
+    if (const RenderBoxModelObject* offsetParent = this->offsetParent()) {
+        if (offsetParent->isBox() && !offsetParent->isBody())
+            referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRenderBox(offsetParent)->borderTop());
         if (!isPositioned()) {
             if (isRelPositioned())
-                xPos += relativePositionOffsetX();
-            RenderObject* curr = parent();
-            while (curr && curr != offsetPar) {
+                referencePoint.move(relativePositionOffset());
+            const RenderObject* curr = parent();
+            while (curr != offsetParent) {
                 // FIXME: What are we supposed to do inside SVG content?
                 if (curr->isBox() && !curr->isTableRow())
-                    xPos += toRenderBox(curr)->left();
+                    referencePoint.moveBy(toRenderBox(curr)->topLeftLocation());
+                referencePoint.move(curr->parent()->offsetForColumns(referencePoint));
                 curr = curr->parent();
             }
-            if (offsetPar->isBox() && offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned())
-                xPos += toRenderBox(offsetPar)->left();
+            if (offsetParent->isBox() && offsetParent->isBody() && !offsetParent->isRelPositioned() && !offsetParent->isPositioned())
+                referencePoint.moveBy(toRenderBox(offsetParent)->topLeftLocation());
         }
     }
 
-    return xPos;
+    return referencePoint;
 }
 
+LayoutUnit RenderBoxModelObject::offsetLeft() const
+{
+    // Note that RenderInline and RenderBox override this to pass a different
+    // startPoint to offsetTopLeft.
+    return offsetTopLeft(LayoutPoint()).x();
+}
+
 LayoutUnit RenderBoxModelObject::offsetTop() const
 {
-    // If the element is the HTML body element or does not have an associated box
-    // return 0 and stop this algorithm.
-    if (isBody())
-        return ZERO_LAYOUT_UNIT;
-    
-    RenderBoxModelObject* offsetPar = offsetParent();
-    LayoutUnit yPos = (isBox() ? toRenderBox(this)->top() : ZERO_LAYOUT_UNIT);
-    
-    // If the offsetParent of the element is null, or is the HTML body element,
-    // return the distance between the canvas origin and the top border edge 
-    // of the element and stop this algorithm.
-    if (offsetPar) {
-        if (offsetPar->isBox() && !offsetPar->isBody())
-            yPos -= toRenderBox(offsetPar)->borderTop();
-        if (!isPositioned()) {
-            if (isRelPositioned())
-                yPos += relativePositionOffsetY();
-            RenderObject* curr = parent();
-            while (curr && curr != offsetPar) {
-                // FIXME: What are we supposed to do inside SVG content?
-                if (curr->isBox() && !curr->isTableRow())
-                    yPos += toRenderBox(curr)->top();
-                curr = curr->parent();
-            }
-            if (offsetPar->isBox() && offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned())
-                yPos += toRenderBox(offsetPar)->top();
-        }
-    }
-    return yPos;
+    // Note that RenderInline and RenderBox override this to pass a different
+    // startPoint to offsetTopLeft.
+    return offsetTopLeft(LayoutPoint()).y();
 }
 
 int RenderBoxModelObject::pixelSnappedOffsetWidth() const

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (116445 => 116446)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-05-08 19:11:14 UTC (rev 116446)
@@ -227,6 +227,8 @@
         IntSize m_tileSize;
     };
 
+    LayoutPoint offsetTopLeft(const LayoutPoint&) const;
+
     void calculateBackgroundImageGeometry(const FillLayer*, const LayoutRect& paintRect, BackgroundImageGeometry&);
     void getBorderEdgeInfo(class BorderEdge[], const RenderStyle*, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
     bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const;

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (116445 => 116446)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2012-05-08 19:11:14 UTC (rev 116446)
@@ -678,18 +678,18 @@
 
 LayoutUnit RenderInline::offsetLeft() const
 {
-    LayoutUnit x = RenderBoxModelObject::offsetLeft();
+    LayoutPoint topLeft;
     if (InlineBox* firstBox = firstLineBoxIncludingCulling())
-        x += firstBox->x();
-    return x;
+        topLeft = flooredLayoutPoint(firstBox->topLeft());
+    return offsetTopLeft(topLeft).x();
 }
 
 LayoutUnit RenderInline::offsetTop() const
 {
-    LayoutUnit y = RenderBoxModelObject::offsetTop();
+    LayoutPoint topLeft;
     if (InlineBox* firstBox = firstLineBoxIncludingCulling())
-        y += firstBox->y();
-    return y;
+        topLeft = flooredLayoutPoint(firstBox->topLeft());
+    return offsetTopLeft(topLeft).y();
 }
 
 static LayoutUnit computeMargin(const RenderInline* renderer, const Length& margin)

Modified: trunk/Source/WebCore/rendering/RenderObject.h (116445 => 116446)


--- trunk/Source/WebCore/rendering/RenderObject.h	2012-05-08 19:09:01 UTC (rev 116445)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2012-05-08 19:11:14 UTC (rev 116446)
@@ -765,6 +765,12 @@
     // If multiple-column layout results in applying an offset to the given point, add the same
     // offset to the given size.
     virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const { }
+    LayoutSize offsetForColumns(const LayoutPoint& point) const
+    {
+        LayoutSize offset;
+        adjustForColumns(offset, point);
+        return offset;
+    }
 
     virtual unsigned int length() const { return 1; }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to