tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 698333553765b352ff1b01264f5c7932e1b5b85b
parent 94124bfa08024db7df2cb6f16dcf1996154b57db
Author: Masayuki Nakano <masayuki@d-toybox.com>
Date:   Fri, 31 Oct 2025 05:02:57 +0000

Bug 1996501 - part 2: Make `WSRunScanner` take an `EnumSet` instead of a set of `Scan` and `BlockInlineCheck` r=m_kato

It's not required explicitly to specify
`BlockInlineCheck::UseComputedDisplayStyle` and
`BlockInlineCheck::UseComputedDisplayOutsideStyle` to `WSRunScanner`
too.  And it should take an `EnumSet` for making it easier to maintain
the class in the future.

Differential Revision: https://phabricator.services.mozilla.com/D270117

Diffstat:
Meditor/libeditor/AutoClonedRangeArray.cpp | 12+++++-------
Meditor/libeditor/HTMLEditSubActionHandler.cpp | 41++++++++++++++++++-----------------------
Meditor/libeditor/HTMLEditUtils.cpp | 44+++++++++++++++-----------------------------
Meditor/libeditor/HTMLEditor.cpp | 8+++-----
Meditor/libeditor/HTMLEditorDataTransfer.cpp | 8+++-----
Meditor/libeditor/HTMLEditorDeleteHandler.cpp | 171+++++++++++++++++++++++++++++++------------------------------------------------
Meditor/libeditor/HTMLEditorInsertLineBreakHandler.cpp | 12++++--------
Meditor/libeditor/HTMLEditorInsertParagraphHandler.cpp | 77++++++++++++++++++++++++++---------------------------------------------------
Meditor/libeditor/HTMLStyleEditor.cpp | 3+--
Meditor/libeditor/WSRunScanner.cpp | 202+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Meditor/libeditor/WSRunScanner.h | 172++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Meditor/libeditor/WSRunScannerNestedClasses.cpp | 114++++++++++++++++++++++++++++++++++---------------------------------------------
Meditor/libeditor/WhiteSpaceVisibilityKeeper.cpp | 66+++++++++++++++++++++++++++---------------------------------------
Meditor/libeditor/WhiteSpaceVisibilityKeeper.h | 1-
14 files changed, 420 insertions(+), 511 deletions(-)

