Title: [248596] trunk/Source/WebCore
Revision
248596
Author
za...@apple.com
Date
2019-08-13 10:05:20 -0700 (Tue, 13 Aug 2019)

Log Message

[LFC][TFC] Introduce TableGrid
https://bugs.webkit.org/show_bug.cgi?id=200656
<rdar://problem/54240833>

Reviewed by Antti Koivisto.

table grid:
A matrix containing as many rows and columns as needed to describe the position of all the table-rows
and table-cells of a table-root, as determined by the grid-dimensioning algorithm.
Each row of the grid might correspond to a table-row, and each column to a table-column.

slot of the table grid:
A slot (r,c) is an available space created by the intersection of a row r and a column c in the table grid.

https://www.w3.org/TR/css-tables-3/#terminology

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::isTableHeader const):
(WebCore::Layout::Box::isTableBody const):
(WebCore::Layout::Box::isTableFooter const):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createLayoutBox):
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::layout const):
(WebCore::Layout::TableFormattingContext::ensureTableGrid const):
(WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns const):
(WebCore::Layout::TableFormattingContext::computeTableWidth const):
(WebCore::Layout::TableFormattingContext::distributeAvailabeWidth const):
(WebCore::Layout::TableFormattingContext::computeTableHeight const):
(WebCore::Layout::TableFormattingContext::distributeAvailableHeight const):
* layout/tableformatting/TableFormattingContext.h:
(WebCore::Layout::TableFormattingContext::formattingState const):
* layout/tableformatting/TableFormattingState.h:
(WebCore::Layout::TableFormattingState::tableGrid):
* layout/tableformatting/TableGrid.cpp: Added.
(WebCore::Layout::TableGrid::CellInfo::CellInfo):
(WebCore::Layout::TableGrid::SlotInfo::SlotInfo):
(WebCore::Layout::TableGrid::TableGrid):
(WebCore::Layout::TableGrid::appendCell):
(WebCore::Layout::TableGrid::insertCell):
(WebCore::Layout::TableGrid::removeCell):
* layout/tableformatting/TableGrid.h: Copied from Source/WebCore/layout/tableformatting/TableFormattingContext.h.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (248595 => 248596)


--- trunk/Source/WebCore/ChangeLog	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/ChangeLog	2019-08-13 17:05:20 UTC (rev 248596)
@@ -1,5 +1,52 @@
 2019-08-13  Zalan Bujtas  <za...@apple.com>
 
+        [LFC][TFC] Introduce TableGrid
+        https://bugs.webkit.org/show_bug.cgi?id=200656
+        <rdar://problem/54240833>
+
+        Reviewed by Antti Koivisto.
+
+        table grid:
+        A matrix containing as many rows and columns as needed to describe the position of all the table-rows
+        and table-cells of a table-root, as determined by the grid-dimensioning algorithm.
+        Each row of the grid might correspond to a table-row, and each column to a table-column.
+
+        slot of the table grid:
+        A slot (r,c) is an available space created by the intersection of a row r and a column c in the table grid.
+
+        https://www.w3.org/TR/css-tables-3/#terminology
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/layouttree/LayoutBox.h:
+        (WebCore::Layout::Box::isTableHeader const):
+        (WebCore::Layout::Box::isTableBody const):
+        (WebCore::Layout::Box::isTableFooter const):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createLayoutBox):
+        * layout/tableformatting/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::layout const):
+        (WebCore::Layout::TableFormattingContext::ensureTableGrid const):
+        (WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns const):
+        (WebCore::Layout::TableFormattingContext::computeTableWidth const):
+        (WebCore::Layout::TableFormattingContext::distributeAvailabeWidth const):
+        (WebCore::Layout::TableFormattingContext::computeTableHeight const):
+        (WebCore::Layout::TableFormattingContext::distributeAvailableHeight const):
+        * layout/tableformatting/TableFormattingContext.h:
+        (WebCore::Layout::TableFormattingContext::formattingState const):
+        * layout/tableformatting/TableFormattingState.h:
+        (WebCore::Layout::TableFormattingState::tableGrid):
+        * layout/tableformatting/TableGrid.cpp: Added.
+        (WebCore::Layout::TableGrid::CellInfo::CellInfo):
+        (WebCore::Layout::TableGrid::SlotInfo::SlotInfo):
+        (WebCore::Layout::TableGrid::TableGrid):
+        (WebCore::Layout::TableGrid::appendCell):
+        (WebCore::Layout::TableGrid::insertCell):
+        (WebCore::Layout::TableGrid::removeCell):
+        * layout/tableformatting/TableGrid.h: Copied from Source/WebCore/layout/tableformatting/TableFormattingContext.h.
+
+2019-08-13  Zalan Bujtas  <za...@apple.com>
+
         [LFC][TFC] Add rowSpan and colSpan to Box
         https://bugs.webkit.org/show_bug.cgi?id=200654
         <rdar://problem/54239281>

