Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2826db838ec7c2b5eb8b1447484f6306e3d29c63
      
https://github.com/WebKit/WebKit/commit/2826db838ec7c2b5eb8b1447484f6306e3d29c63
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-07-28 (Tue, 28 Jul 2026)

  Changed paths:
    M Source/WebCore/editing/FrameSelection.cpp

  Log Message:
  -----------
  Split the start/end block in FrameSelection::respondToNodeModification onto 
its own line
https://bugs.webkit.org/show_bug.cgi?id=318194
rdar://181000906

Reviewed by Chris Dumez.

This change is just to make code easier to understand true intention as
mentioned below:

respondToNodeModification() adjusts the selection for a node removal. The
start/end block is written as `} if (startRemoved || endRemoved) {`, sharing a
line with the close of the anchor/focus block, which reads like a dropped 
`else`.
It isn't one, and the missing separation is what makes it look like a typo.

The two blocks are sequential passes, and both are needed. nodeWillBeRemoved()
runs before the node leaves the tree. The anchor/focus block rewrites
anchor-relative positions into positions in the removed node's parent via
positionInParentBefore/AfterNode(), and setWithoutValidation() derives the start
and end from them. Those parent offsets still describe the pre-removal tree, so
the start/end block runs afterwards to apply the child-index shift.

For `foo<hr>bar` with the caret after the hr, the first block produces (div, 2),
which lands after "bar" once the hr is gone; the second maps it to (div, 1),
matching the expected result in editing/execCommand/insertHorizontalRule. The
double pass cannot over-decrement, since the first block only runs when the
removed node is an inclusive ancestor of the anchor or focus, so it always emits
an offset equal to the node's own index or one past it.

Put the second `if` on its own line so the fallthrough is deliberate on its 
face.
No behavior change.

* Source/WebCore/editing/FrameSelection.cpp:
(WebCore::FrameSelection::respondToNodeModification):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to