Bug 1939220 - part 3: Make TextFragmentData::BoundaryData not depend on the editing host r=m_kato

Its role is scanning the DOM.  Therefore, it can know which node is an editing
host during a scan.  Therefore, it does not require the editing host parameter.
To fix that, some utility methods of `HTMLEditUtils` needs to work with
non-editable nodes.  Therefore, this patch also updates `HTMLEditUtils`.

Finally, this gets rid of the `NS_ASSERTION`s in the constructor of
`TextFragmentData` because it'll be available with non-editable nodes too.
Although current all callers assume that it works as in an editing host.

Differential Revision: https://phabricator.services.mozilla.com/D232934
This commit is contained in:
Masayuki Nakano
2025-01-20 08:03:58 +00:00
parent 5b0da1a66e
commit bd4fdbf30a
21 changed files with 213 additions and 260 deletions

View File

@@ -3362,13 +3362,12 @@ HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces(
*newCaretPosition.ContainerAs<nsIContent>(),
HTMLEditUtils::ClosestEditableBlockElementOrInlineEditingHost,
BlockInlineCheck::UseComputedDisplayStyle)) {
Element* editingHost = ComputeEditingHost();
// Try to put caret next to immediately after previous editable leaf.
nsIContent* previousContent =
HTMLEditUtils::GetPreviousLeafContentOrPreviousBlockElement(
newCaretPosition, *editableBlockElementOrInlineEditingHost,
{LeafNodeType::LeafNodeOrNonEditableNode},
BlockInlineCheck::UseComputedDisplayStyle, editingHost);
newCaretPosition, {LeafNodeType::LeafNodeOrNonEditableNode},
BlockInlineCheck::UseComputedDisplayStyle,
editableBlockElementOrInlineEditingHost);
if (previousContent &&
!HTMLEditUtils::IsBlockElement(
*previousContent, BlockInlineCheck::UseComputedDisplayStyle)) {
@@ -3383,10 +3382,9 @@ HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces(
else if (nsIContent* nextContent =
HTMLEditUtils::GetNextLeafContentOrNextBlockElement(
newCaretPosition,
*editableBlockElementOrInlineEditingHost,
{LeafNodeType::LeafNodeOrNonEditableNode},
BlockInlineCheck::UseComputedDisplayStyle,
editingHost)) {
editableBlockElementOrInlineEditingHost)) {
newCaretPosition = nextContent->IsText() ||
HTMLEditUtils::IsContainerNode(*nextContent)
? EditorDOMPoint(nextContent, 0)