Changeset 80814 in webkit


Ignore:
Timestamp:
Mar 10, 2011 9:36:37 PM (13 years ago)
Author:
jeremy@chromium.org
Message:

2011-03-10 Jeremy Moskovich <jeremy@chromium.org>

Reviewed by Darin Adler.

Fix navigation menus on a bunch of sites in WebKit.
https://bugs.webkit.org/show_bug.cgi?id=52535

Add test to make sure that offsetLeft matches FF/IE for a relatively
positioned TD and IFRAME elements.
Testcase is a reduction from doula.co.il.

  • fast/block/positioning/offsetLeft-relative-iframe-expected.txt: Added.
  • fast/block/positioning/offsetLeft-relative-iframe.html: Added.
  • fast/block/positioning/offsetLeft-relative-td-expected.txt: Added.
  • fast/block/positioning/offsetLeft-relative-td.html: Added.

2011-03-10 Jeremy Moskovich <jeremy@chromium.org>

Reviewed by Darin Adler.

Fix navigation menus on a bunch of sites in WebKit.
https://bugs.webkit.org/show_bug.cgi?id=52535

WebKit doesn't support position:relative for several table elements and
overwrites the style internally when position:relative is encountered.
Unfortunately position:relative affects the choice of nodes returned by
offsetParent.

This CL adds a bit to RenderStyle to track whether position:relative was
overwritten. The value is then consulted in offsetParent which makes us
match FF/IE.

Tests: fast/block/positioning/offsetLeft-relative-iframe.html

