Bug 1154336 - Convert nsTextEditorState::mRestoringSelection into a strong reference; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 14 Apr 2015 12:26:56 -0400
changeset 270505 f343995171cbe3cd8d997befeeacfb495b7eafc6
parent 270504 fdd746ef10bdf5b2fcf47c9ba1e3d5da66445742
child 270506 bb16a021fcefb9e1bfbd0bab8aaff1c34c1e08ac
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1154336
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1154336 - Convert nsTextEditorState::mRestoringSelection into a strong reference; r=baku
dom/html/nsTextEditorState.cpp
dom/html/nsTextEditorState.h
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -972,17 +972,16 @@ nsTextInputListener::UpdateTextInputComm
 }
 
 // END nsTextInputListener
 
 // nsTextEditorState
 
 nsTextEditorState::nsTextEditorState(nsITextControlElement* aOwningElement)
   : mTextCtrlElement(aOwningElement),
-    mRestoringSelection(nullptr),
     mBoundFrame(nullptr),
     mEverInited(false),
     mEditorInitialized(false),
     mInitializing(false),
     mValueTransferInProgress(false),
     mSelectionCached(true),
     mSelectionRestoreEagerInit(false),
     mPlaceholderVisibility(false)
@@ -1447,16 +1446,22 @@ nsTextEditorState::PrepareEditor(const n
     number->ClearSelectionCached();
   } else {
     mSelectionCached = false;
   }
 
   return rv;
 }
 
+void
+nsTextEditorState::FinishedRestoringSelection()
+{
+  mRestoringSelection = nullptr;
+}
+
 bool
 nsTextEditorState::IsSelectionCached() const
 {
   if (mBoundFrame) {
     HTMLInputElement* number = GetParentNumberControl(mBoundFrame);
     if (number) {
       return number->IsSelectionCached();
     }
--- a/dom/html/nsTextEditorState.h
+++ b/dom/html/nsTextEditorState.h
@@ -234,17 +234,17 @@ private:
 
   void ValueWasChanged(bool aNotify);
 
   void DestroyEditor();
   void Clear();
 
   nsresult InitializeRootNode();
 
-  void FinishedRestoringSelection() { mRestoringSelection = nullptr; }
+  void FinishedRestoringSelection();
 
   mozilla::dom::HTMLInputElement* GetParentNumberControl(nsFrame* aFrame) const;
 
   class InitializationGuard {
   public:
     explicit InitializationGuard(nsTextEditorState& aState) :
       mState(aState),
       mGuardSet(false)
@@ -266,17 +266,17 @@ private:
     nsTextEditorState& mState;
     bool mGuardSet;
   };
   friend class InitializationGuard;
   friend class PrepareEditorEvent;
 
   nsITextControlElement* const mTextCtrlElement;
   nsRefPtr<nsTextInputSelectionImpl> mSelCon;
-  RestoreSelectionState* mRestoringSelection;
+  nsRefPtr<RestoreSelectionState> mRestoringSelection;
   nsCOMPtr<nsIEditor> mEditor;
   nsCOMPtr<mozilla::dom::Element> mRootNode;
   nsCOMPtr<mozilla::dom::Element> mPlaceholderDiv;
   nsTextControlFrame* mBoundFrame;
   nsRefPtr<nsTextInputListener> mTextListener;
   nsAutoPtr<nsCString> mValue;
   nsRefPtr<nsAnonDivObserver> mMutationObserver;
   mutable nsString mCachedValue; // Caches non-hard-wrapped value on a multiline control.