Modified: trunk/Source/WebCore/Sources.txt (248595 => 248596)


--- trunk/Source/WebCore/Sources.txt	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/Sources.txt	2019-08-13 17:05:20 UTC (rev 248596)
@@ -1418,6 +1418,7 @@
 layout/layouttree/LayoutTreeBuilder.cpp
 layout/tableformatting/TableFormattingContext.cpp
 layout/tableformatting/TableFormattingState.cpp
+layout/tableformatting/TableGrid.cpp
 layout/tableformatting/TableInvalidation.cpp
 
 loader/AdClickAttribution.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (248595 => 248596)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-08-13 17:05:20 UTC (rev 248596)
@@ -9138,6 +9138,7 @@
 		6F3E1F5F2136141700A65A08 /* FloatBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FloatBox.cpp; sourceTree = "<group>"; };
 		6F3E1F612136141700A65A08 /* FloatBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FloatBox.h; sourceTree = "<group>"; };
 		6F4A5BD522F9F16B00A80F25 /* LayoutPhase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutPhase.cpp; sourceTree = "<group>"; };
+		6F5B7EAA2300A79E0067D9C3 /* TableGrid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableGrid.cpp; sourceTree = "<group>"; };
 		6F73918C2106CEDD006AF262 /* LayoutUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutUnits.h; sourceTree = "<group>"; };
 		6F7CA3C4208C2956002F29AB /* LayoutState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutState.h; sourceTree = "<group>"; };
 		6F7CA3C5208C2956002F29AB /* LayoutState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutState.cpp; sourceTree = "<group>"; };
@@ -9172,6 +9173,7 @@
 		6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
 		6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
 		6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
+		6FB22E30230097E300C20866 /* TableGrid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableGrid.h; sourceTree = "<group>"; };
 		6FB47E612277425A00C7BCB0 /* InlineLineBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLineBox.h; sourceTree = "<group>"; };
 		6FB5E212221F2447003989CF /* ContentChangeObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentChangeObserver.h; sourceTree = "<group>"; };
 		6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
@@ -17084,8 +17086,8 @@
 				C21BF72021CD89DD00227979 /* WHLSLEnumerationDefinition.h */,
 				C21BF72621CD89E300227979 /* WHLSLEnumerationMember.h */,
 				C21BF70221CD89C400227979 /* WHLSLEnumerationMemberLiteral.h */,
+				522D07A322FBAB4300B905BE /* WHLSLExpression.cpp */,
 				C21BF70C21CD89CC00227979 /* WHLSLExpression.h */,
-				522D07A322FBAB4300B905BE /* WHLSLExpression.cpp */,
 				C21BF70021CD89C200227979 /* WHLSLFallthrough.h */,
 				C21BF73521CD89F200227979 /* WHLSLFloatLiteral.h */,
 				1CB69B3821DF03E1006E846A /* WHLSLFloatLiteralType.cpp */,
@@ -20446,6 +20448,8 @@
 				6FC5CA9522E3599400B13E11 /* TableFormattingContext.h */,
 				6FC5CA9222E3599300B13E11 /* TableFormattingState.cpp */,
 				6FC5CA9622E3599500B13E11 /* TableFormattingState.h */,
+				6F5B7EAA2300A79E0067D9C3 /* TableGrid.cpp */,
+				6FB22E30230097E300C20866 /* TableGrid.h */,
 				6FC5CA9722E3599500B13E11 /* TableInvalidation.cpp */,
 				6FC5CA9322E3599300B13E11 /* TableInvalidation.h */,
 			);

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (248595 => 248596)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2019-08-13 17:05:20 UTC (rev 248596)
@@ -52,6 +52,7 @@
         TableColumnGroup,
         TableRowGroup,
         TableHeaderGroup,
+        TableBodyGroup,
         TableFooterGroup,
         Image,
         IFrame,
@@ -116,6 +117,9 @@
     bool isTableWrapperBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableWrapperBox; }
     bool isTableBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableBox; }
     bool isTableCaption() const { return style().display() == DisplayType::TableCaption; }
