Changeset 261924 in webkit


Ignore:
Timestamp:
May 20, 2020 9:05:43 AM (4 years ago)
Author:
Noam Rosenthal
Message:

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

Reviewed by Zalan Bujtas.

Source/WebCore:

Based on previous patch by László Langó <lango@inf.u-szeged.hu>

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

A table should always be wide enough to contain its content (preferred logical width).
This constraint should be stronger than the table style's specified min-width/width.

The behavior matches the spec, and behavior on Firefox/Chrome.

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::updateLogicalWidth):

Max-width should only affect the table's max preferred width.

(WebCore::RenderTable::computePreferredLogicalWidths):

Change the order of constraints so that content constraint is stronger than style width/max-width constraint.

LayoutTests:

Based on a previous patch by László Langó <lango@inf.u-szeged.hu>

  • fast/table/css-table-max-width-expected.txt:
  • fast/table/css-table-max-width.html:

Change in behavior, test was expecting buggy behavior.

  • fast/table/html-table-width-max-width-constrained-expected.txt: Added.
  • fast/table/html-table-width-max-width-constrained.html: Added.

Test the desired behavior with content-constrained tables.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r261922 r261924  
     12020-05-20  Noam Rosenthal  <noam@webkit.org>
     2
     3        Fix table sizing when 'max-width' is used
     4        https://bugs.webkit.org/show_bug.cgi?id=115156
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Based on a previous patch by László Langó  <lango@inf.u-szeged.hu>
     9
     10        * fast/table/css-table-max-width-expected.txt:
     11        * fast/table/css-table-max-width.html:
     12                Change in behavior, test was expecting buggy behavior.
     13
     14        * fast/table/html-table-width-max-width-constrained-expected.txt: Added.
     15        * fast/table/html-table-width-max-width-constrained.html: Added.
     16                Test the desired behavior with content-constrained tables.
     17
    1182020-05-20  Philippe Normand  <pnormand@igalia.com>
    219
  • trunk/LayoutTests/fast/table/css-table-max-width-expected.txt

    r163175 r261924  
    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

    r163175 r261924  
    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

    r261923 r261924  
     12020-05-20  Noam Rosenthal  <noam@webkit.org>
     2
     3        Fix table sizing when 'max-width' is used
     4        https://bugs.webkit.org/show_bug.cgi?id=115156
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Based on previous patch by László Langó  <lango@inf.u-szeged.hu>
     9
     10        Test: fast/table/html-table-width-max-width-constrained.html
     11
     12        A table should always be wide enough to contain its content (preferred logical width).
     13        This constraint should be stronger than the table style's specified min-width/width.
     14
     15        The behavior matches the spec, and behavior on Firefox/Chrome.
     16
     17        * rendering/RenderTable.cpp:
     18        (WebCore::RenderTable::updateLogicalWidth):
     19                Max-width should only affect the table's max preferred width.
     20
     21        (WebCore::RenderTable::computePreferredLogicalWidths):
     22                Change the order of constraints so that content constraint is stronger than style width/max-width constraint.
     23
    1242020-05-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    225
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r260482 r261924  
    281281    }
    282282
    283     // Ensure we aren't smaller than our min preferred width.
    284     setLogicalWidth(std::max(logicalWidth(), minPreferredLogicalWidth()));
    285 
    286    
    287283    // Ensure we aren't bigger than our max-width style.
    288284    Length styleMaxLogicalWidth = style().logicalMaxWidth();
     
    291287        setLogicalWidth(std::min(logicalWidth(), computedMaxLogicalWidth));
    292288    }
     289
     290    // Ensure we aren't smaller than our min preferred width.
     291    setLogicalWidth(std::max(logicalWidth(), minPreferredLogicalWidth()));   
    293292
    294293    // Ensure we aren't smaller than our min-width style.
     
    828827    if (styleToUse.logicalMaxWidth().isFixed()) {
    829828        m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
    830         m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalMaxWidth().value()));
     829        m_maxPreferredLogicalWidth = std::max(m_maxPreferredLogicalWidth, m_minPreferredLogicalWidth);
    831830    }
    832831
Note: See TracChangeset for help on using the changeset viewer.