Bug 1403841 - IsSelectionEditable should check whether focus node and anchor node aren't null. r?masayuki
This might be regression by
bug 1319340, but there is crash signature from old version. We should check whether focus node and anchor node aren't null.
MozReview-Commit-ID: J7npxN5kC9G
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -554,22 +554,28 @@ EditorBase::IsSelectionEditable()
if (!mIsHTMLEditorClass) {
// 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<nsINode> anchorNode = selection->GetAnchorNode();
return anchorNode && IsEditable(anchorNode);
}
+ nsINode* anchorNode = selection->GetAnchorNode();
+ nsINode* focusNode = selection->GetFocusNode();
+ if (!anchorNode || !focusNode) {
+ return false;
+ }
+
// 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.)
bool isSelectionEditable = selection->RangeCount() &&
- selection->GetAnchorNode()->IsEditable() &&
- selection->GetFocusNode()->IsEditable();
+ anchorNode->IsEditable() &&
+ focusNode->IsEditable();
if (!isSelectionEditable) {
return false;
}
nsINode* commonAncestor =
selection->GetAnchorFocusRange()->GetCommonAncestor();
while (commonAncestor && !commonAncestor->IsEditable()) {
commonAncestor = commonAncestor->GetParentNode();