Changeset 246484 in webkit
- Timestamp:
- Jun 16, 2019, 1:41:59 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContextLineLayout.cpp (modified) (3 diffs)
-
layout/inlineformatting/InlineLine.cpp (modified) (5 diffs)
-
layout/inlineformatting/InlineLine.h (modified) (4 diffs)
-
layout/inlineformatting/InlineLineBox.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r246483 r246484 1 2019-06-16 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Decouple baseline ascent/descent and baseline offset. 4 https://bugs.webkit.org/show_bug.cgi?id=198901 5 <rdar://problem/51782393> 6 7 Reviewed by Antti Koivisto. 8 9 Baseline offset is the baseline's distance from the line's logical top -and it is not necessarily the same as the baseline's ascent. 10 It's easier to track the baseline and its top separately since certain properties only change one or the other. 11 12 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 13 (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const): 14 (WebCore::Layout::InlineFormattingContext::LineLayout::createDisplayRuns const): 15 * layout/inlineformatting/InlineLine.cpp: 16 (WebCore::Layout::Line::Line): 17 (WebCore::Layout::Line::close): 18 (WebCore::Layout::Line::adjustBaselineAndLineHeight): 19 (WebCore::Layout::Line::halfLeadingMetrics): 20 * layout/inlineformatting/InlineLine.h: 21 (WebCore::Layout::Line::Content::baselineOffset const): 22 (WebCore::Layout::Line::Content::setBaselineOffset): 23 (WebCore::Layout::Line::baselineOffset const): 24 * layout/inlineformatting/InlineLineBox.h: 25 (WebCore::Layout::LineBox::baselineOffset const): 26 (WebCore::Layout::LineBox::LineBox): 27 1 28 2019-06-16 Zalan Bujtas <zalan@apple.com> 2 29 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r246483 r246484 131 131 if (lineInput.skipVerticalAligment == LineInput::SkipVerticalAligment::No) { 132 132 auto mimimumLineHeight = m_formattingRoot.style().computedLineHeight(); 133 auto initialBaselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight). offset;133 auto initialBaselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).ascent; 134 134 line = std::make_unique<Line>(layoutState(), lineInput.horizontalConstraint.logicalTopLeft, lineInput.horizontalConstraint.availableLogicalWidth, mimimumLineHeight, initialBaselineOffset); 135 135 } else … … 316 316 // Spec tells us to create a zero height, empty line box. 317 317 auto lineBox = Display::Rect { lineContent.logicalTop(), lineContent.logicalLeft(), 0 , 0 }; 318 m_formattingState.addLineBox({ lineBox, lineContent.baseline() });318 m_formattingState.addLineBox({ lineBox, lineContent.baseline(), lineContent.baselineOffset() }); 319 319 return; 320 320 } … … 407 407 } 408 408 // FIXME linebox needs to be ajusted after content alignment. 409 m_formattingState.addLineBox({ lineBox, lineContent.baseline() });409 m_formattingState.addLineBox({ lineBox, lineContent.baseline(), lineContent.baselineOffset() }); 410 410 alignRuns(m_formattingRoot.style().textAlign(), previousLineLastRunIndex.valueOr(-1) + 1, widthConstraint - lineContent.logicalWidth()); 411 411 } -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r246481 r246484 58 58 , m_content(std::make_unique<Line::Content>()) 59 59 , m_logicalTopLeft(topLeft) 60 , m_baseline({ baselineOffset, minimumHeight - baselineOffset , { }})60 , m_baseline({ baselineOffset, minimumHeight - baselineOffset }) 61 61 , m_contentLogicalHeight(minimumHeight) 62 62 , m_lineLogicalWidth(availableWidth) … … 98 98 if (isVisuallyEmpty()) { 99 99 m_baseline = { }; 100 m_baselineTop = { }; 100 101 m_contentLogicalHeight = { }; 101 102 } … … 150 151 m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() }); 151 152 m_content->setBaseline(m_baseline); 153 m_content->setBaselineOffset(baselineOffset()); 152 154 return WTFMove(m_content); 153 155 } … … 337 339 case VerticalAlign::Bottom: 338 340 if (m_contentLogicalHeight < runHeight) { 339 m_baseline .offset = m_baseline.offset + (runHeight - m_contentLogicalHeight);341 m_baselineTop += runHeight - m_contentLogicalHeight; 340 342 m_contentLogicalHeight = runHeight; 341 343 } … … 380 382 auto adjustedAscent = std::max((ascent + leading / 2).floor(), 0); 381 383 auto adjustedDescent = std::max((descent + leading / 2).ceil(), 0); 382 return { adjustedAscent, adjustedDescent , adjustedAscent};384 return { adjustedAscent, adjustedDescent }; 383 385 } 384 386 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r246478 r246484 69 69 LayoutUnit logicalHeight() const { return m_logicalRect.height(); } 70 70 LineBox::Baseline baseline() const { return m_baseline; } 71 LayoutUnit baselineOffset() const { return m_baselineOffset; } 71 72 72 73 private: … … 75 76 void setLogicalRect(const Display::Rect& logicalRect) { m_logicalRect = logicalRect; } 76 77 void setBaseline(LineBox::Baseline baseline) { m_baseline = baseline; } 78 void setBaselineOffset(LayoutUnit baselineOffset) { m_baselineOffset = baselineOffset; } 77 79 Runs& runs() { return m_runs; } 78 80 79 81 Display::Rect m_logicalRect; 80 82 LineBox::Baseline m_baseline; 83 LayoutUnit m_baselineOffset; 81 84 Runs m_runs; 82 85 }; … … 113 116 LayoutUnit contentLogicalWidth() const { return m_contentLogicalWidth; } 114 117 LayoutUnit baselineAlignedContentHeight() const { return m_baseline.ascent + m_baseline.descent; } 115 LayoutUnit baselineOffset() const { return m_baseline. offset; }118 LayoutUnit baselineOffset() const { return m_baseline.ascent + m_baselineTop; } 116 119 117 120 void appendNonBreakableSpace(const InlineItem&, const Display::Rect& logicalRect); … … 130 133 131 134 LineBox::Baseline m_baseline; 135 LayoutUnit m_baselineTop; 136 132 137 LayoutUnit m_contentLogicalHeight; 133 138 LayoutUnit m_lineLogicalWidth; -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h
r246234 r246484 38 38 LayoutUnit ascent; 39 39 LayoutUnit descent; 40 LayoutUnit offset; // baseline offset from line logical top. Note that offset does not necessarily equal to ascent.41 40 }; 42 LineBox(Display::Rect, const Baseline& );41 LineBox(Display::Rect, const Baseline&, LayoutUnit baselineOffset); 43 42 44 43 LayoutPoint logicalTopLeft() const { return m_rect.topLeft(); } … … 53 52 54 53 Baseline baseline() const { return m_baseline; } 54 // Baseline offset from line logical top. Note that offset does not necessarily equal to ascent. 55 // 56 // ------------------- line logical top 57 // ^ 58 // | 59 // ^ | baseline offset 60 // | | 61 // | ascent | 62 // | | 63 // v v 64 // ----------------- baseline 65 // ^ 66 // | descent 67 // v 68 // ------------------- line logical bottom 69 LayoutUnit baselineOffset() const { return m_baselineOffset; } 55 70 56 71 private: 57 72 Display::Rect m_rect; 58 73 Baseline m_baseline; 74 LayoutUnit m_baselineOffset; 59 75 }; 60 76 61 inline LineBox::LineBox(Display::Rect rect, const Baseline& baseline )77 inline LineBox::LineBox(Display::Rect rect, const Baseline& baseline, LayoutUnit baselineOffset) 62 78 : m_rect(rect) 63 79 , m_baseline(baseline) 80 , m_baselineOffset(baselineOffset) 64 81 { 65 82 }
Note:
See TracChangeset
for help on using the changeset viewer.