Title: [278279] trunk/Source/WebCore
Revision
278279
Author
za...@apple.com
Date
2021-05-31 08:47:28 -0700 (Mon, 31 May 2021)

Log Message

[LFC][TFC] Move ensureTableGrid to TableFormattingState
https://bugs.webkit.org/show_bug.cgi?id=226424

Reviewed by Antti Koivisto.

We can certainly have this much logic in a formatting state class.

* layout/formattingContexts/table/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::ensureTableGrid): Deleted.
* layout/formattingContexts/table/TableFormattingContext.h:
* layout/formattingContexts/table/TableFormattingState.cpp:
(WebCore::Layout::ensureTableGrid):
(WebCore::Layout::TableFormattingState::TableFormattingState):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (278278 => 278279)


--- trunk/Source/WebCore/ChangeLog	2021-05-31 15:04:24 UTC (rev 278278)
+++ trunk/Source/WebCore/ChangeLog	2021-05-31 15:47:28 UTC (rev 278279)
@@ -1,3 +1,19 @@
+2021-05-31  Alan Bujtas  <za...@apple.com>
+
+        [LFC][TFC] Move ensureTableGrid to TableFormattingState
+        https://bugs.webkit.org/show_bug.cgi?id=226424
+
+        Reviewed by Antti Koivisto.
+
+        We can certainly have this much logic in a formatting state class.
+
+        * layout/formattingContexts/table/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::ensureTableGrid): Deleted.
+        * layout/formattingContexts/table/TableFormattingContext.h:
+        * layout/formattingContexts/table/TableFormattingState.cpp:
+        (WebCore::Layout::ensureTableGrid):
+        (WebCore::Layout::TableFormattingState::TableFormattingState):
+
 2021-05-31  Antti Koivisto  <an...@apple.com>
 
         Rename presentationAttributeStyle to presentationalHintStyle to match spec language

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp (278278 => 278279)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2021-05-31 15:04:24 UTC (rev 278278)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2021-05-31 15:47:28 UTC (rev 278279)
@@ -339,57 +339,6 @@
     return computedWidthConstraints;
 }
 
