Changeset 276169 in webkit
- Timestamp:
- Apr 16, 2021, 2:13:11 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
rendering/line/BreakingContext.h (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r276167 r276169 1 2021-04-16 Zalan Bujtas <zalan@apple.com> 2 3 Remove redundant renderObject in BreakingContext::handleText 4 https://bugs.webkit.org/show_bug.cgi?id=224682 5 6 Reviewed by Darin Adler. 7 8 * rendering/line/BreakingContext.h: 9 (WebCore::BreakingContext::handleText): 10 1 11 2021-04-16 Basuke Suzuki <basuke.suzuki@sony.com> 2 12 -
trunk/Source/WebCore/rendering/line/BreakingContext.h
r275130 r276169 672 672 m_appliedStartWidth = false; 673 673 674 RenderObject& renderObject = *m_current.renderer(); 675 RenderText& renderText = downcast<RenderText>(renderObject); 676 677 bool isSVGText = renderText.isSVGInlineText(); 674 auto& renderer = downcast<RenderText>(*m_current.renderer()); 675 bool isSVGText = renderer.isSVGInlineText(); 678 676 679 677 // If we have left a no-wrap inline and entered an autowrap inline while ignoring spaces 680 678 // then we need to mark the start of the autowrap inline as a potential linebreak now. 681 679 if (m_autoWrap && !RenderStyle::autoWrap(m_lastWS) && m_ignoringSpaces) 682 commitLineBreakAtCurrentWidth(render Text);683 684 if (render Text.style().hasTextCombine() && is<RenderCombineText>(*m_current.renderer())) {680 commitLineBreakAtCurrentWidth(renderer); 681 682 if (renderer.style().hasTextCombine() && is<RenderCombineText>(*m_current.renderer())) { 685 683 auto& combineRenderer = downcast<RenderCombineText>(*m_current.renderer()); 686 684 combineRenderer.combineTextIfNeeded(); … … 693 691 } 694 692 695 const RenderStyle& style = lineStyle(render Text, m_lineInfo);693 const RenderStyle& style = lineStyle(renderer, m_lineInfo); 696 694 const FontCascade& font = style.fontCascade(); 697 695 bool isFixedPitch = font.isFixedPitch(); … … 700 698 bool canHangPunctuationAtEnd = style.hangingPunctuation().contains(HangingPunctuation::Last); 701 699 bool canHangStopOrCommaAtLineEnd = style.hangingPunctuation().contains(HangingPunctuation::AllowEnd); 702 int endPunctuationIndex = canHangPunctuationAtEnd && m_collapseWhiteSpace ? render Text.lastCharacterIndexStrippingSpaces() : renderText.text().length() - 1;700 int endPunctuationIndex = canHangPunctuationAtEnd && m_collapseWhiteSpace ? renderer.lastCharacterIndexStrippingSpaces() : renderer.text().length() - 1; 703 701 unsigned lastSpace = m_current.offset(); 704 702 float wordSpacing = m_currentStyle->fontCascade().wordSpacing(); … … 727 725 } 728 726 729 if (m_renderTextInfo.text != &render Text) {730 updateCounterIfNeeded(render Text);731 m_renderTextInfo.text = &render Text;727 if (m_renderTextInfo.text != &renderer) { 728 updateCounterIfNeeded(renderer); 729 m_renderTextInfo.text = &renderer; 732 730 m_renderTextInfo.font = &font; 733 m_renderTextInfo.layout = font.createLayout(render Text, m_width.currentWidth(), m_collapseWhiteSpace);734 m_renderTextInfo.lineBreakIterator.resetStringAndReleaseIterator(render Text.text(), style.computedLocale(), iteratorMode);731 m_renderTextInfo.layout = font.createLayout(renderer, m_width.currentWidth(), m_collapseWhiteSpace); 732 m_renderTextInfo.lineBreakIterator.resetStringAndReleaseIterator(renderer.text(), style.computedLocale(), iteratorMode); 735 733 } else if (m_renderTextInfo.layout && m_renderTextInfo.font != &font) { 736 734 m_renderTextInfo.font = &font; 737 m_renderTextInfo.layout = font.createLayout(render Text, m_width.currentWidth(), m_collapseWhiteSpace);735 m_renderTextInfo.layout = font.createLayout(renderer, m_width.currentWidth(), m_collapseWhiteSpace); 738 736 } 739 737 … … 748 746 TextLayout* textLayout = m_renderTextInfo.layout.get(); 749 747 WordTrailingSpace wordTrailingSpace(style, !textLayout); 750 for (; m_current.offset() < render Text.text().length(); m_current.fastIncrementInTextNode()) {748 for (; m_current.offset() < renderer.text().length(); m_current.fastIncrementInTextNode()) { 751 749 bool previousCharacterIsSpace = m_currentCharacterIsSpace; 752 750 bool previousCharacterIsWS = m_currentCharacterIsWS; … … 763 761 764 762 if (canHangPunctuationAtStart && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !inlineLogicalWidth(m_current.renderer(), true, false)) { 765 m_width.addUncommittedWidth(-render Text.hangablePunctuationStartWidth(m_current.offset()));763 m_width.addUncommittedWidth(-renderer.hangablePunctuationStartWidth(m_current.offset())); 766 764 canHangPunctuationAtStart = false; 767 765 } 768 766 769 767 if (canHangPunctuationAtEnd && !m_nextObject && (int)m_current.offset() == endPunctuationIndex && !inlineLogicalWidth(m_current.renderer(), false, true)) { 770 m_width.addUncommittedWidth(-render Text.hangablePunctuationEndWidth(endPunctuationIndex));768 m_width.addUncommittedWidth(-renderer.hangablePunctuationEndWidth(endPunctuationIndex)); 771 769 canHangPunctuationAtEnd = false; 772 770 } … … 776 774 777 775 if (c == softHyphen && m_autoWrap && !hyphenWidth && style.hyphens() != Hyphens::None) { 778 hyphenWidth = measureHyphenWidth(render Text, font, &fallbackFonts);776 hyphenWidth = measureHyphenWidth(renderer, font, &fallbackFonts); 779 777 m_width.addUncommittedWidth(hyphenWidth); 780 778 } … … 786 784 if (canBreakMidWord && !midWordBreak && (!m_currentCharacterIsSpace || m_atStart || style.whiteSpace() != WhiteSpace::PreWrap)) { 787 785 wrapW += charWidth; 788 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && U16_IS_TRAIL(render Text.characterAt(m_current.offset() + 1));789 charWidth = textWidth(render Text, m_current.offset(), midWordBreakIsBeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, isFixedPitch, m_collapseWhiteSpace, fallbackFonts, textLayout);786 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && U16_IS_TRAIL(renderer.characterAt(m_current.offset() + 1)); 787 charWidth = textWidth(renderer, m_current.offset(), midWordBreakIsBeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, isFixedPitch, m_collapseWhiteSpace, fallbackFonts, textLayout); 790 788 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_width.availableWidth(); 791 789 } … … 796 794 m_current.setNextBreakablePosition(nextBreakablePosition); 797 795 798 if (canHangStopOrCommaAtLineEnd && render Text.isHangableStopOrComma(c) && m_width.fitsOnLine()) {796 if (canHangStopOrCommaAtLineEnd && renderer.isHangableStopOrComma(c) && m_width.fitsOnLine()) { 799 797 // We need to see if a measurement that excludes the stop would fit. If so, then we should hang 800 798 // the stop/comma at the end. First measure including the comma. 801 799 m_hangsAtEnd = false; 802 800 float inlineStartWidth = !m_appliedStartWidth ? inlineLogicalWidth(m_current.renderer(), true, false) : 0_lu; 803 float widthIncludingComma = computeAdditionalBetweenWordsWidth(render Text, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset() + 1) + inlineStartWidth;801 float widthIncludingComma = computeAdditionalBetweenWordsWidth(renderer, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset() + 1) + inlineStartWidth; 804 802 m_width.addUncommittedWidth(widthIncludingComma); 805 803 if (!m_width.fitsOnLine()) { 806 804 // See if we fit without the comma involved. If we do, then this is a potential hang point. 807 float widthWithoutStopOrComma = computeAdditionalBetweenWordsWidth(render Text, textLayout, lastCharacter, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset()) + inlineStartWidth;805 float widthWithoutStopOrComma = computeAdditionalBetweenWordsWidth(renderer, textLayout, lastCharacter, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset()) + inlineStartWidth; 808 806 m_width.addUncommittedWidth(widthWithoutStopOrComma - widthIncludingComma); 809 807 if (m_width.fitsOnLine()) … … 831 829 } 832 830 833 float additionalTempWidth = computeAdditionalBetweenWordsWidth(render Text, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset());831 float additionalTempWidth = computeAdditionalBetweenWordsWidth(renderer, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset()); 834 832 m_width.addUncommittedWidth(additionalTempWidth); 835 833 … … 857 855 bool lineWasTooWide = false; 858 856 if (fitsOnLineOrHangsAtEnd() && m_currentCharacterIsWS && m_currentStyle->breakOnlyAfterWhiteSpace() && (!midWordBreak || m_currWS == WhiteSpace::BreakSpaces)) { 859 float charWidth = textWidth(render Text, m_current.offset(), 1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0);857 float charWidth = textWidth(renderer, m_current.offset(), 1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0); 860 858 // Check if line is too big even without the extra space 861 859 // at the end of the line. If it is not, do nothing. … … 866 864 lineWasTooWide = true; 867 865 if (m_currWS == WhiteSpace::BreakSpaces) 868 trailingSpacesHang(m_lineBreak, render Object, canBreakMidWord, previousCharacterIsSpace);866 trailingSpacesHang(m_lineBreak, renderer, canBreakMidWord, previousCharacterIsSpace); 869 867 else { 870 m_lineBreak.moveTo(render Object, m_current.offset(), m_current.nextBreakablePosition());868 m_lineBreak.moveTo(renderer, m_current.offset(), m_current.nextBreakablePosition()); 871 869 m_lineBreaker.skipTrailingWhitespace(m_lineBreak, m_lineInfo); 872 870 } … … 877 875 // no more content, and a hyphenated single word would end up on a line by itself. This looks 878 876 // bad so just don't allow it. 879 if (canHyphenate && !m_width.fitsOnLine() && (m_nextObject || !render Text.containsOnlyHTMLWhitespace(m_current.offset(), renderText.text().length() - m_current.offset()) || isLineEmpty)) {880 tryHyphenating(render Text, font, style.computedLocale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated);877 if (canHyphenate && !m_width.fitsOnLine() && (m_nextObject || !renderer.containsOnlyHTMLWhitespace(m_current.offset(), renderer.text().length() - m_current.offset()) || isLineEmpty)) { 878 tryHyphenating(renderer, font, style.computedLocale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated); 881 879 if (m_lineBreaker.m_hyphenated) { 882 880 m_atEnd = true; … … 943 941 if (!stoppedIgnoringSpaces && m_current.offset()) 944 942 ensureCharacterGetsLineBox(m_lineWhitespaceCollapsingState, m_current); 945 commitLineBreakAtCurrentWidth(render Object, m_current.offset(), m_current.nextBreakablePosition());943 commitLineBreakAtCurrentWidth(renderer, m_current.offset(), m_current.nextBreakablePosition()); 946 944 m_lineBreak.increment(); 947 945 m_lineInfo.setPreviousLineBrokeCleanly(true); … … 950 948 951 949 if (m_autoWrap && betweenWords) { 952 commitLineBreakAtCurrentWidth(render Object, m_current.offset(), m_current.nextBreakablePosition());950 commitLineBreakAtCurrentWidth(renderer, m_current.offset(), m_current.nextBreakablePosition()); 953 951 wrapWidthOffset = 0; 954 952 wrapW = wrapWidthOffset; … … 963 961 // Remember this as a breakable position in case 964 962 // adding the end width forces a break. 965 m_lineBreak.moveTo(render Object, m_current.offset(), m_current.nextBreakablePosition());963 m_lineBreak.moveTo(renderer, m_current.offset(), m_current.nextBreakablePosition()); 966 964 midWordBreak &= canBreakMidWord; 967 965 } … … 988 986 // Measuring the width of complex text character-by-character, rather than measuring it all together, 989 987 // could produce considerably different width values. 990 if (!render Text.canUseSimpleFontCodePath() && midWordBreak && m_width.fitsOnLine()) {988 if (!renderer.canUseSimpleFontCodePath() && midWordBreak && m_width.fitsOnLine()) { 991 989 midWordBreak = false; 992 990 wrapW = wrapWidthOffset + additionalTempWidth; … … 1002 1000 m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(nullptr, m_current.renderer(), m_current.offset())); 1003 1001 } 1004 if (m_hangsAtEnd && !render Text.isHangableStopOrComma(c))1002 if (m_hangsAtEnd && !renderer.isHangableStopOrComma(c)) 1005 1003 m_hangsAtEnd = false; 1006 1004 } … … 1008 1006 if (isSVGText && m_current.offset()) { 1009 1007 // Force creation of new InlineBoxes for each absolute positioned character (those that start new text chunks). 1010 if (downcast<RenderSVGInlineText>(render Text).characterStartsNewTextChunk(m_current.offset()))1008 if (downcast<RenderSVGInlineText>(renderer).characterStartsNewTextChunk(m_current.offset())) 1011 1009 ensureCharacterGetsLineBox(m_lineWhitespaceCollapsingState, m_current); 1012 1010 } … … 1021 1019 m_startOfIgnoredSpaces.setOffset(m_startOfIgnoredSpaces.offset() - 1); 1022 1020 // If there's just a single trailing space start ignoring it now so it collapses away. 1023 if (m_current.offset() == render Text.text().length() - 1)1021 if (m_current.offset() == renderer.text().length() - 1) 1024 1022 m_lineWhitespaceCollapsingState.startIgnoringSpaces(m_startOfIgnoredSpaces); 1025 1023 } … … 1028 1026 if (!m_currentCharacterIsWS && previousCharacterIsWS) { 1029 1027 if (m_autoWrap && m_currentStyle->breakOnlyAfterWhiteSpace()) 1030 m_lineBreak.moveTo(render Object, m_current.offset(), m_current.nextBreakablePosition());1028 m_lineBreak.moveTo(renderer, m_current.offset(), m_current.nextBreakablePosition()); 1031 1029 } 1032 1030 … … 1044 1042 wordMeasurements.grow(wordMeasurements.size() + 1); 1045 1043 WordMeasurement& wordMeasurement = wordMeasurements.last(); 1046 wordMeasurement.renderer = &render Text;1044 wordMeasurement.renderer = &renderer; 1047 1045 1048 1046 // IMPORTANT: current.m_pos is > length here! 1049 float additionalTempWidth = m_ignoringSpaces ? 0 : textWidth(render Text, lastSpace, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout);1047 float additionalTempWidth = m_ignoringSpaces ? 0 : textWidth(renderer, lastSpace, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout); 1050 1048 wordMeasurement.startOffset = lastSpace; 1051 1049 wordMeasurement.endOffset = m_current.offset(); … … 1072 1070 // bad so just don't allow it. 1073 1071 if (canHyphenate && (m_nextObject || isLineEmpty)) 1074 tryHyphenating(render Text, font, style.computedLocale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated);1072 tryHyphenating(renderer, font, style.computedLocale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated); 1075 1073 1076 1074 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen && style.hyphens() != Hyphens::None) {
Note:
See TracChangeset
for help on using the changeset viewer.