[LFC][TFC] Include horizontal spacing when checking for the extra horizontal space
https://bugs.webkit.org/show_bug.cgi?id=203154
<rdar://problem/56408032>
Reviewed by Antti Koivisto.
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::computeAndDistributeExtraHorizontalSpace):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251284 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b37f358..c548d34 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,5 +1,16 @@
2019-10-18 Zalan Bujtas <zalan@apple.com>
+ [LFC][TFC] Include horizontal spacing when checking for the extra horizontal space
+ https://bugs.webkit.org/show_bug.cgi?id=203154
+ <rdar://problem/56408032>
+
+ Reviewed by Antti Koivisto.
+
+ * layout/tableformatting/TableFormattingContext.cpp:
+ (WebCore::Layout::TableFormattingContext::computeAndDistributeExtraHorizontalSpace):
+
+2019-10-18 Zalan Bujtas <zalan@apple.com>
+
[LFC][TFC] Fix table's total horizontal spacing computation
https://bugs.webkit.org/show_bug.cgi?id=203151
<rdar://problem/56406930>
diff --git a/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp b/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
index 3ebb43c..f67ffc0 100644
--- a/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
+++ b/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
@@ -276,7 +276,6 @@
auto& grid = formattingState().tableGrid();
ASSERT(grid.hasComputedWidthConstraints());
auto tableWidthConstraints = grid.widthConstraints();
- auto tableMinimumContentWidth = tableWidthConstraints.minimum - grid.totalHorizontalSpacing();
// Column and caption widths influence the final table width as follows:
// If the 'table' or 'inline-table' element's 'width' property has a computed value (W) other than 'auto', the used width is the greater of
@@ -289,6 +288,7 @@
auto& columns = grid.columnsContext().columns();
ASSERT(!columns.isEmpty());
+ auto tableMinimumContentWidth = tableWidthConstraints.minimum - grid.totalHorizontalSpacing();
auto adjustabledHorizontalSpace = tableMinimumContentWidth;
auto numberOfColumns = columns.size();
// Fixed width columns don't participate in available space distribution.
@@ -313,20 +313,21 @@
}
};
- auto containingBlockWidth = geometryForBox(*root().containingBlock(), EscapeType::TableFormattingContextAccessParentTableWrapperBlockFormattingContext).contentBoxWidth();
- auto width = geometry().computedValueIfNotAuto(root().style().width(), containingBlockWidth);
- if (width) {
- if (*width > tableMinimumContentWidth)
- distributeExtraHorizontalSpace(*width - tableMinimumContentWidth);
+ auto& tableBox = root();
+ auto containingBlockWidth = geometryForBox(*tableBox.containingBlock(), EscapeType::TableFormattingContextAccessParentTableWrapperBlockFormattingContext).contentBoxWidth();
+ auto contentWidth = geometry().computedContentWidth(tableBox, containingBlockWidth);
+ if (contentWidth) {
+ if (*contentWidth > tableWidthConstraints.minimum)
+ distributeExtraHorizontalSpace(*contentWidth - tableWidthConstraints.minimum);
else
useAsContentLogicalWidth(WidthConstraintsType::Minimum);
} else {
- if (tableMinimumContentWidth > containingBlockWidth)
+ if (tableWidthConstraints.minimum > containingBlockWidth)
useAsContentLogicalWidth(WidthConstraintsType::Minimum);
else if (tableWidthConstraints.maximum < containingBlockWidth)
useAsContentLogicalWidth(WidthConstraintsType::Maximum);
else
- distributeExtraHorizontalSpace(containingBlockWidth - tableMinimumContentWidth);
+ distributeExtraHorizontalSpace(containingBlockWidth - tableWidthConstraints.minimum);
}
}