Changeset 269989 in webkit
- Timestamp:
- Nov 18, 2020 2:42:20 PM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269984 r269989 1 2020-11-18 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][Integration] Line::enclosingRect should only include the border box (exclude vertical margins) 4 https://bugs.webkit.org/show_bug.cgi?id=219106 5 6 Reviewed by Antti Koivisto. 7 8 LineIteratorPath::top/bottom expects border box enclosing values (and not margin box values). 9 (and while we are here, let's just compute the vertical enclosing values and ignore the horizontal aspect of it as the line box always 10 encloses all the inline level boxes on the line anyway) 11 12 * layout/inlineformatting/InlineFormattingContext.cpp: 13 (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent): 14 * layout/inlineformatting/InlineLineBox.cpp: 15 (WebCore::Layout::LineBox::logicalMarginRectForInlineLevelBox const): 16 (WebCore::Layout::LineBox::logicalRectForInlineLevelBox const): Deleted. 17 * layout/inlineformatting/InlineLineBox.h: 18 * layout/integration/LayoutIntegrationInlineContentBuilder.cpp: 19 (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const): 20 * layout/integration/LayoutIntegrationLine.h: 21 (WebCore::LayoutIntegration::Line::Line): 22 (WebCore::LayoutIntegration::Line::enclosingContentTop const): 23 (WebCore::LayoutIntegration::Line::enclosingContentBottom const): 24 (WebCore::LayoutIntegration::Line::enclosingContentRect const): Deleted. 25 * layout/integration/LayoutIntegrationLineIteratorModernPath.h: 26 (WebCore::LayoutIntegration::LineIteratorModernPath::top const): 27 (WebCore::LayoutIntegration::LineIteratorModernPath::bottom const): 28 * layout/integration/LayoutIntegrationPagination.cpp: 29 (WebCore::LayoutIntegration::makeAdjustedContent): 30 * layout/integration/LayoutIntegrationRunIteratorModernPath.h: 31 (WebCore::LayoutIntegration::RunIteratorModernPath::selectionRect const): 32 * layout/layouttree/LayoutTreeBuilder.cpp: 33 (WebCore::Layout::showInlineTreeAndRuns): 34 1 35 2020-11-18 Antoine Quint <graouts@webkit.org> 2 36 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r269571 r269989 439 439 formattingState.addLineRun({ lineIndex, lineRun.layoutBox(), lineBox.logicalRectForTextRun(lineRun), lineRun.expansion(), lineRun.textContent() }); 440 440 else if (lineRun.isBox()) 441 formattingState.addLineRun({ lineIndex, lineRun.layoutBox(), lineBox.logical RectForInlineLevelBox(lineRun.layoutBox()), lineRun.expansion(), { } });441 formattingState.addLineRun({ lineIndex, lineRun.layoutBox(), lineBox.logicalMarginRectForInlineLevelBox(lineRun.layoutBox()), lineRun.expansion(), { } }); 442 442 } 443 443 }; … … 456 456 // Inline box coordinates are relative to the line box. 457 457 // Let's convert top/left relative to the formatting context root. 458 auto logicalRect = lineBox.logical RectForInlineLevelBox(layoutBox);458 auto logicalRect = lineBox.logicalMarginRectForInlineLevelBox(layoutBox); 459 459 // Inline box height includes the margin box. Let's account for that. 460 460 auto borderBoxLogicalTopLeft = lineLogicalRect.topLeft(); -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp
r269912 r269989 111 111 } 112 112 113 InlineRect LineBox::logical RectForInlineLevelBox(const Box& layoutBox) const113 InlineRect LineBox::logicalMarginRectForInlineLevelBox(const Box& layoutBox) const 114 114 { 115 115 auto* inlineBox = &inlineLevelBoxForLayoutBox(layoutBox); -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h
r269912 r269989 142 142 143 143 InlineRect logicalRectForTextRun(const Line::Run&) const; 144 InlineRect logical RectForInlineLevelBox(const Box&) const;144 InlineRect logicalMarginRectForInlineLevelBox(const Box&) const; 145 145 146 146 auto inlineLevelBoxList() const { return m_inlineLevelBoxRectMap.values(); } -
trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp
r269817 r269989 318 318 auto runCount = runIndex - firstRunIndex; 319 319 auto lineRect = FloatRect { line.logicalRect() }; 320 auto enclosing ContentRect= [&] {320 auto enclosingTopAndBottom = [&] { 321 321 // Let's (vertically)enclose all the inline level boxes. 322 322 // This mostly matches 'lineRect', unless line-height triggers line box overflow (not to be confused with ink or scroll overflow). 323 auto enclosingRect = FloatRect { lineRect.location(), lineBoxLogicalSize }; 323 auto enclosingTop = Optional<float> { }; 324 auto enclosingBottom = Optional<float> { }; 324 325 auto& lineBox = lineBoxes[lineIndex]; 325 326 for (auto& inlineLevelBox : lineBox.inlineLevelBoxList()) { 326 auto inlineLevelBoxLogicalRect = lineBox.logicalRectForInlineLevelBox(inlineLevelBox->layoutBox()); 327 // inlineLevelBoxLogicalRect is relative to the line. 328 inlineLevelBoxLogicalRect.moveBy(lineRect.location()); 329 enclosingRect.setY(std::min(enclosingRect.y(), inlineLevelBoxLogicalRect.top())); 330 enclosingRect.shiftMaxYEdgeTo(std::max(enclosingRect.maxY(), inlineLevelBoxLogicalRect.bottom())); 331 } 332 return enclosingRect; 327 auto& layoutBox = inlineLevelBox->layoutBox(); 328 auto inlineLevelBoxLogicalRect = lineBox.logicalMarginRectForInlineLevelBox(layoutBox); 329 // inlineLevelBoxLogicalRect encloses the margin box, but we need border box for the display line. 330 auto& geometry = m_layoutState.geometryForBox(layoutBox); 331 inlineLevelBoxLogicalRect.expandVertically(-std::max(0_lu, geometry.marginBefore() + geometry.marginAfter())); 332 inlineLevelBoxLogicalRect.moveVertically(std::max(0_lu, geometry.marginBefore())); 333 334 enclosingTop = std::min(enclosingTop.valueOr(inlineLevelBoxLogicalRect.top()), inlineLevelBoxLogicalRect.top()); 335 enclosingBottom = std::max(enclosingBottom.valueOr(inlineLevelBoxLogicalRect.bottom()), inlineLevelBoxLogicalRect.bottom()); 336 } 337 // There's always at least one inline level box, the root inline box. 338 ASSERT(enclosingBottom && enclosingTop); 339 // inline boxes are relative to the line, let's make them relative to the root's content box. 340 return Line::EnclosingTopAndBottom { lineRect.y() + *enclosingTop, lineRect.y() + *enclosingBottom }; 333 341 }(); 334 342 if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition) { 335 343 lineRect.setY(roundToInt(lineRect.y())); 336 enclosingContentRect.setY(roundToInt(enclosingContentRect.y())); 344 enclosingTopAndBottom.top = roundToInt(enclosingTopAndBottom.top); 345 enclosingTopAndBottom.bottom = roundToInt(enclosingTopAndBottom.bottom); 337 346 } 338 inlineContent.lines.append({ firstRunIndex, runCount, lineRect, lineBoxLogicalSize.width(), enclosing ContentRect, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.horizontalAlignmentOffset() });347 inlineContent.lines.append({ firstRunIndex, runCount, lineRect, lineBoxLogicalSize.width(), enclosingTopAndBottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.horizontalAlignmentOffset() }); 339 348 } 340 349 } -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h
r269571 r269989 36 36 WTF_MAKE_FAST_ALLOCATED; 37 37 public: 38 Line(size_t firstRunIndex, size_t runCount, const FloatRect& lineRect, float lineBoxWidth, const FloatRect& enclosingContentRect, const FloatRect& scrollableOverflow, const FloatRect& inkOverflow, float baseline, float horizontalAlignmentOffset) 38 struct EnclosingTopAndBottom { 39 // This values encloses the root inline box and any other inline level box's border box. 40 float top { 0 }; 41 float bottom { 0 }; 42 }; 43 Line(size_t firstRunIndex, size_t runCount, const FloatRect& lineRect, float lineBoxWidth, EnclosingTopAndBottom enclosingTopAndBottom, const FloatRect& scrollableOverflow, const FloatRect& inkOverflow, float baseline, float horizontalAlignmentOffset) 39 44 : m_firstRunIndex(firstRunIndex) 40 45 , m_runCount(runCount) 41 46 , m_lineRect(lineRect) 42 47 , m_lineBoxWidth(lineBoxWidth) 43 , m_enclosing ContentRect(enclosingContentRect)48 , m_enclosingTopAndBottom(enclosingTopAndBottom) 44 49 , m_scrollableOverflow(scrollableOverflow) 45 50 , m_inkOverflow(inkOverflow) … … 53 58 const FloatRect& rect() const { return m_lineRect; } 54 59 float lineBoxWidth() const { return m_lineBoxWidth; } 55 const FloatRect& enclosingContentRect() const { return m_enclosingContentRect; } 60 float enclosingContentTop() const { return m_enclosingTopAndBottom.top; } 61 float enclosingContentBottom() const { return m_enclosingTopAndBottom.bottom; } 56 62 const FloatRect& scrollableOverflow() const { return m_scrollableOverflow; } 57 63 const FloatRect& inkOverflow() const { return m_inkOverflow; } … … 64 70 // Line is always as tall as the line box is. However they may differ in width. 65 71 // While line box encloses all the inline level boxes on the line horizontally, the line itself may be shorter (and trigger horizontal overflow). 66 // Enclosing content rect includes all inline level boxes both vertically and horizontally. In certain cases (see line-height property)72 // Enclosing top and bottom includes all inline level boxes (border box) vertically. In certain cases (see line-height property) 67 73 // the line (and the line box) is not as tall as the inline level boxes on the line. 68 74 FloatRect m_lineRect; 69 75 float m_lineBoxWidth { 0 }; 70 FloatRect m_enclosingContentRect;76 EnclosingTopAndBottom m_enclosingTopAndBottom; 71 77 FloatRect m_scrollableOverflow; 72 78 FloatRect m_inkOverflow; -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h
r269916 r269989 50 50 LineIteratorModernPath& operator=(LineIteratorModernPath&&) = default; 51 51 52 LayoutUnit top() const { return LayoutUnit::fromFloatRound(line().enclosingContent Rect().y()); }53 LayoutUnit bottom() const { return LayoutUnit::fromFloatRound(line().enclosingContent Rect().maxY()); }52 LayoutUnit top() const { return LayoutUnit::fromFloatRound(line().enclosingContentTop()); } 53 LayoutUnit bottom() const { return LayoutUnit::fromFloatRound(line().enclosingContentBottom()); } 54 54 LayoutUnit lineBoxTop() const { return LayoutUnit::fromFloatRound(line().rect().y()); } 55 55 LayoutUnit lineBoxBottom() const { return LayoutUnit::fromFloatRound(line().rect().maxY()); } -
trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp
r269571 r269989 132 132 moveVertically(line.rect(), offset), 133 133 line.rect().width(), 134 moveVertically(line.enclosingContentRect(), offset),134 { line.enclosingContentTop() + offset, line.enclosingContentBottom() + offset }, 135 135 moveVertically(line.scrollableOverflow(), offset), 136 136 moveVertically(line.inkOverflow(), offset), -
trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h
r269916 r269989 118 118 119 119 // FIXME: These should share implementation with the line iterator. 120 auto selectionTop = LayoutUnit::fromFloatRound(line().enclosingContent Rect().y());121 auto selectionHeight = LayoutUnit::fromFloatRound(line().enclosingContent Rect().height());120 auto selectionTop = LayoutUnit::fromFloatRound(line().enclosingContentTop()); 121 auto selectionHeight = LayoutUnit::fromFloatRound(line().enclosingContentBottom() - line().enclosingContentTop()); 122 122 123 123 LayoutRect selectionRect { logicalLeft, selectionTop, logicalWidth, selectionHeight }; -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r269298 r269989 416 416 else 417 417 stream << "Generic inline level box"; 418 auto logicalRect = lineBox.logical RectForInlineLevelBox(inlineLevelBox.layoutBox());418 auto logicalRect = lineBox.logicalMarginRectForInlineLevelBox(inlineLevelBox.layoutBox()); 419 419 stream 420 420 << " at (" << logicalRect.left() << "," << logicalRect.top() << ")"
Note: See TracChangeset
for help on using the changeset viewer.