Title: [279543] trunk
- Revision
- 279543
- Author
- [email protected]
- Date
- 2021-07-03 07:17:35 -0700 (Sat, 03 Jul 2021)
Log Message
[LFC][TFC] Add support for priority list of width types when expanding columns
https://bugs.webkit.org/show_bug.cgi?id=227627
Reviewed by Antti Koivisto.
Source/WebCore:
When expanding the columns to use the extra space available, we need to prioritize certain columns
with specific width types: fixed > percent > relative > auto
This is _almost_ the reversed version of the shrinking priority list (but not quite).
Now we can have mixed column types across multiple rows with expanding and shrinking columns.
Test: fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html
* layout/formattingContexts/table/TableLayout.cpp:
(WebCore::Layout::distributeAvailableSpace):
LayoutTests:
* fast/layoutformattingcontext/table-space-mixed-width-type-simple3-expected.html: Added.
* fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (279542 => 279543)
--- trunk/LayoutTests/ChangeLog 2021-07-03 07:01:52 UTC (rev 279542)
+++ trunk/LayoutTests/ChangeLog 2021-07-03 14:17:35 UTC (rev 279543)
@@ -1,3 +1,13 @@
+2021-07-03 Alan Bujtas <[email protected]>
+
+ [LFC][TFC] Add support for priority list of width types when expanding columns
+ https://bugs.webkit.org/show_bug.cgi?id=227627
+
+ Reviewed by Antti Koivisto.
+
+ * fast/layoutformattingcontext/table-space-mixed-width-type-simple3-expected.html: Added.
+ * fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html: Added.
+
2021-07-03 Jean-Yves Avenard <[email protected]>
SourceBuffer.abort() doesn't go back to state WAITING_FOR_SEGMENT properly
Added: trunk/LayoutTests/fast/layoutformattingcontext/table-space-mixed-width-type-simple3-expected.html (0 => 279543)
--- trunk/LayoutTests/fast/layoutformattingcontext/table-space-mixed-width-type-simple3-expected.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-space-mixed-width-type-simple3-expected.html 2021-07-03 14:17:35 UTC (rev 279543)
@@ -0,0 +1,25 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+body {
+ font-size: 16px;
+ overflow: hidden;
+}
+
+div {
+ height: 20px;
+ background-color: blue;
+}
+
+.inner {
+ background-color: green;
+}
+</style>
+
+<div style="width: 100px"><div class=inner style="width: 50px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 500px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 56px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 500px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 5px"></div></div>
+<div style="width: 500px"><div class=inner style="width: 250px"></div></div>
+<div style="width: 429px; height: 30px;"><div class=inner style="width: 300px; height: 30px;"></div></div>
+<div style="width: 500px; height: 30px;"><div class=inner style="width: 500px; height: 30px;"></div></div>
Added: trunk/LayoutTests/fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html (0 => 279543)
--- trunk/LayoutTests/fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html 2021-07-03 14:17:35 UTC (rev 279543)
@@ -0,0 +1,56 @@
+<!DOCTYPE html><!-- webkit-test-runner [ LayoutFormattingContextEnabled=true LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+td {
+ height: 10px;
+ background-color: blue;
+ padding: 0px;
+}
+
+table {
+ border-spacing: 0px;
+}
+
+body {
+ background-color: white;
+}
+
+td:nth-child(odd) {
+ background-color: green;
+}
+</style>
+<div style="width: 500px;">
+<table>
+<tr><td style="width: 10px;"></td><td style="width: 10%;"></td></tr>
+<tr><td style="width: 10%;"></td><td style="width: 10px;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 100px;"></td><td style="width: 100%;"></td></tr>
+<tr><td style="width: 100%;"></td><td style="width: 100px;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 80px;"></td><td style="width: 200px;"></td></tr>
+<tr><td style="width: 10%;"></td><td style="width: 80%;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 80px;"></td><td style="width: 10%;"></td></tr>
+<tr><td style="width: 100%;"></td><td style="width: 200px;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 1000px;"></td><td style="width: 1000%;"></td></tr>
+<tr><td style="width: 1%;"></td><td style="width: 1px;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 250px;"></td><td style="width: 50%;"></td></tr>
+<tr><td style="width: 500px;"></td><td style="width: 0%;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 100px;"></td><td style="width: 10%;"></td></tr>
+<tr><td style="width: 200px;"></td><td style="width: 20%;"></td></tr>
+<tr><td style="width: 300px;"></td><td style="width: 30%;"></td></tr>
+</table>
+<table>
+<tr><td style="width: 100px;"></td><td style="width: 10%;"></td></tr>
+<tr><td style="width: 200%;"></td><td style="width: 200px;"></td></tr>
+<tr><td style="width: 300px;"></td><td style="width: 30%;"></td></tr>
+</table>
+</div>
Modified: trunk/Source/WebCore/ChangeLog (279542 => 279543)
--- trunk/Source/WebCore/ChangeLog 2021-07-03 07:01:52 UTC (rev 279542)
+++ trunk/Source/WebCore/ChangeLog 2021-07-03 14:17:35 UTC (rev 279543)
@@ -1,3 +1,20 @@
+2021-07-03 Alan Bujtas <[email protected]>
+
+ [LFC][TFC] Add support for priority list of width types when expanding columns
+ https://bugs.webkit.org/show_bug.cgi?id=227627
+
+ Reviewed by Antti Koivisto.
+
+ When expanding the columns to use the extra space available, we need to prioritize certain columns
+ with specific width types: fixed > percent > relative > auto
+ This is _almost_ the reversed version of the shrinking priority list (but not quite).
+ Now we can have mixed column types across multiple rows with expanding and shrinking columns.
+
+ Test: fast/layoutformattingcontext/table-space-mixed-width-type-simple3.html
+
+ * layout/formattingContexts/table/TableLayout.cpp:
+ (WebCore::Layout::distributeAvailableSpace):
+
2021-07-03 Jean-Yves Avenard <[email protected]>
SourceBuffer.abort() doesn't go back to state WAITING_FOR_SEGMENT properly
Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp (279542 => 279543)
--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp 2021-07-03 07:01:52 UTC (rev 279542)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp 2021-07-03 14:17:35 UTC (rev 279543)
@@ -464,7 +464,6 @@
continue;
}
auto percent = std::min(*maximumPercentColumnWidths[columnIndex], remainingPercent);
- ASSERT(percent > 0);
columnList[columnIndex].setComputedLogicalWidth({ percent, LengthType::Percent });
percentMaximumWidth = std::max(percentMaximumWidth, LayoutUnit { nonPercentColumnWidth * 100.0f / percent });
remainingPercent -= percent;
Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp (279542 => 279543)
--- trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp 2021-07-03 07:01:52 UTC (rev 279542)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp 2021-07-03 14:17:35 UTC (rev 279543)
@@ -224,66 +224,101 @@
for (size_t columnIndex = 0; columnIndex < resolvedItems.size(); ++columnIndex)
distributedSpaces[columnIndex] = LayoutUnit { resolvedItems[columnIndex]->preferredSize };
+ if (!spaceToDistribute) {
+ // Preferred size covers the spaces. There's nothing extra spaace to distribute.
+ return distributedSpaces;
+ }
+
+ // Setup the priority lists. We use these when expanding/shrinking slots.
+ Vector<size_t> autoColumnIndexes;
+ Vector<size_t> relativeColumnIndexes;
+ Vector<size_t> fixedColumnIndexes;
+ Vector<size_t> percentColumnIndexes;
+
+ for (size_t columnIndex = 0; columnIndex < resolvedItems.size(); ++columnIndex) {
+ switch (resolvedItems[columnIndex]->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;
+ }
+ }
+
if (spaceToDistribute > 0) {
// Each column can get some extra space.
- auto columnsFlexBase = adjustabledSpace.flexBase ? spaceToDistribute / adjustabledSpace.flexBase : 0.f;
- for (size_t columnIndex = 0; columnIndex < resolvedItems.size(); ++columnIndex) {
- auto columnExtraSpace = columnsFlexBase * resolvedItems[columnIndex]->flexBase;
- distributedSpaces[columnIndex] += LayoutUnit { columnExtraSpace };
- }
- } else if (spaceToDistribute < 0) {
- // Can't accomodate the preferred width. Let's use the priority list to shrink columns.
- Vector<size_t> autoColumnIndexes;
- Vector<size_t> relativeColumnIndexes;
- Vector<size_t> fixedColumnIndexes;
- Vector<size_t> percentColumnIndexes;
+ auto hasSpaceToDistribute = [&] {
+ ASSERT(spaceToDistribute > -LayoutUnit::epsilon());
+ return spaceToDistribute > LayoutUnit::epsilon();
+ };
- for (size_t columnIndex = 0; columnIndex < resolvedItems.size(); ++columnIndex) {
- switch (resolvedItems[columnIndex]->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;
- }
- }
-
- auto spaceNeeded = -spaceToDistribute;
- auto shrinkSpaceForType = [&](const auto& columnIndexes) {
+ auto expandSpace = [&](const auto& columnIndexes) {
auto adjustabledSpace = GridSpace { };
for (auto& columnIndex : columnIndexes)
adjustabledSpace += *resolvedItems[columnIndex];
- auto columnsFlexBase = adjustabledSpace.flexBase ? spaceNeeded / adjustabledSpace.flexBase : 0.f;
+ auto columnsFlexBase = adjustabledSpace.flexBase ? spaceToDistribute / adjustabledSpace.flexBase : 0.f;
for (auto& columnIndex : columnIndexes) {
- auto& resolvedItem = *resolvedItems[columnIndex];
- auto spaceToRemove = std::min(resolvedItem.preferredSize - resolvedItem.minimumSize, columnsFlexBase * resolvedItem.flexBase);
- spaceToRemove = std::min(spaceToRemove, spaceNeeded);
- distributedSpaces[columnIndex] -= spaceToRemove;
- spaceNeeded -= spaceToRemove;
- if (!spaceNeeded)
+ auto extraSpace = columnsFlexBase * resolvedItems[columnIndex]->flexBase;
+ distributedSpaces[columnIndex] += LayoutUnit { extraSpace };
+ spaceToDistribute -= extraSpace;
+ if (!hasSpaceToDistribute())
return;
}
- ASSERT(spaceNeeded > 0);
};
- shrinkSpaceForType(autoColumnIndexes);
- if (spaceNeeded)
- shrinkSpaceForType(relativeColumnIndexes);
- if (spaceNeeded)
- shrinkSpaceForType(fixedColumnIndexes);
- if (spaceNeeded)
- shrinkSpaceForType(percentColumnIndexes);
+ // We distribute the extra space among columns in the priority order as follows:
+ expandSpace(fixedColumnIndexes);
+ if (hasSpaceToDistribute())
+ expandSpace(percentColumnIndexes);
+ if (hasSpaceToDistribute())
+ expandSpace(relativeColumnIndexes);
+ if (hasSpaceToDistribute())
+ expandSpace(autoColumnIndexes);
+ ASSERT(!hasSpaceToDistribute());
+ return distributedSpaces;
}
+ // Can't accomodate the preferred width. Let's use the priority list to shrink columns.
+ auto spaceNeeded = -spaceToDistribute;
+
+ auto needsMoreSpace = [&] {
+ ASSERT(spaceNeeded > -LayoutUnit::epsilon());
+ return spaceNeeded > LayoutUnit::epsilon();
+ };
+
+ auto shrinkSpace = [&](const auto& columnIndexes) {
+ auto adjustabledSpace = GridSpace { };
+ for (auto& columnIndex : columnIndexes)
+ adjustabledSpace += *resolvedItems[columnIndex];
+
+ auto columnsFlexBase = adjustabledSpace.flexBase ? spaceNeeded / adjustabledSpace.flexBase : 0.f;
+ for (auto& columnIndex : columnIndexes) {
+ auto& resolvedItem = *resolvedItems[columnIndex];
+ auto spaceToRemove = std::min(resolvedItem.preferredSize - resolvedItem.minimumSize, columnsFlexBase * resolvedItem.flexBase);
+ spaceToRemove = std::min(spaceToRemove, spaceNeeded);
+ distributedSpaces[columnIndex] -= spaceToRemove;
+ spaceNeeded -= spaceToRemove;
+ if (!needsMoreSpace())
+ return;
+ }
+ };
+ shrinkSpace(autoColumnIndexes);
+ if (needsMoreSpace())
+ shrinkSpace(relativeColumnIndexes);
+ if (needsMoreSpace())
+ shrinkSpace(fixedColumnIndexes);
+ if (needsMoreSpace())
+ shrinkSpace(percentColumnIndexes);
+ ASSERT(!needsMoreSpace());
return distributedSpaces;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes