Title: [261226] trunk/Source/WebCore
Revision
261226
Author
[email protected]
Date
2020-05-06 07:18:18 -0700 (Wed, 06 May 2020)

Log Message

[LFC] BlockFormattingContext::computeHeightAndMargin should special case the table box
https://bugs.webkit.org/show_bug.cgi?id=211493

Reviewed by Antti Koivisto.

By the time we get to BlockFormattingContext::computeHeightAndMargin(), the used valued for the table height is already been computed.
(Table box height is mostly content driven, and both the computed height and the min/max pair are taken into account
while we are laying out the table content).

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (261225 => 261226)


--- trunk/Source/WebCore/ChangeLog	2020-05-06 14:15:11 UTC (rev 261225)
+++ trunk/Source/WebCore/ChangeLog	2020-05-06 14:18:18 UTC (rev 261226)
@@ -1,3 +1,19 @@
+2020-05-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] BlockFormattingContext::computeHeightAndMargin should special case the table box
+        https://bugs.webkit.org/show_bug.cgi?id=211493
+
+        Reviewed by Antti Koivisto.
+
+        By the time we get to BlockFormattingContext::computeHeightAndMargin(), the used valued for the table height is already been computed.
+        (Table box height is mostly content driven, and both the computed height and the min/max pair are taken into account
+        while we are laying out the table content).
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+
 2020-05-06  Antoine Quint  <[email protected]>
 
         Add watchOS media controls assets

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (261225 => 261226)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-05-06 14:15:11 UTC (rev 261225)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-05-06 14:18:18 UTC (rev 261226)
@@ -372,23 +372,34 @@
         return { };
     };
 
-    auto contentHeightAndMargin = compute({ });
-    if (auto maxHeight = geometry().computedMaxHeight(layoutBox)) {
-        if (contentHeightAndMargin.contentHeight > *maxHeight) {
-            auto maxHeightAndMargin = compute(maxHeight);
-            // Used height should remain the same.
-            ASSERT((layoutState().inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || maxHeightAndMargin.contentHeight == *maxHeight);
-            contentHeightAndMargin = { *maxHeight, maxHeightAndMargin.nonCollapsedMargin };
-        }
+    auto usedHeightValue = Optional<LayoutUnit> { };
+    auto ignoreMinMaxHeightCompute = false;
+    if (layoutBox.establishesTableFormattingContext()) {
+        // Table is a special BFC content. Its height is mainly driven by the content. Computed height, min-height and max-height are all
+        // already been taken into account during the TFC layout.
+        usedHeightValue = geometry().contentHeightForFormattingContextRoot(downcast<ContainerBox>(layoutBox));
+        ignoreMinMaxHeightCompute = true;
     }
 
-    if (auto minHeight = geometry().computedMinHeight(layoutBox)) {
-        if (contentHeightAndMargin.contentHeight < *minHeight) {
-            auto minHeightAndMargin = compute(minHeight);
-            // Used height should remain the same.
-            ASSERT((layoutState().inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || minHeightAndMargin.contentHeight == *minHeight);
-            contentHeightAndMargin = { *minHeight, minHeightAndMargin.nonCollapsedMargin };
+    auto contentHeightAndMargin = compute({ usedHeightValue });
+    if (!ignoreMinMaxHeightCompute) {
+        if (auto maxHeight = geometry().computedMaxHeight(layoutBox)) {
+            if (contentHeightAndMargin.contentHeight > *maxHeight) {
+                auto maxHeightAndMargin = compute(maxHeight);
+                // Used height should remain the same.
+                ASSERT((layoutState().inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || maxHeightAndMargin.contentHeight == *maxHeight);
+                contentHeightAndMargin = { *maxHeight, maxHeightAndMargin.nonCollapsedMargin };
+            }
         }
+
+        if (auto minHeight = geometry().computedMinHeight(layoutBox)) {
+            if (contentHeightAndMargin.contentHeight < *minHeight) {
+                auto minHeightAndMargin = compute(minHeight);
+                // Used height should remain the same.
+                ASSERT((layoutState().inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || minHeightAndMargin.contentHeight == *minHeight);
+                contentHeightAndMargin = { *minHeight, minHeightAndMargin.nonCollapsedMargin };
+            }
+        }
     }
 
     // 1. Compute collapsed margins.

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (261225 => 261226)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-05-06 14:15:11 UTC (rev 261225)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-05-06 14:18:18 UTC (rev 261226)
@@ -255,17 +255,6 @@
         return inlineReplacedHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, overrideVerticalValues);
 
     ContentHeightAndMargin contentHeightAndMargin;
-    // FIXME: Let's special case the table height computation for now -> figure out whether tables fall into the "inFlowNonReplacedHeightAndMargin" category.
-    if (layoutBox.establishesTableFormattingContext()) {
-        auto& tableBox = downcast<ContainerBox>(layoutBox);
-        auto computedTableHeight = computedHeight(tableBox);
-        auto contentHeight = contentHeightForFormattingContextRoot(tableBox);
-        if (computedTableHeight && contentHeight > computedTableHeight) {
-            // Table content needs more vertical space than the table has.
-            return complicatedCases(tableBox, horizontalConstraints, { contentHeight });
-        }
-        return complicatedCases(tableBox, horizontalConstraints, overrideVerticalValues);
-    }
     if (layoutBox.isOverflowVisible() && !layoutBox.isDocumentBox()) {
         // TODO: Figure out the case for the document element. Let's just complicated-case it for now.
         contentHeightAndMargin = inFlowNonReplacedHeightAndMargin(layoutBox, horizontalConstraints, overrideVerticalValues);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to