Title: [279316] trunk/Source/WebCore
Revision
279316
Author
[email protected]
Date
2021-06-27 10:20:08 -0700 (Sun, 27 Jun 2021)

Log Message

[LFC][TFC] Rename GridSpace::preferredSpace to preferredSize
https://bugs.webkit.org/show_bug.cgi?id=227425

Reviewed by Antti Koivisto.

It is a more descriptive name.

* layout/formattingContexts/table/TableLayout.cpp:
(WebCore::Layout::GridSpace::isEmpty const):
(WebCore::Layout::operator-):
(WebCore::Layout::operator+=):
(WebCore::Layout::operator/):
(WebCore::Layout::distributeAvailableSpace):
(WebCore::Layout::TableFormattingContext::TableLayout::distributedHorizontalSpace): preferredWidth is the same in both cases.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279315 => 279316)


--- trunk/Source/WebCore/ChangeLog	2021-06-27 16:51:27 UTC (rev 279315)
+++ trunk/Source/WebCore/ChangeLog	2021-06-27 17:20:08 UTC (rev 279316)
@@ -1,5 +1,22 @@
 2021-06-27  Alan Bujtas  <[email protected]>
 
+        [LFC][TFC] Rename GridSpace::preferredSpace to preferredSize
+        https://bugs.webkit.org/show_bug.cgi?id=227425
+
+        Reviewed by Antti Koivisto.
+
+        It is a more descriptive name.
+
+        * layout/formattingContexts/table/TableLayout.cpp:
+        (WebCore::Layout::GridSpace::isEmpty const):
+        (WebCore::Layout::operator-):
+        (WebCore::Layout::operator+=):
+        (WebCore::Layout::operator/):
+        (WebCore::Layout::distributeAvailableSpace):
+        (WebCore::Layout::TableFormattingContext::TableLayout::distributedHorizontalSpace): preferredWidth is the same in both cases.
+
+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
 

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp (279315 => 279316)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp	2021-06-27 16:51:27 UTC (rev 279315)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableLayout.cpp	2021-06-27 17:20:08 UTC (rev 279316)
@@ -71,7 +71,7 @@
 };
 
 struct GridSpace {
-    bool isEmpty() const { return !preferredSpace; }
+    bool isEmpty() const { return !preferredSize; }
 
     enum class Type {
         Percent,
@@ -81,7 +81,7 @@
     };
     Type type { Type::Auto };
     // Preferred width/height for column/row we start the distribution with (usually the minimum content width).
-    float preferredSpace { 0 };
+    float preferredSize { 0 };
     // The base space value for the distribution computation e.g [ 9 ] [ 1 ] values for 2 columns in the table means that if
     // we've go 100px flexible space to distribute, 90px and 10px go to the columns respectively.
     float flexBase { 0 };
@@ -89,7 +89,7 @@
 
 inline static GridSpace& operator-(GridSpace& a, const GridSpace& b)
 {
-    a.preferredSpace = std::max(0.0f, a.preferredSpace - b.preferredSpace);
+    a.preferredSize = std::max(0.0f, a.preferredSize - b.preferredSize);
     a.flexBase = std::max(0.0f, a.flexBase - b.flexBase);
     return a;
 }
@@ -96,7 +96,7 @@
 
 inline static GridSpace& operator+=(GridSpace& a, const GridSpace& b)
 {
-    a.preferredSpace += b.preferredSpace;
+    a.preferredSize += b.preferredSize;
     a.flexBase += b.flexBase;
     return a;
 }
@@ -108,7 +108,7 @@
 
 inline static GridSpace& operator/(GridSpace& a, unsigned value)
 {
-    a.preferredSpace /= value;
+    a.preferredSize /= value;
     a.flexBase /= value;
     return a;
 }
@@ -134,7 +134,7 @@
             auto& resolvedItem = resolvedItems[index];
             // FIXME: Add support for mixed column/row types e.g. first row first column is fixed, while second row first column is percent.
             ASSERT(resolvedItem->type == currentSpace.type);
-            resolvedItem->preferredSpace = std::max(resolvedItem->preferredSpace, currentSpace.preferredSpace);
+            resolvedItem->preferredSize = std::max(resolvedItem->preferredSize, currentSpace.preferredSize);
             resolvedItem->flexBase = std::max(resolvedItem->flexBase, currentSpace.flexBase);
         }
     }
