Changeset 261991 in webkit


Ignore:
Timestamp:
May 21, 2020 5:33:00 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][TFC] Collapse in-between cell borders
https://bugs.webkit.org/show_bug.cgi?id=212183

Reviewed by Antti Koivisto.

Source/WebCore:

This patch expands border collapsing to in-between cell borders.

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

  • layout/tableformatting/TableFormattingContext.cpp:

(WebCore::Layout::TableFormattingContext::layoutCell):

  • layout/tableformatting/TableFormattingContext.h:
  • layout/tableformatting/TableFormattingContextGeometry.cpp:

(WebCore::Layout::TableFormattingContext::Geometry::computedCellBorder const):
(WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):

LayoutTests:

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

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r261989 r261991  
     12020-05-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][TFC] Collapse in-between cell borders
     4        https://bugs.webkit.org/show_bug.cgi?id=212183
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/layoutformattingcontext/table-simple-border-collapse3-expected.html: Added.
     9        * fast/layoutformattingcontext/table-simple-border-collapse3.html: Added.
     10
    1112020-05-21  Diego Pino Garcia  <dpino@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r261986 r261991  
     12020-05-21  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][TFC] Collapse in-between cell borders
     4        https://bugs.webkit.org/show_bug.cgi?id=212183
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch expands border collapsing to in-between cell borders.
     9
     10        Test: fast/layoutformattingcontext/table-simple-border-collapse3.html
     11
     12        * layout/tableformatting/TableFormattingContext.cpp:
     13        (WebCore::Layout::TableFormattingContext::layoutCell):
     14        * layout/tableformatting/TableFormattingContext.h:
     15        * layout/tableformatting/TableFormattingContextGeometry.cpp:
     16        (WebCore::Layout::TableFormattingContext::Geometry::computedCellBorder const):
     17        (WebCore::Layout::TableFormattingContext::Geometry::intrinsicWidthConstraintsForCell):
     18
    1192020-05-21  Enrique Ocaña González  <eocanha@igalia.com>
    220
  • trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp

    r261980 r261991  
    200200    auto& cellDisplayBox = formattingState().displayBox(cellBox);
    201201
    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);
     202    cellDisplayBox.setBorder(geometry().computedCellBorder(cell));
    219203    cellDisplayBox.setPadding(geometry().computedPadding(cellBox, availableHorizontalSpace));
    220204    // Internal table elements do not have margins.
  • trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h

    r261980 r261991  
    6767    public:
    6868        LayoutUnit cellHeigh(const ContainerBox&) const;
     69        Edges computedCellBorder(const TableGrid::Cell&) const;
    6970        Optional<LayoutUnit> computedColumnWidth(const ContainerBox& columnBox) const;
    7071        FormattingContext::IntrinsicWidthConstraints intrinsicWidthConstraintsForCell(const TableGrid::Cell&);
  • trunk/Source/WebCore/layout/tableformatting/TableFormattingContextGeometry.cpp

    r261980 r261991  
    4747}
    4848
     49Edges TableFormattingContext::Geometry::computedCellBorder(const TableGrid::Cell& cell) const
     50{
     51    auto& cellBox = cell.box();
     52    auto border = computedBorder(cellBox);
     53    auto collapsedBorder = m_grid.collapsedBorder();
     54    if (!collapsedBorder)
     55        return border;
     56
     57    // We might want to cache these collapsed borders on the grid.
     58    auto cellPosition = cell.position();
     59    if (!cellPosition.column)
     60        border.horizontal.left = collapsedBorder->horizontal.left / 2;
     61    else {
     62        auto adjacentBorderRight = computedBorder(m_grid.slot({ cellPosition.column - 1, cellPosition.row })->cell().box()).horizontal.right;
     63        border.horizontal.left = std::max(border.horizontal.left, adjacentBorderRight) / 2;
     64    }
     65    if (cellPosition.column == m_grid.columns().size() - 1)
     66        border.horizontal.right = collapsedBorder->horizontal.right / 2;
     67    else {
     68        auto adjacentBorderLeft = computedBorder(m_grid.slot({ cellPosition.column + 1, cellPosition.row })->cell().box()).horizontal.left;
     69        border.horizontal.right = std::max(border.horizontal.right, adjacentBorderLeft) / 2;
     70    }
     71    if (!cellPosition.row)
     72        border.vertical.top = collapsedBorder->vertical.top / 2;
     73    else {
     74        auto adjacentBorderBottom = computedBorder(m_grid.slot({ cellPosition.column, cellPosition.row - 1 })->cell().box()).vertical.bottom;
     75        border.vertical.top = std::max(border.vertical.top, adjacentBorderBottom) / 2;
     76    }
     77    if (cellPosition.row == m_grid.rows().size() - 1)
     78        border.vertical.bottom = collapsedBorder->vertical.bottom / 2;
     79    else {
     80        auto adjacentBorderTop = computedBorder(m_grid.slot({ cellPosition.column, cellPosition.row + 1 })->cell().box()).vertical.top;
     81        border.vertical.bottom = std::max(border.vertical.bottom, adjacentBorderTop) / 2;
     82    }
     83    return border;
     84}
     85
    4986Optional<LayoutUnit> TableFormattingContext::Geometry::computedColumnWidth(const ContainerBox& columnBox) const
    5087{
     
    6198    auto& style = cellBox.style();
    6299
    63     auto computedHorizontalBorder = [&] {
    64         auto leftBorderWidth = LayoutUnit { style.borderLeftWidth() };
    65         auto rightBorderWidth = LayoutUnit { style.borderRightWidth() };
    66         if (auto collapsedBorder = m_grid.collapsedBorder()) {
    67             auto cellPosition = cell.position();
    68             if (!cellPosition.column)
    69                 leftBorderWidth = collapsedBorder->horizontal.left / 2;
    70             if (cellPosition.column == m_grid.columns().size() - 1)
    71                 rightBorderWidth = collapsedBorder->horizontal.right / 2;
    72         }
    73         return leftBorderWidth + rightBorderWidth;
    74     };
    75 
    76100    auto computedIntrinsicWidthConstraints = [&] {
    77101        // Even fixed width cells expand to their minimum content width
     
    80104        if (cellBox.hasChild())
    81105            intrinsicWidthConstraints = LayoutContext::createFormattingContext(cellBox, layoutState())->computedIntrinsicWidthConstraints();
    82         if (auto width = fixedValue(cellBox.style().logicalWidth()))
     106        if (auto width = fixedValue(style.logicalWidth()))
    83107            return FormattingContext::IntrinsicWidthConstraints { std::max(intrinsicWidthConstraints.minimum, *width), *width };
    84108        return intrinsicWidthConstraints;
     
    87111    auto intrinsicWidthConstraints = constrainByMinMaxWidth(cellBox, computedIntrinsicWidthConstraints());
    88112    // Expand with border
    89     intrinsicWidthConstraints.expand(computedHorizontalBorder());
     113    intrinsicWidthConstraints.expand(computedCellBorder(cell).horizontal.width());
    90114    // padding
    91115    intrinsicWidthConstraints.expand(fixedValue(style.paddingLeft()).valueOr(0) + fixedValue(style.paddingRight()).valueOr(0));
Note: See TracChangeset for help on using the changeset viewer.