Skip to content

Commit

Permalink
Bug 1716728 - Part 7: Move mPaddingBRElementForEmptyEditor to HTMLEdi…
Browse files Browse the repository at this point in the history
…tor r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D118074
  • Loading branch information
saschanaz committed Jun 21, 2021
1 parent cdcec8e commit 3f6410d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
3 changes: 0 additions & 3 deletions editor/libeditor/EditorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(EditorBase)
}

NS_IMPL_CYCLE_COLLECTION_UNLINK(mRootElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPaddingBRElementForEmptyEditor)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSelectionController)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIMEContentObserver)
Expand All @@ -230,7 +229,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(EditorBase)
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRootElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPaddingBRElementForEmptyEditor)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectionController)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIMEContentObserver)
Expand Down Expand Up @@ -645,7 +643,6 @@ void EditorBase::PreDestroy(bool aDestroyingFrames) {
mTextInputListener = nullptr;
mSpellcheckCheckboxState = eTriUnset;
mRootElement = nullptr;
mPaddingBRElementForEmptyEditor = nullptr;

// Transaction may grab this instance. Therefore, they should be released
// here for stopping the circular reference with this instance.
Expand Down
4 changes: 0 additions & 4 deletions editor/libeditor/EditorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2810,10 +2810,6 @@ class EditorBase : public nsIEditor,
// Cached root node.
RefPtr<Element> mRootElement;

// mPaddingBRElementForEmptyEditor should be used for placing caret
// at proper position when editor is empty.
RefPtr<dom::HTMLBRElement> mPaddingBRElementForEmptyEditor;

// The form field as an event receiver.
nsCOMPtr<dom::EventTarget> mEventTarget;
RefPtr<EditorEventListener> mEventListener;
Expand Down
4 changes: 4 additions & 0 deletions editor/libeditor/HTMLEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLEditor, EditorBase)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTypeInState)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mComposerCommandsUpdater)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChangedRangeForTopLevelEditSubAction)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPaddingBRElementForEmptyEditor)
tmp->HideAnonymousEditingUIs();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLEditor, EditorBase)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTypeInState)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mComposerCommandsUpdater)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChangedRangeForTopLevelEditSubAction)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPaddingBRElementForEmptyEditor)

NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTopLeftHandle)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTopHandle)
Expand Down Expand Up @@ -357,6 +359,8 @@ void HTMLEditor::PreDestroy(bool aDestroyingFrames) {
HideAnonymousEditingUIs();
}

mPaddingBRElementForEmptyEditor = nullptr;

EditorBase::PreDestroy(aDestroyingFrames);
}

Expand Down
4 changes: 4 additions & 0 deletions editor/libeditor/HTMLEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,10 @@ class HTMLEditor final : public EditorBase,
RefPtr<Runnable> mPendingRootElementUpdatedRunner;
RefPtr<Runnable> mPendingDocumentModifiedRunner;

// mPaddingBRElementForEmptyEditor should be used for placing caret
// at proper position when editor is empty.
RefPtr<dom::HTMLBRElement> mPaddingBRElementForEmptyEditor;

bool mCRInParagraphCreatesParagraph;

bool mCSSAware;
Expand Down
4 changes: 0 additions & 4 deletions editor/libeditor/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ already_AddRefed<Element> TextEditor::GetInputEventTargetElement() const {
}

bool TextEditor::IsEmpty() const {
if (mPaddingBRElementForEmptyEditor) {
return true;
}

// Even if there is no padding <br> element for empty editor, we should be
// detected as empty editor if all the children are text nodes and these
// have no content.
Expand Down

0 comments on commit 3f6410d

Please sign in to comment.