Changeset 239971 in webkit


Ignore:
Timestamp:
Jan 14, 2019 7:31:41 PM (5 years ago)
Author:
Simon Fraser
Message:

Only run the node comparison code in FrameSelection::respondToNodeModification() for range selections
https://bugs.webkit.org/show_bug.cgi?id=193416

Reviewed by Wenson Hsieh.

The code inside the m_selection.firstRange() clause needs to only run for non-collapsed selections, and
it shows up on Speedometer profiles so optimize to only run this code if we have a selection range.

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::respondToNodeModification):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239965 r239971  
     12019-01-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Only run the node comparison code in FrameSelection::respondToNodeModification() for range selections
     4        https://bugs.webkit.org/show_bug.cgi?id=193416
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        The code inside the m_selection.firstRange() clause needs to only run for non-collapsed selections, and
     9        it shows up on Speedometer profiles so optimize to only run this code if we have a selection range.
     10
     11        * editing/FrameSelection.cpp:
     12        (WebCore::FrameSelection::respondToNodeModification):
     13
    1142019-01-14  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r239881 r239971  
    538538        else
    539539            m_selection.setWithoutValidation(m_selection.end(), m_selection.start());
    540     } else if (RefPtr<Range> range = m_selection.firstRange()) {
    541         auto compareNodeResult = range->compareNode(node);
    542         if (!compareNodeResult.hasException()) {
    543             auto compareResult = compareNodeResult.releaseReturnValue();
    544             if (compareResult == Range::NODE_BEFORE_AND_AFTER || compareResult == Range::NODE_INSIDE) {
    545                 // If we did nothing here, when this node's renderer was destroyed, the rect that it
    546                 // occupied would be invalidated, but, selection gaps that change as a result of
    547                 // the removal wouldn't be invalidated.
    548                 // FIXME: Don't do so much unnecessary invalidation.
    549                 clearRenderTreeSelection = true;
     540    } else if (isRange()) {
     541        if (RefPtr<Range> range = m_selection.firstRange()) {
     542            auto compareNodeResult = range->compareNode(node);
     543            if (!compareNodeResult.hasException()) {
     544                auto compareResult = compareNodeResult.releaseReturnValue();
     545                if (compareResult == Range::NODE_BEFORE_AND_AFTER || compareResult == Range::NODE_INSIDE) {
     546                    // If we did nothing here, when this node's renderer was destroyed, the rect that it
     547                    // occupied would be invalidated, but, selection gaps that change as a result of
     548                    // the removal wouldn't be invalidated.
     549                    // FIXME: Don't do so much unnecessary invalidation.
     550                    clearRenderTreeSelection = true;
     551                }
    550552            }
    551553        }
Note: See TracChangeset for help on using the changeset viewer.