Bug 1742933 - part 12: Make all aInitializer arguments optional r=m_kato

For making the callers simpler, they should be able to be omitted if they
want to do nothing.

Differential Revision: https://phabricator.services.mozilla.com/D140701
This commit is contained in:
Masayuki Nakano 2022-03-11 09:21:36 +00:00
parent 75a4321f48
commit c98a4265f6
3 changed files with 44 additions and 63 deletions

View file

@ -3051,14 +3051,11 @@ EditActionResult HTMLEditor::ChangeSelectedHardLinesToList(
// MOZ_CAN_RUN_SCRIPT_BOUNDARY due to bug 1758868 // MOZ_CAN_RUN_SCRIPT_BOUNDARY due to bug 1758868
[&](Element& aListElement) MOZ_CAN_RUN_SCRIPT_BOUNDARY { [&](Element& aListElement) MOZ_CAN_RUN_SCRIPT_BOUNDARY {
Result<RefPtr<Element>, nsresult> listItemElementOrError = Result<RefPtr<Element>, nsresult> listItemElementOrError =
CreateAndInsertElement( CreateAndInsertElement(aListElement.IsInComposedDoc()
aListElement.IsInComposedDoc() ? WithTransaction::Yes ? WithTransaction::Yes
: WithTransaction::No, : WithTransaction::No,
aListItemElementTagName, aListItemElementTagName,
EditorDOMPoint(&aListElement, 0u), EditorDOMPoint(&aListElement, 0u));
[](Element& aListItemElement) -> nsresult {
return NS_OK;
});
if (listItemElementOrError.isErr()) { if (listItemElementOrError.isErr()) {
NS_WARNING(nsPrintfCString( NS_WARNING(nsPrintfCString(
"HTMLEditor::CreateAndInsertElement(%s) failed", "HTMLEditor::CreateAndInsertElement(%s) failed",
@ -3227,8 +3224,7 @@ EditActionResult HTMLEditor::ChangeSelectedHardLinesToList(
Result<RefPtr<Element>, nsresult> maybeNewListElement = Result<RefPtr<Element>, nsresult> maybeNewListElement =
CreateAndInsertElement( CreateAndInsertElement(
WithTransaction::Yes, aListElementTagName, WithTransaction::Yes, aListElementTagName,
splitListItemParentResult.AtNextContent<EditorDOMPoint>(), splitListItemParentResult.AtNextContent<EditorDOMPoint>());
[](Element& aListElement) -> nsresult { return NS_OK; });
if (maybeNewListElement.isErr()) { if (maybeNewListElement.isErr()) {
NS_WARNING( NS_WARNING(
"HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) " "HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) "
@ -3366,8 +3362,7 @@ EditActionResult HTMLEditor::ChangeSelectedHardLinesToList(
prevListItem = nullptr; prevListItem = nullptr;
Result<RefPtr<Element>, nsresult> newListElementOrError = Result<RefPtr<Element>, nsresult> newListElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
aListElementTagName, atContent, BRElementNextToSplitPoint::Keep, aListElementTagName, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aListElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newListElementOrError.isErr())) { if (MOZ_UNLIKELY(newListElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
nsPrintfCString( nsPrintfCString(
@ -3689,8 +3684,7 @@ nsresult HTMLEditor::FormatBlockContainerWithTransaction(nsAtom& blockType) {
// Make sure we can put a block here. // Make sure we can put a block here.
Result<RefPtr<Element>, nsresult> newBlockElementOrError = Result<RefPtr<Element>, nsresult> newBlockElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
blockType, pointToInsertBlock, BRElementNextToSplitPoint::Keep, blockType, pointToInsertBlock, BRElementNextToSplitPoint::Keep);
[](Element& aBlockElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
nsPrintfCString( nsPrintfCString(
@ -3895,8 +3889,7 @@ nsresult HTMLEditor::IndentListChild(RefPtr<Element>* aCurList,
Result<RefPtr<Element>, nsresult> newListElementOrError = Result<RefPtr<Element>, nsresult> newListElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
MOZ_KnownLive(*containerName), aCurPoint, MOZ_KnownLive(*containerName), aCurPoint,
BRElementNextToSplitPoint::Keep, BRElementNextToSplitPoint::Keep);
[](Element& aListElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newListElementOrError.isErr())) { if (MOZ_UNLIKELY(newListElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
nsPrintfCString( nsPrintfCString(
@ -4058,8 +4051,7 @@ nsresult HTMLEditor::HandleCSSIndentAtSelectionInternal() {
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atStartOfSelection, *nsGkAtoms::div, atStartOfSelection,
BRElementNextToSplitPoint::Keep, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newDivElementOrError.isErr())) { if (MOZ_UNLIKELY(newDivElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -4155,8 +4147,7 @@ nsresult HTMLEditor::HandleCSSIndentAtSelectionInternal() {
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep, *nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newDivElementOrError.isErr())) { if (MOZ_UNLIKELY(newDivElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -4267,8 +4258,7 @@ nsresult HTMLEditor::HandleHTMLIndentAtSelectionInternal() {
Result<RefPtr<Element>, nsresult> newBlockQuoteElementOrError = Result<RefPtr<Element>, nsresult> newBlockQuoteElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::blockquote, atStartOfSelection, *nsGkAtoms::blockquote, atStartOfSelection,
BRElementNextToSplitPoint::Keep, BRElementNextToSplitPoint::Keep);
[](Element& aBlockquoteElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockQuoteElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockQuoteElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -4372,8 +4362,7 @@ nsresult HTMLEditor::HandleHTMLIndentAtSelectionInternal() {
Result<RefPtr<Element>, nsresult> newListElementOrError = Result<RefPtr<Element>, nsresult> newListElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
MOZ_KnownLive(*containerName), atListItem, MOZ_KnownLive(*containerName), atListItem,
BRElementNextToSplitPoint::Keep, BRElementNextToSplitPoint::Keep);
[](Element& aListElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newListElementOrError.isErr())) { if (MOZ_UNLIKELY(newListElementOrError.isErr())) {
NS_WARNING(nsPrintfCString("HTMLEditor::" NS_WARNING(nsPrintfCString("HTMLEditor::"
"InsertElementWithSplittingAncestorsWithTr" "InsertElementWithSplittingAncestorsWithTr"
@ -4421,8 +4410,7 @@ nsresult HTMLEditor::HandleHTMLIndentAtSelectionInternal() {
Result<RefPtr<Element>, nsresult> newBlockQuoteElementOrError = Result<RefPtr<Element>, nsresult> newBlockQuoteElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::blockquote, atContent, *nsGkAtoms::blockquote, atContent,
BRElementNextToSplitPoint::Keep, BRElementNextToSplitPoint::Keep);
[](Element& aBlockquoteElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockQuoteElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockQuoteElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -5426,8 +5414,7 @@ EditActionResult HTMLEditor::AlignContentsAtSelectionWithEmptyDivElement(
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atStartOfSelection, *nsGkAtoms::div, atStartOfSelection,
BRElementNextToSplitPoint::Delete, BRElementNextToSplitPoint::Delete);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (newDivElementOrError.isErr()) { if (newDivElementOrError.isErr()) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -5603,8 +5590,7 @@ nsresult HTMLEditor::AlignNodesAndDescendants(
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep, *nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newDivElementOrError.isErr())) { if (MOZ_UNLIKELY(newDivElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -7502,8 +7488,8 @@ nsresult HTMLEditor::HandleInsertParagraphInListItemElement(
Result<RefPtr<Element>, nsresult> maybeNewListItemElement = Result<RefPtr<Element>, nsresult> maybeNewListItemElement =
CreateAndInsertElement( CreateAndInsertElement(
WithTransaction::Yes, WithTransaction::Yes,
MOZ_KnownLive(*nextDefinitionListItemTagName), atNextListItem, MOZ_KnownLive(*nextDefinitionListItemTagName),
[](Element& aListItemElement) -> nsresult { return NS_OK; }); atNextListItem);
if (maybeNewListItemElement.isErr()) { if (maybeNewListItemElement.isErr()) {
NS_WARNING( NS_WARNING(
"HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) " "HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) "
@ -7634,8 +7620,7 @@ nsresult HTMLEditor::MoveNodesIntoNewBlockquoteElement(
Result<RefPtr<Element>, nsresult> newBlockQuoteElementOrError = Result<RefPtr<Element>, nsresult> newBlockQuoteElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::blockquote, EditorDOMPoint(content), *nsGkAtoms::blockquote, EditorDOMPoint(content),
BRElementNextToSplitPoint::Keep, BRElementNextToSplitPoint::Keep);
[](Element& aBlockquoteElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockQuoteElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockQuoteElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -7885,8 +7870,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
// Make sure we can put a block here // Make sure we can put a block here
Result<RefPtr<Element>, nsresult> newBlockElementOrError = Result<RefPtr<Element>, nsresult> newBlockElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
aBlockTag, atContent, BRElementNextToSplitPoint::Keep, aBlockTag, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aBlockElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
nsPrintfCString( nsPrintfCString(
@ -7926,8 +7910,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
// block for it. // block for it.
Result<RefPtr<Element>, nsresult> newBlockElementOrError = Result<RefPtr<Element>, nsresult> newBlockElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
aBlockTag, atContent, BRElementNextToSplitPoint::Keep, aBlockTag, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aBlockElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
nsPrintfCString( nsPrintfCString(
@ -7975,8 +7958,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
if (!curBlock) { if (!curBlock) {
Result<RefPtr<Element>, nsresult> newBlockElementOrError = Result<RefPtr<Element>, nsresult> newBlockElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
aBlockTag, atContent, BRElementNextToSplitPoint::Keep, aBlockTag, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aBlockElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) { if (MOZ_UNLIKELY(newBlockElementOrError.isErr())) {
NS_WARNING(nsPrintfCString("HTMLEditor::" NS_WARNING(nsPrintfCString("HTMLEditor::"
"InsertElementWithSplittingAncestorsWithTr" "InsertElementWithSplittingAncestorsWithTr"
@ -9741,8 +9723,7 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
// Make sure we can put a block here. // Make sure we can put a block here.
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atCaret, BRElementNextToSplitPoint::Keep, *nsGkAtoms::div, atCaret, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newDivElementOrError.isErr())) { if (MOZ_UNLIKELY(newDivElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("
@ -9833,8 +9814,7 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
// element with splitting the ancestors. // element with splitting the ancestors.
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep, *nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newDivElementOrError.isErr())) { if (MOZ_UNLIKELY(newDivElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::" "HTMLEditor::"
@ -9846,10 +9826,9 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
targetDivElement = newDivElementOrError.unwrap(); targetDivElement = newDivElementOrError.unwrap();
} }
Result<RefPtr<Element>, nsresult> maybeNewListElement = Result<RefPtr<Element>, nsresult> maybeNewListElement =
CreateAndInsertElement( CreateAndInsertElement(WithTransaction::Yes,
WithTransaction::Yes, MOZ_KnownLive(*ULOrOLOrDLTagName), MOZ_KnownLive(*ULOrOLOrDLTagName),
EditorDOMPoint::AtEndOf(targetDivElement), EditorDOMPoint::AtEndOf(targetDivElement));
[](Element& aListElement) -> nsresult { return NS_OK; });
if (maybeNewListElement.isErr()) { if (maybeNewListElement.isErr()) {
NS_WARNING( NS_WARNING(
"HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) " "HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) "
@ -9916,8 +9895,7 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
// element with splitting the ancestors. // element with splitting the ancestors.
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep, *nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (MOZ_UNLIKELY(newDivElementOrError.isErr())) { if (MOZ_UNLIKELY(newDivElementOrError.isErr())) {
NS_WARNING( NS_WARNING(
"HTMLEditor::" "HTMLEditor::"
@ -9930,10 +9908,9 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
} }
// XXX So, createdListElement may be set to a non-list element. // XXX So, createdListElement may be set to a non-list element.
Result<RefPtr<Element>, nsresult> maybeNewListElement = Result<RefPtr<Element>, nsresult> maybeNewListElement =
CreateAndInsertElement( CreateAndInsertElement(WithTransaction::Yes,
WithTransaction::Yes, MOZ_KnownLive(*containerName), MOZ_KnownLive(*containerName),
EditorDOMPoint::AtEndOf(targetDivElement), EditorDOMPoint::AtEndOf(targetDivElement));
[](Element& aListElement) -> nsresult { return NS_OK; });
if (maybeNewListElement.isErr()) { if (maybeNewListElement.isErr()) {
NS_WARNING( NS_WARNING(
"HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) " "HTMLEditor::CreateAndInsertElement(WithTransaction::Yes) "
@ -9975,8 +9952,7 @@ nsresult HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition(
// and to contain all selected nodes. // and to contain all selected nodes.
Result<RefPtr<Element>, nsresult> newDivElementOrError = Result<RefPtr<Element>, nsresult> newDivElementOrError =
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
*nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep, *nsGkAtoms::div, atContent, BRElementNextToSplitPoint::Keep);
[](Element& aDivElement) -> nsresult { return NS_OK; });
if (newDivElementOrError.isErr()) { if (newDivElementOrError.isErr()) {
NS_WARNING( NS_WARNING(
"HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction(" "HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction("

View file

@ -3668,8 +3668,7 @@ Result<RefPtr<Element>, nsresult> HTMLEditor::InsertBRElement(
MOZ_ASSERT(maybePointToInsert.inspect().IsSetAndValid()); MOZ_ASSERT(maybePointToInsert.inspect().IsSetAndValid());
Result<RefPtr<Element>, nsresult> maybeNewBRElement = CreateAndInsertElement( Result<RefPtr<Element>, nsresult> maybeNewBRElement = CreateAndInsertElement(
aWithTransaction, *nsGkAtoms::br, maybePointToInsert.inspect(), aWithTransaction, *nsGkAtoms::br, maybePointToInsert.inspect());
[](Element& aBRElement) -> nsresult { return NS_OK; });
if (maybeNewBRElement.isErr()) { if (maybeNewBRElement.isErr()) {
NS_WARNING(nsPrintfCString("HTMLEditor::CreateAndInsertElement(%s) failed", NS_WARNING(nsPrintfCString("HTMLEditor::CreateAndInsertElement(%s) failed",
ToString(aWithTransaction).c_str()) ToString(aWithTransaction).c_str())

View file

@ -1505,9 +1505,12 @@ class HTMLEditor final : public EditorBase,
* @return The created new element node or an error. * @return The created new element node or an error.
*/ */
[[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<RefPtr<Element>, nsresult> [[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<RefPtr<Element>, nsresult>
CreateAndInsertElement(WithTransaction aWithTransaction, nsAtom& aTagName, CreateAndInsertElement(
const EditorDOMPoint& aPointToInsert, WithTransaction aWithTransaction, nsAtom& aTagName,
const std::function<nsresult(Element&)>& aInitializer); const EditorDOMPoint& aPointToInsert,
const std::function<nsresult(Element&)>& aInitializer = [](Element&) {
return NS_OK;
});
/** /**
* MaybeSplitAncestorsForInsertWithTransaction() does nothing if container of * MaybeSplitAncestorsForInsertWithTransaction() does nothing if container of
@ -1555,7 +1558,9 @@ class HTMLEditor final : public EditorBase,
InsertElementWithSplittingAncestorsWithTransaction( InsertElementWithSplittingAncestorsWithTransaction(
nsAtom& aTagName, const EditorDOMPoint& aPointToInsert, nsAtom& aTagName, const EditorDOMPoint& aPointToInsert,
BRElementNextToSplitPoint aBRElementNextToSplitPoint, BRElementNextToSplitPoint aBRElementNextToSplitPoint,
const std::function<nsresult(Element&)>& aInitializer); const std::function<nsresult(Element&)>& aInitializer = [](Element&) {
return NS_OK;
});
/** /**
* SplitRangeOffFromBlock() splits aBlockElement at two points, before * SplitRangeOffFromBlock() splits aBlockElement at two points, before
@ -3435,7 +3440,8 @@ class HTMLEditor final : public EditorBase,
*/ */
MOZ_CAN_RUN_SCRIPT Result<RefPtr<Element>, nsresult> MOZ_CAN_RUN_SCRIPT Result<RefPtr<Element>, nsresult>
DeleteSelectionAndCreateElement( DeleteSelectionAndCreateElement(
nsAtom& aTag, const std::function<nsresult(Element&)>& aInitializer); nsAtom& aTag, const std::function<nsresult(Element&)>& aInitializer =
[](Element&) { return NS_OK; });
/** /**
* This method first deletes the selection, if it's not collapsed. Then if * This method first deletes the selection, if it's not collapsed. Then if