-UniqueRef<TableGrid> TableFormattingContext::ensureTableGrid(const ContainerBox& tableBox)
-{
-    auto tableGrid = makeUniqueRef<TableGrid>();
-    auto& tableStyle = tableBox.style();
-    auto shouldApplyBorderSpacing = tableStyle.borderCollapse() == BorderCollapse::Separate;
-    tableGrid->setHorizontalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.horizontalBorderSpacing() : 0 });
-    tableGrid->setVerticalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.verticalBorderSpacing() : 0 });
-
-    auto* firstChild = tableBox.firstChild();
-    if (!firstChild) {
-        // The rare case of empty table.
-        return tableGrid;
-    }
-
-    const Box* tableCaption = nullptr;
-    const Box* colgroup = nullptr;
-    // Table caption is an optional element; if used, it is always the first child of a <table>.
-    if (firstChild->isTableCaption())
-        tableCaption = firstChild;
-    // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element.
-    auto* colgroupCandidate = firstChild;
-    if (tableCaption)
-        colgroupCandidate = tableCaption->nextSibling();
-    if (colgroupCandidate->isTableColumnGroup())
-        colgroup = colgroupCandidate;
-
-    if (colgroup) {
-        auto& columns = tableGrid->columns();
-        for (auto* column = downcast<ContainerBox>(*colgroup).firstChild(); column; column = column->nextSibling()) {
-            ASSERT(column->isTableColumn());
-            auto columnSpanCount = column->columnSpan();
-            ASSERT(columnSpanCount > 0);
-            while (columnSpanCount--)
-                columns.addColumn(downcast<ContainerBox>(*column));
-        }
-    }
-
-    auto* firstSection = colgroup ? colgroup->nextSibling() : tableCaption ? tableCaption->nextSibling() : firstChild;
-    for (auto* section = firstSection; section; section = section->nextSibling()) {
-        ASSERT(section->isTableHeader() || section->isTableBody() || section->isTableFooter());
-        for (auto* row = downcast<ContainerBox>(*section).firstChild(); row; row = row->nextSibling()) {
-            ASSERT(row->isTableRow());
-            for (auto* cell = downcast<ContainerBox>(*row).firstChild(); cell; cell = cell->nextSibling()) {
-                ASSERT(cell->isTableCell());
-                tableGrid->appendCell(downcast<ContainerBox>(*cell));
-            }
-        }
-    }
-    return tableGrid;
-}
-
 IntrinsicWidthConstraints TableFormattingContext::computedPreferredWidthForColumns()
 {
     auto& formattingState = this->formattingState();

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h (278278 => 278279)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h	2021-05-31 15:04:24 UTC (rev 278278)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h	2021-05-31 15:47:28 UTC (rev 278279)
@@ -51,9 +51,6 @@
 
     const TableFormattingGeometry& formattingGeometry() const final { return m_tableFormattingGeometry; }
     const TableFormattingQuirks& formattingQuirks() const final { return m_tableFormattingQuirks; }
-
-    static UniqueRef<TableGrid> ensureTableGrid(const ContainerBox& tableBox);
-
     const TableFormattingState& formattingState() const { return downcast<TableFormattingState>(FormattingContext::formattingState()); }
 
 private:

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingState.cpp (278278 => 278279)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingState.cpp	2021-05-31 15:04:24 UTC (rev 278278)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingState.cpp	2021-05-31 15:47:28 UTC (rev 278279)
@@ -36,9 +36,61 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(TableFormattingState);
 
+static UniqueRef<TableGrid> ensureTableGrid(const ContainerBox& tableBox)
+{
+    auto tableGrid = makeUniqueRef<TableGrid>();
+    auto& tableStyle = tableBox.style();
+    auto shouldApplyBorderSpacing = tableStyle.borderCollapse() == BorderCollapse::Separate;
+    tableGrid->setHorizontalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.horizontalBorderSpacing() : 0 });
+    tableGrid->setVerticalSpacing(LayoutUnit { shouldApplyBorderSpacing ? tableStyle.verticalBorderSpacing() : 0 });
+
+    auto* firstChild = tableBox.firstChild();
+    if (!firstChild) {
+        // The rare case of empty table.
+        return tableGrid;
+    }
+
+    const Box* tableCaption = nullptr;
+    const Box* colgroup = nullptr;
+    // Table caption is an optional element; if used, it is always the first child of a <table>.
+    if (firstChild->isTableCaption())
+        tableCaption = firstChild;
+    // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element.
+    auto* colgroupCandidate = firstChild;
+    if (tableCaption)
+        colgroupCandidate = tableCaption->nextSibling();
+    if (colgroupCandidate->isTableColumnGroup())
+        colgroup = colgroupCandidate;
+
+    if (colgroup) {
+        auto& columns = tableGrid->columns();
+        for (auto* column = downcast<ContainerBox>(*colgroup).firstChild(); column; column = column->nextSibling()) {
+            ASSERT(column->isTableColumn());
+            auto columnSpanCount = column->columnSpan();
+            ASSERT(columnSpanCount > 0);
+            while (columnSpanCount--)
+                columns.addColumn(downcast<ContainerBox>(*column));
+        }
+    }
+
+    auto* firstSection = colgroup ? colgroup->nextSibling() : tableCaption ? tableCaption->nextSibling() : firstChild;
+    for (auto* section = firstSection; section; section = section->nextSibling()) {
+        ASSERT(section->isTableHeader() || section->isTableBody() || section->isTableFooter());
+        for (auto* row = downcast<ContainerBox>(*section).firstChild(); row; row = row->nextSibling()) {
+            ASSERT(row->isTableRow());
+            for (auto* cell = downcast<ContainerBox>(*row).firstChild(); cell; cell = cell->nextSibling()) {
+                ASSERT(cell->isTableCell());
+                tableGrid->appendCell(downcast<ContainerBox>(*cell));
+            }
+        }
+    }
+    return tableGrid;
+}
+
+
 TableFormattingState::TableFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState, const ContainerBox& tableBox)
     : FormattingState(WTFMove(floatingState), Type::Table, layoutState)
-    , m_tableGrid(TableFormattingContext::ensureTableGrid(tableBox))
+    , m_tableGrid(ensureTableGrid(tableBox))
 {
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to