@@ -197,7 +197,7 @@
             auto resolvedSpanningSpace = GridSpace { };
             for (auto spanIndex = SpanType::startSpan(cell); spanIndex < SpanType::endSpan(cell); ++spanIndex)
                 resolvedSpanningSpace += *resolvedItems[spanIndex];
-            if (resolvedSpanningSpace.preferredSpace >= unresolvedSpanningSpace.preferredSpace) {
+            if (resolvedSpanningSpace.preferredSize >= unresolvedSpanningSpace.preferredSize) {
                 // The spanning cell fits the spanned columns/rows just fine. Nothing to distribute.
                 continue;
             }
@@ -206,7 +206,7 @@
             if (!spaceToDistribute.isEmpty()) {
                 auto columnsFlexBase = spaceToDistribute.flexBase / resolvedSpanningSpace.flexBase;
                 for (auto spanIndex = SpanType::startSpan(cell); spanIndex < SpanType::endSpan(cell); ++spanIndex)
-                    *resolvedItems[spanIndex] += GridSpace { resolvedItems[spanIndex]->type, resolvedItems[spanIndex]->preferredSpace * columnsFlexBase, resolvedItems[spanIndex]->flexBase * columnsFlexBase };
+                    *resolvedItems[spanIndex] += GridSpace { resolvedItems[spanIndex]->type, resolvedItems[spanIndex]->preferredSize * columnsFlexBase, resolvedItems[spanIndex]->flexBase * columnsFlexBase };
             }
         }
     }
@@ -249,7 +249,7 @@
     float spaceToDistribute = availableSpace;
     // Top and bottom spacing are fixed.
     spaceToDistribute -= 2 * SpanType::spacing(grid);
-    spaceToDistribute -= adjustabledSpace.preferredSpace + ((resolvedItems.size() - 1) * SpanType::spacing(grid));
+    spaceToDistribute -= adjustabledSpace.preferredSize + ((resolvedItems.size() - 1) * SpanType::spacing(grid));
     // 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;
@@ -256,7 +256,7 @@
     auto distributeSpaceForType = [&](const auto& columnIndexes) {
         for (auto& columnIndex : columnIndexes) {
             auto columnExtraSpace = columnsFlexBase * resolvedItems[columnIndex]->flexBase;
-            distributedSpaces[columnIndex] = LayoutUnit { resolvedItems[columnIndex]->preferredSpace + columnExtraSpace };
+            distributedSpaces[columnIndex] = LayoutUnit { resolvedItems[columnIndex]->preferredSize + columnExtraSpace };
         }
     };
     // Distribute the available space starting with percent columns and ending with autos.
@@ -284,6 +284,7 @@
 
         float minimumContentWidth = slot.widthConstraints().minimum;
         float maximumContentWidth = slot.widthConstraints().maximum;
+        auto preferredWidth = std::max(minimumContentWidth, columnWidth.value_or(maximumContentWidth));
         if (!hasEnoughAvailableSpaceForMaximumWidth) {
             // maximum width > available horizontal space
             // preferred width: it's always at least as wide as the minimum content width and if column fixed width is set then the greater of the two.
@@ -303,7 +304,6 @@
             // total adjustable space: 120px - 80px - 50px = -10px <- Note the negative available space with over-constrained values.
             // columns extra widths: -10px / (30px + 0px) * 30px = -10px and -10px / (30px + 0px) * 0px = 0px
             // columns final widths: 70px and 50px (first column is narrower than its preferred width and the second is as wide as the minimum content width)
-            auto preferredWidth = std::max(minimumContentWidth, columnWidth.value_or(maximumContentWidth));
             return GridSpace { type, preferredWidth, preferredWidth - minimumContentWidth };
         }
 
@@ -324,7 +324,6 @@
         // total adjustable space: 2600px - 500px = 2100px
         // columns extra widths: 2100px / 500px * 200px = 840px and 2100px / 500px * 300px = 1260px
         // columns final widths: 1040px and 1560px
-        auto preferredWidth = std::max(minimumContentWidth, columnWidth.value_or(maximumContentWidth));
         return GridSpace { type, preferredWidth, preferredWidth };
     });
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to