Bug 1926483 - part 4: Make WSRunScanner::Scan(InclusiveNext|Previous)VisibleNodeOrBlockBoundary take WSRunScanner::Scan and ancestor limiter r=m_kato
Note that this removes a lot of `aEditingHost` params. This may cause odd behavior if editing host is changed by a legacy mutation event listener. However, it'll be completely deleted soon and even if we meet some regressions, we can just restore the param to set `aAncestorLimiter`. Differential Revision: https://phabricator.services.mozilla.com/D233794
This commit is contained in:
@@ -284,6 +284,11 @@ class EditorDOMPointBase final {
|
||||
*/
|
||||
bool IsContainerElement() const { return mParent && mParent->IsElement(); }
|
||||
|
||||
/**
|
||||
* Returns true if the container node is an editing host.
|
||||
*/
|
||||
[[nodiscard]] bool IsContainerEditableRoot() const;
|
||||
|
||||
/**
|
||||
* IsContainerHTMLElement() returns true if the container node is an HTML
|
||||
* element node and its node name is aTag.
|
||||
|
||||
@@ -352,6 +352,15 @@ bool EditorDOMPointBase<
|
||||
EditorUtils::IsOnlyNewLinePreformatted(*ContainerAs<Text>());
|
||||
}
|
||||
|
||||
template <typename PT, typename CT>
|
||||
bool EditorDOMPointBase<PT, CT>::IsContainerEditableRoot() const {
|
||||
if (MOZ_UNLIKELY(!mParent) || MOZ_UNLIKELY(!mParent->IsEditable()) ||
|
||||
NS_WARN_IF(mParent->IsInNativeAnonymousSubtree())) {
|
||||
return false;
|
||||
}
|
||||
return HTMLEditUtils::ElementIsEditableRoot(*mParent);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::EditorDOMRangeBase
|
||||
*****************************************************************************/
|
||||
|
||||
@@ -486,29 +486,26 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
|
||||
NS_WARNING("There was no selection range");
|
||||
return NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE;
|
||||
}
|
||||
if (const RefPtr<Element> editingHost =
|
||||
ComputeEditingHost(LimitInBodyElement::No)) {
|
||||
Result<CreateLineBreakResult, nsresult>
|
||||
insertPaddingBRElementResultOrError =
|
||||
InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded(
|
||||
newCaretPosition, *editingHost);
|
||||
if (MOZ_UNLIKELY(insertPaddingBRElementResultOrError.isErr())) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::"
|
||||
"InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded() failed");
|
||||
return insertPaddingBRElementResultOrError.unwrapErr();
|
||||
}
|
||||
nsresult rv =
|
||||
insertPaddingBRElementResultOrError.unwrap().SuggestCaretPointTo(
|
||||
*this, {SuggestCaret::OnlyIfHasSuggestion});
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("CaretPoint::SuggestCaretPointTo() failed");
|
||||
return rv;
|
||||
}
|
||||
NS_WARNING_ASSERTION(
|
||||
rv != NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR,
|
||||
"CaretPoint::SuggestCaretPointTo() failed, but ignored");
|
||||
Result<CreateLineBreakResult, nsresult>
|
||||
insertPaddingBRElementResultOrError =
|
||||
InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded(
|
||||
newCaretPosition);
|
||||
if (MOZ_UNLIKELY(insertPaddingBRElementResultOrError.isErr())) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::"
|
||||
"InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded() failed");
|
||||
return insertPaddingBRElementResultOrError.unwrapErr();
|
||||
}
|
||||
nsresult rv =
|
||||
insertPaddingBRElementResultOrError.unwrap().SuggestCaretPointTo(
|
||||
*this, {SuggestCaret::OnlyIfHasSuggestion});
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("CaretPoint::SuggestCaretPointTo() failed");
|
||||
return rv;
|
||||
}
|
||||
NS_WARNING_ASSERTION(
|
||||
rv != NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR,
|
||||
"CaretPoint::SuggestCaretPointTo() failed, but ignored");
|
||||
}
|
||||
|
||||
// add in any needed <br>s, and remove any unneeded ones.
|
||||
@@ -1208,7 +1205,7 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
||||
const InsertTextResult insertEmptyTextResult =
|
||||
insertEmptyTextResultOrError.unwrap();
|
||||
nsresult rv = EnsureNoFollowingUnnecessaryLineBreak(
|
||||
insertEmptyTextResult.EndOfInsertedTextRef(), *editingHost);
|
||||
insertEmptyTextResult.EndOfInsertedTextRef());
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
@@ -1257,7 +1254,7 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
||||
}
|
||||
InsertTextResult unwrappedReplacedTextResult = replaceTextResult.unwrap();
|
||||
nsresult rv = EnsureNoFollowingUnnecessaryLineBreak(
|
||||
unwrappedReplacedTextResult.EndOfInsertedTextRef(), *editingHost);
|
||||
unwrappedReplacedTextResult.EndOfInsertedTextRef());
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -1532,8 +1529,7 @@ Result<EditActionResult, nsresult> HTMLEditor::HandleInsertText(
|
||||
mLastCollapsibleWhiteSpaceAppendedTextNode =
|
||||
currentPoint.ContainerAs<Text>();
|
||||
}
|
||||
nsresult rv =
|
||||
EnsureNoFollowingUnnecessaryLineBreak(currentPoint, *editingHost);
|
||||
nsresult rv = EnsureNoFollowingUnnecessaryLineBreak(currentPoint);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -1661,7 +1657,8 @@ nsresult HTMLEditor::InsertLineBreakAsSubAction() {
|
||||
}
|
||||
const WSScanResult backwardScanFromBeforeBRElementResult =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
editingHost, insertLineBreakResult.AtLineBreak<EditorDOMPoint>(),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
insertLineBreakResult.AtLineBreak<EditorDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (MOZ_UNLIKELY(backwardScanFromBeforeBRElementResult.Failed())) {
|
||||
NS_WARNING(
|
||||
@@ -1671,7 +1668,7 @@ nsresult HTMLEditor::InsertLineBreakAsSubAction() {
|
||||
|
||||
const WSScanResult forwardScanFromAfterBRElementResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
editingHost, pointToPutCaret,
|
||||
WSRunScanner::Scan::EditableNodes, pointToPutCaret,
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (MOZ_UNLIKELY(forwardScanFromAfterBRElementResult.Failed())) {
|
||||
NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed");
|
||||
@@ -1901,7 +1898,7 @@ HTMLEditor::InsertParagraphSeparatorAsSubAction(const Element& aEditingHost) {
|
||||
// table cell boundaries?
|
||||
Result<CaretPoint, nsresult> caretPointOrError =
|
||||
HandleInsertParagraphInMailCiteElement(*mailCiteElement,
|
||||
pointToInsert, aEditingHost);
|
||||
pointToInsert);
|
||||
if (MOZ_UNLIKELY(caretPointOrError.isErr())) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::HandleInsertParagraphInMailCiteElement() failed");
|
||||
@@ -2472,7 +2469,7 @@ Result<CreateElementResult, nsresult> HTMLEditor::HandleInsertBRElement(
|
||||
|
||||
const WSScanResult forwardScanFromAfterBRElementResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, afterBRElement,
|
||||
WSRunScanner::Scan::EditableNodes, afterBRElement,
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (MOZ_UNLIKELY(forwardScanFromAfterBRElementResult.Failed())) {
|
||||
NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed");
|
||||
@@ -2687,8 +2684,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::HandleInsertLinefeed(
|
||||
}
|
||||
|
||||
Result<CaretPoint, nsresult> HTMLEditor::HandleInsertParagraphInMailCiteElement(
|
||||
Element& aMailCiteElement, const EditorDOMPoint& aPointToSplit,
|
||||
const Element& aEditingHost) {
|
||||
Element& aMailCiteElement, const EditorDOMPoint& aPointToSplit) {
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
MOZ_ASSERT(aPointToSplit.IsSet());
|
||||
NS_ASSERTION(!HTMLEditUtils::IsEmptyNode(
|
||||
@@ -2711,7 +2707,8 @@ Result<CaretPoint, nsresult> HTMLEditor::HandleInsertParagraphInMailCiteElement(
|
||||
// mailquote may affect wrapping behavior, or font color, etc.
|
||||
const WSScanResult forwardScanFromPointToSplitResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, pointToSplit, BlockInlineCheck::UseHTMLDefaultStyle);
|
||||
WSRunScanner::Scan::EditableNodes, pointToSplit,
|
||||
BlockInlineCheck::UseHTMLDefaultStyle);
|
||||
if (forwardScanFromPointToSplitResult.Failed()) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
@@ -2831,7 +2828,7 @@ Result<CaretPoint, nsresult> HTMLEditor::HandleInsertParagraphInMailCiteElement(
|
||||
// resultOfInsertingBRElement.inspect()?
|
||||
const WSScanResult backwardScanFromPointToCreateNewBRElementResult =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, pointToCreateNewBRElement,
|
||||
WSRunScanner::Scan::EditableNodes, pointToCreateNewBRElement,
|
||||
BlockInlineCheck::UseHTMLDefaultStyle);
|
||||
if (MOZ_UNLIKELY(
|
||||
backwardScanFromPointToCreateNewBRElementResult.Failed())) {
|
||||
@@ -2848,7 +2845,7 @@ Result<CaretPoint, nsresult> HTMLEditor::HandleInsertParagraphInMailCiteElement(
|
||||
}
|
||||
const WSScanResult forwardScanFromPointAfterNewBRElementResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint::After(pointToCreateNewBRElement),
|
||||
BlockInlineCheck::UseHTMLDefaultStyle);
|
||||
if (MOZ_UNLIKELY(forwardScanFromPointAfterNewBRElementResult.Failed())) {
|
||||
@@ -3407,8 +3404,7 @@ HTMLEditor::DeleteTextAndNormalizeSurroundingWhiteSpaces(
|
||||
{
|
||||
AutoTrackDOMPoint trackPointToPutCaret(RangeUpdaterRef(),
|
||||
&newCaretPosition);
|
||||
nsresult rv =
|
||||
EnsureNoFollowingUnnecessaryLineBreak(newCaretPosition, aEditingHost);
|
||||
nsresult rv = EnsureNoFollowingUnnecessaryLineBreak(newCaretPosition);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -3464,7 +3460,7 @@ bool HTMLEditor::CanInsertLineBreak(LineBreakType aLineBreakType,
|
||||
|
||||
Result<CreateLineBreakResult, nsresult>
|
||||
HTMLEditor::InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded(
|
||||
const EditorDOMPoint& aPointToInsert, const Element& aEditingHost) {
|
||||
const EditorDOMPoint& aPointToInsert) {
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
MOZ_ASSERT(aPointToInsert.IsSet());
|
||||
|
||||
@@ -3487,7 +3483,7 @@ HTMLEditor::InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded(
|
||||
// here.
|
||||
const WSScanResult previousThing =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, aPointToInsert,
|
||||
WSRunScanner::Scan::EditableNodes, aPointToInsert,
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (!previousThing.ReachedLineBoundary()) {
|
||||
return CreateLineBreakResult::NotHandled();
|
||||
@@ -3497,7 +3493,7 @@ HTMLEditor::InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded(
|
||||
// line break here.
|
||||
const WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, aPointToInsert,
|
||||
WSRunScanner::Scan::EditableNodes, aPointToInsert,
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (!nextThing.ReachedBlockBoundary()) {
|
||||
return CreateLineBreakResult::NotHandled();
|
||||
@@ -7043,8 +7039,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::CreateStyleForInsertText(
|
||||
NS_WARNING("AutoClonedRangeArray::AutoClonedRangeArray() failed");
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
nsresult rv =
|
||||
SetInlinePropertiesAroundRanges(ranges, stylesToSet, aEditingHost);
|
||||
nsresult rv = SetInlinePropertiesAroundRanges(ranges, stylesToSet);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::SetInlinePropertiesAroundRanges() failed");
|
||||
return Err(rv);
|
||||
@@ -9177,7 +9172,8 @@ HTMLEditor::HandleInsertParagraphInListItemElement(
|
||||
// the element is proper position.
|
||||
const WSScanResult forwardScanFromStartOfListItemResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, EditorRawDOMPoint(&rightListItemElement, 0u),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(&rightListItemElement, 0u),
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (MOZ_UNLIKELY(forwardScanFromStartOfListItemResult.Failed())) {
|
||||
NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed");
|
||||
@@ -11212,7 +11208,7 @@ HTMLEditor::InsertPaddingBRElementIfNeeded(
|
||||
if (IsPlaintextMailComposer()) {
|
||||
const WSScanResult nextVisibleThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, aPoint,
|
||||
WSRunScanner::Scan::EditableNodes, aPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (nextVisibleThing.ReachedBlockBoundary() &&
|
||||
HTMLEditUtils::IsMailCite(*nextVisibleThing.ElementPtr()) &&
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "nsError.h" // for NS_SUCCEEDED
|
||||
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::a, etc.
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsIContentInlines.h" // for nsIContent::IsInDesignMode(), etc.
|
||||
#include "nsIFrameInlines.h" // for nsIFrame::IsFlexOrGridItem()
|
||||
#include "nsLiteralString.h" // for NS_LITERAL_STRING
|
||||
#include "nsNameSpaceManager.h" // for kNameSpaceID_None
|
||||
@@ -125,13 +126,13 @@ template EditorRawDOMPoint HTMLEditUtils::GetBetterInsertionPointFor(
|
||||
const nsIContent& aContentToInsert, const EditorDOMPoint& aPointToInsert);
|
||||
|
||||
template EditorDOMPoint HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
const EditorDOMPoint& aPoint, const Element& aEditingHost);
|
||||
const EditorDOMPoint& aPoint);
|
||||
template EditorDOMPoint HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
const EditorRawDOMPoint& aPoint, const Element& aEditingHost);
|
||||
const EditorRawDOMPoint& aPoint);
|
||||
template EditorRawDOMPoint HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
const EditorDOMPoint& aPoint, const Element& aEditingHost);
|
||||
const EditorDOMPoint& aPoint);
|
||||
template EditorRawDOMPoint HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
const EditorRawDOMPoint& aPoint, const Element& aEditingHost);
|
||||
const EditorRawDOMPoint& aPoint);
|
||||
|
||||
template Result<EditorDOMPoint, nsresult>
|
||||
HTMLEditUtils::ComputePointToPutCaretInElementIfOutside(
|
||||
@@ -152,48 +153,54 @@ template bool HTMLEditUtils::IsSameCSSColorValue(const nsACString& aColorA,
|
||||
const nsACString& aColorB);
|
||||
|
||||
template Maybe<EditorLineBreak> HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorDOMPoint& aPoint, const Element& aEditingHost);
|
||||
const EditorDOMPoint& aPoint);
|
||||
template Maybe<EditorLineBreak> HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorRawDOMPoint& aPoint, const Element& aEditingHost);
|
||||
const EditorRawDOMPoint& aPoint);
|
||||
template Maybe<EditorLineBreak> HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorDOMPointInText& aPoint, const Element& aEditingHost);
|
||||
const EditorDOMPointInText& aPoint);
|
||||
template Maybe<EditorLineBreak> HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorRawDOMPointInText& aPoint, const Element& aEditingHost);
|
||||
const EditorRawDOMPointInText& aPoint);
|
||||
template Maybe<EditorRawLineBreak>
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak(const EditorDOMPoint& aPoint,
|
||||
const Element& aEditingHost);
|
||||
template Maybe<EditorRawLineBreak>
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak(const EditorRawDOMPoint& aPoint,
|
||||
const Element& aEditingHost);
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak(const EditorDOMPoint& aPoint);
|
||||
template Maybe<EditorRawLineBreak>
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorDOMPointInText& aPoint, const Element& aEditingHost);
|
||||
const EditorRawDOMPoint& aPoint);
|
||||
template Maybe<EditorRawLineBreak>
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorRawDOMPointInText& aPoint, const Element& aEditingHost);
|
||||
const EditorDOMPointInText& aPoint);
|
||||
template Maybe<EditorRawLineBreak>
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorRawDOMPointInText& aPoint);
|
||||
|
||||
template bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
const EditorDOMPoint& aPoint,
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak,
|
||||
const Element& aEditingHost);
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak);
|
||||
template bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
const EditorRawDOMPoint& aPoint,
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak,
|
||||
const Element& aEditingHost);
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak);
|
||||
template bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
const EditorDOMPointInText& aPoint,
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak,
|
||||
const Element& aEditingHost);
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak);
|
||||
template bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
const EditorRawDOMPointInText& aPoint,
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak,
|
||||
const Element& aEditingHost);
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak);
|
||||
|
||||
template Maybe<EditorLineBreak> HTMLEditUtils::GetUnnecessaryLineBreak(
|
||||
const Element& aBlockElement, ScanLineBreak aScanLineBreak);
|
||||
template Maybe<EditorRawLineBreak> HTMLEditUtils::GetUnnecessaryLineBreak(
|
||||
const Element& aBlockElement, ScanLineBreak aScanLineBreak);
|
||||
|
||||
bool HTMLEditUtils::ElementIsEditableRoot(const Element& aElement) {
|
||||
MOZ_ASSERT(!aElement.IsInNativeAnonymousSubtree());
|
||||
if (NS_WARN_IF(!aElement.IsEditable()) ||
|
||||
NS_WARN_IF(!aElement.IsInComposedDoc())) {
|
||||
return false;
|
||||
}
|
||||
return !aElement.GetParent() || // root element
|
||||
!aElement.GetParent()->IsEditable() || // editing host
|
||||
aElement.OwnerDoc()->GetBody() == &aElement; // the <body>
|
||||
}
|
||||
|
||||
bool HTMLEditUtils::CanContentsBeJoined(const nsIContent& aLeftContent,
|
||||
const nsIContent& aRightContent) {
|
||||
if (aLeftContent.NodeInfo()->NameAtom() !=
|
||||
@@ -809,7 +816,7 @@ EditorDOMPoint HTMLEditUtils::LineRequiresPaddingLineBreakToBeVisible(
|
||||
}
|
||||
const WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, point,
|
||||
WSRunScanner::Scan::EditableNodes, point,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (nextThing.ReachedBlockBoundary()) {
|
||||
if (nextThing.ReachedCurrentBlockBoundary()) {
|
||||
@@ -831,7 +838,7 @@ EditorDOMPoint HTMLEditUtils::LineRequiresPaddingLineBreakToBeVisible(
|
||||
}
|
||||
const WSScanResult previousThing =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, preferredPaddingLineBreakPoint,
|
||||
WSRunScanner::Scan::EditableNodes, preferredPaddingLineBreakPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (previousThing.ContentIsText()) {
|
||||
if (MOZ_UNLIKELY(!previousThing.TextPtr()->TextDataLength())) {
|
||||
@@ -982,16 +989,15 @@ Element* HTMLEditUtils::GetElementOfImmediateBlockBoundary(
|
||||
template <typename PT, typename CT>
|
||||
bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak,
|
||||
const Element& aEditingHost) {
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak) {
|
||||
MOZ_ASSERT(aPoint.IsSetAndValidInComposedDoc());
|
||||
|
||||
if (MOZ_UNLIKELY(!aPoint.IsInContentNode())) {
|
||||
return false;
|
||||
}
|
||||
WSScanResult nextThing =
|
||||
const WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, aPoint,
|
||||
WSRunScanner::Scan::EditableNodes, aPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (nextThing.ReachedCurrentBlockBoundary()) {
|
||||
return true;
|
||||
@@ -1000,9 +1006,9 @@ bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
if (aIgnoreInvisibleLineBreak == IgnoreInvisibleLineBreak::No) {
|
||||
return false;
|
||||
}
|
||||
WSScanResult afterInvisibleBRThing =
|
||||
const WSScanResult afterInvisibleBRThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
nextThing.PointAfterReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
return afterInvisibleBRThing.ReachedCurrentBlockBoundary();
|
||||
@@ -1011,9 +1017,9 @@ bool HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
if (aIgnoreInvisibleLineBreak == IgnoreInvisibleLineBreak::No) {
|
||||
return false;
|
||||
}
|
||||
WSScanResult afterPreformattedLineBreakThing =
|
||||
const WSScanResult afterPreformattedLineBreakThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
nextThing.PointAfterReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
return afterPreformattedLineBreakThing.ReachedCurrentBlockBoundary();
|
||||
@@ -1192,22 +1198,23 @@ Maybe<EditorLineBreakType> HTMLEditUtils::GetUnnecessaryLineBreak(
|
||||
|
||||
template <typename EditorLineBreakType, typename EditorDOMPointType>
|
||||
Maybe<EditorLineBreakType> HTMLEditUtils::GetFollowingUnnecessaryLineBreak(
|
||||
const EditorDOMPointType& aPoint, const Element& aEditingHost) {
|
||||
const EditorDOMPointType& aPoint) {
|
||||
MOZ_ASSERT(aPoint.IsSetAndValid());
|
||||
MOZ_ASSERT(aPoint.IsInContentNode());
|
||||
|
||||
WSScanResult nextThing =
|
||||
const WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, aPoint, BlockInlineCheck::UseComputedDisplayStyle);
|
||||
WSRunScanner::Scan::EditableNodes, aPoint,
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (!nextThing.ReachedBRElement() &&
|
||||
!(nextThing.ReachedPreformattedLineBreak() &&
|
||||
nextThing.PointAtReachedContent<EditorRawDOMPoint>()
|
||||
.IsAtLastContent())) {
|
||||
return Nothing(); // no line break next to aPoint
|
||||
}
|
||||
WSScanResult nextThingOfLineBreak =
|
||||
const WSScanResult nextThingOfLineBreak =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
nextThing.PointAfterReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
const Element* const blockElement =
|
||||
@@ -2540,12 +2547,12 @@ nsIContent* HTMLEditUtils::GetContentToPreserveInlineStyles(
|
||||
for (auto point = aPoint.template To<EditorRawDOMPoint>(); point.IsSet();) {
|
||||
const WSScanResult nextVisibleThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, point,
|
||||
WSRunScanner::Scan::EditableNodes, point,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (nextVisibleThing.InVisibleOrCollapsibleCharacters()) {
|
||||
return nextVisibleThing.TextPtr();
|
||||
}
|
||||
if (nextVisibleThing.GetContent() == &aEditingHost) {
|
||||
if (nextVisibleThing.IsContentEditableRoot()) {
|
||||
break;
|
||||
}
|
||||
// Ignore empty inline container elements because it's not visible for
|
||||
@@ -2631,10 +2638,9 @@ EditorDOMPointType HTMLEditUtils::GetBetterInsertionPointFor(
|
||||
// static
|
||||
template <typename EditorDOMPointType, typename EditorDOMPointTypeInput>
|
||||
EditorDOMPointType HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
const EditorDOMPointTypeInput& aPoint, const Element& aEditingHost) {
|
||||
const EditorDOMPointTypeInput& aPoint) {
|
||||
MOZ_ASSERT(aPoint.IsSetAndValid());
|
||||
MOZ_ASSERT(
|
||||
aPoint.GetContainer()->IsInclusiveFlatTreeDescendantOf(&aEditingHost));
|
||||
MOZ_ASSERT(HTMLEditUtils::IsSimplyEditableNode(*aPoint.GetContainer()));
|
||||
|
||||
if (aPoint.IsInTextNode()) {
|
||||
return aPoint.template To<EditorDOMPointType>();
|
||||
@@ -2646,7 +2652,8 @@ EditorDOMPointType HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
if (aPoint.IsEndOfContainer()) {
|
||||
const WSScanResult previousThing =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, aPoint, BlockInlineCheck::UseComputedDisplayStyle);
|
||||
WSRunScanner::Scan::EditableNodes, aPoint,
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (previousThing.InVisibleOrCollapsibleCharacters()) {
|
||||
return EditorDOMPointType::AtEndOf(*previousThing.TextPtr());
|
||||
}
|
||||
@@ -2655,7 +2662,7 @@ EditorDOMPointType HTMLEditUtils::GetBetterCaretPositionToInsertText(
|
||||
*nsGkAtoms::textTagName)) {
|
||||
return aPoint.template To<EditorDOMPointType>();
|
||||
}
|
||||
if (MOZ_UNLIKELY(aPoint.GetContainer() == &aEditingHost ||
|
||||
if (MOZ_UNLIKELY(aPoint.GetContainer()->IsEditingHost() ||
|
||||
!aPoint.template GetContainerParentAs<nsIContent>() ||
|
||||
!HTMLEditUtils::CanNodeContain(
|
||||
*aPoint.template ContainerParentAs<nsIContent>(),
|
||||
|
||||
@@ -76,6 +76,14 @@ class HTMLEditUtils final {
|
||||
return aNode.IsEditable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if aElement is an editing host which is either:
|
||||
* - the root element
|
||||
* - parent is not editable
|
||||
* - the <body> element of the document
|
||||
*/
|
||||
[[nodiscard]] static bool ElementIsEditableRoot(const Element& aElement);
|
||||
|
||||
/**
|
||||
* Return true if inclusive flat tree ancestor has `inert` state.
|
||||
*/
|
||||
@@ -540,8 +548,7 @@ class HTMLEditUtils final {
|
||||
template <typename PT, typename CT>
|
||||
[[nodiscard]] static bool PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak,
|
||||
const Element& aEditingHost);
|
||||
IgnoreInvisibleLineBreak aIgnoreInvisibleLineBreak);
|
||||
|
||||
/**
|
||||
* Return true if aRange crosses the inclusive ancestor block element at
|
||||
@@ -2071,8 +2078,7 @@ class HTMLEditUtils final {
|
||||
*/
|
||||
template <typename EditorLineBreakType, typename EditorDOMPointType>
|
||||
[[nodiscard]] static Maybe<EditorLineBreakType>
|
||||
GetFollowingUnnecessaryLineBreak(const EditorDOMPointType& aPoint,
|
||||
const Element& aEditingHost);
|
||||
GetFollowingUnnecessaryLineBreak(const EditorDOMPointType& aPoint);
|
||||
|
||||
/**
|
||||
* IsInTableCellSelectionMode() returns true when Gecko's editor thinks that
|
||||
@@ -2382,7 +2388,7 @@ class HTMLEditUtils final {
|
||||
*/
|
||||
template <typename EditorDOMPointType, typename EditorDOMPointTypeInput>
|
||||
static EditorDOMPointType GetBetterCaretPositionToInsertText(
|
||||
const EditorDOMPointTypeInput& aPoint, const Element& aEditingHost);
|
||||
const EditorDOMPointTypeInput& aPoint);
|
||||
|
||||
/**
|
||||
* ComputePointToPutCaretInElementIfOutside() returns a good point in aElement
|
||||
|
||||
@@ -1194,7 +1194,7 @@ nsresult HTMLEditor::MaybeCollapseSelectionAtFirstEditableNode(
|
||||
// the visible character.
|
||||
const WSScanResult scanResultInTextNode =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
editingHost, EditorRawDOMPoint(text, 0),
|
||||
WSRunScanner::Scan::EditableNodes, EditorRawDOMPoint(text, 0),
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if ((scanResultInTextNode.InVisibleOrCollapsibleCharacters() ||
|
||||
scanResultInTextNode.ReachedPreformattedLineBreak()) &&
|
||||
@@ -2295,8 +2295,7 @@ nsresult HTMLEditor::InsertElementAtSelectionAsAction(
|
||||
if (MOZ_LIKELY(aElement->IsInComposedDoc())) {
|
||||
const auto afterElement = EditorDOMPoint::After(*aElement);
|
||||
if (MOZ_LIKELY(afterElement.IsInContentNode())) {
|
||||
nsresult rv =
|
||||
EnsureNoFollowingUnnecessaryLineBreak(afterElement, *editingHost);
|
||||
nsresult rv = EnsureNoFollowingUnnecessaryLineBreak(afterElement);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
@@ -4519,8 +4518,7 @@ Result<CreateLineBreakResult, nsresult> HTMLEditor::InsertLineBreak(
|
||||
}
|
||||
|
||||
nsresult HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak(
|
||||
const EditorDOMPoint& aNextOrAfterModifiedPoint,
|
||||
const Element& aEditingHost) {
|
||||
const EditorDOMPoint& aNextOrAfterModifiedPoint) {
|
||||
MOZ_ASSERT(aNextOrAfterModifiedPoint.IsInContentNode());
|
||||
|
||||
// If the point is in a mailcite in plaintext mail composer (it is a <span>
|
||||
@@ -4548,7 +4546,7 @@ nsresult HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak(
|
||||
|
||||
const Maybe<EditorLineBreak> unnecessaryLineBreak =
|
||||
HTMLEditUtils::GetFollowingUnnecessaryLineBreak<EditorLineBreak>(
|
||||
aNextOrAfterModifiedPoint, aEditingHost);
|
||||
aNextOrAfterModifiedPoint);
|
||||
if (MOZ_LIKELY(unnecessaryLineBreak.isNothing())) {
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -7847,7 +7845,7 @@ nsresult HTMLEditor::OnModifyDocument(const DocumentModifiedEvent& aRunner) {
|
||||
}
|
||||
const WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
editingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
atCollapsibleWhiteSpace.AfterContainer<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (!nextThing.ReachedBlockBoundary()) {
|
||||
@@ -7909,21 +7907,18 @@ void HTMLEditor::DocumentModifiedEvent::MaybeAppendNewInvisibleWhiteSpace(
|
||||
!aContentWillBeRemoved->IsHTMLElement(nsGkAtoms::br)) {
|
||||
return;
|
||||
}
|
||||
const Element* const editingHost =
|
||||
const_cast<nsIContent*>(aContentWillBeRemoved)->GetEditingHost();
|
||||
if (MOZ_UNLIKELY(!editingHost)) {
|
||||
return;
|
||||
}
|
||||
const WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
editingHost, EditorRawDOMPoint::After(*aContentWillBeRemoved),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint::After(*aContentWillBeRemoved),
|
||||
BlockInlineCheck::UseComputedDisplayStyle);
|
||||
if (!nextThing.ReachedBlockBoundary()) {
|
||||
return;
|
||||
}
|
||||
const WSScanResult previousThing =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
editingHost, EditorRawDOMPoint(aContentWillBeRemoved),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(aContentWillBeRemoved),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (!previousThing.ContentIsText() || !previousThing.IsContentEditable()) {
|
||||
return;
|
||||
|
||||
@@ -1213,14 +1213,12 @@ class HTMLEditor final : public EditorBase,
|
||||
*
|
||||
* @param aMailCiteElement The mail-cite element which should be split.
|
||||
* @param aPointToSplit The point to split.
|
||||
* @param aEditingHost The editing host.
|
||||
* @return Candidate caret position where is at inserted
|
||||
* <br> element into the split point.
|
||||
*/
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<CaretPoint, nsresult>
|
||||
HandleInsertParagraphInMailCiteElement(Element& aMailCiteElement,
|
||||
const EditorDOMPoint& aPointToSplit,
|
||||
const Element& aEditingHost);
|
||||
const EditorDOMPoint& aPointToSplit);
|
||||
|
||||
/**
|
||||
* HandleInsertBRElement() inserts a <br> element into aPointToBreak.
|
||||
@@ -1657,7 +1655,7 @@ class HTMLEditor final : public EditorBase,
|
||||
*/
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<CreateLineBreakResult, nsresult>
|
||||
InsertPaddingBRElementToMakeEmptyLineVisibleIfNeeded(
|
||||
const EditorDOMPoint& aPointToInsert, const Element& aEditingHost);
|
||||
const EditorDOMPoint& aPointToInsert);
|
||||
|
||||
/**
|
||||
* Insert a padding <br> if aPoint is in an empty block.
|
||||
@@ -3400,12 +3398,10 @@ class HTMLEditor final : public EditorBase,
|
||||
* content.
|
||||
* If you deleted something, this should be
|
||||
* end of the deleted range.
|
||||
* @param aEditingHost The editing host.
|
||||
*/
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
|
||||
EnsureNoFollowingUnnecessaryLineBreak(
|
||||
const EditorDOMPoint& aNextOrAfterModifiedPoint,
|
||||
const Element& aEditingHost);
|
||||
const EditorDOMPoint& aNextOrAfterModifiedPoint);
|
||||
|
||||
/**
|
||||
* IndentAsSubAction() indents the content around Selection.
|
||||
@@ -3455,8 +3451,7 @@ class HTMLEditor final : public EditorBase,
|
||||
template <size_t N>
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult SetInlinePropertiesAroundRanges(
|
||||
AutoClonedRangeArray& aRanges,
|
||||
const AutoTArray<EditorInlineStyleAndValue, N>& aStylesToSet,
|
||||
const Element& aEditingHost);
|
||||
const AutoTArray<EditorInlineStyleAndValue, N>& aStylesToSet);
|
||||
|
||||
/**
|
||||
* RemoveInlinePropertiesAsSubAction() removes specified styles from
|
||||
|
||||
@@ -903,7 +903,7 @@ Result<EditActionResult, nsresult> HTMLEditor::HTMLWithContextInserter::Run(
|
||||
lastInsertedPoint.inspect().NextPointOrAfterContainer();
|
||||
if (MOZ_LIKELY(afterLastInsertedContent.IsInContentNode())) {
|
||||
nsresult rv = mHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(
|
||||
afterLastInsertedContent, mEditingHost);
|
||||
afterLastInsertedContent);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
|
||||
@@ -2373,8 +2373,8 @@ Result<CaretPoint, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
if (MOZ_LIKELY(pointToPutCaret.IsInContentNode())) {
|
||||
AutoTrackDOMPoint trackPointToPutCaret(aHTMLEditor.RangeUpdaterRef(),
|
||||
&pointToPutCaret);
|
||||
nsresult rv = aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(
|
||||
pointToPutCaret, aEditingHost);
|
||||
nsresult rv =
|
||||
aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(pointToPutCaret);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -2581,8 +2581,8 @@ Result<CaretPoint, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
if (MOZ_LIKELY(pointToPutCaret.IsInContentNode())) {
|
||||
AutoTrackDOMPoint trackPointToPutCaret(aHTMLEditor.RangeUpdaterRef(),
|
||||
&pointToPutCaret);
|
||||
nsresult rv = aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(
|
||||
pointToPutCaret, aEditingHost);
|
||||
nsresult rv =
|
||||
aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(pointToPutCaret);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -2756,8 +2756,8 @@ HTMLEditor::AutoDeleteRangesHandler::HandleDeleteAtomicContent(
|
||||
if (MOZ_LIKELY(pointToPutCaret.IsInContentNode())) {
|
||||
AutoTrackDOMPoint trackPointToPutCaret(aHTMLEditor.RangeUpdaterRef(),
|
||||
&pointToPutCaret);
|
||||
nsresult rv = aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(
|
||||
pointToPutCaret, aEditingHost);
|
||||
nsresult rv =
|
||||
aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(pointToPutCaret);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -3586,7 +3586,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
}
|
||||
const WSScanResult prevVisibleThingBeforeCurrentBlock =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(
|
||||
inclusiveAncestorOfRightChildBlockOrError.inspect()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -3605,7 +3605,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
MOZ_ASSERT(atPrecedingLineBreak.IsSet());
|
||||
const WSScanResult prevVisibleThingBeforeLineBreak =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, atPrecedingLineBreak,
|
||||
WSRunScanner::Scan::EditableNodes, atPrecedingLineBreak,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (prevVisibleThingBeforeLineBreak.ReachedBRElement() ||
|
||||
prevVisibleThingBeforeLineBreak.ReachedPreformattedLineBreak() ||
|
||||
@@ -4214,7 +4214,8 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
// rough check.
|
||||
const WSScanResult nextVisibleThingOfEndBoundary =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, EditorRawDOMPoint(aRangeToDelete.EndRef()),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(aRangeToDelete.EndRef()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (!nextVisibleThingOfEndBoundary.ReachedCurrentBlockBoundary()) {
|
||||
MOZ_ASSERT(mLeftContent->IsElement());
|
||||
@@ -4227,7 +4228,8 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
if (MOZ_LIKELY(mostDistantBlockOrError.inspect())) {
|
||||
const WSScanResult prevVisibleThingOfStartBoundary =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, EditorRawDOMPoint(aRangeToDelete.StartRef()),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(aRangeToDelete.StartRef()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (prevVisibleThingOfStartBoundary.ReachedBRElement()) {
|
||||
// If the range start after a <br> followed by the block boundary,
|
||||
@@ -4235,7 +4237,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
// not a part of empty line like `<div>abc<br>{<div>]def`.
|
||||
const WSScanResult nextVisibleThingOfBR =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint::After(
|
||||
*prevVisibleThingOfStartBoundary.GetContent()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -4249,7 +4251,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
}
|
||||
const WSScanResult prevVisibleThingOfBR =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(
|
||||
prevVisibleThingOfStartBoundary.GetContent()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -4264,7 +4266,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
.ReachedPreformattedLineBreak()) {
|
||||
const WSScanResult nextVisibleThingOfLineBreak =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
prevVisibleThingOfStartBoundary
|
||||
.PointAfterReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -4279,7 +4281,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
}
|
||||
const WSScanResult prevVisibleThingOfLineBreak =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
prevVisibleThingOfStartBoundary
|
||||
.PointAtReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -4296,7 +4298,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
mLeftContent);
|
||||
const WSScanResult firstVisibleThingInBlock =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(
|
||||
prevVisibleThingOfStartBoundary.ElementPtr(), 0),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -4309,7 +4311,7 @@ bool HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
} else if (prevVisibleThingOfStartBoundary.ReachedOtherBlockElement()) {
|
||||
const WSScanResult firstVisibleThingAfterBlock =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint::After(
|
||||
*prevVisibleThingOfStartBoundary.ElementPtr()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -4903,8 +4905,8 @@ Result<Element*, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
|
||||
const WSScanResult prevVisibleThing =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
aAncestorLimiter, aPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
WSRunScanner::Scan::EditableNodes, aPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle, aAncestorLimiter);
|
||||
if (!ReachedCurrentBlockBoundaryWhichWeCanCross(prevVisibleThing)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -4914,8 +4916,8 @@ Result<Element*, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
for (Element* ancestorBlock = prevVisibleThing.ElementPtr(); ancestorBlock;) {
|
||||
const WSScanResult prevVisibleThing =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
aAncestorLimiter, EditorRawDOMPoint(ancestorBlock),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
WSRunScanner::Scan::EditableNodes, EditorRawDOMPoint(ancestorBlock),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle, aAncestorLimiter);
|
||||
if (!ReachedCurrentBlockBoundaryWhichWeCanCross(prevVisibleThing)) {
|
||||
return ancestorBlock;
|
||||
}
|
||||
@@ -4981,7 +4983,8 @@ void HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
|
||||
const WSScanResult prevVisibleThingOfStartBoundary =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, EditorRawDOMPoint(aRangeToDelete.StartRef()),
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint(aRangeToDelete.StartRef()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
// If the range starts after an invisible <br> of empty line immediately
|
||||
// before the most distant inclusive ancestor of the right block like
|
||||
@@ -4991,13 +4994,13 @@ void HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
prevVisibleThingOfStartBoundary.ReachedPreformattedLineBreak()) {
|
||||
const WSScanResult prevVisibleThingOfPreviousLineBreak =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
prevVisibleThingOfStartBoundary
|
||||
.PointAtReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
const WSScanResult nextVisibleThingOfPreviousBR =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
prevVisibleThingOfStartBoundary
|
||||
.PointAfterReachedContent<EditorRawDOMPoint>(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -5028,8 +5031,9 @@ void HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::
|
||||
while (true) {
|
||||
WSScanResult scanResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
mLeftContent->AsElement(), scanStartPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
WSRunScanner::Scan::EditableNodes, scanStartPoint,
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle,
|
||||
mLeftContent->AsElement());
|
||||
if (scanResult.ReachedBlockBoundary() ||
|
||||
scanResult.ReachedInlineEditingHostBoundary()) {
|
||||
return lastScanResult;
|
||||
@@ -5181,7 +5185,7 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
mMode != Mode::DeletePrecedingLinesAndContentInRange &&
|
||||
HTMLEditUtils::PointIsImmediatelyBeforeCurrentBlockBoundary(
|
||||
EditorRawDOMPoint(aRangeToDelete.StartRef()),
|
||||
HTMLEditUtils::IgnoreInvisibleLineBreak::Yes, aEditingHost);
|
||||
HTMLEditUtils::IgnoreInvisibleLineBreak::Yes);
|
||||
const PutCaretTo putCaretTo = [&]() {
|
||||
// When we delete only preceding lines of the right child block, we should
|
||||
// put caret into start of the right block.
|
||||
@@ -5405,8 +5409,8 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
aHTMLEditor.RangeUpdaterRef(), &moveFirstLineResult);
|
||||
AutoTrackDOMPoint trackPointToPutCaret(
|
||||
aHTMLEditor.RangeUpdaterRef(), &pointToPutCaret);
|
||||
nsresult rv = aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(
|
||||
aPoint, aEditingHost);
|
||||
nsresult rv =
|
||||
aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(aPoint);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
@@ -5496,7 +5500,7 @@ Result<EditActionResult, nsresult> HTMLEditor::AutoDeleteRangesHandler::
|
||||
}
|
||||
WSScanResult nextThing =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
deleteContentResult.DeleteRangeRef().EndRef(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
return nextThing.ReachedBRElement() ||
|
||||
@@ -5645,8 +5649,8 @@ nsresult HTMLEditor::AutoDeleteRangesHandler::DeleteUnnecessaryNodes(
|
||||
|
||||
if (MOZ_LIKELY(range.EndRef().IsInContentNode())) {
|
||||
AutoTrackDOMRange trackRange(aHTMLEditor.RangeUpdaterRef(), &range);
|
||||
nsresult rv = aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(
|
||||
range.EndRef(), aEditingHost);
|
||||
nsresult rv =
|
||||
aHTMLEditor.EnsureNoFollowingUnnecessaryLineBreak(range.EndRef());
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::EnsureNoFollowingUnnecessaryLineBreak() failed");
|
||||
return Err(rv);
|
||||
@@ -5737,7 +5741,7 @@ HTMLEditor::AutoDeleteRangesHandler::DeleteParentBlocksWithTransactionIfEmpty(
|
||||
if (wsScannerForPoint.GetEndReasonContent()->GetNextSibling()) {
|
||||
const WSScanResult scanResult =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
editingHost,
|
||||
WSRunScanner::Scan::EditableNodes,
|
||||
EditorRawDOMPoint::After(
|
||||
*wsScannerForPoint.GetEndReasonContent()),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
@@ -8349,7 +8353,7 @@ HTMLEditor::AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete(
|
||||
for (;;) {
|
||||
const WSScanResult backwardScanFromStartResult =
|
||||
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
closestEditingHost, rangeToDelete.StartRef(),
|
||||
WSRunScanner::Scan::EditableNodes, rangeToDelete.StartRef(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (!backwardScanFromStartResult.ReachedCurrentBlockBoundary() &&
|
||||
!backwardScanFromStartResult.ReachedInlineEditingHostBoundary()) {
|
||||
|
||||
@@ -78,8 +78,7 @@ class MOZ_STACK_CLASS HTMLEditor::AutoInlineStyleSetter final
|
||||
* See comments in the definition what this does.
|
||||
*/
|
||||
Result<EditorRawDOMRange, nsresult> ExtendOrShrinkRangeToApplyTheStyle(
|
||||
const HTMLEditor& aHTMLEditor, const EditorDOMRange& aRange,
|
||||
const Element& aEditingHost) const;
|
||||
const HTMLEditor& aHTMLEditor, const EditorDOMRange& aRange) const;
|
||||
|
||||
/**
|
||||
* Returns next/previous sibling of aContent or an ancestor of it if it's
|
||||
@@ -104,7 +103,6 @@ class MOZ_STACK_CLASS HTMLEditor::AutoInlineStyleSetter final
|
||||
* @param aHTMLEditor The editor.
|
||||
* @param aCandidatePointToInsert The point where the caller wants to
|
||||
* insert new text.
|
||||
* @param aEditingHost The editing host.
|
||||
* @return If this creates new empty text node returns it.
|
||||
* If this couldn't create new empty text node due to
|
||||
* the point or aEditingHost cannot have text node,
|
||||
@@ -112,9 +110,8 @@ class MOZ_STACK_CLASS HTMLEditor::AutoInlineStyleSetter final
|
||||
* Otherwise, returns error.
|
||||
*/
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT static Result<RefPtr<Text>, nsresult>
|
||||
GetEmptyTextNodeToApplyNewStyle(HTMLEditor& aHTMLEditor,
|
||||
const EditorDOMPoint& aCandidatePointToInsert,
|
||||
const Element& aEditingHost);
|
||||
GetEmptyTextNodeToApplyNewStyle(
|
||||
HTMLEditor& aHTMLEditor, const EditorDOMPoint& aCandidatePointToInsert);
|
||||
|
||||
private:
|
||||
[[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<CaretPoint, nsresult> ApplyStyle(
|
||||
|
||||
@@ -75,12 +75,10 @@ template nsresult HTMLEditor::SetInlinePropertiesAsSubAction(
|
||||
|
||||
template nsresult HTMLEditor::SetInlinePropertiesAroundRanges(
|
||||
AutoClonedRangeArray& aRanges,
|
||||
const AutoTArray<EditorInlineStyleAndValue, 1>& aStylesToSet,
|
||||
const Element& aEditingHost);
|
||||
const AutoTArray<EditorInlineStyleAndValue, 1>& aStylesToSet);
|
||||
template nsresult HTMLEditor::SetInlinePropertiesAroundRanges(
|
||||
AutoClonedRangeArray& aRanges,
|
||||
const AutoTArray<EditorInlineStyleAndValue, 32>& aStylesToSet,
|
||||
const Element& aEditingHost);
|
||||
const AutoTArray<EditorInlineStyleAndValue, 32>& aStylesToSet);
|
||||
|
||||
nsresult HTMLEditor::SetInlinePropertyAsAction(nsStaticAtom& aProperty,
|
||||
nsStaticAtom* aAttribute,
|
||||
@@ -310,8 +308,7 @@ nsresult HTMLEditor::SetInlinePropertiesAsSubAction(
|
||||
AutoTransactionsConserveSelection dontChangeMySelection(*this);
|
||||
|
||||
AutoClonedSelectionRangeArray selectionRanges(SelectionRef());
|
||||
nsresult rv = SetInlinePropertiesAroundRanges(selectionRanges, aStylesToSet,
|
||||
aEditingHost);
|
||||
nsresult rv = SetInlinePropertiesAroundRanges(selectionRanges, aStylesToSet);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("HTMLEditor::SetInlinePropertiesAroundRanges() failed");
|
||||
return rv;
|
||||
@@ -329,8 +326,7 @@ nsresult HTMLEditor::SetInlinePropertiesAsSubAction(
|
||||
template <size_t N>
|
||||
nsresult HTMLEditor::SetInlinePropertiesAroundRanges(
|
||||
AutoClonedRangeArray& aRanges,
|
||||
const AutoTArray<EditorInlineStyleAndValue, N>& aStylesToSet,
|
||||
const Element& aEditingHost) {
|
||||
const AutoTArray<EditorInlineStyleAndValue, N>& aStylesToSet) {
|
||||
MOZ_ASSERT(!aRanges.HasSavedRanges());
|
||||
for (const EditorInlineStyleAndValue& styleToSet : aStylesToSet) {
|
||||
AutoInlineStyleSetter inlineStyleSetter(styleToSet);
|
||||
@@ -371,8 +367,7 @@ nsresult HTMLEditor::SetInlinePropertiesAroundRanges(
|
||||
}
|
||||
}
|
||||
Result<EditorRawDOMRange, nsresult> rangeOrError =
|
||||
inlineStyleSetter.ExtendOrShrinkRangeToApplyTheStyle(*this, range,
|
||||
aEditingHost);
|
||||
inlineStyleSetter.ExtendOrShrinkRangeToApplyTheStyle(*this, range);
|
||||
if (MOZ_UNLIKELY(rangeOrError.isErr())) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::ExtendOrShrinkRangeToApplyTheStyle() failed, but "
|
||||
@@ -394,7 +389,7 @@ nsresult HTMLEditor::SetInlinePropertiesAroundRanges(
|
||||
if (range.Collapsed()) {
|
||||
Result<RefPtr<Text>, nsresult> emptyTextNodeOrError =
|
||||
AutoInlineStyleSetter::GetEmptyTextNodeToApplyNewStyle(
|
||||
*this, range.StartRef(), aEditingHost);
|
||||
*this, range.StartRef());
|
||||
if (MOZ_UNLIKELY(emptyTextNodeOrError.isErr())) {
|
||||
NS_WARNING(
|
||||
"AutoInlineStyleSetter::GetEmptyTextNodeToApplyNewStyle() "
|
||||
@@ -579,11 +574,10 @@ nsresult HTMLEditor::SetInlinePropertiesAroundRanges(
|
||||
// static
|
||||
Result<RefPtr<Text>, nsresult>
|
||||
HTMLEditor::AutoInlineStyleSetter::GetEmptyTextNodeToApplyNewStyle(
|
||||
HTMLEditor& aHTMLEditor, const EditorDOMPoint& aCandidatePointToInsert,
|
||||
const Element& aEditingHost) {
|
||||
HTMLEditor& aHTMLEditor, const EditorDOMPoint& aCandidatePointToInsert) {
|
||||
auto pointToInsertNewText =
|
||||
HTMLEditUtils::GetBetterCaretPositionToInsertText<EditorDOMPoint>(
|
||||
aCandidatePointToInsert, aEditingHost);
|
||||
aCandidatePointToInsert);
|
||||
if (MOZ_UNLIKELY(!pointToInsertNewText.IsSet())) {
|
||||
return RefPtr<Text>(); // cannot insert text there
|
||||
}
|
||||
@@ -1925,8 +1919,7 @@ EditorRawDOMRange HTMLEditor::AutoInlineStyleSetter::
|
||||
|
||||
Result<EditorRawDOMRange, nsresult>
|
||||
HTMLEditor::AutoInlineStyleSetter::ExtendOrShrinkRangeToApplyTheStyle(
|
||||
const HTMLEditor& aHTMLEditor, const EditorDOMRange& aRange,
|
||||
const Element& aEditingHost) const {
|
||||
const HTMLEditor& aHTMLEditor, const EditorDOMRange& aRange) const {
|
||||
if (NS_WARN_IF(!aRange.IsPositioned())) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
@@ -1945,7 +1938,7 @@ HTMLEditor::AutoInlineStyleSetter::ExtendOrShrinkRangeToApplyTheStyle(
|
||||
if (range.EndRef().IsInContentNode()) {
|
||||
const WSScanResult nextContentData =
|
||||
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
&aEditingHost, range.EndRef(),
|
||||
WSRunScanner::Scan::EditableNodes, range.EndRef(),
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
if (nextContentData.ReachedInvisibleBRElement() &&
|
||||
nextContentData.BRElementPtr()->GetParentElement() &&
|
||||
|
||||
@@ -238,6 +238,11 @@ class MOZ_STACK_CLASS WSScanResult final {
|
||||
*/
|
||||
bool IsContentEditable() const { return mContent && mContent->IsEditable(); }
|
||||
|
||||
[[nodiscard]] bool IsContentEditableRoot() const {
|
||||
return mContent && mContent->IsElement() &&
|
||||
HTMLEditUtils::ElementIsEditableRoot(*mContent->AsElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset_Deprecated() returns meaningful value only when
|
||||
* InVisibleOrCollapsibleCharacters() returns true or the scanner reached to
|
||||
@@ -455,10 +460,10 @@ class MOZ_STACK_CLASS WSRunScanner final {
|
||||
const EditorDOMPointBase<PT, CT>& aPoint) const;
|
||||
template <typename PT, typename CT>
|
||||
static WSScanResult ScanInclusiveNextVisibleNodeOrBlockBoundary(
|
||||
const Element* aEditingHost, const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
BlockInlineCheck aBlockInlineCheck) {
|
||||
return WSRunScanner(Scan::EditableNodes, aPoint, aBlockInlineCheck,
|
||||
aEditingHost)
|
||||
Scan aScanMode, const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
BlockInlineCheck aBlockInlineCheck,
|
||||
const Element* aAncestorLimiter = nullptr) {
|
||||
return WSRunScanner(aScanMode, aPoint, aBlockInlineCheck, aAncestorLimiter)
|
||||
.ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom(aPoint);
|
||||
}
|
||||
|
||||
@@ -473,10 +478,10 @@ class MOZ_STACK_CLASS WSRunScanner final {
|
||||
const EditorDOMPointBase<PT, CT>& aPoint) const;
|
||||
template <typename PT, typename CT>
|
||||
static WSScanResult ScanPreviousVisibleNodeOrBlockBoundary(
|
||||
const Element* aEditingHost, const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
BlockInlineCheck aBlockInlineCheck) {
|
||||
return WSRunScanner(Scan::EditableNodes, aPoint, aBlockInlineCheck,
|
||||
aEditingHost)
|
||||
Scan aScanMode, const EditorDOMPointBase<PT, CT>& aPoint,
|
||||
BlockInlineCheck aBlockInlineCheck,
|
||||
const Element* aAncestorLimiter = nullptr) {
|
||||
return WSRunScanner(aScanMode, aPoint, aBlockInlineCheck, aAncestorLimiter)
|
||||
.ScanPreviousVisibleNodeOrBlockBoundaryFrom(aPoint);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user