Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f5e6dd1893d0ba8146411e4e62891fd8f6056eb5
      
https://github.com/WebKit/WebKit/commit/f5e6dd1893d0ba8146411e4e62891fd8f6056eb5
  Author: Ryosuke Niwa <rn...@webkit.org>
  Date:   2024-03-27 (Wed, 27 Mar 2024)

  Changed paths:
    M Source/WebCore/dom/Node.cpp
    M Source/WebCore/dom/Node.h
    M Source/WebCore/editing/FrameSelection.cpp
    M Source/WebCore/editing/FrameSelection.h

  Log Message:
  -----------
  Avoid tree traversal in FrameSelection::nodeWillBeRemoved in most cases
https://bugs.webkit.org/show_bug.cgi?id=271748

Reviewed by Wenson Hsieh and Yusuke Suzuki.

This PR introduces a new node flag, StateFlag::ContainsSelectionEndPoint, which 
indicates whether
a given node contains a selection end point (start, end, base, extent, focus, 
or anchor), and uses
it to avoid tree walks in FrameSelection::nodeWillBeRemoved.

* Source/WebCore/dom/Node.cpp:
(WebCore::Node::insertedIntoAncestor): Assert that the node flag isn't set when 
a node is just
inserted into a DOM tree.
(WebCore::Node::removedFromAncestor): Ditto for removal.

* Source/WebCore/dom/Node.h:
(WebCore::Node::containsSelectionEndPoint const): Added.
(WebCore::Node::setContainsSelectionEndPoint): Added.

* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance):
(WebCore::setNodeContainsSelectionEndPoint): Added. Sets the node flag on all 
ancestor nodes given
a position.
(WebCore::FrameSelection::setNodeFlags): Added. Sets the node flag on ancestor 
nodes of each
selection end points: start, end, base, extent, focus, or anchor.
(WebCore::FrameSelection::nodeWillBeRemoved): Added the optimization.
(WebCore::FrameSelection::respondToNodeModification):
(WebCore::FrameSelection::willBeModified):

* Source/WebCore/editing/FrameSelection.h:

Canonical link: https://commits.webkit.org/276766@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to