Changeset 263639 in webkit


Ignore:
Timestamp:
Jun 28, 2020 5:00:58 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][Painting] Use the table section as the paint container for table cells
https://bugs.webkit.org/show_bug.cgi?id=213693

Reviewed by Antti Koivisto.

The cell's containing block is the table box (skipping both the row and the section),
but it's positioned relative to the table section.

Let's skip the row and go right to the section box when painting the cells.

  • layout/displaytree/DisplayPainter.cpp:

(WebCore::Display::absoluteDisplayBox):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r263638 r263639  
     12020-06-28  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][Painting] Use the table section as the paint container for table cells
     4        https://bugs.webkit.org/show_bug.cgi?id=213693
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The cell's containing block is the table box (skipping both the row and the section),
     9        but it's positioned relative to the table section.
     10
     11        Let's skip the row and go right to the section box when painting the cells.
     12
     13        * layout/displaytree/DisplayPainter.cpp:
     14        (WebCore::Display::absoluteDisplayBox):
     15
    1162020-06-28  Alexey Shvayka  <shvaikalesh@gmail.com>
    217
  • trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp

    r258904 r263639  
    142142}
    143143
    144 static Box absoluteDisplayBox(const Layout::LayoutState& layoutState, const Layout::Box& layoutBox)
     144static Box absoluteDisplayBox(const Layout::LayoutState& layoutState, const Layout::Box& layoutBoxToPaint)
    145145{
    146146    // Should never really happen but table code is way too incomplete.
    147     if (!layoutState.hasDisplayBox(layoutBox))
     147    if (!layoutState.hasDisplayBox(layoutBoxToPaint))
    148148        return { };
    149     if (is<Layout::InitialContainingBlock>(layoutBox))
    150         return layoutState.displayBoxForLayoutBox(layoutBox);
    151 
    152     auto absoluteBox = Box { layoutState.displayBoxForLayoutBox(layoutBox) };
    153     for (auto* containingBlock = &layoutBox.containingBlock(); !is<Layout::InitialContainingBlock>(*containingBlock); containingBlock = &containingBlock->containingBlock())
    154         absoluteBox.moveBy(layoutState.displayBoxForLayoutBox(*containingBlock).topLeft());
     149    if (is<Layout::InitialContainingBlock>(layoutBoxToPaint))
     150        return layoutState.displayBoxForLayoutBox(layoutBoxToPaint);
     151
     152    auto paintContainer = [&] (const auto& layoutBox) {
     153        if (layoutBox.isTableCell()) {
     154            // The table cell's containing block is the table box (skipping both the row and the section), but it's positioned relative to the table section.
     155            // Let's skip the row and go right to the section box.
     156            return &layoutBox.parent().parent();
     157        }
     158        return &layoutBox.containingBlock();
     159    };
     160    auto absoluteBox = Box { layoutState.displayBoxForLayoutBox(layoutBoxToPaint) };
     161    for (auto* container = paintContainer(layoutBoxToPaint); !is<Layout::InitialContainingBlock>(container); container = paintContainer(*container))
     162        absoluteBox.moveBy(layoutState.displayBoxForLayoutBox(*container).topLeft());
    155163    return absoluteBox;
    156164}
Note: See TracChangeset for help on using the changeset viewer.