Bug 1382189 - Persist preview value in PressState for select element to ensure the text is consistent after frame re-construction. r=heycam draft
authorRay Lin <ralin@mozilla.com>
Thu, 20 Jul 2017 15:40:46 +0800
changeset 612947 584041894b0ed262d9e4576cc776791f9b3510de
parent 612696 7d2e89fb92331d7e4296391213c1e63db628e046
child 638558 dd8be0a045dbd32a89ca796b0668de5798e1cb74
push id69665
push userbmo:ralin@mozilla.com
push dateFri, 21 Jul 2017 09:17:11 +0000
reviewersheycam
bugs1382189
milestone56.0a1
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