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

Changeset 271349 in webkit


Ignore:
Timestamp:
Jan 10, 2021, 4:04:02 AM (6 years ago)
Author:
Antti Koivisto
Message:

Remove InlineBox::hasSelectedChildren bit
​https://bugs.webkit.org/show_bug.cgi?id=220240

Reviewed by Sam Weinig.

It is only needed for selection gap painting and easily computed.

  • rendering/ComplexLineLayout.cpp:

(WebCore::ComplexLineLayout::constructLine):

  • rendering/InlineBox.h:

(WebCore::InlineBox::setCanHaveLeftExpansion):
(WebCore::InlineBox::InlineBoxBitfields::InlineBoxBitfields):
(WebCore::InlineBox::hasEllipsisBox const):
(WebCore::InlineBox::canHaveLeftExpansion const):
(WebCore::InlineBox::hasSelectedChildren const): Deleted.
(WebCore::InlineBox::setHasSelectedChildren): Deleted.

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::inlineSelectionGaps):

  • rendering/RenderLineBreak.cpp:

(WebCore::RenderLineBreak::setSelectionState): Deleted.

  • rendering/RenderLineBreak.h:
  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::setSelectionState): Deleted.

  • rendering/RenderListMarker.h:
  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::setSelectionState): Deleted.

  • rendering/RenderReplaced.h:
  • rendering/RenderText.cpp:

(WebCore::RenderText::setSelectionState):

  • rendering/RenderTextLineBoxes.cpp:

