From 57de44ee8a53f4ea9e889b11b3bd242b69c30d36 Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Mon, 1 Feb 1999 18:44:59 +0000 Subject: [PATCH] Moved GetPrimaryFrame to nsGenericHTMLElement. Modifed nsHTMLTextAreaElement to go through it's frame to set and get values --- .../html/content/src/nsGenericHTMLElement.cpp | 27 ++++++++++++++ .../html/content/src/nsGenericHTMLElement.h | 5 +++ .../html/content/src/nsHTMLInputElement.cpp | 33 ++--------------- .../content/src/nsHTMLTextAreaElement.cpp | 37 ++++++++----------- layout/forms/nsTextControlFrame.cpp | 20 +++++++--- .../html/content/src/nsGenericHTMLElement.cpp | 27 ++++++++++++++ .../html/content/src/nsGenericHTMLElement.h | 5 +++ .../html/content/src/nsHTMLInputElement.cpp | 33 ++--------------- .../content/src/nsHTMLTextAreaElement.cpp | 37 ++++++++----------- layout/html/forms/src/nsTextControlFrame.cpp | 20 +++++++--- 10 files changed, 132 insertions(+), 112 deletions(-) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 7937a7dc235..ebb8bd91fa3 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -67,6 +67,7 @@ #include "nsDOMCSSDeclaration.h" #include "prprf.h" #include "prmem.h" +#include "nsIFormControlFrame.h" // XXX todo: add in missing out-of-memory checks NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID); @@ -83,6 +84,7 @@ static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIDOMDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID); static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID); +static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID); //---------------------------------------------------------------------- @@ -1407,6 +1409,31 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue, return PR_FALSE; } +// XXX This creates a dependency between content and frames +nsresult +nsGenericHTMLElement::GetPrimaryFrame(nsIHTMLContent* aContent, + nsIFormControlFrame *&aFormControlFrame) +{ + nsIDocument* doc = nsnull; + nsresult res; + // Get the document + if (NS_OK == aContent->GetDocument(doc)) { + // Get presentation shell 0 + nsIPresShell* presShell = doc->GetShellAt(0); + if (nsnull != presShell) { + nsIFrame *frame = nsnull; + presShell->GetPrimaryFrameFor(aContent, frame); + if (nsnull != frame) { + res = frame->QueryInterface(kIFormControlFrameIID, (void**)&aFormControlFrame); + } + NS_RELEASE(presShell); + } + NS_RELEASE(doc); + } + + return res; +} + // XXX check all mappings against ebina's usage static nsGenericHTMLElement::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 02972e377c1..f24c1199fc2 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -46,6 +46,7 @@ class nsChildContentList; class nsDOMCSSDeclaration; class nsIDOMCSSStyleDeclaration; class nsIURL; +class nsIFormControlFrame; class nsGenericHTMLElement : public nsGenericElement { public: @@ -237,6 +238,10 @@ public: const nsIAtom* aAttribute, PRInt32* aHint); + //XXX This creates a dependency between content and frames + static nsresult GetPrimaryFrame(nsIHTMLContent* aContent, + nsIFormControlFrame *&aFormControlFrame); + nsIHTMLAttributes* mAttributes; }; diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index ed3220b5f6e..10db0cf9103 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -139,9 +139,6 @@ protected: nsIForm* mForm; PRInt32 mType; - // Return the primary frame associated with this content - nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame); - PRBool IsImage() const { nsAutoString tmp; mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp); @@ -324,7 +321,7 @@ nsHTMLInputElement::GetValue(nsString& aValue) GetType(&type); if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { formControlFrame->GetProperty(nsHTMLAtoms::value, aValue); NS_RELEASE(formControlFrame); return NS_OK; @@ -341,7 +338,7 @@ nsHTMLInputElement::SetValue(const nsString& aValue) GetType(&type); if (NS_FORM_INPUT_TEXT == type) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { formControlFrame->SetProperty(nsHTMLAtoms::value, aValue); NS_RELEASE(formControlFrame); } @@ -353,7 +350,7 @@ NS_IMETHODIMP nsHTMLInputElement::GetChecked(PRBool* aValue) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { if (nsnull != formControlFrame) { nsString value("0"); formControlFrame->GetProperty(nsHTMLAtoms::checked, value); @@ -373,7 +370,7 @@ NS_IMETHODIMP nsHTMLInputElement::SetChecked(PRBool aValue) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { if (PR_TRUE == aValue) { formControlFrame->SetProperty(nsHTMLAtoms::checked, "1"); } @@ -679,26 +676,4 @@ nsHTMLInputElement::GetStyleHintForAttributeChange( return NS_OK; } -nsresult nsHTMLInputElement::GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame) -{ - nsIDocument* doc = nsnull; - nsresult res = NS_NOINTERFACE; - // Get the document - if (NS_OK == GetDocument(doc)) { - // Get presentation shell 0 - nsIPresShell* presShell = doc->GetShellAt(0); - if (nsnull != presShell) { - nsIFrame *frame = nsnull; - presShell->GetPrimaryFrameFor(this, frame); - if (nsnull != frame) { - res = frame->QueryInterface(kIFormControlFrameIID, (void**)&aFormControlFrame); - } - NS_RELEASE(presShell); - } - NS_RELEASE(doc); - } - - return res; -} - diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 812b5abf90e..2a36887132a 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -32,6 +32,7 @@ #include "nsIWidget.h" #include "nsITextAreaWidget.h" #include "nsIHTMLAttributes.h" +#include "nsIFormControlFrame.h" static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID); static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID); @@ -265,39 +266,32 @@ nsHTMLTextAreaElement::GetType(nsString& aType) NS_IMETHODIMP nsHTMLTextAreaElement::GetValue(nsString& aValue) { - if (nsnull != mWidget) { - nsITextAreaWidget* text = nsnull; - if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID,(void**)&text)) { - PRUint32 size; - text->GetText(aValue,0,size); - NS_RELEASE(text); + nsIFormControlFrame* formControlFrame = nsnull; + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { + formControlFrame->GetProperty(nsHTMLAtoms::value, aValue); + NS_RELEASE(formControlFrame); return NS_OK; - } - } - - return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue); + } + //XXX: Should this ASSERT instead of getting the default value here? + return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue); } NS_IMETHODIMP nsHTMLTextAreaElement::SetValue(const nsString& aValue) { - if (nsnull != mWidget) { - nsITextAreaWidget* text = nsnull; - if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID,(void**)&text)) { - PRUint32 size; - text->SetText(aValue,size); - NS_RELEASE(text); - } - } - - return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue, PR_TRUE); + nsIFormControlFrame* formControlFrame = nsnull; + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { + formControlFrame->SetProperty(nsHTMLAtoms::value, aValue); + NS_RELEASE(formControlFrame); + } + return NS_OK; } NS_IMETHODIMP nsHTMLTextAreaElement::GetDefaultValue(nsString& aDefaultValue) { - mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, aDefaultValue); + mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aDefaultValue); return NS_OK; } @@ -308,7 +302,6 @@ nsHTMLTextAreaElement::SetDefaultValue(const nsString& aDefaultValue) static char whitespace[] = " \r\n\t"; nsString value(aDefaultValue); value.Trim(whitespace, PR_TRUE, PR_FALSE); - mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, value, PR_TRUE); mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, value, PR_TRUE); return NS_OK; diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index d37534361f9..dc3150e6260 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -739,11 +739,17 @@ void nsTextControlFrame::GetTextControlFrameState(nsString& aValue) { if (nsnull != mWidget) { nsITextWidget* text = nsnull; + nsITextAreaWidget* textArea = nsnull; + PRUint32 size = 0; if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) { - PRUint32 size; text->GetText(aValue,0,size); NS_RELEASE(text); } + else if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID, + (void**)&textArea)) { + textArea->GetText(aValue,0, size); + NS_RELEASE(textArea); + } } else { //XXX: this should return the a local field for GFX-rendered widgets aValue = ""; @@ -754,13 +760,18 @@ void nsTextControlFrame::SetTextControlFrameState(const nsString& aValue) { if (nsnull != mWidget) { nsITextWidget* text = nsnull; + nsITextAreaWidget* textArea = nsnull; + PRUint32 size = 0; if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) { - PRUint32 size; text->SetText(aValue,size); NS_RELEASE(text); + } else if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID, + (void**)&textArea)) { + textArea->SetText(aValue,size); + NS_RELEASE(textArea); } - } -} + } +} NS_IMETHODIMP nsTextControlFrame::SetProperty(nsIAtom* aName, const nsString& aValue) { @@ -769,7 +780,6 @@ NS_IMETHODIMP nsTextControlFrame::SetProperty(nsIAtom* aName, const nsString& aV else { return nsFormControlFrame::SetProperty(aName, aValue); } - return NS_OK; } diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index 7937a7dc235..ebb8bd91fa3 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -67,6 +67,7 @@ #include "nsDOMCSSDeclaration.h" #include "prprf.h" #include "prmem.h" +#include "nsIFormControlFrame.h" // XXX todo: add in missing out-of-memory checks NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID); @@ -83,6 +84,7 @@ static NS_DEFINE_IID(kIDOMCSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIDOMDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID); static NS_DEFINE_IID(kIHTMLContentContainerIID, NS_IHTMLCONTENTCONTAINER_IID); +static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID); //---------------------------------------------------------------------- @@ -1407,6 +1409,31 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue, return PR_FALSE; } +// XXX This creates a dependency between content and frames +nsresult +nsGenericHTMLElement::GetPrimaryFrame(nsIHTMLContent* aContent, + nsIFormControlFrame *&aFormControlFrame) +{ + nsIDocument* doc = nsnull; + nsresult res; + // Get the document + if (NS_OK == aContent->GetDocument(doc)) { + // Get presentation shell 0 + nsIPresShell* presShell = doc->GetShellAt(0); + if (nsnull != presShell) { + nsIFrame *frame = nsnull; + presShell->GetPrimaryFrameFor(aContent, frame); + if (nsnull != frame) { + res = frame->QueryInterface(kIFormControlFrameIID, (void**)&aFormControlFrame); + } + NS_RELEASE(presShell); + } + NS_RELEASE(doc); + } + + return res; +} + // XXX check all mappings against ebina's usage static nsGenericHTMLElement::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index 02972e377c1..f24c1199fc2 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -46,6 +46,7 @@ class nsChildContentList; class nsDOMCSSDeclaration; class nsIDOMCSSStyleDeclaration; class nsIURL; +class nsIFormControlFrame; class nsGenericHTMLElement : public nsGenericElement { public: @@ -237,6 +238,10 @@ public: const nsIAtom* aAttribute, PRInt32* aHint); + //XXX This creates a dependency between content and frames + static nsresult GetPrimaryFrame(nsIHTMLContent* aContent, + nsIFormControlFrame *&aFormControlFrame); + nsIHTMLAttributes* mAttributes; }; diff --git a/layout/html/content/src/nsHTMLInputElement.cpp b/layout/html/content/src/nsHTMLInputElement.cpp index ed3220b5f6e..10db0cf9103 100644 --- a/layout/html/content/src/nsHTMLInputElement.cpp +++ b/layout/html/content/src/nsHTMLInputElement.cpp @@ -139,9 +139,6 @@ protected: nsIForm* mForm; PRInt32 mType; - // Return the primary frame associated with this content - nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame); - PRBool IsImage() const { nsAutoString tmp; mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, tmp); @@ -324,7 +321,7 @@ nsHTMLInputElement::GetValue(nsString& aValue) GetType(&type); if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { formControlFrame->GetProperty(nsHTMLAtoms::value, aValue); NS_RELEASE(formControlFrame); return NS_OK; @@ -341,7 +338,7 @@ nsHTMLInputElement::SetValue(const nsString& aValue) GetType(&type); if (NS_FORM_INPUT_TEXT == type) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { formControlFrame->SetProperty(nsHTMLAtoms::value, aValue); NS_RELEASE(formControlFrame); } @@ -353,7 +350,7 @@ NS_IMETHODIMP nsHTMLInputElement::GetChecked(PRBool* aValue) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { if (nsnull != formControlFrame) { nsString value("0"); formControlFrame->GetProperty(nsHTMLAtoms::checked, value); @@ -373,7 +370,7 @@ NS_IMETHODIMP nsHTMLInputElement::SetChecked(PRBool aValue) { nsIFormControlFrame* formControlFrame = nsnull; - if (NS_OK == GetPrimaryFrame(formControlFrame)) { + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { if (PR_TRUE == aValue) { formControlFrame->SetProperty(nsHTMLAtoms::checked, "1"); } @@ -679,26 +676,4 @@ nsHTMLInputElement::GetStyleHintForAttributeChange( return NS_OK; } -nsresult nsHTMLInputElement::GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame) -{ - nsIDocument* doc = nsnull; - nsresult res = NS_NOINTERFACE; - // Get the document - if (NS_OK == GetDocument(doc)) { - // Get presentation shell 0 - nsIPresShell* presShell = doc->GetShellAt(0); - if (nsnull != presShell) { - nsIFrame *frame = nsnull; - presShell->GetPrimaryFrameFor(this, frame); - if (nsnull != frame) { - res = frame->QueryInterface(kIFormControlFrameIID, (void**)&aFormControlFrame); - } - NS_RELEASE(presShell); - } - NS_RELEASE(doc); - } - - return res; -} - diff --git a/layout/html/content/src/nsHTMLTextAreaElement.cpp b/layout/html/content/src/nsHTMLTextAreaElement.cpp index 812b5abf90e..2a36887132a 100644 --- a/layout/html/content/src/nsHTMLTextAreaElement.cpp +++ b/layout/html/content/src/nsHTMLTextAreaElement.cpp @@ -32,6 +32,7 @@ #include "nsIWidget.h" #include "nsITextAreaWidget.h" #include "nsIHTMLAttributes.h" +#include "nsIFormControlFrame.h" static NS_DEFINE_IID(kIDOMHTMLTextAreaElementIID, NS_IDOMHTMLTEXTAREAELEMENT_IID); static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID); @@ -265,39 +266,32 @@ nsHTMLTextAreaElement::GetType(nsString& aType) NS_IMETHODIMP nsHTMLTextAreaElement::GetValue(nsString& aValue) { - if (nsnull != mWidget) { - nsITextAreaWidget* text = nsnull; - if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID,(void**)&text)) { - PRUint32 size; - text->GetText(aValue,0,size); - NS_RELEASE(text); + nsIFormControlFrame* formControlFrame = nsnull; + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { + formControlFrame->GetProperty(nsHTMLAtoms::value, aValue); + NS_RELEASE(formControlFrame); return NS_OK; - } - } - - return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue); + } + //XXX: Should this ASSERT instead of getting the default value here? + return mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue); } NS_IMETHODIMP nsHTMLTextAreaElement::SetValue(const nsString& aValue) { - if (nsnull != mWidget) { - nsITextAreaWidget* text = nsnull; - if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID,(void**)&text)) { - PRUint32 size; - text->SetText(aValue,size); - NS_RELEASE(text); - } - } - - return mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aValue, PR_TRUE); + nsIFormControlFrame* formControlFrame = nsnull; + if (NS_OK == nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame)) { + formControlFrame->SetProperty(nsHTMLAtoms::value, aValue); + NS_RELEASE(formControlFrame); + } + return NS_OK; } NS_IMETHODIMP nsHTMLTextAreaElement::GetDefaultValue(nsString& aDefaultValue) { - mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, aDefaultValue); + mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, aDefaultValue); return NS_OK; } @@ -308,7 +302,6 @@ nsHTMLTextAreaElement::SetDefaultValue(const nsString& aDefaultValue) static char whitespace[] = " \r\n\t"; nsString value(aDefaultValue); value.Trim(whitespace, PR_TRUE, PR_FALSE); - mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::defaultvalue, value, PR_TRUE); mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::value, value, PR_TRUE); return NS_OK; diff --git a/layout/html/forms/src/nsTextControlFrame.cpp b/layout/html/forms/src/nsTextControlFrame.cpp index d37534361f9..dc3150e6260 100644 --- a/layout/html/forms/src/nsTextControlFrame.cpp +++ b/layout/html/forms/src/nsTextControlFrame.cpp @@ -739,11 +739,17 @@ void nsTextControlFrame::GetTextControlFrameState(nsString& aValue) { if (nsnull != mWidget) { nsITextWidget* text = nsnull; + nsITextAreaWidget* textArea = nsnull; + PRUint32 size = 0; if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) { - PRUint32 size; text->GetText(aValue,0,size); NS_RELEASE(text); } + else if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID, + (void**)&textArea)) { + textArea->GetText(aValue,0, size); + NS_RELEASE(textArea); + } } else { //XXX: this should return the a local field for GFX-rendered widgets aValue = ""; @@ -754,13 +760,18 @@ void nsTextControlFrame::SetTextControlFrameState(const nsString& aValue) { if (nsnull != mWidget) { nsITextWidget* text = nsnull; + nsITextAreaWidget* textArea = nsnull; + PRUint32 size = 0; if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) { - PRUint32 size; text->SetText(aValue,size); NS_RELEASE(text); + } else if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID, + (void**)&textArea)) { + textArea->SetText(aValue,size); + NS_RELEASE(textArea); } - } -} + } +} NS_IMETHODIMP nsTextControlFrame::SetProperty(nsIAtom* aName, const nsString& aValue) { @@ -769,7 +780,6 @@ NS_IMETHODIMP nsTextControlFrame::SetProperty(nsIAtom* aName, const nsString& aV else { return nsFormControlFrame::SetProperty(aName, aValue); } - return NS_OK; }