Title: [251151] trunk/Source/WebCore
Revision
251151
Author
za...@apple.com
Date
2019-10-15 12:29:24 -0700 (Tue, 15 Oct 2019)

Log Message

[LFC][TFC] Use <col> to adjust the preferred column width.
https://bugs.webkit.org/show_bug.cgi?id=202997
<rdar://problem/56300345>

Reviewed by Antti Koivisto.

The <col> elment can set the preferred width on the table column. Let's take these values into account while computing the preferred width for columns.

* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns):
* layout/tableformatting/TableFormattingContext.h:
* layout/tableformatting/TableFormattingContextGeometry.cpp:
(WebCore::Layout::TableFormattingContext::Geometry::computedColumnWidth const):
* layout/tableformatting/TableGrid.h:
(WebCore::Layout::TableGrid::Column::columnBox const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (251150 => 251151)


--- trunk/Source/WebCore/ChangeLog	2019-10-15 19:13:35 UTC (rev 251150)
+++ trunk/Source/WebCore/ChangeLog	2019-10-15 19:29:24 UTC (rev 251151)
@@ -1,5 +1,23 @@
 2019-10-15  Zalan Bujtas  <za...@apple.com>
 
+        [LFC][TFC] Use <col> to adjust the preferred column width.
+        https://bugs.webkit.org/show_bug.cgi?id=202997
+        <rdar://problem/56300345>
+
+        Reviewed by Antti Koivisto.
+
+        The <col> elment can set the preferred width on the table column. Let's take these values into account while computing the preferred width for columns.
+
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns):
+        * layout/tableformatting/TableFormattingContext.h:
+        * layout/tableformatting/TableFormattingContextGeometry.cpp:
+        (WebCore::Layout::TableFormattingContext::Geometry::computedColumnWidth const):
+        * layout/tableformatting/TableGrid.h:
+        (WebCore::Layout::TableGrid::Column::columnBox const):
+
+2019-10-15  Zalan Bujtas  <za...@apple.com>
+
         [LFC][TFC] Add support for colgroup/col
         https://bugs.webkit.org/show_bug.cgi?id=202991
         <rdar://problem/56294715>

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (251150 => 251151)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2019-10-15 19:13:35 UTC (rev 251150)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2019-10-15 19:29:24 UTC (rev 251151)
@@ -249,9 +249,15 @@
             columnIntrinsicWidths.minimum = std::max(slot->widthConstraints.minimum, columnIntrinsicWidths.minimum);
             columnIntrinsicWidths.maximum = std::max(slot->widthConstraints.maximum, columnIntrinsicWidths.maximum);
         }
+        // Now that we have the content driven min/max widths, check if <col> sets a preferred width on this column.
+        if (auto* columnBox = columns[columnIndex].columnBox()) {
+            if (auto columnPreferredWidth = geometry().computedColumnWidth(*columnBox)) {
+                // Let's stay at least as wide as the preferred width.
+                columnIntrinsicWidths.minimum = std::max(columnIntrinsicWidths.minimum, *columnPreferredWidth);
+            }
+        }
         columns[columnIndex].setWidthConstraints(columnIntrinsicWidths);
     }
-    // FIXME: Take column group elements into account.
 }
 
 LayoutUnit TableFormattingContext::computedTableWidth()

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h (251150 => 251151)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2019-10-15 19:13:35 UTC (rev 251150)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2019-10-15 19:29:24 UTC (rev 251151)
@@ -47,6 +47,7 @@
     class Geometry : public FormattingContext::Geometry {
     public:
         ContentHeightAndMargin tableCellHeightAndMargin(const Box&) const;
+        Optional<LayoutUnit> computedColumnWidth(const Box& columnBox) const;
 
     private:
         friend class TableFormattingContext;

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp (251150 => 251151)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp	2019-10-15 19:13:35 UTC (rev 251150)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp	2019-10-15 19:29:24 UTC (rev 251151)
@@ -45,7 +45,16 @@
     return ContentHeightAndMargin { *height, { } };
 }
 
+Optional<LayoutUnit> TableFormattingContext::Geometry::computedColumnWidth(const Box& columnBox) const
+{
+    // Check both style and <col>'s width attribute.
+    // FIXME: Figure out what to do with calculated values, like <col style="width: 10%">.
+    if (auto computedWidthValue = computedContentWidth(columnBox, { }))
+        return computedWidthValue;
+    return columnBox.columnWidth();
 }
+
 }
+}
 
 #endif

Modified: trunk/Source/WebCore/layout/tableformatting/TableGrid.h (251150 => 251151)


--- trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2019-10-15 19:13:35 UTC (rev 251150)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2019-10-15 19:29:24 UTC (rev 251151)
@@ -80,6 +80,8 @@
         void setLogicalWidth(LayoutUnit);
         LayoutUnit logicalWidth() const;
 
+        const Box* columnBox() const { return m_columnBox.get(); }
+
     private:
         friend class ColumnsContext;
         Column(const Box* columnBox);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to