mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
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.
This commit is contained in:
parent
583b5c34a3
commit
92f7e0e48e
2 changed files with 9 additions and 3 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue