Bug 1771448 - part 3: Get rid of EditorBase::GetEditorRoot r=m_kato

It returns the anonymous `<div>` element if the instance is a `TextEditor`, and
compute editing host otherwise.  So it's unclear what it returns.  Additionally,
all users except `EditorBase::CreateTransactionForCollapsedRange` are the
methods of `HTMLEditor`.  Therefore, we should remove it and unwrap the code
which it's done.

Differential Revision: https://phabricator.services.mozilla.com/D147503
This commit is contained in:
Masayuki Nakano
2022-05-31 03:41:01 +00:00
parent 6536c89a75
commit 3b9dee039a
8 changed files with 35 additions and 60 deletions

View File

@@ -2079,10 +2079,10 @@ NS_IMETHODIMP HTMLEditor::SelectElement(Element* aElement) {
nsresult HTMLEditor::SelectContentInternal(nsIContent& aContentToSelect) {
MOZ_ASSERT(IsEditActionDataAvailable());
// Must be sure that element is contained in the editor root node
const RefPtr<Element> editorRoot = GetEditorRoot();
if (NS_WARN_IF(!editorRoot) ||
NS_WARN_IF(!aContentToSelect.IsInclusiveDescendantOf(editorRoot))) {
// Must be sure that element is contained in the editing host
const RefPtr<Element> editingHost = GetActiveEditingHost();
if (NS_WARN_IF(!editingHost) ||
NS_WARN_IF(!aContentToSelect.IsInclusiveDescendantOf(editingHost))) {
return NS_ERROR_FAILURE;
}
@@ -4293,8 +4293,8 @@ bool HTMLEditor::SetCaretInTableCell(Element* aElement) {
!HTMLEditUtils::IsAnyTableElement(aElement)) {
return false;
}
const RefPtr<Element> editorRoot = GetEditorRoot();
if (!editorRoot || !aElement->IsInclusiveDescendantOf(editorRoot)) {
const RefPtr<Element> editingHost = GetActiveEditingHost();
if (!editingHost || !aElement->IsInclusiveDescendantOf(editingHost)) {
return false;
}
@@ -6561,8 +6561,6 @@ already_AddRefed<Element> HTMLEditor::GetInputEventTargetElement() const {
return nullptr;
}
Element* HTMLEditor::GetEditorRoot() const { return GetActiveEditingHost(); }
nsresult HTMLEditor::OnModifyDocument() {
MOZ_ASSERT(mPendingDocumentModifiedRunner,
"HTMLEditor::OnModifyDocument() should be called via a runner");