Bug 13058: Handle SetTextControlState for native widgets even before the widget is created (cache the value).
git-svn-id: svn://10.0.0.236/trunk@47356 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -71,6 +71,19 @@ NS_NewNativeTextControlFrame(nsIFrame** aNewFrame)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsNativeTextControlFrame::nsNativeTextControlFrame()
|
||||
: mCachedState(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsNativeTextControlFrame::~nsNativeTextControlFrame()
|
||||
{
|
||||
if (mCachedState) {
|
||||
delete mCachedState;
|
||||
mCachedState = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeTextControlFrame::EnterPressed(nsIPresContext& aPresContext)
|
||||
{
|
||||
@@ -244,7 +257,12 @@ nsNativeTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
|
||||
nsITextAreaWidget* textArea = nsnull;
|
||||
nsITextWidget* text = nsnull;
|
||||
if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) {
|
||||
GetText(&value, PR_TRUE);
|
||||
if (mCachedState) {
|
||||
value = *mCachedState;
|
||||
delete mCachedState;
|
||||
mCachedState = nsnull;
|
||||
} else
|
||||
GetText(&value, PR_TRUE);
|
||||
text->SetText(value, ignore);
|
||||
PRInt32 maxLength;
|
||||
nsresult result = GetMaxLength(&maxLength);
|
||||
@@ -253,7 +271,12 @@ nsNativeTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
|
||||
}
|
||||
NS_RELEASE(text);
|
||||
} else if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID,(void**)&textArea)) {
|
||||
GetText(&value, PR_TRUE);
|
||||
if (mCachedState) {
|
||||
value = *mCachedState;
|
||||
delete mCachedState;
|
||||
mCachedState = nsnull;
|
||||
} else
|
||||
GetText(&value, PR_TRUE);
|
||||
textArea->SetText(value, ignore);
|
||||
NS_RELEASE(textArea);
|
||||
}
|
||||
@@ -539,7 +562,9 @@ void nsNativeTextControlFrame::SetTextControlFrameState(const nsString& aValue)
|
||||
textArea->SetText(aValue,size);
|
||||
NS_RELEASE(textArea);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mCachedState = new nsString(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsNativeTextControlFrame::SetProperty(nsIAtom* aName, const nsString& aValue)
|
||||
|
||||
@@ -30,7 +30,10 @@ private:
|
||||
typedef nsNativeFormControlFrame Inherited;
|
||||
|
||||
public:
|
||||
// nsIFormControlFrame
|
||||
nsNativeTextControlFrame();
|
||||
virtual ~nsNativeTextControlFrame();
|
||||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
|
||||
|
||||
@@ -75,6 +78,8 @@ public:
|
||||
|
||||
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
|
||||
|
||||
protected:
|
||||
nsString* mCachedState;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user