mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1220696 - part 6: Support insertLineBreak
and insertParagraphSeparator
commands in <textarea>
r=smaug
Those command handlers just check whether the given editor is an `HTMLEditor` or not. Therefore, we should make them check whether the given editor is a single line editor or not instead. Differential Revision: https://phabricator.services.mozilla.com/D108572
This commit is contained in:
parent
fad3ed3447
commit
d68f6fc838
@ -870,7 +870,7 @@ StaticRefPtr<InsertParagraphCommand> InsertParagraphCommand::sInstance;
|
||||
|
||||
bool InsertParagraphCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor || !aTextEditor->AsHTMLEditor()) {
|
||||
if (!aTextEditor || aTextEditor->IsSingleLineEditor()) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
@ -879,14 +879,20 @@ bool InsertParagraphCommand::IsCommandEnabled(Command aCommand,
|
||||
nsresult InsertParagraphCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
return NS_OK; // Do nothing for now.
|
||||
if (aTextEditor.IsSingleLineEditor()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv =
|
||||
MOZ_KnownLive(htmlEditor)->InsertParagraphSeparatorAsAction(aPrincipal);
|
||||
if (aTextEditor.IsHTMLEditor()) {
|
||||
nsresult rv = MOZ_KnownLive(aTextEditor.AsHTMLEditor())
|
||||
->InsertParagraphSeparatorAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"HTMLEditor::InsertParagraphSeparatorAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
nsresult rv = aTextEditor.InsertLineBreakAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"HTMLEditor::InsertParagraphSeparatorAsAction() failed");
|
||||
"TextEditor::InsertLineBreakAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -905,7 +911,7 @@ StaticRefPtr<InsertLineBreakCommand> InsertLineBreakCommand::sInstance;
|
||||
|
||||
bool InsertLineBreakCommand::IsCommandEnabled(Command aCommand,
|
||||
TextEditor* aTextEditor) const {
|
||||
if (!aTextEditor || !aTextEditor->AsHTMLEditor()) {
|
||||
if (!aTextEditor || aTextEditor->IsSingleLineEditor()) {
|
||||
return false;
|
||||
}
|
||||
return aTextEditor->IsSelectionEditable();
|
||||
@ -914,13 +920,12 @@ bool InsertLineBreakCommand::IsCommandEnabled(Command aCommand,
|
||||
nsresult InsertLineBreakCommand::DoCommand(Command aCommand,
|
||||
TextEditor& aTextEditor,
|
||||
nsIPrincipal* aPrincipal) const {
|
||||
HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
|
||||
if (!htmlEditor) {
|
||||
if (aTextEditor.IsSingleLineEditor()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv = MOZ_KnownLive(htmlEditor)->InsertLineBreakAsAction(aPrincipal);
|
||||
nsresult rv = aTextEditor.InsertLineBreakAsAction(aPrincipal);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"HTMLEditor::InsertLineBreakAsAction() failed");
|
||||
"TextEditor::InsertLineBreakAsAction() failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -110,36 +110,9 @@
|
||||
[In <textarea>, execCommand("inserthtml", false, <b>inserted</b>), a[b\]c): input.target should be [object HTMLTextAreaElement\]]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertparagraph", false, null), a[b\]c): The command should be enabled]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertparagraph", false, null), a[b\]c): execCommand() should return true]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertparagraph", false, null), a[b\]c): <textarea>.value should be "a\n[\]c"]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertparagraph", false, null), a[b\]c): input.inputType should be insertParagraph]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertparagraph", false, null), a[b\]c): input.target should be [object HTMLTextAreaElement\]]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertlinebreak", false, null), a[b\]c): The command should be enabled]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertlinebreak", false, null), a[b\]c): execCommand() should return true]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertlinebreak", false, null), a[b\]c): <textarea>.value should be "a\n[\]c"]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertlinebreak", false, null), a[b\]c): input.inputType should be insertLineBreak]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("insertlinebreak", false, null), a[b\]c): input.target should be [object HTMLTextAreaElement\]]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea>, execCommand("contentReadOnly", false, true), a[b\]c): contentReadOnly state should be true when <textarea> has focus]
|
||||
expected: FAIL
|
||||
|
||||
@ -245,36 +218,9 @@
|
||||
[In <textarea> in contenteditable, execCommand("inserthtml", false, <b>inserted</b>), a[b\]c): input.target should be [object HTMLTextAreaElement\]]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertparagraph", false, null), a[b\]c): The command should be enabled]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertparagraph", false, null), a[b\]c): execCommand() should return true]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertparagraph", false, null), a[b\]c): <textarea>.value should be "a\n[\]c"]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertparagraph", false, null), a[b\]c): input.inputType should be insertParagraph]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertparagraph", false, null), a[b\]c): input.target should be [object HTMLTextAreaElement\]]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertlinebreak", false, null), a[b\]c): The command should be enabled]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertlinebreak", false, null), a[b\]c): execCommand() should return true]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertlinebreak", false, null), a[b\]c): <textarea>.value should be "a\n[\]c"]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertlinebreak", false, null), a[b\]c): input.inputType should be insertLineBreak]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("insertlinebreak", false, null), a[b\]c): input.target should be [object HTMLTextAreaElement\]]
|
||||
expected: FAIL
|
||||
|
||||
[In <textarea> in contenteditable, execCommand("contentReadOnly", false, true), a[b\]c): contentReadOnly state should be true when <textarea> has focus]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user