⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276201 in webkit


Ignore:
Timestamp:
Apr 17, 2021, 8:38:31 AM (5 years ago)
Author:
Alan Bujtas
Message:

[Cleanup] BreakingContext::handleText should consistently use the cached renderer
https://bugs.webkit.org/show_bug.cgi?id=224711

Reviewed by Antti Koivisto.

Since this function is not supposed to increment the renderer, let's replace m_current.renderer() with "renderer".

  • rendering/line/BreakingContext.h:

(WebCore::BreakingContext::handleText):

  • rendering/line/TrailingObjects.h:

(WebCore::TrailingObjects::setTrailingWhitespace):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276200 r276201  
     12021-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
    1152021-04-17  Zalan Bujtas  <zalan@apple.com>
    216
  • trunk/Source/WebCore/rendering/line/BreakingContext.h

    r276200 r276201  
    679679        commitLineBreakAtCurrentWidth(renderer);
    680680
    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);
    683683        combineRenderer.combineTextIfNeeded();
    684684        // The length of the renderer's text may have changed. Increment stale iterator positions
     
    703703    float wordSpacingForWordMeasurement = 0;
    704704
    705     float wrapWidthOffset = m_width.uncommittedWidth() + inlineLogicalWidth(*m_current.renderer(), !m_appliedStartWidth, true);
     705    float wrapWidthOffset = m_width.uncommittedWidth() + inlineLogicalWidth(renderer, !m_appliedStartWidth, true);
    706706    float wrapW = wrapWidthOffset;
    707707    float charWidth = 0;
     
    746746    WordTrailingSpace wordTrailingSpace(style, !textLayout);
    747747    for (; m_current.offset() < renderer.text().length(); m_current.fastIncrementInTextNode()) {
     748        ASSERT(&renderer == m_current.renderer());
    748749        bool previousCharacterIsSpace = m_currentCharacterIsSpace;
    749750        bool previousCharacterIsWS = m_currentCharacterIsWS;
     
    759760        }
    760761
    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)) {
    762763            m_width.addUncommittedWidth(-renderer.hangablePunctuationStartWidth(m_current.offset()));
    763764            canHangPunctuationAtStart = false;
    764765        }
    765766       
    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)) {
    767768            m_width.addUncommittedWidth(-renderer.hangablePunctuationEndWidth(endPunctuationIndex));
    768769            canHangPunctuationAtEnd = false;
     
    797798            // the stop/comma at the end. First measure including the comma.
    798799            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;
    800801            float widthIncludingComma = computeAdditionalBetweenWordsWidth(renderer, textLayout, c, wordTrailingSpace, fallbackFonts, wordMeasurements, font, isFixedPitch, lastSpace, lastSpaceWordSpacing, wordSpacingForWordMeasurement, m_current.offset() + 1) + inlineStartWidth;
    801802            m_width.addUncommittedWidth(widthIncludingComma);
     
    819820                    wordSpacingForWordMeasurement = 0;
    820821                    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()));
    822823                    stoppedIgnoringSpaces = true;
    823824                } else {
     
    837838
    838839            if (!m_appliedStartWidth) {
    839                 float inlineStartWidth = inlineLogicalWidth(*m_current.renderer(), true, false);
     840                float inlineStartWidth = inlineLogicalWidth(renderer, true, false);
    840841                m_width.addUncommittedWidth(inlineStartWidth);
    841842                m_appliedStartWidth = true;
     
    898899                            // We might just be right after the soft-hyphen
    899900                            lastBreakingPosition = m_current.nextBreakablePosition().value();
    900                             rendererAtBreakingPosition = m_current.renderer();
     901                            rendererAtBreakingPosition = &renderer;
    901902                        }
    902903                        if (lastBreakingPosition) {
     
    997998                wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurements.last().width) ? wordSpacing : 0;
    998999                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()));
    10001001            }
    10011002            if (m_hangsAtEnd && !renderer.isHangableStopOrComma(c))
     
    10101011
    10111012        if (m_currentCharacterIsSpace && !previousCharacterIsSpace) {
    1012             m_startOfIgnoredSpaces.setRenderer(m_current.renderer());
     1013            m_startOfIgnoredSpaces.setRenderer(&renderer);
    10131014            m_startOfIgnoredSpaces.setOffset(m_current.offset());
    10141015            // Spaces after right-aligned text and before a line-break get collapsed away completely so that the trailing
     
    10291030
    10301031        if (m_collapseWhiteSpace && m_currentCharacterIsSpace && !m_ignoringSpaces)
    1031             m_trailingObjects.setTrailingWhitespace(downcast<RenderText>(m_current.renderer()));
     1032            m_trailingObjects.setTrailingWhitespace(renderer);
    10321033        else if (!m_currentStyle->collapseWhiteSpace() || !m_currentCharacterIsSpace)
    10331034            m_trailingObjects.clear();
     
    10501051    additionalTempWidth += lastSpaceWordSpacing;
    10511052
    1052     float inlineLogicalTempWidth = inlineLogicalWidth(*m_current.renderer(), !m_appliedStartWidth, m_includeEndWidth);
     1053    float inlineLogicalTempWidth = inlineLogicalWidth(renderer, !m_appliedStartWidth, m_includeEndWidth);
    10531054    m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth);
    10541055    if (m_hangsAtEnd && inlineLogicalTempWidth)
  • trunk/Source/WebCore/rendering/line/TrailingObjects.h

    r208668 r276201  
    4848    { }
    4949
    50     void setTrailingWhitespace(RenderText* whitespace)
     50    void setTrailingWhitespace(RenderText& whitespace)
    5151    {
    52         ASSERT(whitespace);
    53         m_whitespace = whitespace;
     52        m_whitespace = &whitespace;
    5453    }
    5554
Note: See TracChangeset for help on using the changeset viewer.