Changeset 96152 in webkit


Ignore:
Timestamp:
Sep 27, 2011 1:55:00 PM (13 years ago)
Author:
ojan@chromium.org
Message:

offsetTop/offsetLeft return the wrong values for horizontal-bt/vertical-rl writing modes
https://bugs.webkit.org/show_bug.cgi?id=68304

Reviewed by David Hyatt.

Source/WebCore:

When grabbing the x/y values of the RenderBox, we need to take writing mode
flipping into account.

Test: fast/dom/offset-position-writing-modes.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::locationIncludingFlipping):

  • rendering/RenderBox.h:

(WebCore::RenderBox::yFlippedForWritingMode):
(WebCore::RenderBox::xFlippedForWritingMode):

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::offsetLeft):
(WebCore::RenderBoxModelObject::offsetTop):

LayoutTests:

  • css3/flexbox/writing-modes-expected.txt:
  • css3/flexbox/writing-modes.html:
  • fast/dom/offset-position-writing-modes-expected.txt: Added.
  • fast/dom/offset-position-writing-modes.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96151 r96152  
     12011-09-27  Ojan Vafai  <ojan@chromium.org>
     2
     3        offsetTop/offsetLeft return the wrong values for horizontal-bt/vertical-rl writing modes
     4        https://bugs.webkit.org/show_bug.cgi?id=68304
     5
     6        Reviewed by David Hyatt.
     7
     8        * css3/flexbox/writing-modes-expected.txt:
     9        * css3/flexbox/writing-modes.html:
     10        * fast/dom/offset-position-writing-modes-expected.txt: Added.
     11        * fast/dom/offset-position-writing-modes.html: Added.
     12
    1132011-09-27  Tim Horton  <timothy_horton@apple.com>
    214
  • trunk/LayoutTests/css3/flexbox/writing-modes-expected.txt

    r95577 r96152  
    1313PASS
    1414PASS
    15 Expected 580 for offsetLeft, but got 0. Expected 580 for offsetLeft, but got 0. Expected 580 for offsetLeft, but got 0.
    16 Expected 580 for offsetLeft, but got 0. Expected 180 for offsetTop, but got 0. Expected 580 for offsetLeft, but got 150. Expected 180 for offsetTop, but got 0. Expected 580 for offsetLeft, but got 450. Expected 180 for offsetTop, but got 0.
     15PASS
     16PASS
    1717
  • trunk/LayoutTests/css3/flexbox/writing-modes.html

    r95644 r96152  
    159159</div>
    160160
    161 <!-- FIXME: There's a bug where offsetLeft reports the wrong value in vertical-rl writing-mode.-->
    162161<div style="position:relative">
    163162<div class="flexbox vertical-rl">
     
    168167</div>
    169168
    170 <!-- FIXME: There's a bug where offsetTop reports the wrong value in horizontal-bt writing-mode.-->
    171169<div style="position:relative">
    172170<div class="flexbox bt" style="height:200px">
    173   <div data-offset-y="180" data-offset-x="580" style="width: -webkit-flex(1 0 0);"></div>
    174   <div data-offset-y="180" data-offset-x="580" style="width: -webkit-flex(2 0 0);"></div>
    175   <div data-offset-y="180" data-offset-x="580" style="width: -webkit-flex(1 0 0);"></div>
     171  <div data-expected-width="150" data-offset-y="180" data-offset-x="0" style="width: -webkit-flex(1 0 0);"></div>
     172  <div data-expected-width="300" data-offset-y="180" data-offset-x="150" style="width: -webkit-flex(2 0 0);"></div>
     173  <div data-expected-width="150" data-offset-y="180" data-offset-x="450" style="width: -webkit-flex(1 0 0);"></div>
    176174</div>
    177175</div>
  • trunk/Source/WebCore/ChangeLog

    r96151 r96152  
     12011-09-27  Ojan Vafai  <ojan@chromium.org>
     2
     3        offsetTop/offsetLeft return the wrong values for horizontal-bt/vertical-rl writing modes
     4        https://bugs.webkit.org/show_bug.cgi?id=68304
     5
     6        Reviewed by David Hyatt.
     7
     8        When grabbing the x/y values of the RenderBox, we need to take writing mode
     9        flipping into account.
     10
     11        Test: fast/dom/offset-position-writing-modes.html
     12
     13        * rendering/RenderBox.cpp:
     14        (WebCore::RenderBox::locationIncludingFlipping):
     15        * rendering/RenderBox.h:
     16        (WebCore::RenderBox::yFlippedForWritingMode):
     17        (WebCore::RenderBox::xFlippedForWritingMode):
     18        * rendering/RenderBoxModelObject.cpp:
     19        (WebCore::RenderBoxModelObject::offsetLeft):
     20        (WebCore::RenderBoxModelObject::offsetTop):
     21
    1222011-09-27  Tim Horton  <timothy_horton@apple.com>
    223
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r96139 r96152  
    13841384                o->adjustForColumns(offset, columnRect.location());
    13851385            } else
    1386                 offset += locationOffsetIncludingFlipping();
     1386                offset += topLeftLocationOffset();
    13871387        } else
    1388             offset += locationOffsetIncludingFlipping();
     1388            offset += topLeftLocationOffset();
    13891389    }
    13901390
     
    36503650}
    36513651
    3652 LayoutSize RenderBox::locationOffsetIncludingFlipping() const
     3652LayoutPoint RenderBox::topLeftLocation() const
     3653{
     3654    RenderBlock* containerBlock = containingBlock();
     3655    if (!containerBlock || containerBlock == this)
     3656        return location();
     3657    return containerBlock->flipForWritingMode(this, location(), RenderBox::ParentToChildFlippingAdjustment);
     3658}
     3659
     3660LayoutSize RenderBox::topLeftLocationOffset() const
    36533661{
    36543662    RenderBlock* containerBlock = containingBlock();
  • trunk/Source/WebCore/rendering/RenderBox.h

    r96139 r96152  
    5050    LayoutUnit height() const { return m_frameRect.height(); }
    5151
     52    // These represent your location relative to your container as a physical offset.
     53    // In layout related methods you almost always want the logical location (e.g. x() and y()).
     54    LayoutUnit top() const { return topLeftLocation().y(); }
     55    LayoutUnit left() const { return topLeftLocation().x(); }
     56
    5257    void setX(LayoutUnit x) { m_frameRect.setX(x); }
    5358    void setY(LayoutUnit y) { m_frameRect.setY(y); }
     
    403408    FloatPoint flipForWritingMode(const FloatPoint&) const;
    404409    void flipForWritingMode(FloatRect&) const;
    405     LayoutSize locationOffsetIncludingFlipping() const;
     410    // These represent your location relative to your container as a physical offset.
     411    // In layout related methods you almost always want the logical location (e.g. x() and y()).
     412    LayoutPoint topLeftLocation() const;
     413    LayoutSize topLeftLocationOffset() const;
    406414
    407415    LayoutRect logicalVisualOverflowRectForPropagation(RenderStyle*) const;
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r95901 r96152  
    439439   
    440440    RenderBoxModelObject* offsetPar = offsetParent();
    441     LayoutUnit xPos = (isBox() ? toRenderBox(this)->x() : 0);
     441    LayoutUnit xPos = (isBox() ? toRenderBox(this)->left() : 0);
    442442   
    443443    // If the offsetParent of the element is null, or is the HTML body element,
     
    454454                // FIXME: What are we supposed to do inside SVG content?
    455455                if (curr->isBox() && !curr->isTableRow())
    456                     xPos += toRenderBox(curr)->x();
     456                    xPos += toRenderBox(curr)->left();
    457457                curr = curr->parent();
    458458            }
    459459            if (offsetPar->isBox() && offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned())
    460                 xPos += toRenderBox(offsetPar)->x();
     460                xPos += toRenderBox(offsetPar)->left();
    461461        }
    462462    }
     
    473473   
    474474    RenderBoxModelObject* offsetPar = offsetParent();
    475     LayoutUnit yPos = (isBox() ? toRenderBox(this)->y() : 0);
     475    LayoutUnit yPos = (isBox() ? toRenderBox(this)->top() : 0);
    476476   
    477477    // If the offsetParent of the element is null, or is the HTML body element,
     
    488488                // FIXME: What are we supposed to do inside SVG content?
    489489                if (curr->isBox() && !curr->isTableRow())
    490                     yPos += toRenderBox(curr)->y();
     490                    yPos += toRenderBox(curr)->top();
    491491                curr = curr->parent();
    492492            }
    493493            if (offsetPar->isBox() && offsetPar->isBody() && !offsetPar->isRelPositioned() && !offsetPar->isPositioned())
    494                 yPos += toRenderBox(offsetPar)->y();
     494                yPos += toRenderBox(offsetPar)->top();
    495495        }
    496496    }
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r95863 r96152  
    708708    } else if (RenderBox* box = renderBox()) {
    709709        setSize(box->size());
    710         localPoint += box->locationOffsetIncludingFlipping();
     710        localPoint += box->topLeftLocationOffset();
    711711    }
    712712
     
    722722                // Rows and cells share the same coordinate space (that of the section).
    723723                // Omit them when computing our xpos/ypos.
    724                 localPoint += toRenderBox(curr)->locationOffsetIncludingFlipping();
     724                localPoint += toRenderBox(curr)->topLeftLocationOffset();
    725725            }
    726726            curr = curr->parent();
     
    728728        if (curr->isBox() && curr->isTableRow()) {
    729729            // Put ourselves into the row coordinate space.
    730             localPoint -= toRenderBox(curr)->locationOffsetIncludingFlipping();
     730            localPoint -= toRenderBox(curr)->topLeftLocationOffset();
    731731        }
    732732    }
Note: See TracChangeset for help on using the changeset viewer.