Bug 1399400 - Use a strong reference when handling mTextField. r=bz a=jcristau
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 18 Dec 2017 19:39:45 -0500
changeset 445419 da31a4d700181af9a20dc91766e5f971162ecf9e
parent 445418 9f1419ed50d72f028d88b2a2da2cb8e507f2dea0
child 445420 ec25006fd49d9c3a926f5ddf537118a1a3b8e85c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, jcristau
bugs1399400
milestone58.0
Bug 1399400 - Use a strong reference when handling mTextField. r=bz a=jcristau MozReview-Commit-ID: IqzGDM4ezeW
layout/forms/nsNumberControlFrame.cpp
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -587,25 +587,27 @@ nsNumberControlFrame::IsFocused() const
          mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS);
 }
 
 void
 nsNumberControlFrame::HandleFocusEvent(WidgetEvent* aEvent)
 {
   if (aEvent->mOriginalTarget != mTextField) {
     // Move focus to our text field
+    RefPtr<HTMLInputElement> textField = HTMLInputElement::FromContent(mTextField);
     IgnoredErrorResult ignored;
-    HTMLInputElement::FromContent(mTextField)->Focus(ignored);
+    textField->Focus(ignored);
   }
 }
 
 void
 nsNumberControlFrame::HandleSelectCall()
 {
-  HTMLInputElement::FromContent(mTextField)->Select();
+  RefPtr<HTMLInputElement> textField = HTMLInputElement::FromContent(mTextField);
+  textField->Select();
 }
 
 #define STYLES_DISABLING_NATIVE_THEMING \
   NS_AUTHOR_SPECIFIED_BACKGROUND | \
   NS_AUTHOR_SPECIFIED_PADDING | \
   NS_AUTHOR_SPECIFIED_BORDER
 
 bool