Bug 259576

Summary: Set logical top and height of table rows and cells in the first layout pass.
Product: WebKit Reporter: Ahmad Saleem <ahmad.saleem792>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bfulgham, karlcow, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: BrowserCompat, InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ahmad Saleem 2023-07-27 13:58:09 PDT
Hi Team,

While going through Blink's commits, I came across another failing test in Safari Technology Preview 174:

Test Case: https://jsfiddle.net/vpxzfscu/

Blink Commit: https://chromium.googlesource.com/chromium/src.git/+/0f36142505fcc4bc9b2f3518649befd2b5cbc63f

WebKit Changes:

In 'void RenderTableRow::layout()':

.
.
 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell()) {
+        cell->setLogicalTop(logicalTop());
        if (!cell->needsLayout() && paginated && (layoutState->pageLogicalHeightChanged()
.
.

In 'void RenderTableSection::layout()'

.
.
const Vector<LayoutUnit>& columnPos = table()->columnPositions();
+    LayoutUnit rowLogicalTop;
    
    for (unsigned r = 0; r < m_grid.size(); ++r) {
        Row& row = m_grid[r].row;
.
.

and

 if (RenderTableRow* rowRenderer = m_grid[r].rowRenderer) {
            if (paginated) {
                rowRenderer->setLogicalTop(rowLogicalTop);
                if (rowRenderer->needsLayout())
                    rowRenderer->setChildNeedsLayout(MarkOnlyThis);
            }
            rowRenderer->layoutIfNeeded();
            if (paginated) {
                rowRenderer->setLogicalTop(LayoutUnit(logicalHeightForRow(*rowRenderer)));
                rowLogicalTop = rowRenderer->logicalBottom();
                rowLogicalTop += LayoutUnit(table()->vBorderSpacing());
            }
        }

and

int RenderTableSection::logicalHeightForRow(const RenderTableRow& rowObject) const
{
    unsigned rowIndex = rowObject.rowIndex();
    int logicalHeight = 0;
    const auto& row = m_grid[rowIndex].row;
    unsigned cols = row.size();
    for (unsigned colIndex = 0; colIndex < cols; colIndex++) {
        const auto& cellStruct = cellAt(rowIndex, colIndex);
        const auto* cell = cellStruct.primaryCell();
        if (!cell || cellStruct.inColSpan)
            continue;
        if (cell->rowSpan() == 1) {
            logicalHeight = std::max<int>(logicalHeight, cell->logicalHeightForRowSizing());
        }
        }
    return logicalHeight;
}

___

In 'Source/WebCore/rendering/RenderTableSection.h'

int logicalHeightForRow(const RenderTableRow&) const;

______

Just wanted to raise to get feedback, whether it is right approach or not.

Thanks!
Comment 1 Radar WebKit Bug Importer 2023-08-03 13:59:18 PDT
<rdar://problem/113356300>