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
--- 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