Bug 1431336. r=smaug a=abillings
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 19 Feb 2018 13:12:29 +0900
changeset 454913 f4859ac00548e672691fb9828b2a9f9368354570
parent 454912 32ca218afee979f9050248a732a03d658ca2964b
child 454914 a9f01ec9c060e2e1fe0c78ce17e011374cce9b95
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, abillings
bugs1431336
milestone59.0
Bug 1431336. r=smaug a=abillings
dom/html/nsTextEditorState.cpp
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -931,17 +931,18 @@ nsTextInputListener::NotifySelectionChan
   }
 
   // if the collapsed state did not change, don't fire notifications
   if (collapsed == mSelectionWasCollapsed)
     return NS_OK;
 
   mSelectionWasCollapsed = collapsed;
 
-  if (!weakFrame.IsAlive() || !nsContentUtils::IsFocusedContent(mFrame->GetContent()))
+  if (!weakFrame.IsAlive() || !mFrame ||
+      !nsContentUtils::IsFocusedContent(mFrame->GetContent()))
     return NS_OK;
 
   return UpdateTextInputCommands(NS_LITERAL_STRING("select"), aSel, aReason);
 }
 
 // END nsIDOMSelectionListener
 
 static void
@@ -1787,18 +1788,19 @@ nsTextEditorState::SetSelectionRange(uin
     SelectionProperties& props = GetSelectionProperties();
     changed = props.GetStart() != aStart ||
               props.GetEnd() != aEnd ||
               props.GetDirection() != aDirection;
     props.SetStart(aStart);
     props.SetEnd(aEnd);
     props.SetDirection(aDirection);
   } else {
+    WeakPtr<nsTextEditorState> self(this);
     aRv = mBoundFrame->SetSelectionRange(aStart, aEnd, aDirection);
-    if (aRv.Failed()) {
+    if (aRv.Failed() || !self.get()) {
       return;
     }
     rv = mBoundFrame->ScrollSelectionIntoView();
     // Press on to firing the event even if that failed, like our old code did.
     // But is that really what we want?  Firing the event _and_ throwing from
     // here is weird.  Maybe we should just ignore ScrollSelectionIntoView
     // failures?