+    bool isTableHeader() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableHeaderGroup; }
+    bool isTableBody() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableBodyGroup; }
+    bool isTableFooter() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableFooterGroup; }
     bool isTableRow() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::TableRow; }
     bool isTableCell() const { return style().display() == DisplayType::TableCell;; }
     bool isReplaced() const { return isImage() || isIFrame(); }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (248595 => 248596)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-08-13 17:05:20 UTC (rev 248596)
@@ -110,10 +110,10 @@
                 return Box::ElementAttributes { Box::ElementType::TableRowGroup };
             if (element->hasTagName(HTMLNames::theadTag))
                 return Box::ElementAttributes { Box::ElementType::TableHeaderGroup };
+            if (element->hasTagName(HTMLNames::tbodyTag))
+                return Box::ElementAttributes { Box::ElementType::TableBodyGroup };
             if (element->hasTagName(HTMLNames::tfootTag))
                 return Box::ElementAttributes { Box::ElementType::TableFooterGroup };
-            if (element->hasTagName(HTMLNames::tfootTag))
-                return Box::ElementAttributes { Box::ElementType::TableFooterGroup };
             if (element->hasTagName(HTMLNames::imgTag))
                 return Box::ElementAttributes { Box::ElementType::Image };
             if (element->hasTagName(HTMLNames::iframeTag))

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (248595 => 248596)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp	2019-08-13 17:05:20 UTC (rev 248596)
@@ -44,6 +44,21 @@
 
 void TableFormattingContext::layout() const
 {
+    // https://www.w3.org/TR/css-tables-3/#table-layout-algorithm
+    // To layout a table, user agents must apply the following actions:
+
+    // 1. Ensure each cell slot is occupied by at least one cell.
+    ensureTableGrid();
+    // 2. Compute the minimum width of each column.
+    computePreferredWidthForColumns();
+    // 3. Compute the width of the table.
+    computeTableWidth();
+    // 4. Distribute the width of the table among columns.
+    distributeAvailabeWidth();
+    // 5. Compute the height of the table.
+    computeTableHeight();
+    // 6. Distribute the height of the table among rows.
+    distributeAvailableHeight();
 }
 
 FormattingContext::IntrinsicWidthConstraints TableFormattingContext::computedIntrinsicWidthConstraints() const
@@ -51,7 +66,44 @@
     return { };
 }
 
+void TableFormattingContext::ensureTableGrid() const
+{
+    auto& tableWrapperBox = downcast<Container>(root());
+    auto& tableGrid = formattingState().tableGrid();
+
+    for (auto* section = tableWrapperBox.firstChild(); section; section = section->nextSibling()) {
+        ASSERT(section->isTableHeader() || section->isTableBody() || section->isTableFooter());
+        for (auto* row = downcast<Container>(*section).firstChild(); row; row = row->nextSibling()) {
+            ASSERT(row->isTableRow());
+            for (auto* cell = downcast<Container>(*row).firstChild(); cell; cell = cell->nextSibling()) {
+                ASSERT(cell->isTableCell());
+                tableGrid.appendCell(*cell);
+            }
+        }
+    }
 }
+
+void TableFormattingContext::computePreferredWidthForColumns() const
+{
 }
 
+void TableFormattingContext::computeTableWidth() const
+{
+}
+
+void TableFormattingContext::distributeAvailabeWidth() const
+{
+}
+
+void TableFormattingContext::computeTableHeight() const
+{
+}
+
+void TableFormattingContext::distributeAvailableHeight() const
+{
+}
+
+}
+}
+
 #endif

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h (248595 => 248596)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h	2019-08-13 17:05:20 UTC (rev 248596)
@@ -44,6 +44,15 @@
 
 private:
     IntrinsicWidthConstraints computedIntrinsicWidthConstraints() const override;
+
+    void ensureTableGrid() const;
+    void computePreferredWidthForColumns() const;
+    void computeTableWidth() const;
+    void distributeAvailabeWidth() const;
+    void computeTableHeight() const;
+    void distributeAvailableHeight() const;
+
+    TableFormattingState& formattingState() const { return downcast<TableFormattingState>(FormattingContext::formattingState()); }
 };
 
 }

Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingState.h (248595 => 248596)


