Title: [259979] trunk/Source/WebCore
Revision
259979
Author
[email protected]
Date
2020-04-12 09:04:48 -0700 (Sun, 12 Apr 2020)

Log Message

[LFC][TFC] Add table support to BlockFormattingContext::Geometry::inFlowWidthAndMargin
https://bugs.webkit.org/show_bug.cgi?id=210400

Reviewed by Antti Koivisto.

Use a slightly modified shrink-to-fit logic to compute the table width.

* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259978 => 259979)


--- trunk/Source/WebCore/ChangeLog	2020-04-12 15:46:50 UTC (rev 259978)
+++ trunk/Source/WebCore/ChangeLog	2020-04-12 16:04:48 UTC (rev 259979)
@@ -1,5 +1,17 @@
 2020-04-12  Zalan Bujtas  <[email protected]>
 
+        [LFC][TFC] Add table support to BlockFormattingContext::Geometry::inFlowWidthAndMargin
+        https://bugs.webkit.org/show_bug.cgi?id=210400
+
+        Reviewed by Antti Koivisto.
+
+        Use a slightly modified shrink-to-fit logic to compute the table width.
+
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
+
+2020-04-12  Zalan Bujtas  <[email protected]>
+
         [LFC][TFC] Cleanup class/struct/variable names in TableGrid/TableFormattingContext
         https://bugs.webkit.org/show_bug.cgi?id=210397
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (259978 => 259979)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-04-12 15:46:50 UTC (rev 259978)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-04-12 16:04:48 UTC (rev 259979)
@@ -286,7 +286,25 @@
             return inFlowNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues);
         // This is a special table "fit-content size" behavior handling. Not in the spec though.
         // Table returns its final width as min/max. Use this final width value to computed horizontal margins etc.
-        auto usedWidth = overrideHorizontalValues.width ? overrideHorizontalValues.width : shrinkToFitWidth(layoutBox, horizontalConstraints.logicalWidth);
+        if (overrideHorizontalValues.width)
+            return inFlowNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, OverrideHorizontalValues { overrideHorizontalValues.width, overrideHorizontalValues.margin });
+
+        auto& tableBox = downcast<ContainerBox>(layoutBox);
+        auto& formattingStateForTableBox = layoutState().ensureFormattingState(tableBox);
+        auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
+        if (auto precomputedIntrinsicWidthConstraints = formattingStateForTableBox.intrinsicWidthConstraints())
+            intrinsicWidthConstraints = *precomputedIntrinsicWidthConstraints;
+        else
+            intrinsicWidthConstraints = LayoutContext::createFormattingContext(tableBox, layoutState())->computedIntrinsicWidthConstraints();
+        auto computedTableWidth = computedContentWidth(tableBox, horizontalConstraints.logicalWidth);
+        auto usedWidth = computedTableWidth;
+        if (computedTableWidth && intrinsicWidthConstraints.minimum > computedTableWidth) {
+            // Table content needs more space than the table has.
+            usedWidth = intrinsicWidthConstraints.minimum;
+        } else if (!computedTableWidth) {
+            // Use the generic shrink-to-fit-width logic.
+            usedWidth = std::min(std::max(intrinsicWidthConstraints.minimum, horizontalConstraints.logicalWidth), intrinsicWidthConstraints.maximum);
+        }
         return inFlowNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, OverrideHorizontalValues { usedWidth, overrideHorizontalValues.margin });
     }
     return inFlowReplacedWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overrideHorizontalValues);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to