Bug 1267929 - Bail out from ExtendPhoneNumberSelection if GetAnchorFocusRange() is nullptr. r=mats a=sylvestre
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 27 Apr 2016 17:19:51 +0800
changeset 332625 91cd25848c032866d7cca41df8d074795b594ea7
parent 332624 070a730a51d3bd2e923f81da9e10633b4d926143
child 332626 6e453fe828bf9054b6db0307ffb034d3acceb9c9
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, sylvestre
bugs1267929
milestone48.0a2
Bug 1267929 - Bail out from ExtendPhoneNumberSelection if GetAnchorFocusRange() is nullptr. r=mats a=sylvestre MozReview-Commit-ID: HvNhZ5o0owh
layout/base/AccessibleCaretManager.cpp
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -862,20 +862,24 @@ void
 AccessibleCaretManager::ExtendPhoneNumberSelection(const nsAString& aDirection) const
 {
   nsIDocument* doc = mPresShell->GetDocument();
 
   // Extend the phone number selection until we find a boundary.
   Selection* selection = GetSelection();
 
   while (selection) {
+    const nsRange* anchorFocusRange = selection->GetAnchorFocusRange();
+    if (!anchorFocusRange) {
+      return;
+    }
+
     // Backup the anchor focus range since both anchor node and focus node might
     // be changed after calling Selection::Modify().
-    RefPtr<nsRange> oldAnchorFocusRange =
-      selection->GetAnchorFocusRange()->CloneRange();
+    RefPtr<nsRange> oldAnchorFocusRange = anchorFocusRange->CloneRange();
 
     // Save current Focus position, and extend the selection one char.
     nsINode* focusNode = selection->GetFocusNode();
     uint32_t focusOffset = selection->FocusOffset();
     selection->Modify(NS_LITERAL_STRING("extend"),
                       aDirection,
                       NS_LITERAL_STRING("character"));