fast/block/positioning/offsetLeft-relative-td.html

  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::adjustRenderStyle):
  • rendering/RenderObject.cpp: (WebCore::RenderObject::isOriginallyRelPositioned): (WebCore::RenderObject::offsetParent):
  • rendering/RenderObject.h:
  • rendering/style/RenderStyle.h: Add a bit to track the original value of position:relative. (WebCore::InheritedFlags::positionWasRelative): (WebCore::InheritedFlags::setPositionWasRelative):
  • rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==):
  • rendering/style/StyleRareNonInheritedData.h:
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80812 r80814  
     12011-03-10  Jeremy Moskovich  <jeremy@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Fix navigation menus on a bunch of sites in WebKit.
     6        https://bugs.webkit.org/show_bug.cgi?id=52535
     7
     8        Add test to make sure that offsetLeft matches FF/IE for a relatively
     9        positioned TD and IFRAME elements.
     10        Testcase is a reduction from doula.co.il.
     11
     12        * fast/block/positioning/offsetLeft-relative-iframe-expected.txt: Added.
     13        * fast/block/positioning/offsetLeft-relative-iframe.html: Added.
     14        * fast/block/positioning/offsetLeft-relative-td-expected.txt: Added.
     15        * fast/block/positioning/offsetLeft-relative-td.html: Added.
     16
    1172011-03-10  Adam Barth  <abarth@webkit.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r80812 r80814  
     12011-03-10  Jeremy Moskovich  <jeremy@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Fix navigation menus on a bunch of sites in WebKit.
     6        https://bugs.webkit.org/show_bug.cgi?id=52535
     7
     8        WebKit doesn't support position:relative for several table elements and
     9        overwrites the style internally when position:relative is encountered.
     10        Unfortunately position:relative affects the choice of nodes returned by
     11        offsetParent.
     12
     13        This CL adds a bit to RenderStyle to track whether position:relative was
     14        overwritten.  The value is then consulted in offsetParent which makes us
     15        match FF/IE.
     16
     17        Tests: fast/block/positioning/offsetLeft-relative-iframe.html
     18               fast/block/positioning/offsetLeft-relative-td.html
     19
     20        * css/CSSStyleSelector.cpp:
     21        (WebCore::CSSStyleSelector::adjustRenderStyle):
     22        * rendering/RenderObject.cpp:
     23        (WebCore::RenderObject::isOriginallyRelPositioned):
     24        (WebCore::RenderObject::offsetParent):
     25        * rendering/RenderObject.h:
     26        * rendering/style/RenderStyle.h: Add a bit to track the original value of position:relative.
     27        (WebCore::InheritedFlags::positionWasRelative):
     28        (WebCore::InheritedFlags::setPositionWasRelative):
     29        * rendering/style/StyleRareNonInheritedData.cpp:
     30        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     31        (WebCore::StyleRareNonInheritedData::operator==):
     32        * rendering/style/StyleRareNonInheritedData.h:
     33
    1342011-03-10  Adam Barth  <abarth@webkit.org>
    235
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r80811 r80814  
    18931893        // fix a crash where a site tries to position these objects.  They also never honor display.
    18941894        if (e && (e->hasTagName(frameTag) || e->hasTagName(framesetTag))) {
     1895            if (style->position() == RelativePosition)
     1896                style->setPositionWasRelative(true);
    18951897            style->setPosition(StaticPosition);
    18961898            style->setDisplay(BLOCK);
     
    19351937        if ((style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_ROW_GROUP ||
    19361938             style->display() == TABLE_FOOTER_GROUP || style->display() == TABLE_ROW || style->display() == TABLE_CELL) &&
    1937              style->position() == RelativePosition)
     1939             style->position() == RelativePosition) {
     1940            style->setPositionWasRelative(true);
    19381941            style->setPosition(StaticPosition);
     1942        }
    19391943
    19401944        // writing-mode does not apply to table row groups, table column groups, table rows, and table columns.
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r80559 r80814  
    21532153}
    21542154
     2155bool RenderObject::wasOriginallyRelativePositioned() const
     2156{
     2157    return isRelPositioned() || style()->positionWasRelative();
     2158}
     2159
    21552160bool RenderObject::isSelectionBorder() const
    21562161{
     
    26112616    //       is one of the following HTML elements: td, th, or table.
    26122617    //     * Our own extension: if there is a difference in the effective zoom
    2613     bool skipTables = isPositioned() || isRelPositioned();
     2618
     2619    bool skipTables = isPositioned() || wasOriginallyRelativePositioned();
    26142620    float currZoom = style()->effectiveZoom();
    26152621    RenderObject* curr = parent();
    26162622    while (curr && (!curr->node() ||
    2617                     (!curr->isPositioned() && !curr->isRelPositioned() && !curr->isBody()))) {
     2623                    (!curr->isPositioned() && !curr->wasOriginallyRelativePositioned() && !curr->isBody()))) {
    26182624        Node* element = curr->node();
    26192625        if (!skipTables && element) {
  • trunk/Source/WebCore/rendering/RenderObject.h

    r80798 r80814  
    401401    bool isPositioned() const { return m_positioned; } // absolute or fixed positioning
    402402    bool isRelPositioned() const { return m_relPositioned; } // relative positioning
     403
     404    // WebKit overwrites the position:relative style for certain elements for which such positioning is illegal or behavior is undefined.
     405    // This function returns the value specified in the source, even if it was corrected by WebKit.
     406    bool wasOriginallyRelativePositioned() const;
     407
    403408    bool isText() const  { return m_isText; }
    404409    bool isBox() const { return m_isBox; }
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r80582 r80814  
    599599    short counterIncrement() const { return rareNonInheritedData->m_counterIncrement; }
    600600    short counterReset() const { return rareNonInheritedData->m_counterReset; }
     601
     602    bool positionWasRelative() const { return rareNonInheritedData->m_positionWasRelative; }
    601603
    602604    EListStyleType listStyleType() const { return static_cast<EListStyleType>(inherited_flags._list_style_type); }
     
    971973    void setCounterIncrement(short v) { SET_VAR(rareNonInheritedData, m_counterIncrement, v) }
    972974    void setCounterReset(short v) { SET_VAR(rareNonInheritedData, m_counterReset, v) }
     975
     976    void setPositionWasRelative(bool v) { SET_VAR(rareNonInheritedData, m_positionWasRelative, v) }
    973977
    974978    void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; }
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r75848 r80814  
    4747    , m_counterIncrement(0)
    4848    , m_counterReset(0)
     49    , m_positionWasRelative(0)
    4950#if USE(ACCELERATED_COMPOSITING)
    5051    , m_runningAcceleratedAnimation(false)
     
    8485    , m_counterIncrement(o.m_counterIncrement)
    8586    , m_counterReset(o.m_counterReset)
     87    , m_positionWasRelative(o.m_positionWasRelative)
    8688#if USE(ACCELERATED_COMPOSITING)
    8789    , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
     
    130132        && m_counterIncrement == o.m_counterIncrement
    131133        && m_counterReset == o.m_counterReset
     134        && m_positionWasRelative == o.m_positionWasRelative
    132135#if USE(ACCELERATED_COMPOSITING)
    133136        && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r74098 r80814  
    109109    short m_counterReset;
    110110   
     111    // This flag preserves the fact that the position attribute was originally specified as relative.
     112    unsigned m_positionWasRelative : 1;
     113
    111114#if USE(ACCELERATED_COMPOSITING)
    112115    bool m_runningAcceleratedAnimation : 1;
Note: See TracChangeset for help on using the changeset viewer.