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

Changeset 276207 in webkit


Ignore:
Timestamp:
Apr 17, 2021, 2:13:20 PM (5 years ago)
Author:
Alan Bujtas
Message:

[Cleanup] Remove redundant BreakingContext::m_currentStyle
https://bugs.webkit.org/show_bug.cgi?id=224717

Reviewed by Antti Koivisto.

  • rendering/line/BreakingContext.h:

(WebCore::BreakingContext::BreakingContext):
(WebCore::BreakingContext::initializeForCurrentObject):
(WebCore::BreakingContext::handleBR):
(WebCore::BreakingContext::handleText):
(WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276206 r276207  
     12021-04-17  Zalan Bujtas  <zalan@apple.com>
     2
     3        [Cleanup] Remove redundant BreakingContext::m_currentStyle
     4        https://bugs.webkit.org/show_bug.cgi?id=224717
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * rendering/line/BreakingContext.h:
     9        (WebCore::BreakingContext::BreakingContext):
     10        (WebCore::BreakingContext::initializeForCurrentObject):
     11        (WebCore::BreakingContext::handleBR):
     12        (WebCore::BreakingContext::handleText):
     13        (WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded):
     14
    1152021-04-17  Brent Fulgham  <bfulgham@apple.com>
    216
  • trunk/Source/WebCore/rendering/line/BreakingContext.h

    r276202 r276207  
    102102        , m_lastObject(m_current.renderer())
    103103        , m_nextObject(nullptr)
    104         , m_currentStyle(nullptr)
    105104        , m_blockStyle(block.style())
    106105        , m_lineInfo(inLineInfo)
     
    188187    RenderObject* m_nextObject;
    189188
    190     const RenderStyle* m_currentStyle;
    191 
    192189    // Firefox and Opera will allow a table cell to grow to fit an image inside it under
    193190    // very specific circumstances (in order to match common WinIE renderings).
     
    240237{
    241238    m_hadUncommittedWidthBeforeCurrent = !!m_width.uncommittedWidth();
    242 
    243     m_currentStyle = &m_current.renderer()->style(); // FIXME: Should this be &lineStyle(*m_current.renderer(), m_lineInfo); ?
    244 
    245     ASSERT(m_currentStyle);
    246 
    247     m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.renderer());
    248     if (m_nextObject && m_nextObject->parent() && !m_nextObject->parent()->isDescendantOf(m_current.renderer()->parent()))
     239    auto& renderer = *m_current.renderer();
     240
     241    m_nextObject = bidiNextSkippingEmptyInlines(m_block, &renderer);
     242    if (m_nextObject && m_nextObject->parent() && !m_nextObject->parent()->isDescendantOf(renderer.parent()))
    249243        m_includeEndWidth = true;
    250244
    251     m_currWS = m_current.renderer()->isReplaced() ? m_current.renderer()->parent()->style().whiteSpace() : m_currentStyle->whiteSpace();
     245    m_currWS = renderer.isReplaced() ? renderer.parent()->style().whiteSpace() : renderer.style().whiteSpace();
    252246    m_lastWS = m_lastObject->isReplaced() ? m_lastObject->parent()->style().whiteSpace() : m_lastObject->style().whiteSpace();
    253247
     
    255249    m_autoWrapWasEverTrueOnLine = m_autoWrapWasEverTrueOnLine || m_autoWrap;
    256250
    257     m_preservesNewline = m_current.renderer()->isSVGInlineText() ? false : RenderStyle::preserveNewline(m_currWS);
     251    m_preservesNewline = renderer.isSVGInlineText() ? false : RenderStyle::preserveNewline(m_currWS);
    258252
    259253    m_collapseWhiteSpace = RenderStyle::collapseWhiteSpace(m_currWS);
     
    277271{
    278272    if (fitsOnLineOrHangsAtEnd()) {
    279         RenderObject& br = *m_current.renderer();
     273        auto& br = *m_current.renderer();
    280274        m_lineBreak.moveToStartOf(br);
    281275        m_lineBreak.increment();
     
    294288        // need to check for floats to clear - so if we're ignoring spaces, stop ignoring them and add a
    295289        // run for this object.
    296         if (m_ignoringSpaces && m_currentStyle->clear() != Clear::None)
     290        if (m_ignoringSpaces && br.style().clear() != Clear::None)
    297291            m_lineWhitespaceCollapsingState.ensureLineBoxInsideIgnoredSpaces(br);
    298292        // If we were preceded by collapsing space and are in a right-aligned container we need to ensure the space gets
     
    303297
    304298        if (!m_lineInfo.isEmpty())
    305             clear = m_currentStyle->clear();
     299            clear = br.style().clear();
    306300    }
    307301    m_atEnd = true;
     
    699693    int endPunctuationIndex = canHangPunctuationAtEnd && m_collapseWhiteSpace ? renderer.lastCharacterIndexStrippingSpaces() : renderer.text().length() - 1;
    700694    unsigned lastSpace = m_current.offset();
    701     float wordSpacing = m_currentStyle->fontCascade().wordSpacing();
     695    float wordSpacing = style.fontCascade().wordSpacing();
    702696    float lastSpaceWordSpacing = 0;
    703697    float wordSpacingForWordMeasurement = 0;
     
    706700    float wrapW = wrapWidthOffset;
    707701    float charWidth = 0;
    708     bool breakNBSP = m_autoWrap && m_currentStyle->nbspMode() == NBSPMode::Space;
     702    bool breakNBSP = m_autoWrap && style.nbspMode() == NBSPMode::Space;
    709703    // Auto-wrapping text should wrap in the middle of a word only if it could not wrap before the word,
    710704    // which is only possible if the word is the first thing on the line.
    711     bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && (!m_width.committedWidth() && !m_width.hasCommittedReplaced())) || m_currWS == WhiteSpace::Pre);
     705    bool breakWords = style.breakWords() && ((m_autoWrap && (!m_width.committedWidth() && !m_width.hasCommittedReplaced())) || m_currWS == WhiteSpace::Pre);
    712706    bool midWordBreak = false;
    713     bool breakAnywhere = m_currentStyle->lineBreak() == LineBreak::Anywhere && m_autoWrap;
    714     bool breakAll = (m_currentStyle->wordBreak() == WordBreak::BreakAll || breakAnywhere) && m_autoWrap;
    715     bool keepAllWords = m_currentStyle->wordBreak() == WordBreak::KeepAll;
     707    bool breakAnywhere = style.lineBreak() == LineBreak::Anywhere && m_autoWrap;
     708    bool breakAll = (style.wordBreak() == WordBreak::BreakAll || breakAnywhere) && m_autoWrap;
     709    bool keepAllWords = style.wordBreak() == WordBreak::KeepAll;
    716710    float hyphenWidth = 0;
    717711    auto iteratorMode = mapLineBreakToIteratorMode(m_blockStyle.lineBreak());
     
    854848                // as candidate width for this line.
    855849                bool lineWasTooWide = false;
    856                 if (fitsOnLineOrHangsAtEnd() && m_currentCharacterIsWS && m_currentStyle->breakOnlyAfterWhiteSpace() && (!midWordBreak || m_currWS == WhiteSpace::BreakSpaces)) {
     850                if (fitsOnLineOrHangsAtEnd() && m_currentCharacterIsWS && style.breakOnlyAfterWhiteSpace() && (!midWordBreak || m_currWS == WhiteSpace::BreakSpaces)) {
    857851                    float charWidth = textWidth(renderer, m_current.offset(), 1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0);
    858852                    // Check if line is too big even without the extra space
     
    971965            }
    972966
    973             if (!m_ignoringSpaces && m_currentStyle->collapseWhiteSpace()) {
     967            if (!m_ignoringSpaces && style.collapseWhiteSpace()) {
    974968                // If we encounter a newline, or if we encounter a second space,
    975969                // we need to break up this run and enter a mode where we start collapsing spaces.
     
    10251019
    10261020        if (!m_currentCharacterIsWS && previousCharacterIsWS) {
    1027             if (m_autoWrap && m_currentStyle->breakOnlyAfterWhiteSpace())
     1021            if (m_autoWrap && style.breakOnlyAfterWhiteSpace())
    10281022                m_lineBreak.moveTo(renderer, m_current.offset(), m_current.nextBreakablePosition());
    10291023        }
     
    10311025        if (m_collapseWhiteSpace && m_currentCharacterIsSpace && !m_ignoringSpaces)
    10321026            m_trailingObjects.setTrailingWhitespace(renderer);
    1033         else if (!m_currentStyle->collapseWhiteSpace() || !m_currentCharacterIsSpace)
     1027        else if (!style.collapseWhiteSpace() || !m_currentCharacterIsSpace)
    10341028            m_trailingObjects.clear();
    10351029
     
    11511145    if (checkForBreak && !m_width.fitsOnLine(m_ignoringSpaces) && !m_hangsAtEnd) {
    11521146        // if we have floats, try to get below them.
    1153         if (m_currentCharacterIsSpace && !m_ignoringSpaces && m_currentStyle->collapseWhiteSpace())
     1147        if (m_currentCharacterIsSpace && !m_ignoringSpaces && m_collapseWhiteSpace)
    11541148            m_trailingObjects.clear();
    11551149
Note: See TracChangeset for help on using the changeset viewer.