Bug 1382189 - Persist preview value in PressState for select element to ensure the text is consistent after frame re-construction. r=heycam
authorRay Lin <ralin@mozilla.com>
Thu, 20 Jul 2017 15:40:46 +0800
changeset 418864 c82858285f0b37cb3f6e16245d5e993a50102e57
parent 418863 e75d2b5e5d29a09dd886e57643c9cbbdf4e8d8c6
child 418865 e999e5ea1f78dd6f89ae485c199477083b369946
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1382189
milestone56.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 1382189 - Persist preview value in PressState for select element to ensure the text is consistent after frame re-construction. r=heycam MozReview-Commit-ID: piZkkGlWrs
layout/base/nsPresState.h
layout/forms/nsComboboxControlFrame.cpp
--- a/layout/base/nsPresState.h
+++ b/layout/base/nsPresState.h
@@ -106,21 +106,32 @@ public:
     mDroppedDown = aDroppedDown;
   }
 
   bool GetDroppedDown() const
   {
     return mDroppedDown;
   }
 
+  void SetPreviewText(const nsAString& aValue)
+  {
+    mPreviewText = aValue;
+  }
+
+  void GetPreviewText(nsAString& aValue)
+  {
+    aValue = mPreviewText;
+  }
+
 // MEMBER VARIABLES
 protected:
   nsCOMPtr<nsISupports> mContentData;
   nsPoint mScrollState;
   bool mAllowScrollOriginDowngrade;
   float mResolution;
   bool mScaleToResolution;
   bool mDisabledSet;
   bool mDisabled;
   bool mDroppedDown;
+  nsString mPreviewText;
 };
 
 #endif /* nsPresState_h_ */
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1676,25 +1676,27 @@ nsComboboxControlFrame::OnContentReset()
 // nsIStatefulFrame
 //--------------------------------------------------------
 NS_IMETHODIMP
 nsComboboxControlFrame::SaveState(nsPresState** aState)
 {
   MOZ_ASSERT(!(*aState));
   (*aState) = new nsPresState();
   (*aState)->SetDroppedDown(mDroppedDown);
+  (*aState)->SetPreviewText(mPreviewText);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComboboxControlFrame::RestoreState(nsPresState* aState)
 {
   if (!aState) {
     return NS_ERROR_FAILURE;
   }
+  aState->GetPreviewText(mPreviewText);
   ShowList(aState->GetDroppedDown()); // might destroy us
   return NS_OK;
 }
 
 // Append a suffix so that the state key for the combobox is different
 // from the state key the list control uses to sometimes save the scroll
 // position for the same Element
 NS_IMETHODIMP