diff --git a/editor/libeditor/AutoClonedRangeArray.cpp b/editor/libeditor/AutoClonedRangeArray.cpp @@ -245,7 +245,7 @@ AutoClonedRangeArray::ShrinkRangesIfStartFromOrEndAfterAtomicContent( "Changing range in selection may cause running script"); Result<bool, nsresult> result = WSRunScanner::ShrinkRangeIfStartsFromOrEndsAfterAtomicContent( - WSRunScanner::Scan::EditableNodes, range); + {WSRunScanner::Option::OnlyEditableNodes}, range); if (result.isErr()) { NS_WARNING( "WSRunScanner::ShrinkRangeIfStartsFromOrEndsAfterAtomicContent() " @@ -1103,9 +1103,8 @@ void AutoClonedRangeArray::ExtendRangeToContainSurroundingInvisibleWhiteSpaces( } const WSScanResult previousThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint(range->StartRef()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(range->StartRef())); if (previousThing.ReachedLineBoundary()) { const EditorRawDOMPoint mostDistantNewStart = [&]() MOZ_NEVER_INLINE_DEBUG { @@ -1166,9 +1165,8 @@ void AutoClonedRangeArray::ExtendRangeToContainSurroundingInvisibleWhiteSpaces( } const WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint(range->EndRef()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(range->EndRef())); if (!nextThing.ReachedLineBoundary()) { continue; } diff --git a/editor/libeditor/HTMLEditSubActionHandler.cpp b/editor/libeditor/HTMLEditSubActionHandler.cpp @@ -1534,8 +1534,7 @@ HTMLEditor::GetPreviousCharPointDataForNormalizingWhiteSpaces( } const auto previousCharPoint = WSRunScanner::GetPreviousCharPoint<EditorRawDOMPointInText>( - WSRunScanner::Scan::EditableNodes, aPoint, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPoint); if (!previousCharPoint.IsSet()) { return CharPointData::InDifferentTextNode(CharPointType::TextEnd); } @@ -1553,8 +1552,7 @@ HTMLEditor::GetInclusiveNextCharPointDataForNormalizingWhiteSpaces( } const auto nextCharPoint = WSRunScanner::GetInclusiveNextCharPoint<EditorRawDOMPointInText>( - WSRunScanner::Scan::EditableNodes, aPoint, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPoint); if (!nextCharPoint.IsSet()) { return CharPointData::InDifferentTextNode(CharPointType::TextEnd); } @@ -2269,12 +2267,10 @@ void HTMLEditor::ExtendRangeToDeleteWithNormalizingWhiteSpaces( // adjacent text node's first or last character information in some cases. const auto precedingCharPoint = WSRunScanner::GetPreviousCharPoint<EditorDOMPointInText>( - WSRunScanner::Scan::EditableNodes, aStartToDelete, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aStartToDelete); const auto followingCharPoint = WSRunScanner::GetInclusiveNextCharPoint<EditorDOMPointInText>( - WSRunScanner::Scan::EditableNodes, aEndToDelete, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aEndToDelete); // Blink-compat: Normalize white-spaces in first node only when not removing // its last character or no text nodes follow the first node. // If removing last character of first node and there are @@ -2794,8 +2790,7 @@ HTMLEditor::InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded( // here. const WSScanResult previousThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPointToInsert, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPointToInsert); if (!previousThing.ReachedLineBoundary()) { return CreateLineBreakResult::NotHandled(); } @@ -2804,8 +2799,7 @@ HTMLEditor::InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded( // line break here. const WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPointToInsert, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPointToInsert); if (!nextThing.ReachedBlockBoundary()) { return CreateLineBreakResult::NotHandled(); } @@ -7212,13 +7206,15 @@ HTMLEditor::GetRangeExtendedToHardLineEdgesForBlockEditAction( // selection past that, it would visibly change meaning of users selection. const WSScanResult prevVisibleThingOfEndPoint = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, endPoint, - // We should refer only the default style of HTML because we need to - // wrap any elements with a specific HTML element. So we should not - // refer actual style. For example, we want to reformat parent HTML - // block element even if selected in a blocked phrase element or - // non-HTMLelement. - BlockInlineCheck::UseHTMLDefaultStyle, &aEditingHost); + { + // We should refer only the default style of HTML because we + // need to wrap any elements with a specific HTML element. So + // we should not refer actual style. For example, we want to + // reformat parent HTML block element even if selected in a + // blocked phrase element or non-HTMLelement. + WSRunScanner::Option::ReferHTMLDefaultStyle, + }, + endPoint, &aEditingHost); if (MOZ_UNLIKELY(prevVisibleThingOfEndPoint.Failed())) { NS_WARNING( "WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary() failed"); @@ -7258,8 +7254,8 @@ HTMLEditor::GetRangeExtendedToHardLineEdgesForBlockEditAction( // selection past that, it would visibly change meaning of users selection. const WSScanResult nextVisibleThingOfStartPoint = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, startPoint, - BlockInlineCheck::UseHTMLDefaultStyle, &aEditingHost); + {WSRunScanner::Option::ReferHTMLDefaultStyle}, startPoint, + &aEditingHost); if (MOZ_UNLIKELY(nextVisibleThingOfStartPoint.Failed())) { NS_WARNING( "WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary() failed"); @@ -9685,8 +9681,7 @@ HTMLEditor::InsertPaddingBRElementIfNeeded( if (IsPlaintextMailComposer()) { const WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPoint); if (nextVisibleThing.ReachedBlockBoundary() && HTMLEditUtils::IsMailCiteElement(*nextVisibleThing.ElementPtr()) && HTMLEditUtils::IsInlineContent( diff --git a/editor/libeditor/HTMLEditUtils.cpp b/editor/libeditor/HTMLEditUtils.cpp @@ -796,9 +796,7 @@ EditorDOMPoint HTMLEditUtils::LineRequiresPaddingLineBreakToBeVisible( return false; } const WSScanResult nextThing = - WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, point, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary({}, point); if (nextThing.ReachedBlockBoundary()) { if (nextThing.ReachedCurrentBlockBoundary()) { preferredPaddingLineBreakPoint = point.AfterContainer<EditorDOMPoint>(); @@ -969,8 +967,7 @@ bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary( } const WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPoint); if (nextThing.ReachedCurrentBlockBoundary()) { return true; } @@ -980,9 +977,8 @@ bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary( } const WSScanResult afterInvisibleBRThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - nextThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + nextThing.PointAfterReachedContent<EditorRawDOMPoint>()); return afterInvisibleBRThing.ReachedCurrentBlockBoundary(); } if (nextThing.ReachedPreformattedLineBreak()) { @@ -991,9 +987,8 @@ bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary( } const WSScanResult afterPreformattedLineBreakThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - nextThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + nextThing.PointAfterReachedContent<EditorRawDOMPoint>()); return afterPreformattedLineBreakThing.ReachedCurrentBlockBoundary(); } return false; @@ -1170,9 +1165,7 @@ Maybe<EditorLineBreakType> HTMLEditUtils::GetFollowingUnnecessaryLineBreak( MOZ_ASSERT(aPoint.IsInContentNode()); const WSScanResult nextThing = - WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, aPoint, - BlockInlineCheck::UseComputedDisplayStyle); + WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary({}, aPoint); if (!nextThing.ReachedBRElement() && !(nextThing.ReachedPreformattedLineBreak() && nextThing.PointAtReachedContent<EditorRawDOMPoint>() @@ -1181,9 +1174,7 @@ Maybe<EditorLineBreakType> HTMLEditUtils::GetFollowingUnnecessaryLineBreak( } const WSScanResult nextThingOfLineBreak = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - nextThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayStyle); + {}, nextThing.PointAfterReachedContent<EditorRawDOMPoint>()); const Element* const blockElement = nextThingOfLineBreak.ReachedBlockBoundary() ? nextThingOfLineBreak.ElementPtr() @@ -1216,8 +1207,7 @@ uint32_t HTMLEditUtils::GetFirstVisibleCharOffset(const Text& aText) { } const WSScanResult previousThingOfText = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, EditorRawDOMPoint(&aText), - BlockInlineCheck::UseComputedDisplayStyle); + {}, EditorRawDOMPoint(&aText)); if (!previousThingOfText.ReachedLineBoundary()) { return 0u; } @@ -1236,8 +1226,7 @@ uint32_t HTMLEditUtils::GetOffsetAfterLastVisibleChar(const Text& aText) { } const WSScanResult nextThingOfText = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, EditorRawDOMPoint::After(aText), - BlockInlineCheck::UseComputedDisplayStyle); + {}, EditorRawDOMPoint::After(aText)); if (!nextThingOfText.ReachedLineBoundary()) { return characterDataBuffer.GetLength(); } @@ -2195,7 +2184,7 @@ EditorDOMPointType HTMLEditUtils::GetPreviousEditablePoint( // There may be invisible trailing white-spaces which should be // ignored. Let's scan its start. return WSRunScanner::GetAfterLastVisiblePoint<EditorDOMPointType>( - WSRunScanner::Scan::EditableNodes, *textNode); + {WSRunScanner::Option::OnlyEditableNodes}, *textNode); } // If it's a container element, return end of it. Otherwise, return @@ -2308,7 +2297,7 @@ EditorDOMPointType HTMLEditUtils::GetNextEditablePoint( // There may be invisible leading white-spaces which should be // ignored. Let's scan its start. return WSRunScanner::GetFirstVisiblePoint<EditorDOMPointType>( - WSRunScanner::Scan::EditableNodes, *textNode); + {WSRunScanner::Option::OnlyEditableNodes}, *textNode); } // If it's a container element, return start of it. Otherwise, return @@ -2709,8 +2698,7 @@ nsIContent* HTMLEditUtils::GetContentToPreserveInlineStyles( for (auto point = aPoint.template To<EditorRawDOMPoint>(); point.IsSet();) { const WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, point, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, point); if (nextVisibleThing.InVisibleOrCollapsibleCharacters()) { return nextVisibleThing.TextPtr(); } @@ -2759,8 +2747,7 @@ EditorDOMPointType HTMLEditUtils::GetBetterInsertionPointFor( } const WSRunScanner wsScannerForPointToInsert( - WSRunScanner::Scan::EditableNodes, pointToInsert, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, pointToInsert); // If the insertion position is after the last visible item in a line, // i.e., the insertion position is just before a visible line break <br>, @@ -2814,8 +2801,7 @@ EditorDOMPointType HTMLEditUtils::GetBetterCaretPositionToInsertText( if (aPoint.IsEndOfContainer()) { const WSScanResult previousThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPoint, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, aPoint); if (previousThing.InVisibleOrCollapsibleCharacters()) { return EditorDOMPointType::AtEndOf(*previousThing.TextPtr()); } diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp @@ -1189,8 +1189,8 @@ nsresult HTMLEditor::MaybeCollapseSelectionAtFirstEditableNode( // the visible character. const WSScanResult scanResultInTextNode = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, EditorRawDOMPoint(text, 0), - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(text, 0)); if ((scanResultInTextNode.InVisibleOrCollapsibleCharacters() || scanResultInTextNode.ReachedPreformattedLineBreak()) && scanResultInTextNode.TextPtr() == text) { @@ -4360,9 +4360,7 @@ nsresult HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak( if (IsPlaintextMailComposer()) { const WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - unnecessaryLineBreak->After<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, unnecessaryLineBreak->After<EditorRawDOMPoint>()); if (nextThing.ReachedOtherBlockElement() && HTMLEditUtils::IsMailCiteElement(*nextThing.ElementPtr()) && HTMLEditUtils::IsInlineContent( diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp @@ -551,14 +551,12 @@ HTMLEditor::HTMLWithContextInserter::GetNewCaretPointAfterInsertingHTML( WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( // We want to put caret to an editable point so that we need to scan // only editable nodes. - WSRunScanner::Scan::EditableNodes, pointToPutCaret, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, pointToPutCaret); if (prevVisibleThing.ReachedInvisibleBRElement()) { const WSScanResult prevVisibleThingOfBRElement = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint(prevVisibleThing.BRElementPtr()), - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(prevVisibleThing.BRElementPtr())); if (prevVisibleThingOfBRElement.InVisibleOrCollapsibleCharacters()) { pointToPutCaret = prevVisibleThingOfBRElement .PointAfterReachedContent<EditorDOMPoint>(); diff --git a/editor/libeditor/HTMLEditorDeleteHandler.cpp b/editor/libeditor/HTMLEditorDeleteHandler.cpp @@ -805,8 +805,7 @@ nsresult HTMLEditor::AutoDeleteRangesHandler::ComputeRangesToDelete( return NS_SUCCESS_DOM_NO_OPERATION; } const WSRunScanner wsRunScannerAtCaret( - WSRunScanner::Scan::EditableNodes, caretPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, caretPoint); const WSScanResult scanFromCaretPointResult = aDirectionAndAmount == nsIEditor::eNext ? wsRunScannerAtCaret @@ -1100,8 +1099,7 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler::Run( return EditActionResult::CanceledResult(); } const WSRunScanner wsRunScannerAtCaret( - WSRunScanner::Scan::EditableNodes, caretPoint.ref(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, caretPoint.ref()); const WSScanResult scanFromCaretPointResult = aDirectionAndAmount == nsIEditor::eNext ? wsRunScannerAtCaret @@ -1157,8 +1155,7 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler::Run( // Let's check whether there is new invisible `<br>` element // for avoiding infinite recursive calls. const WSRunScanner wsRunScannerAtCaret( - WSRunScanner::Scan::EditableNodes, caretPoint.ref(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, caretPoint.ref()); const WSScanResult scanFromCaretPointResult = aDirectionAndAmount == nsIEditor::eNext ? wsRunScannerAtCaret @@ -1485,7 +1482,7 @@ nsresult HTMLEditor::AutoDeleteRangesHandler:: if (aDirectionAndAmount == nsIEditor::eNext) { Result<EditorDOMRangeInTexts, nsresult> result = WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom( - WSRunScanner::Scan::EditableNodes, caretPosition); + {WSRunScanner::Option::OnlyEditableNodes}, caretPosition); if (result.isErr()) { NS_WARNING( "WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom() failed"); @@ -1498,7 +1495,7 @@ nsresult HTMLEditor::AutoDeleteRangesHandler:: } else { Result<EditorDOMRangeInTexts, nsresult> result = WSRunScanner::GetRangeInTextNodesToBackspaceFrom( - WSRunScanner::Scan::EditableNodes, caretPosition); + {WSRunScanner::Option::OnlyEditableNodes}, caretPosition); if (result.isErr()) { NS_WARNING("WSRunScanner::GetRangeInTextNodesToBackspaceFrom() failed"); return result.unwrapErr(); @@ -1557,22 +1554,18 @@ HTMLEditor::AutoDeleteRangesHandler::HandleDeleteTextAroundCollapsedRanges( } const WSScanResult previousThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, rangeToDelete.StartRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, rangeToDelete.StartRef()); if (!previousThing.ReachedLineBoundary() || previousThing.ReachedBlockBoundary()) { return false; } WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, rangeToDelete.EndRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, rangeToDelete.EndRef()); if (nextThing.ReachedBRElement() || nextThing.ReachedPreformattedLineBreak()) { nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - nextThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, nextThing.PointAfterReachedContent<EditorRawDOMPoint>()); } return nextThing.ReachedBlockBoundary(); }(); @@ -1653,7 +1646,7 @@ HTMLEditor::AutoDeleteRangesHandler::ComputeRangesToDeleteAtomicContent( AutoClonedSelectionRangeArray& aRangesToDelete) const { EditorDOMRange rangeToDelete = WSRunScanner::GetRangesForDeletingAtomicContent( - WSRunScanner::Scan::EditableNodes, aAtomicContent); + {WSRunScanner::Option::OnlyEditableNodes}, aAtomicContent); if (!rangeToDelete.IsPositioned()) { NS_WARNING("WSRunScanner::GetRangeForDeleteAContentNode() failed"); return NS_ERROR_FAILURE; @@ -2042,9 +2035,8 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler:: aHTMLEditor.GetEditAction())) { return EditorDOMPoint(); } - const WSRunScanner scanner( - WSRunScanner::Scan::EditableNodes, EditorRawDOMPoint(mBRElement), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + const WSRunScanner scanner({WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(mBRElement)); const WSScanResult maybePreviousText = scanner.ScanPreviousVisibleNodeOrBlockBoundaryFrom( EditorRawDOMPoint(mBRElement)); @@ -2156,15 +2148,13 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler:: // compatibility with the other browsers. WSScanResult nextThingOfCaretPoint = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, newCaretPosition, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, newCaretPosition); if (nextThingOfCaretPoint.ReachedBRElement() || nextThingOfCaretPoint.ReachedPreformattedLineBreak()) { nextThingOfCaretPoint = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - nextThingOfCaretPoint.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, nextThingOfCaretPoint + .PointAfterReachedContent<EditorRawDOMPoint>()); } if (nextThingOfCaretPoint.ReachedBlockBoundary()) { const EditorDOMPoint atBlockBoundary = @@ -2605,10 +2595,9 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: } const WSScanResult prevVisibleThingBeforeCurrentBlock = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, EditorRawDOMPoint( - inclusiveAncestorOfRightChildBlockOrError.inspect()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + inclusiveAncestorOfRightChildBlockOrError.inspect())); if (!prevVisibleThingBeforeCurrentBlock.ReachedBRElement() && !prevVisibleThingBeforeCurrentBlock.ReachedPreformattedLineBreak()) { return WSScanResult::Error(); @@ -2624,8 +2613,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: MOZ_ASSERT(atPrecedingLineBreak.IsSet()); const WSScanResult prevVisibleThingBeforeLineBreak = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, atPrecedingLineBreak, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, atPrecedingLineBreak); if (prevVisibleThingBeforeLineBreak.ReachedBRElement() || prevVisibleThingBeforeLineBreak.ReachedPreformattedLineBreak() || prevVisibleThingBeforeLineBreak.ReachedCurrentBlockBoundary()) { @@ -2929,7 +2917,7 @@ HTMLEditor::AutoDeleteRangesHandler::ComputeRangesToDeleteNonCollapsedRanges( EditorDOMRange firstRange(aRangesToDelete.FirstRangeRef()); EditorDOMRange extendedRange = WSRunScanner::GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, EditorDOMRange(aRangesToDelete.FirstRangeRef())); if (firstRange != extendedRange) { nsresult rv = aRangesToDelete.FirstRangeRef()->SetStartAndEnd( @@ -3270,9 +3258,8 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: // rough check. const WSScanResult nextVisibleThingOfEndBoundary = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint(aRangeToDelete.EndRef()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(aRangeToDelete.EndRef())); if (!nextVisibleThingOfEndBoundary.ReachedCurrentBlockBoundary()) { MOZ_ASSERT(mLeftContent->IsElement()); Result<Element*, nsresult> mostDistantBlockOrError = @@ -3284,19 +3271,17 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: if (MOZ_LIKELY(mostDistantBlockOrError.inspect())) { const WSScanResult prevVisibleThingOfStartBoundary = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint(aRangeToDelete.StartRef()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(aRangeToDelete.StartRef())); if (prevVisibleThingOfStartBoundary.ReachedBRElement()) { // If the range start after a <br> followed by the block boundary, // we want to delete the <br> or following <br> element unless it's // not a part of empty line like `<div>abc<br>{<div>]def`. const WSScanResult nextVisibleThingOfBR = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, EditorRawDOMPoint::After( - *prevVisibleThingOfStartBoundary.GetContent()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + *prevVisibleThingOfStartBoundary.GetContent())); MOZ_ASSERT(!nextVisibleThingOfBR.ReachedCurrentBlockBoundary()); if (!nextVisibleThingOfBR.ReachedOtherBlockElement() || nextVisibleThingOfBR.GetContent() != @@ -3307,10 +3292,9 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: } const WSScanResult prevVisibleThingOfBR = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, EditorRawDOMPoint( - prevVisibleThingOfStartBoundary.GetContent()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + prevVisibleThingOfStartBoundary.GetContent())); if (prevVisibleThingOfBR.ReachedBRElement() || prevVisibleThingOfBR.ReachedPreformattedLineBreak() || prevVisibleThingOfBR.ReachedBlockBoundary()) { @@ -3322,10 +3306,9 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: .ReachedPreformattedLineBreak()) { const WSScanResult nextVisibleThingOfLineBreak = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, prevVisibleThingOfStartBoundary - .PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + .PointAfterReachedContent<EditorRawDOMPoint>()); MOZ_ASSERT( !nextVisibleThingOfLineBreak.ReachedCurrentBlockBoundary()); if (!nextVisibleThingOfLineBreak.ReachedOtherBlockElement() || @@ -3337,10 +3320,9 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: } const WSScanResult prevVisibleThingOfLineBreak = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, prevVisibleThingOfStartBoundary - .PointAtReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + .PointAtReachedContent<EditorRawDOMPoint>()); if (prevVisibleThingOfLineBreak.ReachedBRElement() || prevVisibleThingOfLineBreak.ReachedPreformattedLineBreak() || prevVisibleThingOfLineBreak.ReachedBlockBoundary()) { @@ -3354,10 +3336,9 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: mLeftContent); const WSScanResult firstVisibleThingInBlock = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, EditorRawDOMPoint( - prevVisibleThingOfStartBoundary.ElementPtr(), 0), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + prevVisibleThingOfStartBoundary.ElementPtr(), 0)); if (!firstVisibleThingInBlock.ReachedOtherBlockElement() || firstVisibleThingInBlock.ElementPtr() != mostDistantBlockOrError.inspect()) { @@ -3367,10 +3348,9 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: } else if (prevVisibleThingOfStartBoundary.ReachedOtherBlockElement()) { const WSScanResult firstVisibleThingAfterBlock = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, EditorRawDOMPoint::After( - *prevVisibleThingOfStartBoundary.ElementPtr()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + *prevVisibleThingOfStartBoundary.ElementPtr())); if (!firstVisibleThingAfterBlock.ReachedOtherBlockElement() || firstVisibleThingAfterBlock.ElementPtr() != mostDistantBlockOrError.inspect()) { @@ -3589,8 +3569,7 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler:: *mLeftContent, BlockInlineCheck::UseComputedDisplayOutsideStyle)) { const WSScanResult lastThingInLeftBlock = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, EditorRawDOMPoint::AtEndOf(*mLeftContent), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, EditorRawDOMPoint::AtEndOf(*mLeftContent)); if (lastThingInLeftBlock.ReachedLineBreak()) { const EditorLineBreak lineBreak = lastThingInLeftBlock.CreateEditorLineBreak<EditorLineBreak>(); @@ -3683,8 +3662,7 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler:: aHTMLEditor.GetEditAction())) { const WSScanResult maybePreviousText = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, startOfRightContent, - BlockInlineCheck::UseComputedDisplayOutsideStyle, &aEditingHost); + {}, startOfRightContent, &aEditingHost); if (maybePreviousText.IsContentEditable() && maybePreviousText.InVisibleOrCollapsibleCharacters()) { nsresult rv = aHTMLEditor.CollapseSelectionTo( @@ -4029,25 +4007,24 @@ Result<Element*, nsresult> HTMLEditor::AutoDeleteRangesHandler:: const WSScanResult prevVisibleThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle, aAncestorLimiter); + {WSRunScanner::Option::OnlyEditableNodes}, aPoint, aAncestorLimiter); if (!ReachedCurrentBlockBoundaryWhichWeCanCross(prevVisibleThing)) { return nullptr; } - MOZ_ASSERT(HTMLEditUtils::IsBlockElement( - *prevVisibleThing.ElementPtr(), - BlockInlineCheck::UseComputedDisplayOutsideStyle)); + MOZ_ASSERT( + HTMLEditUtils::IsBlockElement(*prevVisibleThing.ElementPtr(), + BlockInlineCheck::UseComputedDisplayStyle)); for (Element* ancestorBlock = prevVisibleThing.ElementPtr(); ancestorBlock;) { const WSScanResult prevVisibleThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, EditorRawDOMPoint(ancestorBlock), - BlockInlineCheck::UseComputedDisplayOutsideStyle, aAncestorLimiter); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(ancestorBlock), aAncestorLimiter); if (!ReachedCurrentBlockBoundaryWhichWeCanCross(prevVisibleThing)) { return ancestorBlock; } MOZ_ASSERT(HTMLEditUtils::IsBlockElement( *prevVisibleThing.ElementPtr(), - BlockInlineCheck::UseComputedDisplayOutsideStyle)); + BlockInlineCheck::UseComputedDisplayStyle)); ancestorBlock = prevVisibleThing.ElementPtr(); } return Err(NS_ERROR_FAILURE); @@ -4107,9 +4084,8 @@ void HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: const WSScanResult prevVisibleThingOfStartBoundary = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint(aRangeToDelete.StartRef()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorRawDOMPoint(aRangeToDelete.StartRef())); // If the range starts after an invisible <br> of empty line immediately // before the most distant inclusive ancestor of the right block like // `<br><br>{<div>]abc`, we should delete the last empty line because @@ -4118,16 +4094,14 @@ void HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: prevVisibleThingOfStartBoundary.ReachedPreformattedLineBreak()) { const WSScanResult prevVisibleThingOfPreviousLineBreak = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, prevVisibleThingOfStartBoundary - .PointAtReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + .PointAtReachedContent<EditorRawDOMPoint>()); const WSScanResult nextVisibleThingOfPreviousBR = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, prevVisibleThingOfStartBoundary - .PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + .PointAfterReachedContent<EditorRawDOMPoint>()); if ((prevVisibleThingOfPreviousLineBreak.ReachedBRElement() || prevVisibleThingOfPreviousLineBreak.ReachedPreformattedLineBreak()) && nextVisibleThingOfPreviousBR.ReachedOtherBlockElement() && @@ -4155,8 +4129,7 @@ void HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: while (true) { WSScanResult scanResult = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, scanStartPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle, + {WSRunScanner::Option::OnlyEditableNodes}, scanStartPoint, mLeftContent->AsElement()); if (scanResult.ReachedBlockBoundary() || scanResult.ReachedInlineEditingHostBoundary()) { @@ -4648,9 +4621,8 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler:: } WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - deleteContentResult.DeleteRangeRef().EndRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + deleteContentResult.DeleteRangeRef().EndRef()); return nextThing.ReachedBRElement() || nextThing.ReachedPreformattedLineBreak() || nextThing.ReachedHRElement() || @@ -4839,9 +4811,7 @@ HTMLEditor::AutoDeleteRangesHandler::DeleteParentBlocksWithTransactionIfEmpty( MOZ_ASSERT(aPoint.IsSet()); MOZ_ASSERT(aHTMLEditor.mPlaceholderBatch); - const WSRunScanner scanner(WSRunScanner::Scan::All, aPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aEditingHost); + const WSRunScanner scanner({}, aPoint, &aEditingHost); // First, check there is visible contents before the point in current block. const WSScanResult prevVisibleThing = @@ -4887,9 +4857,7 @@ HTMLEditor::AutoDeleteRangesHandler::DeleteParentBlocksWithTransactionIfEmpty( if (nextVisibleThing.BRElementPtr()->GetNextSibling()) { const WSScanResult nextVisibleThingAfterBR = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - EditorRawDOMPoint::After(*nextVisibleThing.BRElementPtr()), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, EditorRawDOMPoint::After(*nextVisibleThing.BRElementPtr())); if (MOZ_UNLIKELY(nextVisibleThingAfterBR.Failed())) { NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed"); return NS_ERROR_FAILURE; @@ -5450,9 +5418,8 @@ Result<bool, nsresult> HTMLEditor::AutoDeleteRangesHandler:: mRightBlockElement) { mPrecedingInvisibleBRElement = WSRunScanner::GetPrecedingBRElementUnlessVisibleContentFound( - WSRunScanner::Scan::EditableNodes, - EditorDOMPoint::AtEndOf(mLeftBlockElement), - WSRunScanner::ReferHTMLDefaultStyle::No); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorDOMPoint::AtEndOf(mLeftBlockElement)); // `WhiteSpaceVisibilityKeeper:: // MergeFirstLineOfRightBlockElementIntoDescendantLeftBlockElement()` // returns ignored when: @@ -5481,9 +5448,8 @@ Result<bool, nsresult> HTMLEditor::AutoDeleteRangesHandler:: mLeftBlockElement) { mPrecedingInvisibleBRElement = WSRunScanner::GetPrecedingBRElementUnlessVisibleContentFound( - WSRunScanner::Scan::EditableNodes, - mPointContainingTheOtherBlockElement, - WSRunScanner::ReferHTMLDefaultStyle::No); + {WSRunScanner::Option::OnlyEditableNodes}, + mPointContainingTheOtherBlockElement); // `WhiteSpaceVisibilityKeeper:: // MergeFirstLineOfRightBlockElementIntoAncestorLeftBlockElement()` // returns ignored when: @@ -5517,9 +5483,8 @@ Result<bool, nsresult> HTMLEditor::AutoDeleteRangesHandler:: } else { mPrecedingInvisibleBRElement = WSRunScanner::GetPrecedingBRElementUnlessVisibleContentFound( - WSRunScanner::Scan::EditableNodes, - EditorDOMPoint::AtEndOf(mLeftBlockElement), - WSRunScanner::ReferHTMLDefaultStyle::No); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorDOMPoint::AtEndOf(mLeftBlockElement)); // `WhiteSpaceVisibilityKeeper:: // MergeFirstLineOfRightBlockElementIntoLeftBlockElement()` always // return "handled". @@ -5554,7 +5519,7 @@ nsresult HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner:: } EditorDOMRange range = WSRunScanner::GetRangeForDeletingBlockElementBoundaries( - WSRunScanner::Scan::EditableNodes, *mLeftBlockElement, + {WSRunScanner::Option::OnlyEditableNodes}, *mLeftBlockElement, *mRightBlockElement, pointContainingTheOtherBlock); if (!range.IsPositioned()) { NS_WARNING( @@ -5647,8 +5612,7 @@ Result<DeleteRangeResult, nsresult> HTMLEditor::AutoDeleteRangesHandler:: auto pointToPutCaret = [&]() -> EditorDOMPoint { const WSScanResult maybePreviousText = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, maybeDeepStartOfRightContent, - BlockInlineCheck::UseComputedDisplayStyle, &aEditingHost); + {}, maybeDeepStartOfRightContent, &aEditingHost); if (maybePreviousText.IsContentEditable() && maybePreviousText.InVisibleOrCollapsibleCharacters()) { return maybePreviousText.PointAfterReachedContent<EditorDOMPoint>(); @@ -5813,9 +5777,7 @@ HTMLEditor::AutoMoveOneLineHandler::CanMoveOrDeleteSomethingInLine( if (HTMLEditUtils::IsBlockElement( *startContent, BlockInlineCheck::UseComputedDisplayOutsideStyle)) { const WSScanResult prevThing = - WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, endPoint, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary({}, endPoint); if (prevThing.ReachedCurrentBlockBoundary() && prevThing.ElementPtr()->IsInclusiveDescendantOf(startContent)) { return false; @@ -7547,8 +7509,8 @@ HTMLEditor::AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete( for (;;) { const WSScanResult backwardScanFromStartResult = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, rangeToDelete.StartRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + rangeToDelete.StartRef()); if (!backwardScanFromStartResult.ReachedCurrentBlockBoundary() && !backwardScanFromStartResult.ReachedInlineEditingHostBoundary()) { break; @@ -7598,8 +7560,7 @@ HTMLEditor::AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete( for (;;) { const WSScanResult forwardScanFromEndResult = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, rangeToDelete.EndRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle, + {}, rangeToDelete.EndRef(), closestBlockAncestorOrInlineEditingHost); if (forwardScanFromEndResult.ReachedBRElement()) { if (HTMLEditUtils::IsVisibleBRElement( diff --git a/editor/libeditor/HTMLEditorInsertLineBreakHandler.cpp b/editor/libeditor/HTMLEditorInsertLineBreakHandler.cpp @@ -170,9 +170,8 @@ nsresult HTMLEditor::AutoInsertLineBreakHandler::HandleInsertBRElement() { } const WSScanResult backwardScanFromBeforeBRElementResult = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - insertLineBreakResult.AtLineBreak<EditorDOMPoint>(), - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, + insertLineBreakResult.AtLineBreak<EditorDOMPoint>()); if (MOZ_UNLIKELY(backwardScanFromBeforeBRElementResult.Failed())) { NS_WARNING("WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary() failed"); return Err(NS_ERROR_FAILURE); @@ -180,8 +179,7 @@ nsresult HTMLEditor::AutoInsertLineBreakHandler::HandleInsertBRElement() { const WSScanResult forwardScanFromAfterBRElementResult = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, pointToPutCaret, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, pointToPutCaret); if (MOZ_UNLIKELY(forwardScanFromAfterBRElementResult.Failed())) { NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed"); return Err(NS_ERROR_FAILURE); @@ -367,9 +365,7 @@ HTMLEditor::AutoInsertLineBreakHandler::InsertLinefeed( // boundary. Note that it should always be <br> for avoiding padding line // breaks appear in `.textContent` value. if (pointToPutCaret.IsInContentNode() && pointToPutCaret.IsEndOfContainer()) { - const WSRunScanner scannerAtCaret(WSRunScanner::Scan::All, pointToPutCaret, - BlockInlineCheck::UseComputedDisplayStyle, - &aEditingHost); + const WSRunScanner scannerAtCaret({}, pointToPutCaret, &aEditingHost); const WSScanResult prevVisibleThing = scannerAtCaret.ScanPreviousVisibleNodeOrBlockBoundaryFrom( pointToPutCaret); diff --git a/editor/libeditor/HTMLEditorInsertParagraphHandler.cpp b/editor/libeditor/HTMLEditorInsertParagraphHandler.cpp @@ -606,9 +606,8 @@ HTMLEditor::AutoInsertParagraphHandler::InsertBRElement( const bool editingHostIsEmpty = HTMLEditUtils::IsEmptyNode( mEditingHost, {EmptyCheckOption::TreatNonEditableContentAsInvisible}); - const WSRunScanner wsRunScanner(WSRunScanner::Scan::EditableNodes, - aPointToBreak, - BlockInlineCheck::UseComputedDisplayStyle); + const WSRunScanner wsRunScanner({WSRunScanner::Option::OnlyEditableNodes}, + aPointToBreak); const WSScanResult backwardScanResult = wsRunScanner.ScanPreviousVisibleNodeOrBlockBoundaryFrom(aPointToBreak); if (MOZ_UNLIKELY(backwardScanResult.Failed())) { @@ -758,8 +757,7 @@ HTMLEditor::AutoInsertParagraphHandler::InsertBRElement( const WSScanResult forwardScanFromAfterBRElementResult = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, afterBRElement, - BlockInlineCheck::UseComputedDisplayStyle); + {WSRunScanner::Option::OnlyEditableNodes}, afterBRElement); if (MOZ_UNLIKELY(forwardScanFromAfterBRElementResult.Failed())) { NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed"); return Err(NS_ERROR_FAILURE); @@ -983,8 +981,9 @@ HTMLEditor::AutoInsertParagraphHandler::SplitMailCiteElement( // mailquote may affect wrapping behavior, or font color, etc. const WSScanResult forwardScanFromPointToSplitResult = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, pointToSplit, - BlockInlineCheck::UseHTMLDefaultStyle); + {WSRunScanner::Option::OnlyEditableNodes, + WSRunScanner::Option::ReferHTMLDefaultStyle}, + pointToSplit); if (forwardScanFromPointToSplitResult.Failed()) { return Err(NS_ERROR_FAILURE); } @@ -1054,8 +1053,9 @@ nsresult HTMLEditor::AutoInsertParagraphHandler:: // resultOfInsertingBRElement.inspect()? const WSScanResult backwardScanFromPointToCreateNewBRElementResult = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, aPointToInsertBRElement, - BlockInlineCheck::UseHTMLDefaultStyle); + {WSRunScanner::Option::OnlyEditableNodes, + WSRunScanner::Option::ReferHTMLDefaultStyle}, + aPointToInsertBRElement); if (MOZ_UNLIKELY(backwardScanFromPointToCreateNewBRElementResult.Failed())) { NS_WARNING( "WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary() " @@ -1070,9 +1070,9 @@ nsresult HTMLEditor::AutoInsertParagraphHandler:: } const WSScanResult forwardScanFromPointAfterNewBRElementResult = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, - EditorRawDOMPoint::After(aPointToInsertBRElement), - BlockInlineCheck::UseHTMLDefaultStyle); + {WSRunScanner::Option::OnlyEditableNodes, + WSRunScanner::Option::ReferHTMLDefaultStyle}, + EditorRawDOMPoint::After(aPointToInsertBRElement)); if (MOZ_UNLIKELY(forwardScanFromPointAfterNewBRElementResult.Failed())) { NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed"); return NS_ERROR_FAILURE; @@ -1282,9 +1282,7 @@ HTMLEditor::AutoInsertParagraphHandler::GetBetterPointToSplitParagraph( { const WSScanResult prevVisibleThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, aCandidatePointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, aCandidatePointToSplit, &aBlockElementToSplit); if (prevVisibleThing.GetContent() && // Only if the previous thing is not in the same container. prevVisibleThing.GetContent() != @@ -1318,15 +1316,12 @@ HTMLEditor::AutoInsertParagraphHandler::GetBetterPointToSplitParagraph( } WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, aCandidatePointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, aCandidatePointToSplit, &aBlockElementToSplit); if (nextVisibleThing.ReachedInvisibleBRElement()) { nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, + {}, nextVisibleThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle, &aBlockElementToSplit); } if (nextVisibleThing.GetContent() && @@ -1380,17 +1375,13 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::AutoInsertParagraphHandler:: const EditorDOMPoint& aPointToSplit) { const WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, aPointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, aPointToSplit, &aBlockElementToSplit); if (!nextVisibleThing.ReachedBlockBoundary()) { return aPointToSplit; } const WSScanResult prevVisibleThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, aPointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, aPointToSplit, &aBlockElementToSplit); Maybe<EditorLineBreak> precedingInvisibleLineBreak; if (prevVisibleThing.ReachedBRElement()) { precedingInvisibleLineBreak.emplace(*prevVisibleThing.BRElementPtr()); @@ -1467,9 +1458,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::AutoInsertParagraphHandler:: [&]() MOZ_NEVER_INLINE_DEBUG { const WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, aPointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, aPointToSplit, &aBlockElementToSplit); if (nextVisibleThing.ReachedBRElement() || nextVisibleThing.ReachedPreformattedLineBreak()) { // If it's followed by a line break in the closest ancestor container @@ -1484,10 +1473,9 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::AutoInsertParagraphHandler:: } const WSScanResult nextVisibleThingAfterLineBreak = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, + {}, nextVisibleThing .PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle, &aBlockElementToSplit); // If the line break is visible, we don't need to insert a padding // <br> element for the right paragraph because it'll have some @@ -1572,17 +1560,13 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::AutoInsertParagraphHandler:: // so, we want to keep it.) const WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, pointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, pointToSplit, &aBlockElementToSplit); if (!nextVisibleThing.ReachedBRElement()) { return pointToSplit; } const WSScanResult nextVisibleThingAfterFirstBRElement = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - nextVisibleThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle, + {}, nextVisibleThing.PointAfterReachedContent<EditorRawDOMPoint>(), &aBlockElementToSplit); if (!nextVisibleThingAfterFirstBRElement.ReachedBRElement()) { return pointToSplit; @@ -1726,9 +1710,7 @@ HTMLEditor::AutoInsertParagraphHandler::SplitParagraphWithTransaction( // break, we need to put a padding <br> to make an empty line. const WSScanResult prevVisibleThing = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - EditorRawDOMPoint::AtEndOf(*deepestContainerElementToSplit), - BlockInlineCheck::UseComputedDisplayOutsideStyle, + {}, EditorRawDOMPoint::AtEndOf(*deepestContainerElementToSplit), leftDivOrParagraphElement); if (prevVisibleThing.ReachedLineBoundary()) { return EditorDOMPoint::AtEndOf(*deepestContainerElementToSplit); @@ -1740,9 +1722,7 @@ HTMLEditor::AutoInsertParagraphHandler::SplitParagraphWithTransaction( } const WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, - EditorRawDOMPoint(deepestContainerElementToSplit, 0), - BlockInlineCheck::UseComputedDisplayOutsideStyle, + {}, EditorRawDOMPoint(deepestContainerElementToSplit, 0), leftDivOrParagraphElement); return nextVisibleThing.ReachedCurrentBlockBoundary() ? EditorDOMPoint::AtEndOf(*deepestContainerElementToSplit) @@ -2010,9 +1990,7 @@ bool HTMLEditor::AutoInsertParagraphHandler::SplitPointIsStartOfSplittingBlock( EditorRawDOMPoint pointToSplit = aPointToSplit.To<EditorRawDOMPoint>(); while (true) { const WSScanResult prevVisibleThing = - WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, pointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary({}, pointToSplit); if (!prevVisibleThing.ReachedCurrentBlockBoundary()) { return false; } @@ -2035,17 +2013,14 @@ bool HTMLEditor::AutoInsertParagraphHandler::SplitPointIsEndOfSplittingBlock( while (true) { WSScanResult nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, pointToSplit, - BlockInlineCheck::UseComputedDisplayOutsideStyle, - &aBlockElementToSplit); + {}, pointToSplit, &aBlockElementToSplit); if (maybeFollowedByInvisibleBRElement && (nextVisibleThing.ReachedBRElement() || nextVisibleThing.ReachedPreformattedLineBreak())) { nextVisibleThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::All, + {}, nextVisibleThing.PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle, &aBlockElementToSplit); } if (!nextVisibleThing.ReachedCurrentBlockBoundary()) { diff --git a/editor/libeditor/HTMLStyleEditor.cpp b/editor/libeditor/HTMLStyleEditor.cpp @@ -1944,8 +1944,7 @@ HTMLEditor::AutoInlineStyleSetter::ExtendOrShrinkRangeToApplyTheStyle( if (range.EndRef().IsInContentNode()) { const WSScanResult nextContentData = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - WSRunScanner::Scan::EditableNodes, range.EndRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {WSRunScanner::Option::OnlyEditableNodes}, range.EndRef()); if (nextContentData.ReachedInvisibleBRElement() && nextContentData.BRElementPtr()->GetParentElement() && HTMLEditUtils::IsInlineContent( diff --git a/editor/libeditor/WSRunScanner.cpp b/editor/libeditor/WSRunScanner.cpp @@ -72,33 +72,44 @@ void WSScanResult::AssertIfInvalidData(const WSRunScanner& aScanner) const { mContent->IsHTMLElement(nsGkAtoms::br)); MOZ_ASSERT_IF(mReason == WSType::PreformattedLineBreak, EditorUtils::IsNewLinePreformatted(*mContent)); - MOZ_ASSERT_IF(mReason == WSType::SpecialContent, - (mContent->IsText() && !mContent->IsEditable()) || - (!mContent->IsHTMLElement(nsGkAtoms::br) && - !HTMLEditUtils::IsBlockElement( - *mContent, RespectChildBlockBoundary( - aScanner.BlockInlineCheckMode())))); - MOZ_ASSERT_IF(mReason == WSType::OtherBlockBoundary, - HTMLEditUtils::IsBlockElement( - *mContent, RespectChildBlockBoundary( - aScanner.BlockInlineCheckMode()))); + MOZ_ASSERT_IF( + mReason == WSType::SpecialContent, + (mContent->IsText() && !mContent->IsEditable()) || + (!mContent->IsHTMLElement(nsGkAtoms::br) && + !HTMLEditUtils::IsBlockElement( + *mContent, + aScanner.ReferredHTMLDefaultStyle() + ? BlockInlineCheck::UseHTMLDefaultStyle + : BlockInlineCheck::UseComputedDisplayOutsideStyle))); + MOZ_ASSERT_IF( + mReason == WSType::OtherBlockBoundary, + HTMLEditUtils::IsBlockElement( + *mContent, aScanner.ReferredHTMLDefaultStyle() + ? BlockInlineCheck::UseHTMLDefaultStyle + : BlockInlineCheck::UseComputedDisplayOutsideStyle)); MOZ_ASSERT_IF(mReason == WSType::CurrentBlockBoundary, mContent->IsElement()); MOZ_ASSERT_IF(mReason == WSType::CurrentBlockBoundary && - aScanner.mScanMode == WSRunScanner::Scan::EditableNodes, + aScanner.ScanOptions().contains( + WSRunScanner::Option::OnlyEditableNodes), mContent->IsEditable()); - MOZ_ASSERT_IF(mReason == WSType::CurrentBlockBoundary, - HTMLEditUtils::IsBlockElement( - *mContent, RespectParentBlockBoundary( - aScanner.BlockInlineCheckMode()))); + MOZ_ASSERT_IF( + mReason == WSType::CurrentBlockBoundary, + HTMLEditUtils::IsBlockElement( + *mContent, aScanner.ReferredHTMLDefaultStyle() + ? BlockInlineCheck::UseHTMLDefaultStyle + : BlockInlineCheck::UseComputedDisplayStyle)); MOZ_ASSERT_IF(mReason == WSType::InlineEditingHostBoundary, mContent->IsElement()); MOZ_ASSERT_IF(mReason == WSType::InlineEditingHostBoundary && - aScanner.mScanMode == WSRunScanner::Scan::EditableNodes, + aScanner.ScanOptions().contains( + WSRunScanner::Option::OnlyEditableNodes), mContent->IsEditable()); - MOZ_ASSERT_IF(mReason == WSType::InlineEditingHostBoundary, - !HTMLEditUtils::IsBlockElement( - *mContent, RespectParentBlockBoundary( - aScanner.BlockInlineCheckMode()))); + MOZ_ASSERT_IF( + mReason == WSType::InlineEditingHostBoundary, + !HTMLEditUtils::IsBlockElement( + *mContent, aScanner.ReferredHTMLDefaultStyle() + ? BlockInlineCheck::UseHTMLDefaultStyle + : BlockInlineCheck::UseComputedDisplayStyle)); MOZ_ASSERT_IF(mReason == WSType::InlineEditingHostBoundary, !mContent->GetParentElement() || !mContent->GetParentElement()->IsEditable()); @@ -129,14 +140,14 @@ WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom( template WSScanResult WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom( const EditorRawDOMPointInText& aPoint) const; -template EditorDOMPoint WSRunScanner::GetAfterLastVisiblePoint( - Scan aScanMode, Text& aTextNode, const Element* aAncestorLimiter); +template EditorDOMPoint WSRunScanner::GetAfterLastVisiblePoint(Options, Text&, + const Element*); template EditorRawDOMPoint WSRunScanner::GetAfterLastVisiblePoint( - Scan aScanMode, Text& aTextNode, const Element* aAncestorLimiter); -template EditorDOMPoint WSRunScanner::GetFirstVisiblePoint( - Scan aScanMode, Text& aTextNode, const Element* aAncestorLimiter); -template EditorRawDOMPoint WSRunScanner::GetFirstVisiblePoint( - Scan aScanMode, Text& aTextNode, const Element* aAncestorLimiter); + Options, Text&, const Element*); +template EditorDOMPoint WSRunScanner::GetFirstVisiblePoint(Options, Text&, + const Element*); +template EditorRawDOMPoint WSRunScanner::GetFirstVisiblePoint(Options, Text&, + const Element*); template <typename PT, typename CT> WSScanResult WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundaryFrom( @@ -171,7 +182,8 @@ WSScanResult WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundaryFrom( // If the visible things are not editable, we shouldn't scan "editable" // things now. Whether keep scanning editable things or not should be // considered by the caller. - if (mScanMode == Scan::EditableNodes && aPoint.GetChild() && + if (ScanOptions().contains(Option::OnlyEditableNodes) && + aPoint.GetChild() && !HTMLEditUtils::IsSimplyEditableNode((*aPoint.GetChild()))) { return WSScanResult(*this, WSScanResult::ScanDirection::Backward, *aPoint.GetChild(), WSType::SpecialContent); @@ -217,7 +229,7 @@ WSScanResult WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundaryFrom( // invisible. while (true) { const EditorRawDOMPoint atComment(comment); - WSRunScanner scanner(mScanMode, atComment, mBlockInlineCheck, + WSRunScanner scanner(ScanOptions(), atComment, mTextFragmentDataAtStart.GetAncestorLimiter()); if (scanner.TextFragmentDataAtStartRef().StartRawReason() == WSType::SpecialContent) { @@ -287,7 +299,8 @@ WSScanResult WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom( // If the visible things are not editable, we shouldn't scan "editable" // things now. Whether keep scanning editable things or not should be // considered by the caller. - if (mScanMode == Scan::EditableNodes && aPoint.GetChild() && + if (ScanOptions().contains(Option::OnlyEditableNodes) && + aPoint.GetChild() && !HTMLEditUtils::IsSimplyEditableNode(*aPoint.GetChild())) { return WSScanResult(*this, WSScanResult::ScanDirection::Forward, *aPoint.GetChild(), WSType::SpecialContent); @@ -335,7 +348,7 @@ WSScanResult WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom( while (true) { const EditorRawDOMPoint afterComment = EditorRawDOMPoint::After(*comment); - WSRunScanner scanner(mScanMode, afterComment, mBlockInlineCheck, + WSRunScanner scanner(ScanOptions(), afterComment, mTextFragmentDataAtStart.GetAncestorLimiter()); if (scanner.TextFragmentDataAtStartRef().EndRawReason() == WSType::SpecialContent) { @@ -376,8 +389,10 @@ WSScanResult WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom( // static template <typename EditorDOMPointType> EditorDOMPointType WSRunScanner::GetAfterLastVisiblePoint( - Scan aScanMode, Text& aTextNode, - const Element* aAncestorLimiter /* = nullptr */) { + Options aOptions, // NOLINT(performance-unnecessary-value-param) + Text& aTextNode, const Element* aAncestorLimiter /* = nullptr */) { + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); + EditorDOMPoint atLastCharOfTextNode( &aTextNode, AssertedCast<uint32_t>(std::max<int64_t>( static_cast<int64_t>(aTextNode.Length()) - 1, 0))); @@ -385,8 +400,7 @@ EditorDOMPointType WSRunScanner::GetAfterLastVisiblePoint( !atLastCharOfTextNode.IsCharCollapsibleASCIISpace()) { return EditorDOMPointType::AtEndOf(aTextNode); } - const TextFragmentData textFragmentData(aScanMode, atLastCharOfTextNode, - ReferHTMLDefaultStyle::No, + const TextFragmentData textFragmentData(aOptions, atLastCharOfTextNode, aAncestorLimiter); if (NS_WARN_IF(!textFragmentData.IsInitialized())) { return EditorDOMPointType(); // TODO: Make here return error with Err. @@ -403,15 +417,16 @@ EditorDOMPointType WSRunScanner::GetAfterLastVisiblePoint( // static template <typename EditorDOMPointType> EditorDOMPointType WSRunScanner::GetFirstVisiblePoint( - Scan aScanMode, Text& aTextNode, - const Element* aAncestorLimiter /* = nullptr */) { + Options aOptions, // NOLINT(performance-unnecessary-value-param) + Text& aTextNode, const Element* aAncestorLimiter /* = nullptr */) { + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); + EditorDOMPoint atStartOfTextNode(&aTextNode, 0); if (!atStartOfTextNode.IsContainerEmpty() && !atStartOfTextNode.IsCharCollapsibleASCIISpace()) { return atStartOfTextNode.To<EditorDOMPointType>(); } - const TextFragmentData textFragmentData(aScanMode, atStartOfTextNode, - ReferHTMLDefaultStyle::No, + const TextFragmentData textFragmentData(aOptions, atStartOfTextNode, aAncestorLimiter); if (NS_WARN_IF(!textFragmentData.IsInitialized())) { return EditorDOMPointType(); // TODO: Make here return error with Err. @@ -433,7 +448,7 @@ EditorDOMPointType WSRunScanner::GetFirstVisiblePoint( EditorDOMRangeInTexts WSRunScanner::ComputeRangeInTextNodesContainingInvisibleWhiteSpaces( const TextFragmentData& aStart, const TextFragmentData& aEnd) { - MOZ_ASSERT(aStart.ScanMode() == aEnd.ScanMode()); + MOZ_ASSERT(aStart.ScanOptions() == aEnd.ScanOptions()); // Corresponding to handling invisible white-spaces part of // `TextFragmentData::GetReplaceRangeDataAtEndOfDeletionRange()` and @@ -497,11 +512,11 @@ WSRunScanner::ComputeRangeInTextNodesContainingInvisibleWhiteSpaces( ? aStart.GetInclusiveNextCharPoint<EditorDOMPointInText>( aroundFirstInvisibleWhiteSpace, ShouldIgnoreNonEditableSiblingsOrDescendants( - aStart.ScanMode())) + aStart.ScanOptions())) : aEnd.GetInclusiveNextCharPoint<EditorDOMPointInText>( aroundFirstInvisibleWhiteSpace, ShouldIgnoreNonEditableSiblingsOrDescendants( - aEnd.ScanMode())); + aEnd.ScanOptions())); MOZ_ASSERT(atFirstInvisibleWhiteSpace.IsSet()); MOZ_ASSERT( atFirstInvisibleWhiteSpace.EqualsOrIsBefore(result.StartRef())); @@ -530,11 +545,12 @@ WSRunScanner::ComputeRangeInTextNodesContainingInvisibleWhiteSpaces( hasInvisibleTrailingWhiteSpaces ? aEnd.GetPreviousCharPoint<EditorDOMPointInText>( afterLastInvisibleWhiteSpace, - ShouldIgnoreNonEditableSiblingsOrDescendants(aEnd.ScanMode())) + ShouldIgnoreNonEditableSiblingsOrDescendants( + aEnd.ScanOptions())) : aStart.GetPreviousCharPoint<EditorDOMPointInText>( afterLastInvisibleWhiteSpace, ShouldIgnoreNonEditableSiblingsOrDescendants( - aStart.ScanMode())); + aStart.ScanOptions())); MOZ_ASSERT(atLastInvisibleWhiteSpace.IsSet()); MOZ_ASSERT(atLastInvisibleWhiteSpace.IsContainerEmpty() || atLastInvisibleWhiteSpace.IsAtLastContent()); @@ -549,20 +565,22 @@ WSRunScanner::ComputeRangeInTextNodesContainingInvisibleWhiteSpaces( // static Result<EditorDOMRangeInTexts, nsresult> WSRunScanner::GetRangeInTextNodesToBackspaceFrom( - Scan aScanMode, const EditorDOMPoint& aPoint, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPoint& aPoint, const Element* aAncestorLimiter /* = nullptr */) { // Corresponding to computing delete range part of // `WhiteSpaceVisibilityKeeper::DeletePreviousWhiteSpace()` MOZ_ASSERT(aPoint.IsSetAndValid()); + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); - const TextFragmentData textFragmentDataAtCaret( - aScanMode, aPoint, ReferHTMLDefaultStyle::No, aAncestorLimiter); + const TextFragmentData textFragmentDataAtCaret(aOptions, aPoint, + aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtCaret.IsInitialized())) { return Err(NS_ERROR_FAILURE); } auto atPreviousChar = textFragmentDataAtCaret.GetPreviousCharPoint<EditorDOMPointInText>( - aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants(aScanMode)); + aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants(aOptions)); if (!atPreviousChar.IsSet()) { return EditorDOMRangeInTexts(); // There is no content in the block. } @@ -597,7 +615,7 @@ WSRunScanner::GetRangeInTextNodesToBackspaceFrom( textFragmentDataAtCaret .GetFirstASCIIWhiteSpacePointCollapsedTo<EditorDOMPointInText>( atPreviousChar, nsIEditor::ePrevious, - ShouldIgnoreNonEditableSiblingsOrDescendants(aScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(aOptions)); if (!startToDelete.IsSet()) { NS_WARNING( "WSRunScanner::GetFirstASCIIWhiteSpacePointCollapsedTo() failed"); @@ -607,7 +625,7 @@ WSRunScanner::GetRangeInTextNodesToBackspaceFrom( textFragmentDataAtCaret .GetEndOfCollapsibleASCIIWhiteSpaces<EditorDOMPointInText>( atPreviousChar, nsIEditor::ePrevious, - ShouldIgnoreNonEditableSiblingsOrDescendants(aScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(aOptions)); if (!endToDelete.IsSet()) { NS_WARNING("WSRunScanner::GetEndOfCollapsibleASCIIWhiteSpaces() failed"); return Err(NS_ERROR_FAILURE); @@ -627,13 +645,12 @@ WSRunScanner::GetRangeInTextNodesToBackspaceFrom( // And also delete invisible white-spaces if they become visible. const TextFragmentData textFragmentDataAtStart = rangeToDelete.StartRef() != aPoint - ? TextFragmentData(aScanMode, rangeToDelete.StartRef(), - ReferHTMLDefaultStyle::No, aAncestorLimiter) + ? TextFragmentData(aOptions, rangeToDelete.StartRef(), + aAncestorLimiter) : textFragmentDataAtCaret; const TextFragmentData textFragmentDataAtEnd = rangeToDelete.EndRef() != aPoint - ? TextFragmentData(aScanMode, rangeToDelete.EndRef(), - ReferHTMLDefaultStyle::No, aAncestorLimiter) + ? TextFragmentData(aOptions, rangeToDelete.EndRef(), aAncestorLimiter) : textFragmentDataAtCaret; if (NS_WARN_IF(!textFragmentDataAtStart.IsInitialized()) || NS_WARN_IF(!textFragmentDataAtEnd.IsInitialized())) { @@ -650,20 +667,22 @@ WSRunScanner::GetRangeInTextNodesToBackspaceFrom( // static Result<EditorDOMRangeInTexts, nsresult> WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom( - Scan aScanMode, const EditorDOMPoint& aPoint, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPoint& aPoint, const Element* aAncestorLimiter /* = nullptr */) { // Corresponding to computing delete range part of // `WhiteSpaceVisibilityKeeper::DeleteInclusiveNextWhiteSpace()` MOZ_ASSERT(aPoint.IsSetAndValid()); + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); - const TextFragmentData textFragmentDataAtCaret( - aScanMode, aPoint, ReferHTMLDefaultStyle::No, aAncestorLimiter); + const TextFragmentData textFragmentDataAtCaret(aOptions, aPoint, + aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtCaret.IsInitialized())) { return Err(NS_ERROR_FAILURE); } auto atCaret = textFragmentDataAtCaret.GetInclusiveNextCharPoint<EditorDOMPointInText>( - aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants(aScanMode)); + aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants(aOptions)); if (!atCaret.IsSet()) { return EditorDOMRangeInTexts(); // There is no content in the block. } @@ -697,7 +716,7 @@ WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom( textFragmentDataAtCaret .GetFirstASCIIWhiteSpacePointCollapsedTo<EditorDOMPointInText>( atCaret, nsIEditor::eNext, - ShouldIgnoreNonEditableSiblingsOrDescendants(aScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(aOptions)); if (!startToDelete.IsSet()) { NS_WARNING( "WSRunScanner::GetFirstASCIIWhiteSpacePointCollapsedTo() failed"); @@ -707,7 +726,7 @@ WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom( textFragmentDataAtCaret .GetEndOfCollapsibleASCIIWhiteSpaces<EditorDOMPointInText>( atCaret, nsIEditor::eNext, - ShouldIgnoreNonEditableSiblingsOrDescendants(aScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(aOptions)); if (!endToDelete.IsSet()) { NS_WARNING("WSRunScanner::GetEndOfCollapsibleASCIIWhiteSpaces() failed"); return Err(NS_ERROR_FAILURE); @@ -727,13 +746,12 @@ WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom( // And also delete invisible white-spaces if they become visible. const TextFragmentData textFragmentDataAtStart = rangeToDelete.StartRef() != aPoint - ? TextFragmentData(aScanMode, rangeToDelete.StartRef(), - ReferHTMLDefaultStyle::No, aAncestorLimiter) + ? TextFragmentData(aOptions, rangeToDelete.StartRef(), + aAncestorLimiter) : textFragmentDataAtCaret; const TextFragmentData textFragmentDataAtEnd = rangeToDelete.EndRef() != aPoint - ? TextFragmentData(aScanMode, rangeToDelete.EndRef(), - ReferHTMLDefaultStyle::No, aAncestorLimiter) + ? TextFragmentData(aOptions, rangeToDelete.EndRef(), aAncestorLimiter) : textFragmentDataAtCaret; if (NS_WARN_IF(!textFragmentDataAtStart.IsInitialized()) || NS_WARN_IF(!textFragmentDataAtEnd.IsInitialized())) { @@ -749,14 +767,16 @@ WSRunScanner::GetRangeInTextNodesToForwardDeleteFrom( // static EditorDOMRange WSRunScanner::GetRangesForDeletingAtomicContent( - Scan aScanMode, const nsIContent& aAtomicContent, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const nsIContent& aAtomicContent, const Element* aAncestorLimiter /* = nullptr */) { + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); + if (aAtomicContent.IsHTMLElement(nsGkAtoms::br)) { // Preceding white-spaces should be preserved, but the following // white-spaces should be invisible around `<br>` element. const TextFragmentData textFragmentDataAfterBRElement( - aScanMode, EditorDOMPoint::After(aAtomicContent), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aOptions, EditorDOMPoint::After(aAtomicContent), aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAfterBRElement.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. } @@ -786,8 +806,8 @@ EditorDOMRange WSRunScanner::GetRangesForDeletingAtomicContent( // Both preceding and following white-spaces can be invisible around a // block element. const TextFragmentData textFragmentDataBeforeAtomicContent( - aScanMode, EditorDOMPoint(const_cast<nsIContent*>(&aAtomicContent)), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aOptions, EditorDOMPoint(const_cast<nsIContent*>(&aAtomicContent)), + aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataBeforeAtomicContent.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. } @@ -796,8 +816,7 @@ EditorDOMRange WSRunScanner::GetRangesForDeletingAtomicContent( textFragmentDataBeforeAtomicContent .InvisibleTrailingWhiteSpaceRangeRef()); const TextFragmentData textFragmentDataAfterAtomicContent( - aScanMode, EditorDOMPoint::After(aAtomicContent), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aOptions, EditorDOMPoint::After(aAtomicContent), aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAfterAtomicContent.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. } @@ -826,8 +845,8 @@ EditorDOMRange WSRunScanner::GetRangesForDeletingAtomicContent( // static EditorDOMRange WSRunScanner::GetRangeForDeletingBlockElementBoundaries( - Scan aScanMode, const Element& aLeftBlockElement, - const Element& aRightBlockElement, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const Element& aLeftBlockElement, const Element& aRightBlockElement, const EditorDOMPoint& aPointContainingTheOtherBlock, const Element* aAncestorLimiter /* = nullptr */) { MOZ_ASSERT(&aLeftBlockElement != &aRightBlockElement); @@ -857,18 +876,19 @@ EditorDOMRange WSRunScanner::GetRangeForDeletingBlockElementBoundaries( aLeftBlockElement.IsInclusiveDescendantOf(aAncestorLimiter)); MOZ_ASSERT_IF(aAncestorLimiter, aRightBlockElement.IsInclusiveDescendantOf(aAncestorLimiter)); - MOZ_ASSERT_IF(aScanMode == Scan::EditableNodes, + MOZ_ASSERT_IF(aOptions.contains(Option::OnlyEditableNodes), const_cast<Element&>(aLeftBlockElement).GetEditingHost() == const_cast<Element&>(aRightBlockElement).GetEditingHost()); + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); EditorDOMRange range; // Include trailing invisible white-spaces in aLeftBlockElement. const TextFragmentData textFragmentDataAtEndOfLeftBlockElement( - aScanMode, + aOptions, aPointContainingTheOtherBlock.GetContainer() == &aLeftBlockElement ? aPointContainingTheOtherBlock : EditorDOMPoint::AtEndOf(const_cast<Element&>(aLeftBlockElement)), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtEndOfLeftBlockElement.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. } @@ -891,12 +911,12 @@ EditorDOMRange WSRunScanner::GetRangeForDeletingBlockElementBoundaries( } // Include leading invisible white-spaces in aRightBlockElement. const TextFragmentData textFragmentDataAtStartOfRightBlockElement( - aScanMode, + aOptions, aPointContainingTheOtherBlock.GetContainer() == &aRightBlockElement && !aPointContainingTheOtherBlock.IsEndOfContainer() ? aPointContainingTheOtherBlock.NextPoint() : EditorDOMPoint(const_cast<Element*>(&aRightBlockElement), 0u), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtStartOfRightBlockElement.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. } @@ -914,15 +934,16 @@ EditorDOMRange WSRunScanner::GetRangeForDeletingBlockElementBoundaries( // static EditorDOMRange WSRunScanner::GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries( - Scan aScanMode, const EditorDOMRange& aRange, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMRange& aRange, const Element* aAncestorLimiter /* = nullptr */) { MOZ_ASSERT(aRange.IsPositionedAndValid()); MOZ_ASSERT(aRange.EndRef().IsSetAndValid()); MOZ_ASSERT(aRange.StartRef().IsSetAndValid()); + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); EditorDOMRange result; - const TextFragmentData textFragmentDataAtStart(aScanMode, aRange.StartRef(), - ReferHTMLDefaultStyle::No, + const TextFragmentData textFragmentDataAtStart(aOptions, aRange.StartRef(), aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtStart.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. @@ -957,8 +978,8 @@ WSRunScanner::GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries( result.SetStart(aRange.StartRef()); } - const TextFragmentData textFragmentDataAtEnd( - aScanMode, aRange.EndRef(), ReferHTMLDefaultStyle::No, aAncestorLimiter); + const TextFragmentData textFragmentDataAtEnd(aOptions, aRange.EndRef(), + aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtEnd.IsInitialized())) { return EditorDOMRange(); // TODO: Make here return error with Err. } @@ -1002,11 +1023,12 @@ WSRunScanner::GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries( // static Result<bool, nsresult> WSRunScanner::ShrinkRangeIfStartsFromOrEndsAfterAtomicContent( - Scan aScanMode, nsRange& aRange, - const Element* aAncestorLimiter /* = nullptr */) { + Options aOptions, // NOLINT(performance-unnecessary-value-param) + nsRange& aRange, const Element* aAncestorLimiter /* = nullptr */) { MOZ_ASSERT(aRange.IsPositioned()); MOZ_ASSERT(!aRange.IsInAnySelection(), "Changing range in selection may cause running script"); + MOZ_ASSERT(!aOptions.contains(Option::ReferHTMLDefaultStyle)); if (NS_WARN_IF(!aRange.GetStartContainer()) || NS_WARN_IF(!aRange.GetEndContainer())) { @@ -1023,13 +1045,13 @@ WSRunScanner::ShrinkRangeIfStartsFromOrEndsAfterAtomicContent( // joining the blocks. if (HTMLEditUtils::GetInclusiveAncestorElement( *aRange.GetStartContainer()->AsContent(), - aScanMode == Scan::EditableNodes + aOptions.contains(Option::OnlyEditableNodes) ? HTMLEditUtils::ClosestEditableBlockElementExceptHRElement : HTMLEditUtils::ClosestBlockElementExceptHRElement, BlockInlineCheck::UseComputedDisplayStyle) != HTMLEditUtils::GetInclusiveAncestorElement( *aRange.GetEndContainer()->AsContent(), - aScanMode == Scan::EditableNodes + aOptions.contains(Option::OnlyEditableNodes) ? HTMLEditUtils::ClosestEditableBlockElementExceptHRElement : HTMLEditUtils::ClosestBlockElementExceptHRElement, BlockInlineCheck::UseComputedDisplayStyle)) { @@ -1043,8 +1065,7 @@ WSRunScanner::ShrinkRangeIfStartsFromOrEndsAfterAtomicContent( // (e.g., `<img>`, non-editable text node, etc) or a block level void // element like `<hr>`, the range should start with it. const TextFragmentData textFragmentDataAtStart( - aScanMode, EditorRawDOMPoint(aRange.StartRef()), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aOptions, EditorRawDOMPoint(aRange.StartRef()), aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtStart.IsInitialized())) { return Err(NS_ERROR_FAILURE); } @@ -1066,8 +1087,7 @@ WSRunScanner::ShrinkRangeIfStartsFromOrEndsAfterAtomicContent( // (e.g., `<img>`, non-editable text node, etc) or a block level void // element like `<hr>`, the range should end after it. const TextFragmentData textFragmentDataAtEnd( - aScanMode, EditorRawDOMPoint(aRange.EndRef()), - ReferHTMLDefaultStyle::No, aAncestorLimiter); + aOptions, EditorRawDOMPoint(aRange.EndRef()), aAncestorLimiter); if (NS_WARN_IF(!textFragmentDataAtEnd.IsInitialized())) { return Err(NS_ERROR_FAILURE); } diff --git a/editor/libeditor/WSRunScanner.h b/editor/libeditor/WSRunScanner.h @@ -389,34 +389,47 @@ class MOZ_STACK_CLASS WSRunScanner final { enum class IgnoreNonEditableNodes : bool { No, Yes }; enum class StopAtNonEditableNode : bool { No, Yes }; - enum class Scan : bool { All, EditableNodes }; enum class ReferHTMLDefaultStyle : bool { No, Yes }; + enum class Option { + // If set, return only editable content or return non-editable content as a + // special content in the closest editing host if the scan start point is + // editable. + OnlyEditableNodes, + // If set, use the HTML default style to consider whether the found one is a + // block or an inline. + ReferHTMLDefaultStyle, + }; + using Options = EnumSet<Option>; [[nodiscard]] constexpr static IgnoreNonEditableNodes - ShouldIgnoreNonEditableSiblingsOrDescendants(Scan aScan) { - return static_cast<IgnoreNonEditableNodes>(static_cast<bool>(aScan)); + ShouldIgnoreNonEditableSiblingsOrDescendants( + Options aOptions // NOLINT(performance-unnecessary-value-param) + ) { + return static_cast<IgnoreNonEditableNodes>( + aOptions.contains(Option::OnlyEditableNodes)); } [[nodiscard]] constexpr static StopAtNonEditableNode - ShouldStopAtNonEditableNode(Scan aScan) { - return static_cast<StopAtNonEditableNode>(static_cast<bool>(aScan)); + ShouldStopAtNonEditableNode( + Options aOptions // NOLINT(performance-unnecessary-value-param) + ) { + return static_cast<StopAtNonEditableNode>( + aOptions.contains(Option::OnlyEditableNodes)); } [[nodiscard]] constexpr static ReferHTMLDefaultStyle - ShouldReferHTMLDefaultStyle(BlockInlineCheck aBlockInlineCheck) { + ShouldReferHTMLDefaultStyle( + Options aOptions // NOLINT(performance-unnecessary-value-param) + ) { return static_cast<ReferHTMLDefaultStyle>( - aBlockInlineCheck == BlockInlineCheck::UseHTMLDefaultStyle); + aOptions.contains(Option::ReferHTMLDefaultStyle)); } template <typename EditorDOMPointType> - WSRunScanner(Scan aScanMode, const EditorDOMPointType& aScanStartPoint, - BlockInlineCheck aBlockInlineCheck, + WSRunScanner(Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aScanStartPoint, const Element* aAncestorLimiter = nullptr) : mScanStartPoint(aScanStartPoint.template To<EditorDOMPoint>()), - mTextFragmentDataAtStart(aScanMode, mScanStartPoint, - ShouldReferHTMLDefaultStyle(aBlockInlineCheck), - aAncestorLimiter), - mScanMode(aScanMode), - mBlockInlineCheck(aBlockInlineCheck) {} + mTextFragmentDataAtStart(aOptions, mScanStartPoint, aAncestorLimiter) {} // ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom() returns the first visible // node at or after aPoint. If there is no visible nodes after aPoint, @@ -429,10 +442,10 @@ class MOZ_STACK_CLASS WSRunScanner final { const EditorDOMPointBase<PT, CT>& aPoint) const; template <typename PT, typename CT> static WSScanResult ScanInclusiveNextVisibleNodeOrBlockBoundary( - Scan aScanMode, const EditorDOMPointBase<PT, CT>& aPoint, - BlockInlineCheck aBlockInlineCheck, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointBase<PT, CT>& aPoint, const Element* aAncestorLimiter = nullptr) { - return WSRunScanner(aScanMode, aPoint, aBlockInlineCheck, aAncestorLimiter) + return WSRunScanner(aOptions, aPoint, aAncestorLimiter) .ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom(aPoint); } @@ -447,10 +460,10 @@ class MOZ_STACK_CLASS WSRunScanner final { const EditorDOMPointBase<PT, CT>& aPoint) const; template <typename PT, typename CT> static WSScanResult ScanPreviousVisibleNodeOrBlockBoundary( - Scan aScanMode, const EditorDOMPointBase<PT, CT>& aPoint, - BlockInlineCheck aBlockInlineCheck, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointBase<PT, CT>& aPoint, const Element* aAncestorLimiter = nullptr) { - return WSRunScanner(aScanMode, aPoint, aBlockInlineCheck, aAncestorLimiter) + return WSRunScanner(aOptions, aPoint, aAncestorLimiter) .ScanPreviousVisibleNodeOrBlockBoundaryFrom(aPoint); } @@ -460,17 +473,17 @@ class MOZ_STACK_CLASS WSRunScanner final { */ template <typename EditorDOMPointType, typename PT, typename CT> static EditorDOMPointType GetInclusiveNextCharPoint( - Scan aScanMode, const EditorDOMPointBase<PT, CT>& aPoint, - BlockInlineCheck aBlockInlineCheck, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointBase<PT, CT>& aPoint, const Element* aAncestorLimiter = nullptr) { if (aPoint.IsInTextNode() && !aPoint.IsEndOfContainer() && - (aScanMode != Scan::EditableNodes || + (!aOptions.contains(Option::OnlyEditableNodes) || HTMLEditUtils::IsSimplyEditableNode( *aPoint.template ContainerAs<Text>()))) { return EditorDOMPointType(aPoint.template ContainerAs<Text>(), aPoint.Offset()); } - return WSRunScanner(aScanMode, aPoint, aBlockInlineCheck, aAncestorLimiter) + return WSRunScanner(aOptions, aPoint, aAncestorLimiter) .GetInclusiveNextCharPoint<EditorDOMPointType>(aPoint); } @@ -479,17 +492,17 @@ class MOZ_STACK_CLASS WSRunScanner final { */ template <typename EditorDOMPointType, typename PT, typename CT> static EditorDOMPointType GetPreviousCharPoint( - Scan aScanMode, const EditorDOMPointBase<PT, CT>& aPoint, - BlockInlineCheck aBlockInlineCheck, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointBase<PT, CT>& aPoint, const Element* aAncestorLimiter = nullptr) { if (aPoint.IsInTextNode() && !aPoint.IsStartOfContainer() && - (aScanMode != Scan::EditableNodes || + (!aOptions.contains(Option::OnlyEditableNodes) || HTMLEditUtils::IsSimplyEditableNode( *aPoint.template ContainerAs<Text>()))) { return EditorDOMPointType(aPoint.template ContainerAs<Text>(), aPoint.Offset() - 1); } - return WSRunScanner(aScanMode, aPoint, aBlockInlineCheck, aAncestorLimiter) + return WSRunScanner(aOptions, aPoint, aAncestorLimiter) .GetPreviousCharPoint<EditorDOMPointType>(aPoint); } @@ -503,12 +516,12 @@ class MOZ_STACK_CLASS WSRunScanner final { */ template <typename EditorDOMPointType> static EditorDOMPointType GetAfterLastVisiblePoint( - Scan aScanMode, Text& aTextNode, - const Element* aAncestorLimiter = nullptr); + Options aOptions, // NOLINT(performance-unnecessary-value-param) + Text& aTextNode, const Element* aAncestorLimiter = nullptr); template <typename EditorDOMPointType> static EditorDOMPointType GetFirstVisiblePoint( - Scan aScanMode, Text& aTextNode, - const Element* aAncestorLimiter = nullptr); + Options aOptions, // NOLINT(performance-unnecessary-value-param) + Text& aTextNode, const Element* aAncestorLimiter = nullptr); /** * GetRangeInTextNodesToForwardDeleteFrom() returns the range to remove @@ -516,17 +529,17 @@ class MOZ_STACK_CLASS WSRunScanner final { */ static Result<EditorDOMRangeInTexts, nsresult> GetRangeInTextNodesToForwardDeleteFrom( - Scan aScanMode, const EditorDOMPoint& aPoint, - const Element* aAncestorLimiter = nullptr); + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPoint& aPoint, const Element* aAncestorLimiter = nullptr); /** * GetRangeInTextNodesToBackspaceFrom() returns the range to remove text * when caret is at aPoint. */ static Result<EditorDOMRangeInTexts, nsresult> - GetRangeInTextNodesToBackspaceFrom(Scan aScanMode, - const EditorDOMPoint& aPoint, - const Element* aAncestorLimiter = nullptr); + GetRangeInTextNodesToBackspaceFrom( + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPoint& aPoint, const Element* aAncestorLimiter = nullptr); /** * GetRangesForDeletingAtomicContent() returns the range to delete @@ -534,7 +547,8 @@ class MOZ_STACK_CLASS WSRunScanner final { * be included into the range. */ static EditorDOMRange GetRangesForDeletingAtomicContent( - Scan aScanMode, const nsIContent& aAtomicContent, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const nsIContent& aAtomicContent, const Element* aAncestorLimiter = nullptr); /** @@ -557,8 +571,8 @@ class MOZ_STACK_CLASS WSRunScanner final { * Otherwise, must not be set. */ static EditorDOMRange GetRangeForDeletingBlockElementBoundaries( - Scan aScanMode, const Element& aLeftBlockElement, - const Element& aRightBlockElement, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const Element& aLeftBlockElement, const Element& aRightBlockElement, const EditorDOMPoint& aPointContainingTheOtherBlock, const Element* aAncestorLimiter = nullptr); @@ -568,16 +582,16 @@ class MOZ_STACK_CLASS WSRunScanner final { * is in adjacent text nodes. Returns true if this modifies the range. */ static Result<bool, nsresult> ShrinkRangeIfStartsFromOrEndsAfterAtomicContent( - Scan aScanMode, nsRange& aRange, - const Element* aAncestorLimiter = nullptr); + Options aOptions, // NOLINT(performance-unnecessary-value-param) + nsRange& aRange, const Element* aAncestorLimiter = nullptr); /** * GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries() returns * extended range if range boundaries of aRange are in invisible white-spaces. */ static EditorDOMRange GetRangeContainingInvisibleWhiteSpacesAtRangeBoundaries( - Scan aScanMode, const EditorDOMRange& aRange, - const Element* aAncestorLimiter = nullptr); + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMRange& aRange, const Element* aAncestorLimiter = nullptr); /** * GetPrecedingBRElementUnlessVisibleContentFound() scans a `<br>` element @@ -588,8 +602,8 @@ class MOZ_STACK_CLASS WSRunScanner final { template <typename EditorDOMPointType> MOZ_NEVER_INLINE_DEBUG static HTMLBRElement* GetPrecedingBRElementUnlessVisibleContentFound( - Scan aScanMode, const EditorDOMPointType& aPoint, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, const Element* aAncestorLimiter = nullptr) { MOZ_ASSERT(aPoint.IsSetAndValid()); // XXX This method behaves differently even in similar point. @@ -604,15 +618,17 @@ class MOZ_STACK_CLASS WSRunScanner final { } // TODO: Scan for end boundary is redundant in this case, we should optimize // it. - TextFragmentData textFragmentData(aScanMode, aPoint, aReferHTMLDefaultStyle, - aAncestorLimiter); + TextFragmentData textFragmentData(aOptions, aPoint, aAncestorLimiter); return textFragmentData.StartsFromBRElement() ? textFragmentData.StartReasonBRElementPtr() : nullptr; } - constexpr BlockInlineCheck BlockInlineCheckMode() const { - return mBlockInlineCheck; + [[nodiscard]] constexpr Options ScanOptions() const { + return mTextFragmentDataAtStart.ScanOptions(); + } + [[nodiscard]] bool ReferredHTMLDefaultStyle() const { + return mTextFragmentDataAtStart.ReferredHTMLDefaultStyle(); } const EditorDOMPoint& ScanStartRef() const { return mScanStartPoint; } @@ -748,7 +764,8 @@ class MOZ_STACK_CLASS WSRunScanner final { const EditorDOMPointBase<PT, CT>& aPoint) const { return TextFragmentDataAtStartRef() .GetInclusiveNextCharPoint<EditorDOMPointType>( - aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants( + mTextFragmentDataAtStart.ScanOptions())); } /** @@ -763,7 +780,8 @@ class MOZ_STACK_CLASS WSRunScanner final { const EditorDOMPointBase<PT, CT>& aPoint) const { return TextFragmentDataAtStartRef() .GetPreviousCharPoint<EditorDOMPointType>( - aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + aPoint, ShouldIgnoreNonEditableSiblingsOrDescendants( + mTextFragmentDataAtStart.ScanOptions())); } /** @@ -829,10 +847,8 @@ class MOZ_STACK_CLASS WSRunScanner final { */ template <typename EditorDOMPointType> static BoundaryData ScanCollapsibleWhiteSpaceStartFrom( - Scan aScanMode, const EditorDOMPointType& aPoint, - NoBreakingSpaceData* aNBSPData, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, - StopAtNonEditableNode aStopAtNonEditableNode, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, NoBreakingSpaceData* aNBSPData, const Element& aAncestorLimiter); /** @@ -847,10 +863,8 @@ class MOZ_STACK_CLASS WSRunScanner final { */ template <typename EditorDOMPointType> static BoundaryData ScanCollapsibleWhiteSpaceEndFrom( - Scan aScanMode, const EditorDOMPointType& aPoint, - NoBreakingSpaceData* aNBSPData, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, - StopAtNonEditableNode aStopAtNonEditableNode, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, NoBreakingSpaceData* aNBSPData, const Element& aAncestorLimiter); BoundaryData() = default; @@ -963,18 +977,18 @@ class MOZ_STACK_CLASS WSRunScanner final { * aAncestorLimiter is specified to the editing host. */ template <typename EditorDOMPointType> - TextFragmentData(Scan aScanMode, const EditorDOMPointType& aPoint, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, - const Element* aAncestorLimiter = nullptr); + TextFragmentData( + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, + const Element* aAncestorLimiter = nullptr); bool IsInitialized() const { return mStart.Initialized() && mEnd.Initialized(); } - constexpr Scan ScanMode() const { return mScanMode; } - - constexpr bool ReferredHTMLDefaultStyle() const { - return static_cast<bool>(mReferHTMLDefaultStyle); + [[nodiscard]] constexpr Options ScanOptions() const { return mOptions; } + [[nodiscard]] bool ReferredHTMLDefaultStyle() const { + return mOptions.contains(Option::ReferHTMLDefaultStyle); } const Element* GetAncestorLimiter() const { return mAncestorLimiter; } @@ -1085,8 +1099,8 @@ class MOZ_STACK_CLASS WSRunScanner final { const EditorDOMPointBase<PT, CT>& aPoint, IgnoreNonEditableNodes aIgnoreNonEditableNodes) const { return GetInclusiveNextCharPoint<EditorDOMPointType>( - aPoint, mReferHTMLDefaultStyle, aIgnoreNonEditableNodes, - GetEndReasonContent()); + aPoint, ShouldReferHTMLDefaultStyle(mOptions), + aIgnoreNonEditableNodes, GetEndReasonContent()); } /** @@ -1105,8 +1119,8 @@ class MOZ_STACK_CLASS WSRunScanner final { const EditorDOMPointBase<PT, CT>& aPoint, IgnoreNonEditableNodes aIgnoreNonEditableNodes) const { return GetPreviousCharPoint<EditorDOMPointType>( - aPoint, mReferHTMLDefaultStyle, aIgnoreNonEditableNodes, - GetStartReasonContent()); + aPoint, ShouldReferHTMLDefaultStyle(mOptions), + aIgnoreNonEditableNodes, GetStartReasonContent()); } /** @@ -1130,8 +1144,9 @@ class MOZ_STACK_CLASS WSRunScanner final { nsIEditor::EDirection aDirectionToDelete, IgnoreNonEditableNodes aIgnoreNonEditableNodes) const { return GetEndOfCollapsibleASCIIWhiteSpaces<EditorDOMPointType>( - aPointAtASCIIWhiteSpace, aDirectionToDelete, mReferHTMLDefaultStyle, - aIgnoreNonEditableNodes, GetEndReasonContent()); + aPointAtASCIIWhiteSpace, aDirectionToDelete, + ShouldReferHTMLDefaultStyle(mOptions), aIgnoreNonEditableNodes, + GetEndReasonContent()); } /** @@ -1156,8 +1171,9 @@ class MOZ_STACK_CLASS WSRunScanner final { nsIEditor::EDirection aDirectionToDelete, IgnoreNonEditableNodes aIgnoreNonEditableNodes) const { return GetFirstASCIIWhiteSpacePointCollapsedTo<EditorDOMPointType>( - aPointAtASCIIWhiteSpace, aDirectionToDelete, mReferHTMLDefaultStyle, - aIgnoreNonEditableNodes, GetStartReasonContent()); + aPointAtASCIIWhiteSpace, aDirectionToDelete, + ShouldReferHTMLDefaultStyle(mOptions), aIgnoreNonEditableNodes, + GetStartReasonContent()); } /** @@ -1406,8 +1422,7 @@ class MOZ_STACK_CLASS WSRunScanner final { mutable Maybe<EditorDOMRange> mLeadingWhiteSpaceRange; mutable Maybe<EditorDOMRange> mTrailingWhiteSpaceRange; mutable Maybe<VisibleWhiteSpacesData> mVisibleWhiteSpacesData; - const ReferHTMLDefaultStyle mReferHTMLDefaultStyle; - Scan mScanMode; + const Options mOptions; }; const TextFragmentData& TextFragmentDataAtStartRef() const { @@ -1436,9 +1451,6 @@ class MOZ_STACK_CLASS WSRunScanner final { TextFragmentData mTextFragmentDataAtStart; - const Scan mScanMode; - const BlockInlineCheck mBlockInlineCheck; - friend class WhiteSpaceVisibilityKeeper; friend class WSScanResult; }; diff --git a/editor/libeditor/WSRunScannerNestedClasses.cpp b/editor/libeditor/WSRunScannerNestedClasses.cpp @@ -27,17 +27,15 @@ using AncestorTypes = HTMLEditUtils::AncestorTypes; using LeafNodeType = HTMLEditUtils::LeafNodeType; using LeafNodeTypes = HTMLEditUtils::LeafNodeTypes; -template WSRunScanner::TextFragmentData::TextFragmentData(Scan, +template WSRunScanner::TextFragmentData::TextFragmentData(Options, const EditorDOMPoint&, - ReferHTMLDefaultStyle, const Element*); template WSRunScanner::TextFragmentData::TextFragmentData( - Scan, const EditorRawDOMPoint&, ReferHTMLDefaultStyle, const Element*); + Options, const EditorRawDOMPoint&, const Element*); template WSRunScanner::TextFragmentData::TextFragmentData( - Scan, const EditorDOMPointInText&, ReferHTMLDefaultStyle, const Element*); + Options, const EditorDOMPointInText&, const Element*); template WSRunScanner::TextFragmentData::TextFragmentData( - Scan, const EditorRawDOMPointInText&, ReferHTMLDefaultStyle, - const Element*); + Options, const EditorRawDOMPointInText&, const Element*); NS_INSTANTIATE_METHOD_RETURNING_ANY_EDITOR_DOM_POINT( WSRunScanner::TextFragmentData::GetInclusiveNextCharPoint, @@ -103,12 +101,10 @@ constexpr static const AncestorTypes kScanEditableRootAncestorTypes = { template <typename EditorDOMPointType> WSRunScanner::TextFragmentData::TextFragmentData( - Scan aScanMode, const EditorDOMPointType& aPoint, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, const Element* aAncestorLimiter /* = nullptr */) - : mAncestorLimiter(aAncestorLimiter), - mReferHTMLDefaultStyle(aReferHTMLDefaultStyle), - mScanMode(aScanMode) { + : mAncestorLimiter(aAncestorLimiter), mOptions(aOptions) { if (NS_WARN_IF(!aPoint.IsInContentNodeAndValidInComposedDoc()) || NS_WARN_IF(!aPoint.GetContainerOrContainerParentElement())) { // We don't need to support composing in uncomposed tree. @@ -125,9 +121,10 @@ WSRunScanner::TextFragmentData::TextFragmentData( editableBlockElementOrInlineEditingHostOrNonEditableRootElement = HTMLEditUtils::GetInclusiveAncestorElement( *mScanStartPoint.ContainerAs<nsIContent>(), - aScanMode == Scan::EditableNodes ? kScanEditableRootAncestorTypes - : kScanAnyRootAncestorTypes, - static_cast<bool>(mReferHTMLDefaultStyle) + mOptions.contains(Option::OnlyEditableNodes) + ? kScanEditableRootAncestorTypes + : kScanAnyRootAncestorTypes, + ReferredHTMLDefaultStyle() ? BlockInlineCheck::UseHTMLDefaultStyle : BlockInlineCheck::UseComputedDisplayOutsideStyle, aAncestorLimiter); @@ -136,16 +133,14 @@ WSRunScanner::TextFragmentData::TextFragmentData( return; } mStart = BoundaryData::ScanCollapsibleWhiteSpaceStartFrom( - aScanMode, mScanStartPoint, &mNBSPData, aReferHTMLDefaultStyle, - ShouldStopAtNonEditableNode(aScanMode), + mOptions, mScanStartPoint, &mNBSPData, *editableBlockElementOrInlineEditingHostOrNonEditableRootElement); MOZ_ASSERT_IF(mStart.IsNonCollapsibleCharacters(), !mStart.PointRef().IsPreviousCharPreformattedNewLine()); MOZ_ASSERT_IF(mStart.IsPreformattedLineBreak(), mStart.PointRef().IsPreviousCharPreformattedNewLine()); mEnd = BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( - aScanMode, mScanStartPoint, &mNBSPData, aReferHTMLDefaultStyle, - ShouldStopAtNonEditableNode(aScanMode), + mOptions, mScanStartPoint, &mNBSPData, *editableBlockElementOrInlineEditingHostOrNonEditableRootElement); MOZ_ASSERT_IF(mEnd.IsNonCollapsibleCharacters(), !mEnd.PointRef().IsCharPreformattedNewLine()); @@ -223,13 +218,11 @@ Maybe<WSRunScanner::TextFragmentData::BoundaryData> WSRunScanner:: template <typename EditorDOMPointType> WSRunScanner::TextFragmentData::BoundaryData WSRunScanner::TextFragmentData:: BoundaryData::ScanCollapsibleWhiteSpaceStartFrom( - Scan aScanMode, const EditorDOMPointType& aPoint, - NoBreakingSpaceData* aNBSPData, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, - StopAtNonEditableNode aStopAtNonEditableNode, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, NoBreakingSpaceData* aNBSPData, const Element& aAncestorLimiter) { MOZ_ASSERT(aPoint.IsSetAndValid()); - MOZ_ASSERT_IF(aScanMode == Scan::EditableNodes, + MOZ_ASSERT_IF(aOptions.contains(Option::OnlyEditableNodes), // FIXME: Both values should be true here. HTMLEditUtils::IsSimplyEditableNode(*aPoint.GetContainer()) == HTMLEditUtils::IsSimplyEditableNode(aAncestorLimiter)); @@ -244,18 +237,17 @@ WSRunScanner::TextFragmentData::BoundaryData WSRunScanner::TextFragmentData:: // The text node does not have visible character, let's keep scanning // preceding nodes. return BoundaryData::ScanCollapsibleWhiteSpaceStartFrom( - aScanMode, EditorDOMPoint(aPoint.template ContainerAs<Text>(), 0), - aNBSPData, aReferHTMLDefaultStyle, aStopAtNonEditableNode, - aAncestorLimiter); + aOptions, EditorDOMPoint(aPoint.template ContainerAs<Text>(), 0), + aNBSPData, aAncestorLimiter); } const BlockInlineCheck blockInlineCheck = - static_cast<bool>(aReferHTMLDefaultStyle) + aOptions.contains(Option::ReferHTMLDefaultStyle) ? BlockInlineCheck::UseHTMLDefaultStyle : BlockInlineCheck::UseComputedDisplayOutsideStyle; // Then, we need to check previous leaf node. const auto leafNodeTypes = - aStopAtNonEditableNode == StopAtNonEditableNode::Yes + aOptions.contains(Option::OnlyEditableNodes) ? LeafNodeTypes{LeafNodeType::LeafNodeOrNonEditableNode} : LeafNodeTypes{LeafNodeType::OnlyLeafNode}; nsIContent* previousLeafContentOrBlock = @@ -278,7 +270,7 @@ WSRunScanner::TextFragmentData::BoundaryData WSRunScanner::TextFragmentData:: } if (!previousLeafContentOrBlock->IsText() || - (aStopAtNonEditableNode == StopAtNonEditableNode::Yes && + (aOptions.contains(Option::OnlyEditableNodes) && HTMLEditUtils::IsSimplyEditableNode(*previousLeafContentOrBlock) != HTMLEditUtils::IsSimplyEditableNode(aAncestorLimiter))) { // it's a break or a special node, like <img>, that is not a block and @@ -294,10 +286,8 @@ WSRunScanner::TextFragmentData::BoundaryData WSRunScanner::TextFragmentData:: // Note that even if the empty text node is preformatted, we should keep // looking for the previous one. return BoundaryData::ScanCollapsibleWhiteSpaceStartFrom( - aScanMode, - EditorDOMPointInText(previousLeafContentOrBlock->AsText(), 0), - aNBSPData, aReferHTMLDefaultStyle, aStopAtNonEditableNode, - aAncestorLimiter); + aOptions, EditorDOMPointInText(previousLeafContentOrBlock->AsText(), 0), + aNBSPData, aAncestorLimiter); } Maybe<BoundaryData> startInTextNode = @@ -311,9 +301,8 @@ WSRunScanner::TextFragmentData::BoundaryData WSRunScanner::TextFragmentData:: // The text node does not have visible character, let's keep scanning // preceding nodes. return BoundaryData::ScanCollapsibleWhiteSpaceStartFrom( - aScanMode, EditorDOMPointInText(previousLeafContentOrBlock->AsText(), 0), - aNBSPData, aReferHTMLDefaultStyle, aStopAtNonEditableNode, - aAncestorLimiter); + aOptions, EditorDOMPointInText(previousLeafContentOrBlock->AsText(), 0), + aNBSPData, aAncestorLimiter); } // static @@ -384,13 +373,11 @@ Maybe<WSRunScanner::TextFragmentData::BoundaryData> WSRunScanner:: template <typename EditorDOMPointType> WSRunScanner::TextFragmentData::BoundaryData WSRunScanner::TextFragmentData::BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( - Scan aScanMode, const EditorDOMPointType& aPoint, - NoBreakingSpaceData* aNBSPData, - ReferHTMLDefaultStyle aReferHTMLDefaultStyle, - StopAtNonEditableNode aStopAtNonEditableNode, + Options aOptions, // NOLINT(performance-unnecessary-value-param) + const EditorDOMPointType& aPoint, NoBreakingSpaceData* aNBSPData, const Element& aAncestorLimiter) { MOZ_ASSERT(aPoint.IsSetAndValid()); - MOZ_ASSERT_IF(aScanMode == Scan::EditableNodes, + MOZ_ASSERT_IF(aOptions.contains(Option::OnlyEditableNodes), // FIXME: Both values should be true here. HTMLEditUtils::IsSimplyEditableNode(*aPoint.GetContainer()) == HTMLEditUtils::IsSimplyEditableNode(aAncestorLimiter)); @@ -404,20 +391,19 @@ WSRunScanner::TextFragmentData::BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( // The text node does not have visible character, let's keep scanning // following nodes. return BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( - aScanMode, + aOptions, EditorDOMPointInText::AtEndOf(*aPoint.template ContainerAs<Text>()), - aNBSPData, aReferHTMLDefaultStyle, aStopAtNonEditableNode, - aAncestorLimiter); + aNBSPData, aAncestorLimiter); } const BlockInlineCheck blockInlineCheck = - static_cast<bool>(aReferHTMLDefaultStyle) + aOptions.contains(Option::ReferHTMLDefaultStyle) ? BlockInlineCheck::UseHTMLDefaultStyle : BlockInlineCheck::UseComputedDisplayOutsideStyle; // Then, we need to check next leaf node. const auto leafNodeTypes = - aStopAtNonEditableNode == StopAtNonEditableNode::Yes + aOptions.contains(Option::OnlyEditableNodes) ? LeafNodeTypes{LeafNodeType::LeafNodeOrNonEditableNode} : LeafNodeTypes{LeafNodeType::OnlyLeafNode}; nsIContent* nextLeafContentOrBlock = @@ -442,7 +428,7 @@ WSRunScanner::TextFragmentData::BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( } if (!nextLeafContentOrBlock->IsText() || - (aStopAtNonEditableNode == StopAtNonEditableNode::Yes && + (aOptions.contains(Option::OnlyEditableNodes) && HTMLEditUtils::IsSimplyEditableNode(*nextLeafContentOrBlock) != HTMLEditUtils::IsSimplyEditableNode(aAncestorLimiter))) { // we encountered a break or a special node, like <img>, @@ -459,9 +445,8 @@ WSRunScanner::TextFragmentData::BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( // Note that even if the empty text node is preformatted, we should keep // looking for the next one. return BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( - aScanMode, EditorDOMPointInText(nextLeafContentOrBlock->AsText(), 0), - aNBSPData, aReferHTMLDefaultStyle, aStopAtNonEditableNode, - aAncestorLimiter); + aOptions, EditorDOMPointInText(nextLeafContentOrBlock->AsText(), 0), + aNBSPData, aAncestorLimiter); } Maybe<BoundaryData> endInTextNode = @@ -474,10 +459,9 @@ WSRunScanner::TextFragmentData::BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( // The text node does not have visible character, let's keep scanning // following nodes. return BoundaryData::ScanCollapsibleWhiteSpaceEndFrom( - aScanMode, + aOptions, EditorDOMPointInText::AtEndOf(*nextLeafContentOrBlock->AsText()), - aNBSPData, aReferHTMLDefaultStyle, aStopAtNonEditableNode, - aAncestorLimiter); + aNBSPData, aAncestorLimiter); } const EditorDOMRange& @@ -571,7 +555,7 @@ WSRunScanner::TextFragmentData::GetNonCollapsedRangeInTexts( ? aRange.StartRef().AsInText() : GetInclusiveNextCharPoint<EditorDOMPointInText>( aRange.StartRef(), - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (!firstPoint.IsSet()) { return EditorDOMRangeInTexts(); } @@ -583,7 +567,7 @@ WSRunScanner::TextFragmentData::GetNonCollapsedRangeInTexts( // text node if it's not empty, but we need end of the text node here. endPoint = GetPreviousCharPoint<EditorDOMPointInText>( aRange.EndRef(), - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (endPoint.IsSet() && endPoint.IsAtLastContent()) { MOZ_ALWAYS_TRUE(endPoint.AdvanceOffset()); } @@ -758,7 +742,7 @@ WSRunScanner::TextFragmentData::GetReplaceRangeDataAtEndOfDeletionRange( return ReplaceRangeData(); } auto nextCharOfStartOfEnd = GetInclusiveNextCharPoint<EditorDOMPointInText>( - endToDelete, ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + endToDelete, ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (!nextCharOfStartOfEnd.IsSet() || nextCharOfStartOfEnd.IsEndOfContainer() || !nextCharOfStartOfEnd.IsCharCollapsibleASCIISpace()) { @@ -770,13 +754,13 @@ WSRunScanner::TextFragmentData::GetReplaceRangeDataAtEndOfDeletionRange( aTextFragmentDataAtStartToDelete .GetFirstASCIIWhiteSpacePointCollapsedTo<EditorDOMPointInText>( nextCharOfStartOfEnd, nsIEditor::eNone, - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); } const auto endOfCollapsibleASCIIWhiteSpaces = aTextFragmentDataAtStartToDelete .GetEndOfCollapsibleASCIIWhiteSpaces<EditorDOMPointInText>( nextCharOfStartOfEnd, nsIEditor::eNone, - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); return ReplaceRangeData(nextCharOfStartOfEnd, endOfCollapsibleASCIIWhiteSpaces, nsDependentSubstring(&HTMLEditUtils::kNBSP, 1)); @@ -837,7 +821,7 @@ WSRunScanner::TextFragmentData::GetReplaceRangeDataAtStartOfDeletionRange( return ReplaceRangeData(); } auto atPreviousCharOfStart = GetPreviousCharPoint<EditorDOMPointInText>( - startToDelete, ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + startToDelete, ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (!atPreviousCharOfStart.IsSet() || atPreviousCharOfStart.IsEndOfContainer() || !atPreviousCharOfStart.IsCharCollapsibleASCIISpace()) { @@ -848,12 +832,12 @@ WSRunScanner::TextFragmentData::GetReplaceRangeDataAtStartOfDeletionRange( atPreviousCharOfStart = GetFirstASCIIWhiteSpacePointCollapsedTo<EditorDOMPointInText>( atPreviousCharOfStart, nsIEditor::eNone, - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); } const auto endOfCollapsibleASCIIWhiteSpaces = GetEndOfCollapsibleASCIIWhiteSpaces<EditorDOMPointInText>( atPreviousCharOfStart, nsIEditor::eNone, - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); return ReplaceRangeData(atPreviousCharOfStart, endOfCollapsibleASCIIWhiteSpaces, nsDependentSubstring(&HTMLEditUtils::kNBSP, 1)); @@ -1321,7 +1305,7 @@ EditorDOMPointInText WSRunScanner::TextFragmentData:: // about what is after it. What is after it now will end up after the // inserted object. const auto atPreviousChar = GetPreviousCharPoint<EditorDOMPointInText>( - aPointToInsert, ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + aPointToInsert, ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (!atPreviousChar.IsSet() || atPreviousChar.IsEndOfContainer() || !atPreviousChar.IsCharNBSP() || EditorUtils::IsWhiteSpacePreformatted( @@ -1332,7 +1316,7 @@ EditorDOMPointInText WSRunScanner::TextFragmentData:: const auto atPreviousCharOfPreviousChar = GetPreviousCharPoint<EditorDOMPointInText>( atPreviousChar, - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (atPreviousCharOfPreviousChar.IsSet()) { // If the previous char is in different text node and it's preformatted, // we shouldn't touch it. @@ -1379,7 +1363,7 @@ EditorDOMPointInText WSRunScanner::TextFragmentData:: // in the ws abut an inserted text, so we don't have to worry about what is // before it. What is before it now will end up before the inserted text. const auto atNextChar = GetInclusiveNextCharPoint<EditorDOMPointInText>( - aPointToInsert, ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + aPointToInsert, ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (!atNextChar.IsSet() || NS_WARN_IF(atNextChar.IsEndOfContainer()) || !atNextChar.IsCharNBSP() || EditorUtils::IsWhiteSpacePreformatted(*atNextChar.ContainerAs<Text>())) { @@ -1389,7 +1373,7 @@ EditorDOMPointInText WSRunScanner::TextFragmentData:: const auto atNextCharOfNextCharOfNBSP = GetInclusiveNextCharPoint<EditorDOMPointInText>( atNextChar.NextPoint<EditorRawDOMPointInText>(), - ShouldIgnoreNonEditableSiblingsOrDescendants(mScanMode)); + ShouldIgnoreNonEditableSiblingsOrDescendants(mOptions)); if (atNextCharOfNextCharOfNBSP.IsSet()) { // If the next char is in different text node and it's preformatted, // we shouldn't touch it. diff --git a/editor/libeditor/WhiteSpaceVisibilityKeeper.cpp b/editor/libeditor/WhiteSpaceVisibilityKeeper.cpp @@ -168,9 +168,7 @@ Result<MoveNodeResult, nsresult> WhiteSpaceVisibilityKeeper:: } auto atStartOfRightText = [&]() MOZ_NEVER_INLINE_DEBUG -> EditorDOMPoint { - const WSRunScanner scanner( - Scan::All, EditorRawDOMPoint(&aRightBlockElement, 0u), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + const WSRunScanner scanner({}, EditorRawDOMPoint(&aRightBlockElement, 0u)); for (EditorRawDOMPointInText atFirstChar = scanner.GetInclusiveNextCharPoint<EditorRawDOMPointInText>( EditorRawDOMPoint(&aRightBlockElement, 0u)); @@ -198,9 +196,8 @@ Result<MoveNodeResult, nsresult> WhiteSpaceVisibilityKeeper:: // MoveNodeResult at last. const RefPtr<HTMLBRElement> invisibleBRElementAtEndOfLeftBlockElement = WSRunScanner::GetPrecedingBRElementUnlessVisibleContentFound( - WSRunScanner::Scan::EditableNodes, - EditorDOMPoint::AtEndOf(aLeftBlockElement), - ReferHTMLDefaultStyle::No); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorDOMPoint::AtEndOf(aLeftBlockElement)); NS_ASSERTION( aPrecedingInvisibleBRElement == invisibleBRElementAtEndOfLeftBlockElement, "The preceding invisible BR element computation was different"); @@ -399,9 +396,7 @@ Result<MoveNodeResult, nsresult> WhiteSpaceVisibilityKeeper:: } auto atStartOfRightText = [&]() MOZ_NEVER_INLINE_DEBUG -> EditorDOMPoint { - const WSRunScanner scanner( - Scan::All, EditorRawDOMPoint(&aRightBlockElement, 0u), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + const WSRunScanner scanner({}, EditorRawDOMPoint(&aRightBlockElement, 0u)); for (EditorRawDOMPointInText atFirstChar = scanner.GetInclusiveNextCharPoint<EditorRawDOMPointInText>( EditorRawDOMPoint(&aRightBlockElement, 0u)); @@ -429,8 +424,7 @@ Result<MoveNodeResult, nsresult> WhiteSpaceVisibilityKeeper:: // MoveNodeResult at last. const RefPtr<HTMLBRElement> invisibleBRElementBeforeLeftBlockElement = WSRunScanner::GetPrecedingBRElementUnlessVisibleContentFound( - WSRunScanner::Scan::EditableNodes, atLeftBlockChild, - ReferHTMLDefaultStyle::No); + {WSRunScanner::Option::OnlyEditableNodes}, atLeftBlockChild); NS_ASSERTION( aPrecedingInvisibleBRElement == invisibleBRElementBeforeLeftBlockElement, "The preceding invisible BR element computation was different"); @@ -708,9 +702,7 @@ Result<MoveNodeResult, nsresult> WhiteSpaceVisibilityKeeper:: return afterLastVisibleThingOrError.propagateErr(); } auto atStartOfRightText = [&]() MOZ_NEVER_INLINE_DEBUG -> EditorDOMPoint { - const WSRunScanner scanner( - Scan::All, EditorRawDOMPoint(&aRightBlockElement, 0u), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + const WSRunScanner scanner({}, EditorRawDOMPoint(&aRightBlockElement, 0u)); for (EditorRawDOMPointInText atFirstChar = scanner.GetInclusiveNextCharPoint<EditorRawDOMPointInText>( EditorRawDOMPoint(&aRightBlockElement, 0u)); @@ -737,9 +729,8 @@ Result<MoveNodeResult, nsresult> WhiteSpaceVisibilityKeeper:: // MoveNodeResult at last. const RefPtr<HTMLBRElement> invisibleBRElementAtEndOfLeftBlockElement = WSRunScanner::GetPrecedingBRElementUnlessVisibleContentFound( - WSRunScanner::Scan::EditableNodes, - EditorDOMPoint::AtEndOf(aLeftBlockElement), - ReferHTMLDefaultStyle::No); + {WSRunScanner::Option::OnlyEditableNodes}, + EditorDOMPoint::AtEndOf(aLeftBlockElement)); NS_ASSERTION( aPrecedingInvisibleBRElement == invisibleBRElementAtEndOfLeftBlockElement, "The preceding invisible BR element computation was different"); @@ -913,7 +904,8 @@ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesAt( Result<EditorDOMPoint, nsresult> WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesBefore( HTMLEditor& aHTMLEditor, const EditorDOMPoint& aPoint, - NormalizeOptions aOptions) { + NormalizeOptions aOptions // NOLINT(performance-unnecessary-value-param) +) { MOZ_ASSERT(aPoint.IsSetAndValid()); MOZ_ASSERT_IF(aPoint.IsInTextNode(), !aPoint.IsMiddleOfContainer()); MOZ_ASSERT( @@ -1031,7 +1023,8 @@ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesBefore( Result<EditorDOMPoint, nsresult> WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesAfter( HTMLEditor& aHTMLEditor, const EditorDOMPoint& aPoint, - NormalizeOptions aOptions) { + NormalizeOptions aOptions // NOLINT(performance-unnecessary-value-param) +) { MOZ_ASSERT(aPoint.IsSetAndValid()); MOZ_ASSERT_IF(aPoint.IsInTextNode(), !aPoint.IsMiddleOfContainer()); MOZ_ASSERT( @@ -1145,7 +1138,8 @@ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesAfter( Result<EditorDOMPoint, nsresult> WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitTextNodeAt( HTMLEditor& aHTMLEditor, const EditorDOMPointInText& aPointToSplit, - NormalizeOptions aOptions) { + NormalizeOptions aOptions // NOLINT(performance-unnecessary-value-param) +) { MOZ_ASSERT(aPointToSplit.IsSetAndValid()); if (EditorUtils::IsWhiteSpacePreformatted( @@ -1239,7 +1233,8 @@ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitTextNodeAt( Result<EditorDOMPoint, nsresult> WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt( HTMLEditor& aHTMLEditor, const EditorDOMPoint& aPointToSplit, - NormalizeOptions aOptions) { + NormalizeOptions aOptions // NOLINT(performance-unnecessary-value-param) +) { MOZ_ASSERT(aPointToSplit.IsSet()); // If the insertion point is not in composed doc, we're probably initializing @@ -1453,8 +1448,7 @@ WhiteSpaceVisibilityKeeper::NormalizeSurroundingWhiteSpacesToJoin( &rangeToDelete); const WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - Scan::All, rangeToDelete.StartRef(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, rangeToDelete.StartRef()); if (nextThing.ReachedLineBoundary()) { nsresult rv = WhiteSpaceVisibilityKeeper::EnsureNoInvisibleWhiteSpacesBefore( @@ -1875,13 +1869,13 @@ WhiteSpaceVisibilityKeeper::EnsureNoInvisibleWhiteSpaces( return EditorDOMPoint(); // aPoint is not in a block. } const TextFragmentData textFragmentDataForLeadingWhiteSpaces( - Scan::EditableNodes, + {WSRunScanner::Option::OnlyEditableNodes}, aPoint.IsStartOfContainer() && (aPoint.GetContainer() == maybeNonEditableClosestBlockElement || aPoint.GetContainer()->IsEditingHost()) ? aPoint : aPoint.PreviousPointOrParentPoint<EditorDOMPoint>(), - ReferHTMLDefaultStyle::No, maybeNonEditableClosestBlockElement); + maybeNonEditableClosestBlockElement); if (NS_WARN_IF(!textFragmentDataForLeadingWhiteSpaces.IsInitialized())) { return Err(NS_ERROR_FAILURE); } @@ -1940,8 +1934,7 @@ WhiteSpaceVisibilityKeeper::EnsureNoInvisibleWhiteSpaces( const TextFragmentData textFragmentData = textFragmentDataForLeadingWhiteSpaces.ScanStartRef() == aPoint ? textFragmentDataForLeadingWhiteSpaces - : TextFragmentData(Scan::EditableNodes, aPoint, - ReferHTMLDefaultStyle::No, + : TextFragmentData({WSRunScanner::Option::OnlyEditableNodes}, aPoint, maybeNonEditableClosestBlockElement); const EditorDOMRange& trailingWhiteSpaceRange = textFragmentData.InvisibleTrailingWhiteSpaceRangeRef(); @@ -2397,16 +2390,13 @@ WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt( if (pointToPutCaret.IsBefore(EditorRawDOMPoint(&aContentToDelete))) { WSScanResult nextThingOfCaretPoint = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - Scan::All, pointToPutCaret, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, pointToPutCaret); if (nextThingOfCaretPoint.ReachedBRElement() || nextThingOfCaretPoint.ReachedPreformattedLineBreak()) { nextThingOfCaretPoint = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - Scan::All, - nextThingOfCaretPoint - .PointAfterReachedContent<EditorRawDOMPoint>(), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, nextThingOfCaretPoint + .PointAfterReachedContent<EditorRawDOMPoint>()); } if (nextThingOfCaretPoint.ReachedBlockBoundary()) { const EditorDOMPoint atBlockBoundary = @@ -2437,8 +2427,7 @@ WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt( .EqualsOrIsBefore(pointToPutCaret)) { const WSScanResult previousThingOfCaretPoint = WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary( - Scan::All, pointToPutCaret, - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, pointToPutCaret); if (previousThingOfCaretPoint.ReachedBlockBoundary()) { const EditorDOMPoint atBlockBoundary = previousThingOfCaretPoint.ReachedCurrentBlockBoundary() @@ -2471,8 +2460,7 @@ WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt( else { const WSScanResult nextThing = WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary( - Scan::All, EditorRawDOMPoint::After(aContentToDelete), - BlockInlineCheck::UseComputedDisplayOutsideStyle); + {}, EditorRawDOMPoint::After(aContentToDelete)); if (nextThing.ReachedLineBoundary()) { AutoTrackDOMPoint trackAtContent(aHTMLEditor.RangeUpdaterRef(), &atContent); @@ -2607,8 +2595,8 @@ Result<CaretPoint, nsresult> WhiteSpaceVisibilityKeeper::DeleteInvisibleASCIIWhiteSpaces( HTMLEditor& aHTMLEditor, const EditorDOMPoint& aPoint) { MOZ_ASSERT(aPoint.IsSet()); - const TextFragmentData textFragmentData(Scan::EditableNodes, aPoint, - ReferHTMLDefaultStyle::No); + const TextFragmentData textFragmentData( + {WSRunScanner::Option::OnlyEditableNodes}, aPoint); if (NS_WARN_IF(!textFragmentData.IsInitialized())) { return Err(NS_ERROR_FAILURE); } diff --git a/editor/libeditor/WhiteSpaceVisibilityKeeper.h b/editor/libeditor/WhiteSpaceVisibilityKeeper.h @@ -47,7 +47,6 @@ class WhiteSpaceVisibilityKeeper final { using LineBreakType = HTMLEditor::LineBreakType; using PointPosition = WSRunScanner::PointPosition; using ReferHTMLDefaultStyle = WSRunScanner::ReferHTMLDefaultStyle; - using Scan = WSRunScanner::Scan; using TextFragmentData = WSRunScanner::TextFragmentData; using VisibleWhiteSpacesData = WSRunScanner::VisibleWhiteSpacesData;