<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[278537] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/278537">278537</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2021-06-06 08:15:40 -0700 (Sun, 06 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][TFC] Adopt a less quirky fixed column width space distribution
https://bugs.webkit.org/show_bug.cgi?id=226696

Reviewed by Antti Koivisto.

Source/WebCore:

This patch adopts a less quirky space distribution model where any fixed cell width
makes the column fixed (as opposed to just when <col> has fixed with).
This distribution model matches both Chrome and Firefox.
It also enables us to simplify some of the distribution logic by using the same set of values (min vs max)
as the base for the distribution ratio.

Test: fast/layoutformattingcontext/table-fixed-width-variations-simple.html

* layout/formattingContexts/table/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::computedPreferredWidthForColumns): Collect the fixed with values from the cells too now.
* layout/formattingContexts/table/TableFormattingGeometry.cpp:
(WebCore::Layout::TableFormattingGeometry::intrinsicWidthConstraintsForCellContent const):
(WebCore::Layout::TableFormattingGeometry::intrinsicWidthConstraintsForCell const): Deleted.
* layout/formattingContexts/table/TableFormattingGeometry.h:
* layout/formattingContexts/table/TableGrid.cpp:
(WebCore::Layout::TableGrid::appendCell):
(WebCore::Layout::TableGrid::Column::isFixedWidth const): Deleted.
(WebCore::Layout::TableGrid::Columns::hasFixedColumnsOnly const): Deleted.
(WebCore::Layout::TableGrid::Cell::isFixedWidth const): Deleted.
* layout/formattingContexts/table/TableGrid.h:
(WebCore::Layout::TableGrid::Column::setFixedWidth):
(WebCore::Layout::TableGrid::Column::fixedWidth const):
(WebCore::Layout::TableGrid::Columns::logicalWidth const):
(WebCore::Layout::TableGrid::Column::setHasFixedWidthCell): Deleted.
(WebCore::Layout::TableGrid::Column::hasFixedWidthCell const): Deleted.
* layout/formattingContexts/table/TableLayout.cpp:
(WebCore::Layout::TableFormattingContext::TableLayout::distributedHorizontalSpace): Adjust the distribution values based on whether
the column has fixed width and use max/max in both fixed and non-fixed cases.

LayoutTests:

* TestExpectations: We don't match current WebKit space distribution anymore.
* fast/layoutformattingcontext/table-fixed-width-variations-simple-expected.html: Added.
* fast/layoutformattingcontext/table-fixed-width-variations-simple.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextstableTableFormattingContextcpp">trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextstableTableFormattingGeometrycpp">trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextstableTableFormattingGeometryh">trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.h</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextstableTableGridcpp">trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextstableTableGridh">trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextstableTableLayoutcpp">trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastlayoutformattingcontexttablefixedwidthvariationssimpleexpectedhtml">trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastlayoutformattingcontexttablefixedwidthvariationssimplehtml">trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/LayoutTests/ChangeLog 2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-06-06  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][TFC] Adopt a less quirky fixed column width space distribution
+        https://bugs.webkit.org/show_bug.cgi?id=226696
+
+        Reviewed by Antti Koivisto.
+
+        * TestExpectations: We don't match current WebKit space distribution anymore.
+        * fast/layoutformattingcontext/table-fixed-width-variations-simple-expected.html: Added.
+        * fast/layoutformattingcontext/table-fixed-width-variations-simple.html: Added.
+
</ins><span class="cx"> 2021-06-05  Cameron McCormack  <heycam@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Diff aspect-ratio property values correctly
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/LayoutTests/TestExpectations  2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -4876,6 +4876,7 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/226002 fast/layoutformattingcontext/table-simple-row-height.html [ Skip ]
</span><span class="cx"> webkit.org/b/226364 fast/layoutformattingcontext/table-with-percent-columns-and-spacing.html [ Skip ]
</span><ins>+[ Debug ] fast/layoutformattingcontext/table-fixed-width-with-max-distribution.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # This webstorage test has crashed since it was imported.
</span><span class="cx"> imported/w3c/web-platform-tests/webstorage/storage_session_setitem_quotaexceedederr.window.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsfastlayoutformattingcontexttablefixedwidthvariationssimpleexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple-expected.html (0 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple-expected.html                         (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple-expected.html    2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+<!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+ background-color: green;
+ width: 100px;
+ height: 350px;
+}
+</style>
+<div></div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastlayoutformattingcontexttablefixedwidthvariationssimplehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple.html (0 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple.html                          (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-fixed-width-variations-simple.html     2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<!DOCTYPE html><!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+td {
+  height: 50px;
+  padding: 0px;
+}
+
+table {
+  border-spacing: 0px;
+  background-color: green;
+}
+</style>
+<table><tr><td style="width: 50px"></td><td style="width: 50px"></td></tr></table>
+<table><tr><td style="width: 90px"></td><td style="width: 10px"></td></tr></table>
+<table><tr><td style="width: 80px"></td><td style="width: 10px"></td><td style="width: 10px"></td></tr></table>
+
+<table style="width: 100px;"><tr><td style="width: 90px"></td><td style="width: 10px"></td></tr></table>
+<table style="width: 100px;"><tr><td style="width: 50px"></td><td style="width: 10px"></td></tr></table>
+<table style="width: 100px;"><tr><td style="width: 900px"></td><td style="width: 100px"></td></tr></table>
+<table style="width: 100px;"><tr><td style="width: 900px"></td><td style="width: 900px"></td></tr></table>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/ChangeLog      2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2021-06-06  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][TFC] Adopt a less quirky fixed column width space distribution
+        https://bugs.webkit.org/show_bug.cgi?id=226696
+
+        Reviewed by Antti Koivisto.
+
+        This patch adopts a less quirky space distribution model where any fixed cell width
+        makes the column fixed (as opposed to just when <col> has fixed with).
+        This distribution model matches both Chrome and Firefox.
+        It also enables us to simplify some of the distribution logic by using the same set of values (min vs max)
+        as the base for the distribution ratio.
+
+        Test: fast/layoutformattingcontext/table-fixed-width-variations-simple.html
+
+        * layout/formattingContexts/table/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::computedPreferredWidthForColumns): Collect the fixed with values from the cells too now.
+        * layout/formattingContexts/table/TableFormattingGeometry.cpp:
+        (WebCore::Layout::TableFormattingGeometry::intrinsicWidthConstraintsForCellContent const):
+        (WebCore::Layout::TableFormattingGeometry::intrinsicWidthConstraintsForCell const): Deleted.
+        * layout/formattingContexts/table/TableFormattingGeometry.h:
+        * layout/formattingContexts/table/TableGrid.cpp:
+        (WebCore::Layout::TableGrid::appendCell):
+        (WebCore::Layout::TableGrid::Column::isFixedWidth const): Deleted.
+        (WebCore::Layout::TableGrid::Columns::hasFixedColumnsOnly const): Deleted.
+        (WebCore::Layout::TableGrid::Cell::isFixedWidth const): Deleted.
+        * layout/formattingContexts/table/TableGrid.h:
+        (WebCore::Layout::TableGrid::Column::setFixedWidth):
+        (WebCore::Layout::TableGrid::Column::fixedWidth const):
+        (WebCore::Layout::TableGrid::Columns::logicalWidth const):
+        (WebCore::Layout::TableGrid::Column::setHasFixedWidthCell): Deleted.
+        (WebCore::Layout::TableGrid::Column::hasFixedWidthCell const): Deleted.
+        * layout/formattingContexts/table/TableLayout.cpp:
+        (WebCore::Layout::TableFormattingContext::TableLayout::distributedHorizontalSpace): Adjust the distribution values based on whether
+        the column has fixed width and use max/max in both fixed and non-fixed cases.
+
</ins><span class="cx"> 2021-06-06  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Rename InlineElementBox to LegacyInlineElementBox
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextstableTableFormattingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp  2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp     2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -316,27 +316,14 @@
</span><span class="cx">     ASSERT(!grid.widthConstraints());
</span><span class="cx"> 
</span><span class="cx">     // Column preferred width computation as follows:
</span><del>-    // 1. Collect each cells' width constraints
-    // 2. Collect fixed column widths set by <colgroup>'s and <col>s
</del><ins>+    // 1. Collect fixed column widths set by <colgroup>'s and <col>s
+    // 2. Collect each cells' width constraints and adjust fixed width column values.
</ins><span class="cx">     // 3. Find the min/max width for each columns using the cell constraints and the <col> fixed widths but ignore column spans.
</span><span class="cx">     // 4. Distribute column spanning cells min/max widths.
</span><span class="cx">     // 5. Add them all up and return the computed min/max widths.
</span><del>-    for (auto& cell : grid.cells()) {
-        auto& cellBox = cell->box();
-        ASSERT(cellBox.establishesBlockFormattingContext());
-
-        auto intrinsicWidth = formattingState.intrinsicWidthConstraintsForBox(cellBox);
-        if (!intrinsicWidth) {
-            intrinsicWidth = formattingGeometry().intrinsicWidthConstraintsForCell(*cell);
-            formattingState.setIntrinsicWidthConstraintsForBox(cellBox, *intrinsicWidth);
-        }
-        // Spanner cells put their intrinsic widths on the initial slots.
-        grid.slot(cell->position())->setWidthConstraints(*intrinsicWidth);
-    }
-
</del><span class="cx">     // 2. Collect the fixed width <col>s.
</span><span class="cx">     auto& columnList = grid.columns().list();
</span><del>-    Vector<std::optional<LayoutUnit>> fixedWidthColumns;
</del><ins>+    auto& formattingGeometry = this->formattingGeometry();
</ins><span class="cx">     for (auto& column : columnList) {
</span><span class="cx">         auto fixedWidth = [&] () -> std::optional<LayoutUnit> {
</span><span class="cx">             auto* columnBox = column.box();
</span><span class="lines">@@ -346,11 +333,35 @@
</span><span class="cx">             }
</span><span class="cx">             if (auto width = columnBox->columnWidth())
</span><span class="cx">                 return width;
</span><del>-            return formattingGeometry().computedColumnWidth(*columnBox);
-        };
-        fixedWidthColumns.append(fixedWidth());
</del><ins>+            return formattingGeometry.computedColumnWidth(*columnBox);
+        }();
+        if (fixedWidth)
+            column.setFixedWidth(*fixedWidth);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    for (auto& cell : grid.cells()) {
+        auto& cellBox = cell->box();
+        ASSERT(cellBox.establishesBlockFormattingContext());
+
+        auto intrinsicWidth = formattingState.intrinsicWidthConstraintsForBox(cellBox);
+        if (!intrinsicWidth) {
+            intrinsicWidth = formattingGeometry.intrinsicWidthConstraintsForCellContent(*cell);
+            formattingState.setIntrinsicWidthConstraintsForBox(cellBox, *intrinsicWidth);
+        }
+        auto cellPosition = cell->position();
+        // Expand it with border and padding.
+        auto horizontalBorderAndPaddingWidth = formattingGeometry.computedCellBorder(*cell).width()
+            + formattingGeometry.fixedValue(cellBox.style().paddingLeft()).value_or(0)
+            + formattingGeometry.fixedValue(cellBox.style().paddingRight()).value_or(0);
+        intrinsicWidth->expand(horizontalBorderAndPaddingWidth);
+        // Spanner cells put their intrinsic widths on the initial slots.
+        grid.slot(cellPosition)->setWidthConstraints(*intrinsicWidth);
+        if (auto fixedWidth = formattingGeometry.fixedValue(cellBox.style().logicalWidth())) {
+            *fixedWidth += horizontalBorderAndPaddingWidth;
+            columnList[cellPosition.column].setFixedWidth(std::max(*fixedWidth, columnList[cellPosition.column].fixedWidth().value_or(0)));
+        }
+    }
+
</ins><span class="cx">     Vector<IntrinsicWidthConstraints> columnIntrinsicWidths(columnList.size());
</span><span class="cx">     // 3. Collect he min/max width for each column but ignore column spans for now.
</span><span class="cx">     Vector<SlotPosition> spanningCellPositionList;
</span><span class="lines">@@ -366,8 +377,10 @@
</span><span class="cx">                 spanningCellPositionList.append({ columnIndex, rowIndex });
</span><span class="cx">                 continue;
</span><span class="cx">             }
</span><del>-            auto columnFixedWidth = fixedWidthColumns[columnIndex];
-            auto widthConstraints = !columnFixedWidth ? slot.widthConstraints() : IntrinsicWidthConstraints { *columnFixedWidth, *columnFixedWidth };
</del><ins>+            auto widthConstraints = slot.widthConstraints();
+            if (auto columnFixedWidth = columnList[columnIndex].fixedWidth())
+                widthConstraints.maximum = std::max(*columnFixedWidth, widthConstraints.minimum);
+
</ins><span class="cx">             columnIntrinsicWidths[columnIndex].minimum = std::max(widthConstraints.minimum, columnIntrinsicWidths[columnIndex].minimum);
</span><span class="cx">             columnIntrinsicWidths[columnIndex].maximum = std::max(widthConstraints.maximum, columnIntrinsicWidths[columnIndex].maximum);
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextstableTableFormattingGeometrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.cpp (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.cpp 2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.cpp    2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -118,35 +118,15 @@
</span><span class="cx">     return columnBox.columnWidth();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-IntrinsicWidthConstraints TableFormattingGeometry::intrinsicWidthConstraintsForCell(const TableGrid::Cell& cell) const
</del><ins>+IntrinsicWidthConstraints TableFormattingGeometry::intrinsicWidthConstraintsForCellContent(const TableGrid::Cell& cell) const
</ins><span class="cx"> {
</span><span class="cx">     auto& cellBox = cell.box();
</span><del>-    auto& style = cellBox.style();
-
-    auto computedIntrinsicWidthConstraints = [&]() -> IntrinsicWidthConstraints {
-        // Even fixed width cells expand to their minimum content width
-        // <td style="width: 10px">test_content</td> will size to max(minimum content width, computed width).
-        auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
-        if (cellBox.hasChild()) {
-            auto& layoutState = this->layoutState();
-            intrinsicWidthConstraints = LayoutContext::createFormattingContext(cellBox, const_cast<LayoutState&>(layoutState))->computedIntrinsicWidthConstraints();
-        }
-        if (auto fixedWidth = fixedValue(style.logicalWidth()))
-            return { std::max(intrinsicWidthConstraints.minimum, *fixedWidth), std::max(intrinsicWidthConstraints.minimum, *fixedWidth) };
-        return intrinsicWidthConstraints;
-    };
-    // FIXME Check for box-sizing: border-box;
-    auto intrinsicWidthConstraints = constrainByMinMaxWidth(cellBox, computedIntrinsicWidthConstraints());
-    // Expand with border
-    intrinsicWidthConstraints.expand(computedCellBorder(cell).width());
-    // padding
-    intrinsicWidthConstraints.expand(fixedValue(style.paddingLeft()).value_or(0) + fixedValue(style.paddingRight()).value_or(0));
-    // and margin
-    intrinsicWidthConstraints.expand(fixedValue(style.marginStart()).value_or(0) + fixedValue(style.marginEnd()).value_or(0));
-    return intrinsicWidthConstraints;
</del><ins>+    if (!cellBox.hasInFlowOrFloatingChild())
+        return { };
+    auto& layoutState = this->layoutState();
+    return LayoutContext::createFormattingContext(cellBox, const_cast<LayoutState&>(layoutState))->computedIntrinsicWidthConstraints();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> InlineLayoutUnit TableFormattingGeometry::usedBaselineForCell(const ContainerBox& cellBox) const
</span><span class="cx"> {
</span><span class="cx">     // The baseline of a cell is defined as the baseline of the first in-flow line box in the cell,
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextstableTableFormattingGeometryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.h (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.h   2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingGeometry.h      2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">     LayoutUnit cellBoxContentHeight(const ContainerBox&) const;
</span><span class="cx">     Edges computedCellBorder(const TableGrid::Cell&) const;
</span><span class="cx">     std::optional<LayoutUnit> computedColumnWidth(const ContainerBox& columnBox) const;
</span><del>-    IntrinsicWidthConstraints intrinsicWidthConstraintsForCell(const TableGrid::Cell&) const;
</del><ins>+    IntrinsicWidthConstraints intrinsicWidthConstraintsForCellContent(const TableGrid::Cell&) const;
</ins><span class="cx">     InlineLayoutUnit usedBaselineForCell(const ContainerBox& cellBox) const;
</span><span class="cx">     LayoutUnit horizontalSpaceForCellContent(const TableGrid::Cell&) const;
</span><span class="cx">     LayoutUnit verticalSpaceForCellContent(const TableGrid::Cell&, std::optional<LayoutUnit> availableVerticalSpace) const;
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextstableTableGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp       2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.cpp  2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -68,11 +68,6 @@
</span><span class="cx">     return m_computedLogicalLeft;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TableGrid::Column::isFixedWidth() const
-{
-    return hasFixedWidthCell() || (box() && box()->columnWidth());
-}
-
</del><span class="cx"> void TableGrid::Columns::addColumn(const ContainerBox& columnBox)
</span><span class="cx"> {
</span><span class="cx">     m_columnList.append({ &columnBox });
</span><span class="lines">@@ -83,15 +78,6 @@
</span><span class="cx">     m_columnList.append({ nullptr });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TableGrid::Columns::hasFixedColumnsOnly() const
-{
-    for (auto& column : m_columnList) {
-        if (!column.isFixedWidth())
-            return false;
-    }
-    return true;
-}
-
</del><span class="cx"> void TableGrid::Rows::addRow(const ContainerBox& rowBox)
</span><span class="cx"> {
</span><span class="cx">     m_rowList.append({ rowBox });
</span><span class="lines">@@ -109,11 +95,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool TableGrid::Cell::isFixedWidth() const
-{
-    return box().style().logicalWidth().isFixed();
-}
-
</del><span class="cx"> TableGrid::Slot::Slot(Cell& cell, bool isColumnSpanned, bool isRowSpanned)
</span><span class="cx">     : m_cell(makeWeakPtr(cell))
</span><span class="cx">     , m_isColumnSpanned(isColumnSpanned)
</span><span class="lines">@@ -170,11 +151,6 @@
</span><span class="cx">     for (auto column = 0; column < missingNumberOfColumns; ++column)
</span><span class="cx">         m_columns.addAnonymousColumn();
</span><span class="cx"> 
</span><del>-    if (cell->isFixedWidth()) {
-        for (auto column = cell->startColumn(); column < cell->endColumn(); ++column)
-            m_columns.list()[column].setHasFixedWidthCell();
-    }
-
</del><span class="cx">     if (isInNewRow)
</span><span class="cx">         m_rows.addRow(cellBox.parent());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextstableTableGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h 2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableGrid.h    2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -73,18 +73,16 @@
</span><span class="cx">         void setLogicalWidth(LayoutUnit);
</span><span class="cx">         LayoutUnit logicalWidth() const;
</span><span class="cx"> 
</span><del>-        bool isFixedWidth() const;
</del><ins>+        void setFixedWidth(LayoutUnit fixedValue) { m_fixedWidth = fixedValue; }
+        std::optional<LayoutUnit> fixedWidth() const { return m_fixedWidth; }
</ins><span class="cx"> 
</span><del>-        void setHasFixedWidthCell() { m_hasFixedWidthCell = true; }
</del><span class="cx">         const ContainerBox* box() const { return m_layoutBox.get(); }
</span><span class="cx"> 
</span><span class="cx">     private:
</span><del>-        bool hasFixedWidthCell() const { return m_hasFixedWidthCell; }
-
</del><span class="cx">         LayoutUnit m_computedLogicalWidth;
</span><span class="cx">         LayoutUnit m_computedLogicalLeft;
</span><ins>+        std::optional<LayoutUnit> m_fixedWidth;
</ins><span class="cx">         WeakPtr<const ContainerBox> m_layoutBox;
</span><del>-        bool m_hasFixedWidthCell { false };
</del><span class="cx"> 
</span><span class="cx"> #if ASSERT_ENABLED
</span><span class="cx">         bool m_hasComputedWidth { false };
</span><span class="lines">@@ -103,7 +101,6 @@
</span><span class="cx">         void addAnonymousColumn();
</span><span class="cx"> 
</span><span class="cx">         LayoutUnit logicalWidth() const { return m_columnList.last().logicalRight() - m_columnList.first().logicalLeft(); }
</span><del>-        bool hasFixedColumnsOnly() const;
</del><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         ColumnList m_columnList;
</span><span class="lines">@@ -167,8 +164,6 @@
</span><span class="cx">         void setBaseline(InlineLayoutUnit baseline) { m_baseline = baseline; }
</span><span class="cx">         InlineLayoutUnit baseline() const { return m_baseline; }
</span><span class="cx"> 
</span><del>-        bool isFixedWidth() const;
-
</del><span class="cx">         const ContainerBox& box() const { return *m_layoutBox.get(); }
</span><span class="cx"> 
</span><span class="cx">     private:
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextstableTableLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp (278536 => 278537)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp     2021-06-06 14:47:34 UTC (rev 278536)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp        2021-06-06 15:15:40 UTC (rev 278537)
</span><span class="lines">@@ -244,18 +244,16 @@
</span><span class="cx">     enum class ColumnWidthBalancingBase { MinimumWidth, MaximumWidth };
</span><span class="cx">     auto columnWidthBalancingBase = availableHorizontalSpace >= m_grid.widthConstraints()->maximum ? ColumnWidthBalancingBase::MaximumWidth : ColumnWidthBalancingBase::MinimumWidth;
</span><span class="cx">     return distributeAvailableSpace<ColumnSpan>(m_grid, availableHorizontalSpace, [&] (const TableGrid::Slot& slot, size_t columnIndex) {
</span><del>-        auto& column = m_grid.columns().list()[columnIndex];
-        auto columnBoxFixedWidth = column.box() ? column.box()->columnWidth().value_or(0_lu) : 0_lu;
-        auto minimumWidth = std::max<float>(slot.widthConstraints().minimum, columnBoxFixedWidth);
-        auto maximumWidth = std::max<float>(slot.widthConstraints().maximum, columnBoxFixedWidth);
</del><ins>+        float minimumWidth = slot.widthConstraints().minimum;
+        float maximumWidth = slot.widthConstraints().maximum;
</ins><span class="cx"> 
</span><ins>+        if (auto fixedWidth = m_grid.columns().list()[columnIndex].fixedWidth())
+            maximumWidth = std::max<float>(minimumWidth, *fixedWidth);
+
</ins><span class="cx">         if (columnWidthBalancingBase == ColumnWidthBalancingBase::MinimumWidth) {
</span><span class="cx">             ASSERT(maximumWidth >= minimumWidth);
</span><span class="cx">             return GridSpace { minimumWidth, maximumWidth - minimumWidth };
</span><span class="cx">         }
</span><del>-        // When the column has a fixed width cell, the maximum width balancing is based on the minimum width.
-        if (column.isFixedWidth())
-            return GridSpace { minimumWidth, maximumWidth };
</del><span class="cx">         return GridSpace { maximumWidth, maximumWidth };
</span><span class="cx">     });
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>