Changeset 263640 in webkit
- Timestamp:
- Jun 28, 2020 5:03:24 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r263638 r263640 1 2020-06-28 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Adjust table content vertical position to match vertical-align 4 https://bugs.webkit.org/show_bug.cgi?id=213692 5 6 Reviewed by Antti Koivisto. 7 8 * fast/layoutformattingcontext/table-cell-vertical-alignment-simple-expected.html: Added. 9 * fast/layoutformattingcontext/table-cell-vertical-alignment-simple.html: Added. 10 1 11 2020-06-28 Alexey Shvayka <shvaikalesh@gmail.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r263639 r263640 1 2020-06-28 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][TFC] Adjust table content vertical position to match vertical-align 4 https://bugs.webkit.org/show_bug.cgi?id=213692 5 6 Reviewed by Antti Koivisto. 7 8 Child boxes (and runs) are always in the coordinate system of the containing block's border box. 9 The content box (where the child content lives) is inside the padding box, which is inside the border box. 10 In order to compute the child box top/left position, we need to know both the padding and the border offsets. 11 12 <div style="border: 2px solid green; padding-top: 10px;"><div></div></div> 13 The inner div's top left position is at [12px, 2px] (let's ignore margin collapsing for now). 14 15 Normally by the time we start positioning the child content, we already have computed borders and paddings for the containing block. 16 This is different with table cells where the final padding offset depends on the content height as we use 17 the padding box to vertically align the table cell content. 18 19 Let's adjust the child boxes and runs to match the new content box position. 20 21 Test: fast/layoutformattingcontext/table-cell-vertical-alignment-simple.html 22 23 * layout/displaytree/DisplayLineBox.h: 24 (WebCore::Display::LineBox::moveVertically): 25 * layout/displaytree/DisplayRun.h: 26 (WebCore::Display::Run::moveVertically): 27 * layout/tableformatting/TableFormattingContext.cpp: 28 (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells): 29 1 30 2020-06-28 Zalan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h
r255257 r263640 62 62 InlineLayoutUnit height() const { return m_rect.height(); } 63 63 64 void moveVertically(InlineLayoutUnit); 65 64 66 const Baseline& baseline() const { return m_baseline; } 65 67 // Baseline offset from line top. Note that offset does not necessarily equal to ascent. … … 106 108 } 107 109 110 inline void LineBox::moveVertically(InlineLayoutUnit offset) 111 { 112 m_rect.moveVertically(offset); 113 m_inkOverflow.moveVertically(offset); 114 } 115 108 116 } 109 117 } -
trunk/Source/WebCore/layout/displaytree/DisplayRun.h
r257841 r263640 79 79 InlineLayoutUnit height() const { return m_rect.height(); } 80 80 81 void moveVertically(InlineLayoutUnit); 82 81 83 Optional<TextContent>& textContent() { return m_textContent; } 82 84 const Optional<TextContent>& textContent() const { return m_textContent; } … … 126 128 } 127 129 130 inline void Run::moveVertically(InlineLayoutUnit offset) 131 { 132 m_rect.moveVertically(offset); 133 m_inkOverflow.moveVertically(offset); 134 } 135 128 136 } 129 137 } -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r262795 r263640 114 114 break; 115 115 } 116 if (intrinsicPaddingTop && cellBox.hasInFlowOrFloatingChild()) { 117 auto adjustCellContentWithInstrinsicPaddingBefore = [&] { 118 // Child boxes (and runs) are always in the coordinate system of the containing block's border box. 119 // The content box (where the child content lives) is inside the padding box, which is inside the border box. 120 // In order to compute the child box top/left position, we need to know both the padding and the border offsets. 121 // Normally by the time we start positioning the child content, we already have computed borders and paddings for the containing block. 122 // This is different with table cells where the final padding offset depends on the content height as we use 123 // the padding box to vertically align the table cell content. 124 auto& formattingState = layoutState().establishedFormattingState(cellBox); 125 for (auto* child = cellBox.firstInFlowOrFloatingChild(); child; child = child->nextInFlowOrFloatingSibling()) { 126 if (child->isAnonymous() || child->isLineBreakBox()) 127 continue; 128 formattingState.displayBox(*child).moveVertically(intrinsicPaddingTop); 129 } 130 if (cellBox.establishesInlineFormattingContext()) { 131 auto& displayContent = layoutState().establishedInlineFormattingState(cellBox).ensureDisplayInlineContent(); 132 for (auto& run : displayContent.runs) 133 run.moveVertically(intrinsicPaddingTop); 134 for (auto& lineBox : displayContent.lineBoxes) 135 lineBox.moveVertically(intrinsicPaddingTop); 136 } 137 }; 138 adjustCellContentWithInstrinsicPaddingBefore(); 139 } 116 140 cellDisplayBox.setVerticalPadding({ paddingTop + intrinsicPaddingTop, paddingBottom + intrinsicPaddingBottom }); 117 141 }
Note: See TracChangeset
for help on using the changeset viewer.