mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1503473 - part 1: Rename TextEditor::OnInputParagraphSeparator() and HTMLEditor::OnInputLineBreak() r=m_kato
TextEditor::OnInputParagraphSeparator() and HTMLEditor::OnInputLineBreak() are also used by command handlers. Therefore, they should be renamed to TextEditor::InsertParagraphSeparatorAsAction() and HTMLEditor::InsertLineBreakAsAction(). Then, current TextEditor::InsertParagraphSeparatorAsAction() should be renamed to AsSubAction() and each caller of it should create AutoPlaceholderBatch by themselves. Differential Revision: https://phabricator.services.mozilla.com/D10521 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
25da1ff728
commit
6ba637600b
@ -1180,9 +1180,7 @@ InsertParagraphCommand::DoCommand(const char* aCommandName,
|
||||
|
||||
TextEditor* textEditor = editor->AsTextEditor();
|
||||
MOZ_ASSERT(textEditor);
|
||||
// XXX OnInputParagraphSeparator() is a handler of user input. So, this
|
||||
// call may not be expected.
|
||||
return textEditor->OnInputParagraphSeparator();
|
||||
return textEditor->InsertParagraphSeparatorAsAction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1244,9 +1242,7 @@ InsertLineBreakCommand::DoCommand(const char* aCommandName,
|
||||
if (!htmlEditor) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// XXX OnInputLineBreak() is a handler of user input. So, this call may not
|
||||
// be expected.
|
||||
return htmlEditor->OnInputLineBreak();
|
||||
return htmlEditor->InsertLineBreakAsAction();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -871,10 +871,10 @@ HTMLEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
|
||||
aKeyboardEvent->PreventDefault(); // consumed
|
||||
if (aKeyboardEvent->IsShift()) {
|
||||
// Only inserts a <br> element.
|
||||
return OnInputLineBreak();
|
||||
return InsertLineBreakAsAction();
|
||||
}
|
||||
// uses rules to figure out what to insert
|
||||
return OnInputParagraphSeparator();
|
||||
return InsertParagraphSeparatorAsAction();
|
||||
}
|
||||
|
||||
if (!aKeyboardEvent->IsInputtingText()) {
|
||||
@ -1123,7 +1123,7 @@ HTMLEditor::UpdateBaseURL()
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::OnInputLineBreak()
|
||||
HTMLEditor::InsertLineBreakAsAction()
|
||||
{
|
||||
AutoEditActionDataSetter editActionData(*this, EditAction::eInsertLineBreak);
|
||||
if (NS_WARN_IF(!editActionData.CanHandle())) {
|
||||
|
@ -171,10 +171,10 @@ public:
|
||||
virtual bool CanPasteTransferable(nsITransferable* aTransferable) override;
|
||||
|
||||
/**
|
||||
* OnInputLineBreak() is called when user inputs a line break with
|
||||
* InsertLineBreakAsAction() is called when user inputs a line break with
|
||||
* Shift + Enter or something.
|
||||
*/
|
||||
nsresult OnInputLineBreak();
|
||||
nsresult InsertLineBreakAsAction();
|
||||
|
||||
/**
|
||||
* CreateElementWithDefaults() creates new element whose name is
|
||||
|
@ -414,7 +414,7 @@ TextEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
aKeyboardEvent->PreventDefault();
|
||||
return OnInputParagraphSeparator();
|
||||
return InsertParagraphSeparatorAsAction();
|
||||
}
|
||||
|
||||
if (!aKeyboardEvent->IsInputtingText()) {
|
||||
@ -443,7 +443,7 @@ TextEditor::OnInputText(const nsAString& aStringToInsert)
|
||||
}
|
||||
|
||||
nsresult
|
||||
TextEditor::OnInputParagraphSeparator()
|
||||
TextEditor::InsertParagraphSeparatorAsAction()
|
||||
{
|
||||
AutoEditActionDataSetter editActionData(
|
||||
*this,
|
||||
@ -452,8 +452,10 @@ TextEditor::OnInputParagraphSeparator()
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// XXX This may be called by execCommand() with "insertParagraph".
|
||||
// In such case, naming the transaction "TypingTxnName" is odd.
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this, *nsGkAtoms::TypingTxnName);
|
||||
nsresult rv = InsertParagraphSeparatorAsAction();
|
||||
nsresult rv = InsertParagraphSeparatorAsSubAction();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1077,11 +1079,12 @@ TextEditor::InsertLineBreak()
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return InsertParagraphSeparatorAsAction();
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
return InsertParagraphSeparatorAsSubAction();
|
||||
}
|
||||
|
||||
nsresult
|
||||
TextEditor::InsertParagraphSeparatorAsAction()
|
||||
TextEditor::InsertParagraphSeparatorAsSubAction()
|
||||
{
|
||||
MOZ_ASSERT(IsEditActionDataAvailable());
|
||||
|
||||
@ -1092,7 +1095,6 @@ TextEditor::InsertParagraphSeparatorAsAction()
|
||||
// Protect the edit rules object from dying
|
||||
RefPtr<TextEditRules> rules(mRules);
|
||||
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
AutoTopLevelEditSubActionNotifier maybeTopLevelEditSubAction(
|
||||
*this,
|
||||
EditSubAction::eInsertParagraphSeparator,
|
||||
|
@ -187,10 +187,10 @@ public:
|
||||
nsRange* aReplaceRange = nullptr);
|
||||
|
||||
/**
|
||||
* OnInputParagraphSeparator() is called when user tries to separate current
|
||||
* paragraph with Enter key press or something.
|
||||
* InsertParagraphSeparatorAsAction() is called when user tries to separate
|
||||
* current paragraph with Enter key press or something.
|
||||
*/
|
||||
nsresult OnInputParagraphSeparator();
|
||||
nsresult InsertParagraphSeparatorAsAction();
|
||||
|
||||
/**
|
||||
* OnCompositionStart() is called when editor receives eCompositionStart
|
||||
@ -376,13 +376,13 @@ protected: // Shouldn't be used by friend classes
|
||||
nsresult OnInputText(const nsAString& aStringToInsert);
|
||||
|
||||
/**
|
||||
* InsertParagraphSeparatorAsAction() inserts a line break if it's TextEditor
|
||||
* or inserts new paragraph if it's HTMLEditor and it's possible.
|
||||
* InsertParagraphSeparatorAsSubAction() inserts a line break if it's
|
||||
* TextEditor or inserts new paragraph if it's HTMLEditor and it's possible.
|
||||
* Although, this method is implementation of
|
||||
* nsIPlaintextEditor.insertLineBreak(), this treats the input is an edit
|
||||
* action.
|
||||
*/
|
||||
nsresult InsertParagraphSeparatorAsAction();
|
||||
nsresult InsertParagraphSeparatorAsSubAction();
|
||||
|
||||
nsresult InsertTextAt(const nsAString& aStringToInsert,
|
||||
nsINode* aDestinationNode,
|
||||
|
Loading…
Reference in New Issue
Block a user