Changeset 276200 in webkit
- Timestamp:
- Apr 17, 2021, 6:48:00 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
rendering/line/BreakingContext.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r276198 r276200 1 2021-04-17 Zalan Bujtas <zalan@apple.com> 2 3 [Cleanup] inlineLogicalWidth should take const RenderObject& 4 https://bugs.webkit.org/show_bug.cgi?id=224700 5 6 Reviewed by Antti Koivisto. 7 8 1. inlineLogicalWidth takes const RenderObject& now. 9 2. Both previousInFlowSibling and shouldAddBorderPaddingMargin moved to inlineLogicalWidth 10 11 * rendering/line/BreakingContext.h: 12 (WebCore::inlineLogicalWidth): 13 (WebCore::BreakingContext::handleOutOfFlowPositioned): 14 (WebCore::BreakingContext::handleEmptyInline): 15 (WebCore::BreakingContext::handleReplaced): 16 (WebCore::BreakingContext::handleText): 17 (WebCore::shouldAddBorderPaddingMargin): Deleted. 18 (WebCore::previousInFlowSibling): Deleted. 19 1 20 2021-04-17 Philippe Normand <pnormand@igalia.com> 2 21 -
trunk/Source/WebCore/rendering/line/BreakingContext.h
r276169 r276200 318 318 } 319 319 320 inline bool shouldAddBorderPaddingMargin(RenderObject* child) 321 { 322 if (!child) 323 return true; 324 // When deciding whether we're at the edge of an inline, adjacent collapsed whitespace is the same as no sibling at all. 325 if (is<RenderText>(*child) && !downcast<RenderText>(*child).text().length()) 326 return true; 320 inline LayoutUnit inlineLogicalWidth(const RenderObject& renderer, bool checkStartEdge = true, bool checkEndEdge = true) 321 { 322 auto previousInFlowSibling = [] (const auto& renderer) { 323 auto* previousSibling = renderer.previousSibling(); 324 for (; previousSibling && previousSibling->isOutOfFlowPositioned(); previousSibling = previousSibling->previousSibling()) { } 325 return previousSibling; 326 }; 327 328 auto shouldAddBorderPaddingMargin = [] (const auto& renderer) { 329 // When deciding whether we're at the edge of an inline, adjacent collapsed whitespace is the same as no sibling at all. 330 if (is<RenderText>(renderer) && !downcast<RenderText>(renderer).text().length()) 331 return true; 327 332 #if ENABLE(CSS_BOX_DECORATION_BREAK) 328 if (is<RenderLineBreak>(*child) && child->parent()->style().boxDecorationBreak() == BoxDecorationBreak::Clone)329 return true;333 if (is<RenderLineBreak>(renderer) && renderer.parent()->style().boxDecorationBreak() == BoxDecorationBreak::Clone) 334 return true; 330 335 #endif 331 return false; 332 } 333 334 inline RenderObject* previousInFlowSibling(RenderObject* child) 335 { 336 do { 337 child = child->previousSibling(); 338 } while (child && child->isOutOfFlowPositioned()); 339 return child; 340 } 341 342 inline LayoutUnit inlineLogicalWidth(RenderObject* child, bool checkStartEdge = true, bool checkEndEdge = true) 343 { 336 return false; 337 }; 338 344 339 unsigned lineDepth = 1; 345 LayoutUnit extraWidth; 346 RenderElement* parent = child->parent(); 340 auto extraWidth = LayoutUnit { }; 341 auto* parent = renderer.parent(); 342 auto* child = &renderer; 347 343 while (is<RenderInline>(*parent) && lineDepth++ < cMaxLineDepth) { 348 344 const auto& parentAsRenderInline = downcast<RenderInline>(*parent); 349 345 if (!isEmptyInline(parentAsRenderInline)) { 350 checkStartEdge = checkStartEdge && shouldAddBorderPaddingMargin(previousInFlowSibling(child)); 346 auto* previousSibling = previousInFlowSibling(*child); 347 checkStartEdge = checkStartEdge && (!previousSibling || shouldAddBorderPaddingMargin(*previousSibling)); 351 348 if (checkStartEdge) 352 349 extraWidth += borderPaddingMarginStart(parentAsRenderInline); 353 checkEndEdge = checkEndEdge && shouldAddBorderPaddingMargin(child->nextSibling()); 350 auto* nextSibling = child->nextSibling(); 351 checkEndEdge = checkEndEdge && (!nextSibling || shouldAddBorderPaddingMargin(*nextSibling)); 354 352 if (checkEndEdge) 355 353 extraWidth += borderPaddingMarginEnd(parentAsRenderInline); … … 359 357 child = parent; 360 358 parent = child->parent(); 359 ASSERT(parent); 361 360 } 362 361 return extraWidth; … … 384 383 positionedObjects.append(&box); 385 384 386 m_width.addUncommittedWidth(inlineLogicalWidth( &box));385 m_width.addUncommittedWidth(inlineLogicalWidth(box)); 387 386 // Reset prior line break context characters. 388 387 m_renderTextInfo.lineBreakIterator.resetPriorContext(); … … 459 458 } 460 459 461 float inlineWidth = inlineLogicalWidth( m_current.renderer()) + borderPaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox);460 float inlineWidth = inlineLogicalWidth(*m_current.renderer()) + borderPaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox); 462 461 m_width.addUncommittedWidth(inlineWidth); 463 462 if (m_hangsAtEnd && inlineWidth) … … 493 492 // Optimize for a common case. If we can't find whitespace after the list 494 493 // item, then this is all moot. 495 LayoutUnit replacedLogicalWidth = m_block.logicalWidthForChild(replacedBox) + m_block.marginStartForChild(replacedBox) + m_block.marginEndForChild(replacedBox) + inlineLogicalWidth( &replacedBox);494 LayoutUnit replacedLogicalWidth = m_block.logicalWidthForChild(replacedBox) + m_block.marginStartForChild(replacedBox) + m_block.marginEndForChild(replacedBox) + inlineLogicalWidth(replacedBox); 496 495 if (is<RenderListMarker>(replacedBox)) { 497 496 if (m_blockStyle.collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, &replacedBox, m_lineWhitespaceCollapsingState)) { … … 704 703 float wordSpacingForWordMeasurement = 0; 705 704 706 float wrapWidthOffset = m_width.uncommittedWidth() + inlineLogicalWidth( m_current.renderer(), !m_appliedStartWidth, true);705 float wrapWidthOffset = m_width.uncommittedWidth() + inlineLogicalWidth(*m_current.renderer(), !m_appliedStartWidth, true); 707 706 float wrapW = wrapWidthOffset; 708 707 float charWidth = 0; … … 760 759 } 761 760 762 if (canHangPunctuationAtStart && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !inlineLogicalWidth( m_current.renderer(), true, false)) {761 if (canHangPunctuationAtStart && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !inlineLogicalWidth(*m_current.renderer(), true, false)) { 763 762 m_width.addUncommittedWidth(-renderer.hangablePunctuationStartWidth(m_current.offset())); 764 763 canHangPunctuationAtStart = false; 765 764 } 766 765 767 if (canHangPunctuationAtEnd && !m_nextObject && (int)m_current.offset() == endPunctuationIndex && !inlineLogicalWidth( m_current.renderer(), false, true)) {766 if (canHangPunctuationAtEnd && !m_nextObject && (int)m_current.offset() == endPunctuationIndex && !inlineLogicalWidth(*m_current.renderer(), false, true)) { 768 767 m_width.addUncommittedWidth(-renderer.hangablePunctuationEndWidth(endPunctuationIndex)); 769 768 canHangPunctuationAtEnd = false; … … 798 797 // the stop/comma at the end. First measure including the comma. 799 798 m_hangsAtEnd = false; 800 float inlineStartWidth = !m_appliedStartWidth ? inlineLogicalWidth( m_current.renderer(), true, false) : 0_lu;799 float inlineStartWidth = !m_appliedStartWidth ? inlineLogicalWidth(*m_current.renderer(), true, false) : 0_lu; 801 800 float widthIncludingComma = computeAdditionalBetweenWordsWidth(renderer, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset() + 1) + inlineStartWidth; 802 801 m_width.addUncommittedWidth(widthIncludingComma); … … 838 837 839 838 if (!m_appliedStartWidth) { 840 float inlineStartWidth = inlineLogicalWidth( m_current.renderer(), true, false);839 float inlineStartWidth = inlineLogicalWidth(*m_current.renderer(), true, false); 841 840 m_width.addUncommittedWidth(inlineStartWidth); 842 841 m_appliedStartWidth = true; … … 1051 1050 additionalTempWidth += lastSpaceWordSpacing; 1052 1051 1053 float inlineLogicalTempWidth = inlineLogicalWidth( m_current.renderer(), !m_appliedStartWidth, m_includeEndWidth);1052 float inlineLogicalTempWidth = inlineLogicalWidth(*m_current.renderer(), !m_appliedStartWidth, m_includeEndWidth); 1054 1053 m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth); 1055 1054 if (m_hangsAtEnd && inlineLogicalTempWidth)
Note:
See TracChangeset
for help on using the changeset viewer.