Changeset 163165 in webkit


Ignore:
Timestamp:
Jan 31, 2014 12:09:07 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Fix table sizing when 'max-width' is used.
https://bugs.webkit.org/show_bug.cgi?id=115156

Patch by László Langó <lango@inf.u-szeged.hu> on 2014-01-31
Reviewed by Andreas Kling.

Source/WebCore:

r143534 make <table> abide by 'max-width' all the time which is wrong.
Per the CSS specification, a table should be wide enough to fit its
content, regardless of 'max-width'.

r140479 fixed part of the regression from that change but made the
same fatal mistake by constraining min-content to fit 'max-width'.

The fix is to avoid constraining min-content and ensure that the table
logical width is at least its min-content size.

Backported from Blink:
https://chromium.googlesource.com/chromium/blink/+/0bca0dec4895aeeb2054ba36316e984e4ebed06f

Test: fast/table/html-table-width-max-width-constrained.html

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::updateLogicalWidth):
(WebCore::RenderTable::computePreferredLogicalWidths):

LayoutTests:

  • fast/table/css-table-max-width-expected.txt:
  • fast/table/css-table-max-width.html:
  • fast/table/html-table-width-max-width-constrained-expected.txt: Added.
  • fast/table/html-table-width-max-width-constrained.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163140 r163165  
     12014-01-31  László Langó  <lango@inf.u-szeged.hu>
     2
     3        Fix table sizing when 'max-width' is used.
     4        https://bugs.webkit.org/show_bug.cgi?id=115156
     5
     6        Reviewed by Andreas Kling.
     7
     8        * fast/table/css-table-max-width-expected.txt:
     9        * fast/table/css-table-max-width.html:
     10        * fast/table/html-table-width-max-width-constrained-expected.txt: Added.
     11        * fast/table/html-table-width-max-width-constrained.html: Added.
     12
    1132014-01-28  Timothy Hatcher  <timothy@apple.com>
    214
  • trunk/LayoutTests/fast/table/css-table-max-width-expected.txt

    r130774 r163165  
    1111PASS minGreatThanMaxWidthAutoLayout.getBoundingClientRect().width is 202
    1212PASS onlyMaxWidthAutoLayout.getBoundingClientRect().width is 202
    13 PASS maxWidthZeroAutoLayout.getBoundingClientRect().width is 0
     13PASS maxWidthZeroAutoLayout.getBoundingClientRect().width is 182
    1414PASS maxGreatThanMinWidthFixedLayout.getBoundingClientRect().width is 202
    1515PASS minGreatThanMaxWidthFixedLayout.getBoundingClientRect().width is 202
    1616PASS onlyMaxWidthFixedLayout.getBoundingClientRect().width is 202
    17 PASS maxWidthZeroFixedLayout.getBoundingClientRect().width is 0
     17PASS maxWidthZeroFixedLayout.getBoundingClientRect().width is 2
    1818PASS successfullyParsed is true
    1919
  • trunk/LayoutTests/fast/table/css-table-max-width.html

    r155272 r163165  
    4343        qui officia deserunt mollit anim id est laborum.
    4444    </div>
    45     <div id="maxWidthZeroAutoLayout" class="child" style="display:table; max-width:0; width:100%;">
     45    <div id="maxWidthZeroAutoLayout" class="child" style="display:table; max-width:0; width:100%; font: 10px/1 Ahem;">
    4646        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    4747        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
     
    9898shouldBe("onlyMaxWidthAutoLayout.getBoundingClientRect().width","202");
    9999maxWidthZeroAutoLayout = document.getElementById("maxWidthZeroAutoLayout");
    100 shouldBe("maxWidthZeroAutoLayout.getBoundingClientRect().width","0");
     100shouldBe("maxWidthZeroAutoLayout.getBoundingClientRect().width","182");
    101101maxGreatThanMinWidthFixedLayout = document.getElementById("maxGreatThanMinWidthFixedLayout");
    102102shouldBe("maxGreatThanMinWidthFixedLayout.getBoundingClientRect().width","202");
     
    106106shouldBe("onlyMaxWidthFixedLayout.getBoundingClientRect().width","202");
    107107maxWidthZeroFixedLayout = document.getElementById("maxWidthZeroFixedLayout");
    108 shouldBe("maxWidthZeroFixedLayout.getBoundingClientRect().width","0");
     108shouldBe("maxWidthZeroFixedLayout.getBoundingClientRect().width","2");
    109109
    110110document.body.removeChild(document.getElementById('container'));
  • trunk/Source/WebCore/ChangeLog

    r163160 r163165  
     12014-01-31  László Langó  <lango@inf.u-szeged.hu>
     2
     3        Fix table sizing when 'max-width' is used.
     4        https://bugs.webkit.org/show_bug.cgi?id=115156
     5
     6        Reviewed by Andreas Kling.
     7
     8        r143534 make <table> abide by 'max-width' all the time which is wrong.
     9        Per the CSS specification, a table should be wide enough to fit its
     10        content, regardless of 'max-width'.
     11
     12        r140479 fixed part of the regression from that change but made the
     13        same fatal mistake by constraining min-content to fit 'max-width'.
     14
     15        The fix is to avoid constraining min-content and ensure that the table
     16        logical width is at least its min-content size.
     17
     18        Backported from Blink:
     19        https://chromium.googlesource.com/chromium/blink/+/0bca0dec4895aeeb2054ba36316e984e4ebed06f
     20
     21        Test: fast/table/html-table-width-max-width-constrained.html
     22
     23        * rendering/RenderTable.cpp:
     24        (WebCore::RenderTable::updateLogicalWidth):
     25        (WebCore::RenderTable::computePreferredLogicalWidths):
     26
    1272014-01-30  Simon Fraser  <simon.fraser@apple.com>
    228
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r163152 r163165  
    293293    }
    294294
    295     // Ensure we aren't smaller than our min preferred width.
    296     setLogicalWidth(std::max<int>(logicalWidth(), minPreferredLogicalWidth()));
    297 
    298    
    299295    // Ensure we aren't bigger than our max-width style.
    300296    Length styleMaxLogicalWidth = style().logicalMaxWidth();
     
    303299        setLogicalWidth(std::min<int>(logicalWidth(), computedMaxLogicalWidth));
    304300    }
     301   
     302    // Ensure we aren't smaller than our min preferred width. This MUST be done after 'max-width' as
     303    // we ignore it if it means we wouldn't accomodate our content.
     304    setLogicalWidth(std::max<int>(logicalWidth(), minPreferredLogicalWidth()));
    305305
    306306    // Ensure we aren't smaller than our min-width style.
     
    329329        setMarginEnd(minimumValueForLength(style().marginEnd(), availableLogicalWidth));
    330330    }
     331
     332    // We should NEVER shrink the table below the min-content logical width, or else the table can't accomodate
     333    // its own content which doesn't match CSS nor what authors expect.
     334    ASSERT(logicalWidth() >= minPreferredLogicalWidth());
    331335}
    332336
     
    779783    // FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for maxWidth.
    780784    if (styleToUse.logicalMaxWidth().isFixed()) {
     785        // We don't constrain m_minPreferredLogicalWidth as the table should be at least the size of its min-content, regardless of 'max-width'.
    781786        m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
    782         m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
     787        m_minPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
    783788    }
    784789
Note: See TracChangeset for help on using the changeset viewer.