Changeset 261919 in webkit


Ignore:
Timestamp:
May 20, 2020 8:34:24 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][TFC] Internal table boxes should take collapsed border into account
https://bugs.webkit.org/show_bug.cgi?id=212135

Source/WebCore:

Reviewed by Antti Koivisto.

Use the collapsed border value to compute the borders for sections, rows and cells.
The collapsed border is propagated to the table box and the adjacent cell boxes.

Test: fast/layoutformattingcontext/table-simple-border-collapse.html

  • layout/LayoutUnits.h:

(WebCore::Layout::operator/):

  • layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:

(WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):

  • layout/tableformatting/TableFormattingContext.cpp:

(WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
(WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
(WebCore::Layout::TableFormattingContext::layoutCell):

  • layout/tableformatting/TableGrid.h:

(WebCore::Layout::TableGrid::setCollapsedBorder):
(WebCore::Layout::TableGrid::collapsedBorder const):

LayoutTests:

Reviewed by Antti Koivisto.

  • fast/layoutformattingcontext/table-simple-border-collapse-expected.html: Added.
  • fast/layoutformattingcontext/table-simple-border-collapse.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r261913 r261919  
     12020-05-20  Alan Kinsley  <zalan@apple.com>
     2
     3        [LFC][TFC] Internal table boxes should take collapsed border into account
     4        https://bugs.webkit.org/show_bug.cgi?id=212135
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/layoutformattingcontext/table-simple-border-collapse-expected.html: Added.
     9        * fast/layoutformattingcontext/table-simple-border-collapse.html: Added.
     10
    1112020-05-20  Zan Dobersek  <zdobersek@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r261915 r261919  
     12020-05-20  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][TFC] Internal table boxes should take collapsed border into account
     4        https://bugs.webkit.org/show_bug.cgi?id=212135
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Use the collapsed border value to compute the borders for sections, rows and cells.
     9        The collapsed border is propagated to the table box and the adjacent cell boxes. 
     10
     11        Test: fast/layoutformattingcontext/table-simple-border-collapse.html
     12
     13        * layout/LayoutUnits.h:
     14        (WebCore::Layout::operator/):
     15        * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
     16        (WebCore::Layout::TableWrapperBlockFormattingContext::computeBorderAndPaddingForTableBox):
     17        * layout/tableformatting/TableFormattingContext.cpp:
     18        (WebCore::Layout::TableFormattingContext::setUsedGeometryForRows):
     19        (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
     20        (WebCore::Layout::TableFormattingContext::layoutCell):
     21        * layout/tableformatting/TableGrid.h:
     22        (WebCore::Layout::TableGrid::setCollapsedBorder):
     23        (WebCore::Layout::TableGrid::collapsedBorder const):
     24
    1252020-05-20  Youenn Fablet  <youenn@apple.com>
    226
  • trunk/Source/WebCore/layout/LayoutUnits.h

    r260827 r261919  
    132132};
    133133
     134inline Edges operator/(const Edges& edge, size_t value)
     135{
     136    return { { edge.horizontal.left / value, edge.horizontal.right / value }, { edge.vertical.top / value, edge.vertical.bottom / value } };
     137}
     138
    134139struct ContentWidthAndMargin {
    135140    LayoutUnit contentWidth;
  • trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp

    r261832 r261919  
    111111            bottomBorder = std::max(bottomBorder, geometry().computedBorder(boxInLastRow).vertical.bottom);
    112112        }
    113         auto collapsedBorder = Edges { { leftBorder / 2, rightBorder / 2 }, { topBorder / 2, bottomBorder / 2 } };
     113        auto collapsedBorder = Edges { { leftBorder, rightBorder }, { topBorder, bottomBorder } };
     114        grid.setCollapsedBorder(collapsedBorder);
    114115
    115116        auto& displayBox = formattingState().displayBox(tableBox);
    116         displayBox.setBorder(collapsedBorder);
     117        displayBox.setBorder(collapsedBorder / 2);
    117118        displayBox.setPadding(geometry().computedPadding(tableBox, horizontalConstraints.logicalWidth));
    118119        return;
  • trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp

    r261810 r261919  
    116116    auto rowWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
    117117    auto rowLogicalTop = grid.verticalSpacing();
    118     for (auto& row : rows) {
     118    for (size_t rowIndex = 0; rowIndex < rows.size(); ++rowIndex) {
     119        auto& row = rows[rowIndex];
    119120        auto& rowBox = row.box();
    120121        auto& rowDisplayBox = formattingState().displayBox(rowBox);
    121         computeBorderAndPadding(rowBox, HorizontalConstraints { { }, availableHorizontalSpace });
     122
     123        auto computedRowBorder = [&] {
     124            auto border = geometry().computedBorder(rowBox);
     125            if (!grid.collapsedBorder())
     126                return border;
     127            // Border collapsing delegates borders to table/cells.
     128            border.horizontal = { };
     129            if (!rowIndex)
     130                border.vertical.top = { };
     131            if (rowIndex == rows.size() - 1)
     132                border.vertical.bottom = { };
     133            return border;
     134        }();
     135        rowDisplayBox.setBorder(computedRowBorder);
     136        rowDisplayBox.setPadding(geometry().computedPadding(rowBox, availableHorizontalSpace));
    122137        // Internal table elements do not have margins.
    123138        rowDisplayBox.setHorizontalMargin({ });
     
    159174    for (auto& section : childrenOfType<ContainerBox>(root())) {
    160175        auto& sectionDisplayBox = formattingState().displayBox(section);
    161         computeBorderAndPadding(section, HorizontalConstraints { { }, constraints.horizontal.logicalWidth });
     176        // FIXME: Multiple sections can have their own borders.
     177        sectionDisplayBox.setBorder(grid.collapsedBorder() ? Edges(): geometry().computedBorder(section));
     178        sectionDisplayBox.setPadding(geometry().computedPadding(section, constraints.horizontal.logicalWidth));
    162179        // Internal table elements do not have margins.
    163180        sectionDisplayBox.setHorizontalMargin({ });
     
    179196    ASSERT(cell.box().establishesBlockFormattingContext());
    180197
     198    auto& grid = formattingState().tableGrid();
    181199    auto& cellBox = cell.box();
    182200    auto& cellDisplayBox = formattingState().displayBox(cellBox);
    183201
    184     computeBorderAndPadding(cellBox, HorizontalConstraints { { }, availableHorizontalSpace });
     202    auto computedCellBorder = [&] {
     203        auto border = geometry().computedBorder(cellBox);
     204        auto collapsedBorder = grid.collapsedBorder();
     205        if (!collapsedBorder)
     206            return border;
     207        auto cellPosition = cell.position();
     208        if (!cellPosition.column)
     209            border.horizontal.left = collapsedBorder->horizontal.left / 2;
     210        if (cellPosition.column == grid.columns().size() - 1)
     211            border.horizontal.right = collapsedBorder->horizontal.right / 2;
     212        if (!cellPosition.row)
     213            border.vertical.top = collapsedBorder->vertical.top / 2;
     214        if (cellPosition.row == grid.rows().size() - 1)
     215            border.vertical.bottom = collapsedBorder->vertical.bottom / 2;
     216        return border;
     217    }();
     218    cellDisplayBox.setBorder(computedCellBorder);
     219    cellDisplayBox.setPadding(geometry().computedPadding(cellBox, availableHorizontalSpace));
    185220    // Internal table elements do not have margins.
    186221    cellDisplayBox.setHorizontalMargin({ });
     
    189224
    190225    auto availableSpaceForContent = [&] {
    191         auto& grid = formattingState().tableGrid();
    192226        auto& columnList = grid.columns().list();
    193227        auto logicalWidth = LayoutUnit { };
  • trunk/Source/WebCore/layout/tableformatting/TableGrid.h

    r261745 r261919  
    5656    LayoutUnit verticalSpacing() const { return m_verticalSpacing; }
    5757
     58    void setCollapsedBorder(const Edges& collapsedBorder) { m_collapsedBorder = collapsedBorder; }
     59    Optional<Edges> collapsedBorder() const { return m_collapsedBorder; }
     60
    5861    void setWidthConstraints(FormattingContext::IntrinsicWidthConstraints intrinsicWidthConstraints) { m_intrinsicWidthConstraints = intrinsicWidthConstraints; }
    5962    Optional<FormattingContext::IntrinsicWidthConstraints> widthConstraints() const { return m_intrinsicWidthConstraints; }
     
    229232    LayoutUnit m_verticalSpacing;
    230233    Optional<FormattingContext::IntrinsicWidthConstraints> m_intrinsicWidthConstraints;
     234    Optional<Edges> m_collapsedBorder;
    231235};
    232236
Note: See TracChangeset for help on using the changeset viewer.