--- trunk/Source/WebCore/layout/tableformatting/TableFormattingState.h	2019-08-13 15:34:29 UTC (rev 248595)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingState.h	2019-08-13 17:05:20 UTC (rev 248596)
@@ -28,6 +28,7 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "FormattingState.h"
+#include "TableGrid.h"
 #include <wtf/IsoMalloc.h>
 
 namespace WebCore {
@@ -39,6 +40,11 @@
 public:
     TableFormattingState(Ref<FloatingState>&&, LayoutState&);
     virtual ~TableFormattingState();
+
+    TableGrid& tableGrid() { return m_tableGrid; }
+
+private:
+    TableGrid m_tableGrid;
 };
 
 }

Added: trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp (0 => 248596)


--- trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.cpp	2019-08-13 17:05:20 UTC (rev 248596)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TableGrid.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(TableGrid);
+
+TableGrid::CellInfo::CellInfo(const Box& tableCellBox, SlotPosition position, CellSize size)
+    : tableCellBox(tableCellBox)
+    , position(position)
+    , size(size)
+{
+}
+
+TableGrid::SlotInfo::SlotInfo(CellInfo& cell)
+    : cell(makeWeakPtr(cell))
+{
+}
+
+TableGrid::TableGrid()
+{
+}
+
+void TableGrid::appendCell(const Box& tableCellBox)
+{
+    int rowSpan = tableCellBox.rowSpan();
+    int columnSpan = tableCellBox.columnSpan();
+    auto initialSlotPosition = SlotPosition { };
+
+    if (!m_cellList.isEmpty()) {
+        auto& lastCell = m_cellList.last();
+        auto lastSlotPosition = lastCell->position;
+        // First table cell in this row?
+        if (!tableCellBox.previousSibling())
+            initialSlotPosition = SlotPosition { 0, lastSlotPosition.y() + 1 };
+        else
+            initialSlotPosition = SlotPosition { lastSlotPosition.x() + 1, lastSlotPosition.y() };
+
+        // Pick the next available slot by avoiding row and column spanners.
+        while (true) {
+            if (!m_slotMap.contains(initialSlotPosition))
+                break;
+            initialSlotPosition.move(1, 0);
+        }
+    }
+    auto cellInfo = std::make_unique<CellInfo>(tableCellBox, initialSlotPosition, CellSize { rowSpan, columnSpan });
+    // Row and column spanners create additional slots.
+    for (int row = 1; row <= rowSpan; ++row) {
+        for (int column = 1; column <= columnSpan; ++column) {
+            auto position = SlotPosition { initialSlotPosition.x() + row - 1, initialSlotPosition.y() + column - 1 };
+            ASSERT(!m_slotMap.contains(position));
+            m_slotMap.add(position, SlotInfo { *cellInfo });
+        }
+    }
+    m_cellList.add(WTFMove(cellInfo));
+}
+
+void TableGrid::insertCell(const Box& tableCellBox, const Box& before)
+{
+    UNUSED_PARAM(tableCellBox);
+    UNUSED_PARAM(before);
+}
+
+void TableGrid::removeCell(const Box& tableCellBox)
+{
+    UNUSED_PARAM(tableCellBox);
+}
+
+}
+}
+#endif

Copied: trunk/Source/WebCore/layout/tableformatting/TableGrid.h (from rev 248595, trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h) (0 => 248596)


--- trunk/Source/WebCore/layout/tableformatting/TableGrid.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/tableformatting/TableGrid.h	2019-08-13 17:05:20 UTC (rev 248596)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "IntPointHash.h"
+#include "LayoutBox.h"
+#include <wtf/HashMap.h>
+#include <wtf/IsoMalloc.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+namespace Layout {
+
+class TableGrid {
+    WTF_MAKE_ISO_ALLOCATED(TableGrid);
+public:
+    TableGrid();
+
+    void appendCell(const Box&);
+    void insertCell(const Box&, const Box& before);
+    void removeCell(const Box&);
+
+private:
+    using SlotPosition = IntPoint;
+    using CellSize = IntSize;
+    using SlotLogicalSize = LayoutSize;
+
+    struct CellInfo : public CanMakeWeakPtr<CellInfo> {
+        CellInfo(const Box& tableCellBox, SlotPosition, CellSize);
+
+        const Box& tableCellBox;
+        SlotPosition position;
+        CellSize size;
+    };
+
+    struct SlotInfo {
+        SlotInfo() = default;
+        SlotInfo(CellInfo&);
+
+        WeakPtr<CellInfo> cell;
+        SlotLogicalSize size;
+    };
+
+    using CellList = WTF::ListHashSet<std::unique_ptr<CellInfo>>;
+    using SlotMap = WTF::HashMap<SlotPosition, SlotInfo>;
+    SlotMap m_slotMap;
+    CellList m_cellList;
+};
+
+}
+}
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to