Title: [279315] trunk/Source/WebCore
- Revision
- 279315
- Author
- [email protected]
- Date
- 2021-06-27 09:51:27 -0700 (Sun, 27 Jun 2021)
Log Message
[LFC][TFC] Introduce a priority order for the grid types
https://bugs.webkit.org/show_bug.cgi?id=227417
Reviewed by Antti Koivisto.
Extra space distribution is based on a priority list with percent columns having the highest priority
and auto columns having the lowest (percent > fixed > relative > auto).
* layout/formattingContexts/table/TableLayout.cpp:
(WebCore::Layout::distributeAvailableSpace):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (279314 => 279315)
--- trunk/Source/WebCore/ChangeLog 2021-06-27 14:48:33 UTC (rev 279314)
+++ trunk/Source/WebCore/ChangeLog 2021-06-27 16:51:27 UTC (rev 279315)
@@ -1,5 +1,18 @@
2021-06-27 Alan Bujtas <[email protected]>
+ [LFC][TFC] Introduce a priority order for the grid types
+ https://bugs.webkit.org/show_bug.cgi?id=227417
+
+ Reviewed by Antti Koivisto.
+
+ Extra space distribution is based on a priority list with percent columns having the highest priority
+ and auto columns having the lowest (percent > fixed > relative > auto).
+
+ * layout/formattingContexts/table/TableLayout.cpp:
+ (WebCore::Layout::distributeAvailableSpace):
+
+2021-06-27 Alan Bujtas <[email protected]>
+
[LFC][TFC] Introduce GridSpace::type
https://bugs.webkit.org/show_bug.cgi?id=227409
Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp (279314 => 279315)
--- trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp 2021-06-27 14:48:33 UTC (rev 279314)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp 2021-06-27 16:51:27 UTC (rev 279315)
@@ -216,10 +216,34 @@
for (auto& resolvedItem : resolvedItems)
ASSERT(resolvedItem);
#endif
+ Vector<size_t> percentColumnIndexes;
+ Vector<size_t> fixedColumnIndexes;
+ Vector<size_t> relativeColumnIndexes;
+ Vector<size_t> autoColumnIndexes;
+
// Fixed size cells don't participate in available space distribution.
auto adjustabledSpace = GridSpace { };
- for (auto& resolvedItem : resolvedItems)
+ for (size_t columnIndex = 0; columnIndex < resolvedItems.size(); ++columnIndex) {
+ auto& resolvedItem = resolvedItems[columnIndex];
adjustabledSpace += *resolvedItem;
+ switch (resolvedItem->type) {
+ case GridSpace::Type::Percent:
+ percentColumnIndexes.append(columnIndex);
+ break;
+ case GridSpace::Type::Fixed:
+ fixedColumnIndexes.append(columnIndex);
+ break;
+ case GridSpace::Type::Relative:
+ relativeColumnIndexes.append(columnIndex);
+ break;
+ case GridSpace::Type::Auto:
+ autoColumnIndexes.append(columnIndex);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
Vector<LayoutUnit> distributedSpaces(resolvedItems.size());
float spaceToDistribute = availableSpace;
@@ -229,10 +253,17 @@
// Distribute the extra space based on the resolved spaces. Note that the extra space could be a negative value in which case
// we may assign less space to columns.
auto columnsFlexBase = adjustabledSpace.flexBase ? spaceToDistribute / adjustabledSpace.flexBase : 0.f;
- for (size_t index = 0; index < resolvedItems.size(); ++index) {
- auto columnExtraSpace = columnsFlexBase * resolvedItems[index]->flexBase;
- distributedSpaces[index] = LayoutUnit { resolvedItems[index]->preferredSpace + columnExtraSpace };
- }
+ auto distributeSpaceForType = [&](const auto& columnIndexes) {
+ for (auto& columnIndex : columnIndexes) {
+ auto columnExtraSpace = columnsFlexBase * resolvedItems[columnIndex]->flexBase;
+ distributedSpaces[columnIndex] = LayoutUnit { resolvedItems[columnIndex]->preferredSpace + columnExtraSpace };
+ }
+ };
+ // Distribute the available space starting with percent columns and ending with autos.
+ distributeSpaceForType(percentColumnIndexes);
+ distributeSpaceForType(fixedColumnIndexes);
+ distributeSpaceForType(relativeColumnIndexes);
+ distributeSpaceForType(autoColumnIndexes);
return distributedSpaces;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes