diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index 79b81ceaba76..2db7a37d6ea6 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -1626,10 +1626,10 @@ nsresult HTMLEditor::WillInsertText(EditSubAction aEditSubAction, bool* aCancel, return rv; } -bool HTMLEditRules::CanContainParagraph(Element& aElement) const { - MOZ_ASSERT(IsEditorDataAvailable()); +bool HTMLEditor::CanContainParagraph(Element& aElement) const { + MOZ_ASSERT(IsEditActionDataAvailable()); - if (HTMLEditorRef().CanContainTag(aElement, *nsGkAtoms::p)) { + if (CanContainTag(aElement, *nsGkAtoms::p)) { return true; } @@ -1731,8 +1731,8 @@ EditActionResult HTMLEditRules::WillInsertParagraphSeparator() { // is
or the editing host cannot contain a

element, we should // insert a
element. else if (host == blockParent) { - insertBRElement = - separator == ParagraphSeparator::br || !CanContainParagraph(*host); + insertBRElement = separator == ParagraphSeparator::br || + !HTMLEditorRef().CanContainParagraph(*host); } // If the nearest block parent is a single-line container declared in // the execCommand spec and not the editing host, we should separate the @@ -1746,7 +1746,7 @@ EditActionResult HTMLEditRules::WillInsertParagraphSeparator() { insertBRElement = true; for (Element* blockAncestor = blockParent; blockAncestor && insertBRElement; blockAncestor = HTMLEditor::GetBlockNodeParent(blockAncestor, host)) { - insertBRElement = !CanContainParagraph(*blockAncestor); + insertBRElement = !HTMLEditorRef().CanContainParagraph(*blockAncestor); } } diff --git a/editor/libeditor/HTMLEditRules.h b/editor/libeditor/HTMLEditRules.h index 3c3f9515358d..3dd745d84599 100644 --- a/editor/libeditor/HTMLEditRules.h +++ b/editor/libeditor/HTMLEditRules.h @@ -176,12 +176,6 @@ class HTMLEditRules : public TextEditRules { */ MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE nsresult InsertBRIfNeeded(); - /** - * CanContainParagraph() returns true if aElement can have a

element as - * its child or its descendant. - */ - bool CanContainParagraph(Element& aElement) const; - /** * Insert normal
element into aNode when aNode is a block and it has * no children. diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h index 7a308c25c18e..197040d50e6e 100644 --- a/editor/libeditor/HTMLEditor.h +++ b/editor/libeditor/HTMLEditor.h @@ -1187,6 +1187,12 @@ class HTMLEditor final : public TextEditor, MOZ_CAN_RUN_SCRIPT MOZ_MUST_USE EditActionResult SplitMailCiteElements(const EditorDOMPoint& aPointToSplit); + /** + * CanContainParagraph() returns true if aElement can have a

element as + * its child or its descendant. + */ + bool CanContainParagraph(Element& aElement) const; + protected: // Called by helper classes. virtual void OnStartToHandleTopLevelEditSubAction( EditSubAction aEditSubAction, nsIEditor::EDirection aDirection) override;