From 0a34cbc059b5d4a0ffdb077c8f897d3e5ac203a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 9 Mar 2021 01:32:47 +0000 Subject: [PATCH] Bug 1695650 - Consider selection editable even if the anchor is the empty
element. r=masayuki Otherwise we disable the context menu commands which seems bad. This also matches the HTML editor. Differential Revision: https://phabricator.services.mozilla.com/D107513 --- editor/libeditor/EditorBase.cpp | 4 +--- editor/libeditor/tests/mochitest.ini | 1 + .../test_nsIEditor_isSelectionEditable.html | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 editor/libeditor/tests/test_nsIEditor_isSelectionEditable.html diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index de149ec934d8..38d20e21d5f4 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -662,9 +662,7 @@ bool EditorBase::IsSelectionEditable() { // XXX we just check that the anchor node is editable at the moment // we should check that all nodes in the selection are editable nsCOMPtr anchorNode = SelectionRefPtr()->GetAnchorNode(); - return anchorNode && anchorNode->IsContent() && - EditorUtils::IsEditableContent(*anchorNode->AsContent(), - GetEditorType()); + return anchorNode && anchorNode->IsContent() && anchorNode->IsEditable(); } nsINode* anchorNode = SelectionRefPtr()->GetAnchorNode(); diff --git a/editor/libeditor/tests/mochitest.ini b/editor/libeditor/tests/mochitest.ini index e219c864caa1..d5373f4c50d2 100644 --- a/editor/libeditor/tests/mochitest.ini +++ b/editor/libeditor/tests/mochitest.ini @@ -266,6 +266,7 @@ skip-if = os == 'android' [test_middle_click_paste.html] skip-if = headless [test_nsIEditor_insertLineBreak.html] +[test_nsIEditor_isSelectionEditable.html] [test_nsIEditorMailSupport_insertAsCitedQuotation.html] [test_nsIHTMLEditor_getElementOrParentByTagName.html] [test_nsIHTMLEditor_getParagraphState.html] diff --git a/editor/libeditor/tests/test_nsIEditor_isSelectionEditable.html b/editor/libeditor/tests/test_nsIEditor_isSelectionEditable.html new file mode 100644 index 000000000000..92c4ba1aee48 --- /dev/null +++ b/editor/libeditor/tests/test_nsIEditor_isSelectionEditable.html @@ -0,0 +1,16 @@ + +Test for nsIEditor.isSelectionEditable + + + + +