Bug 1716350 - Remove redundant editor type checks r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D117662
This commit is contained in:
Kagami Sascha Rosylight 2021-06-15 10:45:20 +00:00
Родитель d39bcd7010
Коммит 92d3464a2e
3 изменённых файлов: 1 добавлений и 15 удалений

Просмотреть файл

@ -4824,7 +4824,6 @@ already_AddRefed<Element> HTMLEditor::DeleteSelectionAndCreateElement(
nsresult HTMLEditor::DeleteSelectionAndPrepareToCreateNode() {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsHTMLEditor()); // TODO: Move this method to `HTMLEditor`
if (NS_WARN_IF(!SelectionRef().GetAnchorFocusRange())) {
return NS_OK;

Просмотреть файл

@ -51,7 +51,6 @@ void TextEditor::OnStartToHandleTopLevelEditSubAction(
EditSubAction aTopLevelEditSubAction,
nsIEditor::EDirection aDirectionOfTopLevelEditSubAction, ErrorResult& aRv) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(!aRv.Failed());
EditorBase::OnStartToHandleTopLevelEditSubAction(
@ -99,7 +98,6 @@ void TextEditor::OnStartToHandleTopLevelEditSubAction(
nsresult TextEditor::OnEndHandlingTopLevelEditSubAction() {
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
nsresult rv;
while (true) {
@ -150,7 +148,6 @@ nsresult TextEditor::OnEndHandlingTopLevelEditSubAction() {
EditActionResult TextEditor::InsertLineFeedCharacterAtSelection() {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(!IsSingleLineEditor());
UndefineCaretBidiLevel();
@ -257,7 +254,6 @@ EditActionResult TextEditor::InsertLineFeedCharacterAtSelection() {
nsresult TextEditor::EnsureCaretNotAtEndOfTextNode() {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsPlaintextEditor());
// If there is no selection ranges, we should set to the end of the editor.
// This is usually performed in InitEditorContentAndSelection(), however,
@ -282,7 +278,6 @@ void TextEditor::HandleNewLinesInStringForSingleLineEditor(
nsString& aString) const {
static const char16_t kLF = static_cast<char16_t>('\n');
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsPlaintextEditor());
MOZ_ASSERT(aString.FindChar(static_cast<uint16_t>('\r')) == kNotFound);
// First of all, check if aString contains '\n' since if the string
@ -356,7 +351,6 @@ void TextEditor::HandleNewLinesInStringForSingleLineEditor(
EditActionResult TextEditor::HandleInsertText(
EditSubAction aEditSubAction, const nsAString& aInsertionString) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(aEditSubAction == EditSubAction::eInsertText ||
aEditSubAction == EditSubAction::eInsertTextComingFromIME);
@ -538,7 +532,6 @@ EditActionResult TextEditor::HandleInsertText(
EditActionResult TextEditor::SetTextWithoutTransaction(
const nsAString& aValue) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(!IsIMEComposing());
MOZ_ASSERT(!IsUndoRedoEnabled());
MOZ_ASSERT(GetEditAction() != EditAction::eReplaceText);
@ -599,7 +592,6 @@ EditActionResult TextEditor::HandleDeleteSelection(
nsIEditor::EDirection aDirectionAndAmount,
nsIEditor::EStripWrappers aStripWrappers) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(aStripWrappers == nsIEditor::eNoStrip);
UndefineCaretBidiLevel();
@ -626,7 +618,6 @@ EditActionResult TextEditor::HandleDeleteSelectionInternal(
nsIEditor::EDirection aDirectionAndAmount,
nsIEditor::EStripWrappers aStripWrappers) {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(aStripWrappers == nsIEditor::eNoStrip);
// If the current selection is empty (e.g the user presses backspace with
@ -729,7 +720,7 @@ EditActionResult TextEditor::MaybeTruncateInsertionStringForMaxLength(
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(mMaxTextLength >= 0);
if (!IsPlaintextEditor() || IsIMEComposing()) {
if (IsIMEComposing()) {
return EditActionIgnored();
}

Просмотреть файл

@ -112,7 +112,6 @@ NS_INTERFACE_MAP_END_INHERITING(EditorBase)
nsresult TextEditor::Init(Document& aDoc, Element* aRoot,
nsISelectionController* aSelCon, uint32_t aFlags,
const nsAString& aInitialValue) {
MOZ_ASSERT(IsTextEditor());
MOZ_ASSERT(!mInitSucceeded,
"TextEditor::Init() called again without calling PreDestroy()?");
@ -255,7 +254,6 @@ nsresult TextEditor::SetTextAsAction(
AllowBeforeInputEventCancelable aAllowBeforeInputEventCancelable,
nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aString.FindChar(nsCRT::CR) == kNotFound);
MOZ_ASSERT(IsTextEditor());
AutoEditActionDataSetter editActionData(*this, EditAction::eSetText,
aPrincipal);
@ -422,7 +420,6 @@ nsresult TextEditor::PasteAsQuotationAsAction(int32_t aClipboardType,
nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aClipboardType == nsIClipboard::kGlobalClipboard ||
aClipboardType == nsIClipboard::kSelectionClipboard);
MOZ_ASSERT(IsTextEditor());
AutoEditActionDataSetter editActionData(*this, EditAction::ePasteAsQuotation,
aPrincipal);
@ -628,7 +625,6 @@ nsresult TextEditor::RemoveAttributeOrEquivalent(Element* aElement,
nsresult TextEditor::EnsurePaddingBRElementForEmptyEditor() {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(IsTextEditor());
// If there is padding <br> element for empty editor, we have no work to do.
if (mPaddingBRElementForEmptyEditor) {