(WebCore::RenderTextLineBoxes::setSelectionState): Deleted.

  • rendering/RenderTextLineBoxes.h:
  • rendering/RootInlineBox.h:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271348 r271349  
     12021-01-10  Antti Koivisto  <antti@apple.com>
     2
     3        Remove InlineBox::hasSelectedChildren bit
     4        https://bugs.webkit.org/show_bug.cgi?id=220240
     5
     6        Reviewed by Sam Weinig.
     7
     8        It is only needed for selection gap painting and easily computed.
     9
     10        * rendering/ComplexLineLayout.cpp:
     11        (WebCore::ComplexLineLayout::constructLine):
     12        * rendering/InlineBox.h:
     13        (WebCore::InlineBox::setCanHaveLeftExpansion):
     14        (WebCore::InlineBox::InlineBoxBitfields::InlineBoxBitfields):
     15        (WebCore::InlineBox::hasEllipsisBox const):
     16        (WebCore::InlineBox::canHaveLeftExpansion const):
     17        (WebCore::InlineBox::hasSelectedChildren const): Deleted.
     18        (WebCore::InlineBox::setHasSelectedChildren): Deleted.
     19        * rendering/RenderBlockFlow.cpp:
     20        (WebCore::RenderBlockFlow::inlineSelectionGaps):
     21        * rendering/RenderLineBreak.cpp:
     22        (WebCore::RenderLineBreak::setSelectionState): Deleted.
     23        * rendering/RenderLineBreak.h:
     24        * rendering/RenderListMarker.cpp:
     25        (WebCore::RenderListMarker::setSelectionState): Deleted.
     26        * rendering/RenderListMarker.h:
     27        * rendering/RenderReplaced.cpp:
     28        (WebCore::RenderReplaced::setSelectionState): Deleted.
     29        * rendering/RenderReplaced.h:
     30        * rendering/RenderText.cpp:
     31        (WebCore::RenderText::setSelectionState):
     32        * rendering/RenderTextLineBoxes.cpp:
     33        (WebCore::RenderTextLineBoxes::setSelectionState): Deleted.
     34        * rendering/RenderTextLineBoxes.h:
     35        * rendering/RootInlineBox.h:
     36
    1372021-01-09  Zalan Bujtas  <zalan@apple.com>
    238
  • trunk/Source/WebCore/rendering/ComplexLineLayout.cpp

    r269149 r271349  
    295295    ASSERT(bidiRuns.firstRun());
    296296
    297     bool rootHasSelectedChildren = false;
    298297    InlineFlowBox* parentBox = 0;
    299298    int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace();
    … …  
    311310        r->setBox(box);
    312311
    313         if (!rootHasSelectedChildren && box->renderer().selectionState() != RenderObject::HighlightState::None)
    314             rootHasSelectedChildren = true;
    315        
    316312        // If we have no parent box yet, or if the run is not simply a sibling,
    317313        // then we need to construct inline boxes as necessary to properly enclose the
    … …  
    343339    // be the last continuation of our line list.
    344340    ASSERT(lastRootBox() && !lastRootBox()->isConstructed());
    345 
    346     // Set the m_selectedChildren flag on the root inline box if one of the leaf inline box
    347     // from the bidi runs walk above has a selection state.
    348     if (rootHasSelectedChildren)
    349         lastRootBox()->root().setHasSelectedChildren(true);
    350341
    351342    // Set bits on our inline flow boxes that indicate which sides should
  • trunk/Source/WebCore/rendering/InlineBox.h

    r269301 r271349  
    276276
    277277    void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(hasHyphen); }
    278     void setCanHaveLeftExpansion(bool canHaveLeftExpansion) { m_bitfields.setHasSelectedChildrenOrCanHaveLeftExpansion(canHaveLeftExpansion); }
     278    void setCanHaveLeftExpansion(bool canHaveLeftExpansion) { m_bitfields.setCanHaveLeftExpansion(canHaveLeftExpansion); }
    279279    void setCanHaveRightExpansion(bool canHaveRightExpansion) { m_bitfields.setCanHaveRightExpansion(canHaveRightExpansion); }
    280280    void setForceRightExpansion() { m_bitfields.setForceRightExpansion(true); }
    … …  
    312312            , m_isHorizontal(isHorizontal)
    313313            , m_endsWithBreak(false)
    314             , m_hasSelectedChildrenOrCanHaveLeftExpansion(false)
     314            , m_canHaveLeftExpansion(false)
    315315            , m_canHaveRightExpansion(false)
    316316            , m_knownToHaveNoOverflow(true) 
    … …  
    344344        ADD_BOOLEAN_BITFIELD(endsWithBreak, EndsWithBreak); // Whether the line ends with a <br>.
    345345        // shared between RootInlineBox and InlineTextBox
    346         ADD_BOOLEAN_BITFIELD(hasSelectedChildrenOrCanHaveLeftExpansion, HasSelectedChildrenOrCanHaveLeftExpansion);
     346        ADD_BOOLEAN_BITFIELD(canHaveLeftExpansion, CanHaveLeftExpansion);
    347347        ADD_BOOLEAN_BITFIELD(canHaveRightExpansion, CanHaveRightExpansion);
    348348        ADD_BOOLEAN_BITFIELD(knownToHaveNoOverflow, KnownToHaveNoOverflow);
    … …  
    393393    void setEndsWithBreak(bool endsWithBreak) { m_bitfields.setEndsWithBreak(endsWithBreak); }
    394394    bool hasEllipsisBox() const { return m_bitfields.hasEllipsisBoxOrHyphen(); }
    395     bool hasSelectedChildren() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeftExpansion(); }
    396     void setHasSelectedChildren(bool hasSelectedChildren) { m_bitfields.setHasSelectedChildrenOrCanHaveLeftExpansion(hasSelectedChildren); }
    397395    void setHasEllipsisBox(bool hasEllipsisBox) { m_bitfields.setHasEllipsisBoxOrHyphen(hasEllipsisBox); }
    398396
    399397    // For InlineTextBox
    400398    bool hasHyphen() const { return m_bitfields.hasEllipsisBoxOrHyphen(); }
    401     bool canHaveLeftExpansion() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeftExpansion(); }
     399    bool canHaveLeftExpansion() const { return m_bitfields.canHaveLeftExpansion(); }
    402400    bool canHaveRightExpansion() const { return m_bitfields.canHaveRightExpansion(); }
    403401    bool forceRightExpansion() const { return m_bitfields.forceRightExpansion(); }
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r271348 r271349  
    32033203    }
    32043204
     3205    auto hasSelectedChildren = [&](const RootInlineBox& root) {
     3206        for (auto* box = root.firstLeafDescendant(); box; box = box->nextLeafOnLine()) {
     3207            if (!is<InlineTextBox>(*box)) {
     3208                if (box->selectionState() != HighlightState::None)
     3209                    return true;
     3210                continue;
     3211            }
     3212
     3213            auto start = view().selection().startOffset();
     3214            auto end = view().selection().endOffset();
     3215
     3216            auto& textBox = downcast<InlineTextBox>(*box);
     3217            switch (textBox.renderer().selectionState()) {
     3218            case RenderObject::HighlightState::None:
     3219                continue;
     3220            case RenderObject::HighlightState::Inside:
     3221                return true;
     3222            case RenderObject::HighlightState::Start:
     3223                end = textBox.renderer().text().length();
     3224                // to handle selection from end of text to end of line
     3225                if (start && start == end)
     3226                    start = end - 1;
     3227                break;
     3228            case RenderObject::HighlightState::End:
     3229                start = 0;
     3230                break;
     3231            case RenderObject::HighlightState::Both:
     3232                break;
     3233            }
     3234            if (textBox.isSelected(start, end))
     3235                return true;
     3236        }
     3237        return false;
     3238    };
     3239
    32053240    RootInlineBox* lastSelectedLine = 0;
    32063241    RootInlineBox* curr;
    3207     for (curr = firstRootBox(); curr && !curr->hasSelectedChildren(); curr = curr->nextRootBox()) { }
     3242    for (curr = firstRootBox(); curr && !hasSelectedChildren(*curr); curr = curr->nextRootBox()) { }
    32083243
    32093244    // Now paint the gaps for the lines.
    3210     for (; curr && curr->hasSelectedChildren(); curr = curr->nextRootBox()) {
     3245    for (; curr && hasSelectedChildren(*curr); curr = curr->nextRootBox()) {
    32113246        LayoutUnit selTop =  curr->selectionTopAdjustedForPrecedingBlock();
    32123247        LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock();
  • trunk/Source/WebCore/rendering/RenderLineBreak.cpp

    r270539 r271349  
    143143}
    144144
    145 void RenderLineBreak::setSelectionState(HighlightState state)
    146 {
    147     RenderBoxModelObject::setSelectionState(state);
    148     if (!m_inlineBoxWrapper)
    149         return;
    150     m_inlineBoxWrapper->root().setHasSelectedChildren(state != HighlightState::None);
    151 }
    152 
    153145IntRect RenderLineBreak::linesBoundingBox() const
    154146{
  • trunk/Source/WebCore/rendering/RenderLineBreak.h

    r270539 r271349  
    6666    int caretMaxOffset() const final;
    6767    bool canBeSelectionLeaf() const final;
    68     void setSelectionState(HighlightState) final;
    6968
    7069    LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode) const final;
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r267940 r271349  
    19491949}
    19501950
    1951 void RenderListMarker::setSelectionState(HighlightState state)
    1952 {
    1953     // The selection state for our containing block hierarchy is updated by the base class call.
    1954     RenderBox::setSelectionState(state);
    1955 
    1956     if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())
    1957         m_inlineBoxWrapper->root().setHasSelectedChildren(state != HighlightState::None);
    1958 }
    1959 
    19601951LayoutRect RenderListMarker::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)
    19611952{
  • trunk/Source/WebCore/rendering/RenderListMarker.h

    r258680 r271349  
    7575    bool isText() const { return !isImage(); }
    7676
    77     void setSelectionState(HighlightState) override;
    7877    LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) override;
    7978    bool canBeSelectionLeaf() const override { return true; }
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r271129 r271349  
    737737}
    738738
    739 void RenderReplaced::setSelectionState(HighlightState state)
    740 {
    741     // The selection state for our containing block hierarchy is updated by the base class call.
    742     RenderBox::setSelectionState(state);
    743 
    744     if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())
    745         m_inlineBoxWrapper->root().setHasSelectedChildren(isHighlighted(selectionState(), view().selection()));
    746 }
    747 
    748739bool RenderReplaced::isSelected() const
    749740{
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r268436 r271349  
    5858    virtual LayoutUnit minimumReplacedHeight() const { return 0_lu; }
    5959
    60     void setSelectionState(HighlightState) override;
    61 
    6260    bool isSelected() const;
    6361
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r271055 r271349  
    12771277    RenderObject::setSelectionState(state);
    12781278
    1279     if (canUpdateSelectionOnRootLineBoxes())
    1280         m_lineBoxes.setSelectionState(*this, state);
    1281 
    12821279    // The containing block can be null in case of an orphaned tree.
    12831280    RenderBlock* containingBlock = this->containingBlock();
  • trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp

    r269301 r271349  
    171171}
    172172
    173 void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject::HighlightState state)
    174 {
    175     if (state == RenderObject::HighlightState::Inside || state == RenderObject::HighlightState::None) {
    176         for (auto* box = m_first; box; box = box->nextTextBox())
    177             box->root().setHasSelectedChildren(state == RenderObject::HighlightState::Inside);
    178         return;
    179     }
    180 
    181     auto start = renderer.view().selection().startOffset();
    182     auto end = renderer.view().selection().endOffset();
    183     if (state == RenderObject::HighlightState::Start) {
    184         end = renderer.text().length();
    185         // to handle selection from end of text to end of line
    186         if (start && start == end)
    187             start = end - 1;
    188     } else if (state == RenderObject::HighlightState::End)
    189         start = 0;
    190 
    191     for (auto* box = m_first; box; box = box->nextTextBox()) {
    192         if (box->isSelected(start, end))
    193             box->root().setHasSelectedChildren(true);
    194     }
    195 }
    196 
    197173void RenderTextLineBoxes::dirtyAll()
    198174{
  • trunk/Source/WebCore/rendering/RenderTextLineBoxes.h

    r269301 r271349  
    5757    InlineTextBox* findNext(int offset, int& position) const;
    5858
    59     void setSelectionState(RenderText&, RenderObject::HighlightState);
    60 
    6159    LayoutRect visualOverflowBoundingBox(const RenderText&) const;
    6260
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r269916 r271349  
    123123    bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override;
    124124
    125     using InlineBox::hasSelectedChildren;
    126     using InlineBox::setHasSelectedChildren;
    127 
    128125    RenderObject::HighlightState selectionState() final;
    129126    InlineBox* firstSelectedBox();
Note: See TracChangeset for help on using the changeset viewer.