mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 07:45:30 +00:00
Bug 1574852 - part 13: Move HTMLEditRules::CanContainParagraph()
to HTMLEditor
r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D42784 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d4d395fb49
commit
6c17e180aa
@ -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 <br> or the editing host cannot contain a <p> element, we should
|
||||
// insert a <br> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 <p> element as
|
||||
* its child or its descendant.
|
||||
*/
|
||||
bool CanContainParagraph(Element& aElement) const;
|
||||
|
||||
/**
|
||||
* Insert normal <br> element into aNode when aNode is a block and it has
|
||||
* no children.
|
||||
|
@ -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 <p> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user