Changeset 276201 in webkit
- Timestamp:
- Apr 17, 2021, 8:38:31 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
rendering/line/BreakingContext.h (modified) (12 diffs)
-
rendering/line/TrailingObjects.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r276200 r276201 1 2021-04-17 Zalan Bujtas <zalan@apple.com> 2 3 [Cleanup] BreakingContext::handleText should consistently use the cached renderer 4 https://bugs.webkit.org/show_bug.cgi?id=224711 5 6 Reviewed by Antti Koivisto. 7 8 Since this function is not supposed to increment the renderer, let's replace m_current.renderer() with "renderer". 9 10 * rendering/line/BreakingContext.h: 11 (WebCore::BreakingContext::handleText): 12 * rendering/line/TrailingObjects.h: 13 (WebCore::TrailingObjects::setTrailingWhitespace): 14 1 15 2021-04-17 Zalan Bujtas <zalan@apple.com> 2 16 -
trunk/Source/WebCore/rendering/line/BreakingContext.h
r276200 r276201 679 679 commitLineBreakAtCurrentWidth(renderer); 680 680 681 if (renderer.style().hasTextCombine() && is<RenderCombineText>( *m_current.renderer())) {682 auto& combineRenderer = downcast<RenderCombineText>( *m_current.renderer());681 if (renderer.style().hasTextCombine() && is<RenderCombineText>(renderer)) { 682 auto& combineRenderer = downcast<RenderCombineText>(renderer); 683 683 combineRenderer.combineTextIfNeeded(); 684 684 // The length of the renderer's text may have changed. Increment stale iterator positions … … 703 703 float wordSpacingForWordMeasurement = 0; 704 704 705 float wrapWidthOffset = m_width.uncommittedWidth() + inlineLogicalWidth( *m_current.renderer(), !m_appliedStartWidth, true);705 float wrapWidthOffset = m_width.uncommittedWidth() + inlineLogicalWidth(renderer, !m_appliedStartWidth, true); 706 706 float wrapW = wrapWidthOffset; 707 707 float charWidth = 0; … … 746 746 WordTrailingSpace wordTrailingSpace(style, !textLayout); 747 747 for (; m_current.offset() < renderer.text().length(); m_current.fastIncrementInTextNode()) { 748 ASSERT(&renderer == m_current.renderer()); 748 749 bool previousCharacterIsSpace = m_currentCharacterIsSpace; 749 750 bool previousCharacterIsWS = m_currentCharacterIsWS; … … 759 760 } 760 761 761 if (canHangPunctuationAtStart && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !inlineLogicalWidth( *m_current.renderer(), true, false)) {762 if (canHangPunctuationAtStart && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !inlineLogicalWidth(renderer, true, false)) { 762 763 m_width.addUncommittedWidth(-renderer.hangablePunctuationStartWidth(m_current.offset())); 763 764 canHangPunctuationAtStart = false; 764 765 } 765 766 766 if (canHangPunctuationAtEnd && !m_nextObject && (int)m_current.offset() == endPunctuationIndex && !inlineLogicalWidth( *m_current.renderer(), false, true)) {767 if (canHangPunctuationAtEnd && !m_nextObject && (int)m_current.offset() == endPunctuationIndex && !inlineLogicalWidth(renderer, false, true)) { 767 768 m_width.addUncommittedWidth(-renderer.hangablePunctuationEndWidth(endPunctuationIndex)); 768 769 canHangPunctuationAtEnd = false; … … 797 798 // the stop/comma at the end. First measure including the comma. 798 799 m_hangsAtEnd = false; 799 float inlineStartWidth = !m_appliedStartWidth ? inlineLogicalWidth( *m_current.renderer(), true, false) : 0_lu;800 float inlineStartWidth = !m_appliedStartWidth ? inlineLogicalWidth(renderer, true, false) : 0_lu; 800 801 float widthIncludingComma = computeAdditionalBetweenWordsWidth(renderer, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset() + 1) + inlineStartWidth; 801 802 m_width.addUncommittedWidth(widthIncludingComma); … … 819 820 wordSpacingForWordMeasurement = 0; 820 821 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in any of the ignored spaces. 821 m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(0, m_current.renderer(), m_current.offset()));822 m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(0, &renderer, m_current.offset())); 822 823 stoppedIgnoringSpaces = true; 823 824 } else { … … 837 838 838 839 if (!m_appliedStartWidth) { 839 float inlineStartWidth = inlineLogicalWidth( *m_current.renderer(), true, false);840 float inlineStartWidth = inlineLogicalWidth(renderer, true, false); 840 841 m_width.addUncommittedWidth(inlineStartWidth); 841 842 m_appliedStartWidth = true; … … 898 899 // We might just be right after the soft-hyphen 899 900 lastBreakingPosition = m_current.nextBreakablePosition().value(); 900 rendererAtBreakingPosition = m_current.renderer();901 rendererAtBreakingPosition = &renderer; 901 902 } 902 903 if (lastBreakingPosition) { … … 997 998 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurements.last().width) ? wordSpacing : 0; 998 999 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in any of the ignored spaces. 999 m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(nullptr, m_current.renderer(), m_current.offset()));1000 m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(nullptr, &renderer, m_current.offset())); 1000 1001 } 1001 1002 if (m_hangsAtEnd && !renderer.isHangableStopOrComma(c)) … … 1010 1011 1011 1012 if (m_currentCharacterIsSpace && !previousCharacterIsSpace) { 1012 m_startOfIgnoredSpaces.setRenderer( m_current.renderer());1013 m_startOfIgnoredSpaces.setRenderer(&renderer); 1013 1014 m_startOfIgnoredSpaces.setOffset(m_current.offset()); 1014 1015 // Spaces after right-aligned text and before a line-break get collapsed away completely so that the trailing … … 1029 1030 1030 1031 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && !m_ignoringSpaces) 1031 m_trailingObjects.setTrailingWhitespace( downcast<RenderText>(m_current.renderer()));1032 m_trailingObjects.setTrailingWhitespace(renderer); 1032 1033 else if (!m_currentStyle->collapseWhiteSpace() || !m_currentCharacterIsSpace) 1033 1034 m_trailingObjects.clear(); … … 1050 1051 additionalTempWidth += lastSpaceWordSpacing; 1051 1052 1052 float inlineLogicalTempWidth = inlineLogicalWidth( *m_current.renderer(), !m_appliedStartWidth, m_includeEndWidth);1053 float inlineLogicalTempWidth = inlineLogicalWidth(renderer, !m_appliedStartWidth, m_includeEndWidth); 1053 1054 m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth); 1054 1055 if (m_hangsAtEnd && inlineLogicalTempWidth) -
trunk/Source/WebCore/rendering/line/TrailingObjects.h
r208668 r276201 48 48 { } 49 49 50 void setTrailingWhitespace(RenderText *whitespace)50 void setTrailingWhitespace(RenderText& whitespace) 51 51 { 52 ASSERT(whitespace); 53 m_whitespace = whitespace; 52 m_whitespace = &whitespace; 54 53 } 55 54
Note:
See TracChangeset
for help on using the changeset viewer.