summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-04-12 12:52:18 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-12 12:52:18 +0200
commita2bc0e0ec6da3a689fa08cb02a9d65889de60f7c (patch)
treee67e9e0b7891279e5f80b6d967431a7a2315915c /editor
parent552470fb6f3e7b3028e725e0affc6e4f5550c511 (diff)
downloadUXP-a2bc0e0ec6da3a689fa08cb02a9d65889de60f7c.tar
UXP-a2bc0e0ec6da3a689fa08cb02a9d65889de60f7c.tar.gz
UXP-a2bc0e0ec6da3a689fa08cb02a9d65889de60f7c.tar.lz
UXP-a2bc0e0ec6da3a689fa08cb02a9d65889de60f7c.tar.xz
UXP-a2bc0e0ec6da3a689fa08cb02a9d65889de60f7c.zip
Issue #1512 - Improve handling of multiple selections.
IsSelectionEditable should check whether the focus node and anchor node aren't null before trying to use them. This also changes the initialization of selections' aOutIndex to the last range in the selection as a fallback in case we don't add a range later (in AddItem) which could also end up with a null selection otherwise if the additional selection nodes are removed.
Diffstat (limited to 'editor')
-rw-r--r--editor/libeditor/HTMLEditor.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index 368f7a3e9..532da7a15 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3344,12 +3344,18 @@ HTMLEditor::GetIsSelectionEditable(bool* aIsSelectionEditable)
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
+ nsINode* anchorNode = selection->GetAnchorNode();
+ nsINode* focusNode = selection->GetFocusNode();
+ if (!anchorNode || !focusNode) {
+ return NS_ERROR_FAILURE;
+ }
+
// Per the editing spec as of June 2012: we have to have a selection whose
// start and end nodes are editable, and which share an ancestor editing
// host. (Bug 766387.)
*aIsSelectionEditable = selection->RangeCount() &&
- selection->GetAnchorNode()->IsEditable() &&
- selection->GetFocusNode()->IsEditable();
+ anchorNode->IsEditable() &&
+ focusNode->IsEditable();
if (*aIsSelectionEditable) {
nsINode* commonAncestor =