Fix textboxes not showing up in Print and Print Preview (bug 109914). r=sicking@bigfoot.com;sr=jst@netscape.com

This commit is contained in:
jkeiser%iname.com 2001-11-16 02:38:10 +00:00
parent cdf0febb70
commit 67ebb1e3b4
8 changed files with 99 additions and 77 deletions

View File

@ -55,18 +55,6 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXTCONTROLELEMENT_IID)
/**
* Get the value of the text control. This is the value that is set when
* the control is not there or goes away.
*/
NS_IMETHOD GetValueInternal(nsAWritableString& str) = 0;
/**
* Set the value of the text control. This is the value that is set when
* the control is not there or goes away.
*/
NS_IMETHOD SetValueInternal(nsAReadableString& str) = 0;
/**
* Tell the control that value has been deliberately changed (or not).
*/

View File

@ -186,8 +186,6 @@ public:
}
// nsITextControlElement
NS_IMETHOD GetValueInternal(nsAWritableString& str);
NS_IMETHOD SetValueInternal(nsAReadableString& str);
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
protected:
@ -413,19 +411,6 @@ nsHTMLInputElement::SetType(const nsAReadableString& aValue)
PR_TRUE);
}
NS_IMETHODIMP
nsHTMLInputElement::GetValueInternal(nsAWritableString& aValue)
{
aValue.Truncate();
if (!mValueChanged || !mValue) {
GetDefaultValue(aValue);
} else {
aValue = NS_ConvertUTF8toUCS2(mValue);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLInputElement::GetValue(nsAWritableString& aValue)
{
@ -440,10 +425,23 @@ nsHTMLInputElement::GetValue(nsAWritableString& aValue)
// have) even if we force it to be created
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
nsIGfxTextControlFrame2* textControlFrame = nsnull;
if (formControlFrame) {
CallQueryInterface(formControlFrame, &textControlFrame);
}
PRBool frameOwnsValue = PR_FALSE;
if (textControlFrame) {
textControlFrame->OwnsValue(&frameOwnsValue);
}
if (frameOwnsValue) {
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue);
} else {
GetValueInternal(aValue);
if (!mValueChanged || !mValue) {
GetDefaultValue(aValue);
} else {
aValue = NS_ConvertUTF8toUCS2(mValue);
}
}
return NS_OK;
@ -465,19 +463,6 @@ nsHTMLInputElement::GetValue(nsAWritableString& aValue)
return rv;
}
NS_IMETHODIMP
nsHTMLInputElement::SetValueInternal(nsAReadableString& aValue)
{
if (mValue) {
nsMemory::Free(mValue);
}
mValue = ToNewUTF8String(aValue);
SetValueChanged(PR_TRUE);
return mValue ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP
nsHTMLInputElement::SetValue(const nsAReadableString& aValue)
{
@ -520,13 +505,30 @@ nsHTMLInputElement::SetValueSecure(const nsAReadableString& aValue,
// new value.
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
nsIGfxTextControlFrame2* textControlFrame = nsnull;
if (formControlFrame) {
CallQueryInterface(formControlFrame, &textControlFrame);
}
PRBool frameOwnsValue = PR_FALSE;
if (textControlFrame) {
textControlFrame->OwnsValue(&frameOwnsValue);
}
if (frameOwnsValue) {
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(this, getter_AddRefs(presContext));
formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue);
} else {
SetValueInternal(aValue);
if (mValue) {
nsMemory::Free(mValue);
}
mValue = ToNewUTF8String(aValue);
SetValueChanged(PR_TRUE);
return mValue ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}

View File

@ -57,6 +57,7 @@
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIFormControlFrame.h"
#include "nsIGfxTextControlFrame.h"
#include "nsIEventStateManager.h"
#include "nsISizeOfHandler.h"
#include "nsLinebreakConverter.h"
@ -112,8 +113,6 @@ public:
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
// nsITextControlElement
NS_IMETHOD GetValueInternal(nsAWritableString& str);
NS_IMETHOD SetValueInternal(nsAReadableString& str);
NS_IMETHOD SetValueChanged(PRBool aValueChanged);
// nsIContent
@ -393,14 +392,6 @@ nsHTMLTextAreaElement::GetType(nsAWritableString& aType)
return NS_OK;
}
NS_IMETHODIMP
nsHTMLTextAreaElement::GetValueInternal(nsAWritableString& aValue)
{
return nsGenericHTMLContainerFormElement::GetAttr(kNameSpaceID_HTML,
nsHTMLAtoms::value,
aValue);
}
NS_IMETHODIMP
nsHTMLTextAreaElement::GetValue(nsAWritableString& aValue)
{
@ -411,27 +402,26 @@ nsHTMLTextAreaElement::GetValue(nsAWritableString& aValue)
// force the frame to be created.
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
nsIGfxTextControlFrame2* textControlFrame = nsnull;
if (formControlFrame) {
CallQueryInterface(formControlFrame, &textControlFrame);
}
PRBool frameOwnsValue = PR_FALSE;
if (textControlFrame) {
textControlFrame->OwnsValue(&frameOwnsValue);
}
if (frameOwnsValue) {
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue);
return NS_OK;
} else {
return GetValueInternal(aValue);
return nsGenericHTMLContainerFormElement::GetAttr(kNameSpaceID_HTML,
nsHTMLAtoms::value,
aValue);
}
}
NS_IMETHODIMP
nsHTMLTextAreaElement::SetValueInternal(nsAReadableString& aValue)
{
// Set the attribute in the DOM too, we call SetAttribute with aNotify
// false so that we don't generate unnecessary reflows.
nsGenericHTMLContainerFormElement::SetAttr(kNameSpaceID_HTML,
nsHTMLAtoms::value, aValue,
PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP
nsHTMLTextAreaElement::SetValue(const nsAReadableString& aValue)
{
@ -441,7 +431,16 @@ nsHTMLTextAreaElement::SetValue(const nsAReadableString& aValue)
// creation of one will not do us any good
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
nsIGfxTextControlFrame2* textControlFrame = nsnull;
if (formControlFrame) {
CallQueryInterface(formControlFrame, &textControlFrame);
}
PRBool frameOwnsValue = PR_FALSE;
if (textControlFrame) {
textControlFrame->OwnsValue(&frameOwnsValue);
}
if (frameOwnsValue) {
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(this, getter_AddRefs(presContext));
@ -449,7 +448,12 @@ nsHTMLTextAreaElement::SetValue(const nsAReadableString& aValue)
}
// Always set the value internally, since it affects layout
SetValueInternal(aValue);
//
// Set the attribute in the DOM too, we call SetAttribute with aNotify
// false so that we don't generate unnecessary reflows.
nsGenericHTMLContainerFormElement::SetAttr(kNameSpaceID_HTML,
nsHTMLAtoms::value, aValue,
PR_FALSE);
return NS_OK;
}

View File

@ -50,8 +50,9 @@ class nsIGfxTextControlFrame2 : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME2_IID; return iid; }
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0;
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;

View File

@ -50,8 +50,9 @@ class nsIGfxTextControlFrame2 : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME2_IID; return iid; }
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0;
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;

View File

@ -50,8 +50,9 @@ class nsIGfxTextControlFrame2 : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME2_IID; return iid; }
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0;
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;

View File

@ -2675,7 +2675,13 @@ nsGfxTextControlFrame2::GetEditor(nsIEditor **aEditor)
return NS_OK;
}
NS_IMETHODIMP
nsGfxTextControlFrame2::OwnsValue(PRBool* aOwnsValue)
{
NS_PRECONDITION(aOwnsValue, "aOwnsValue must be non-null");
*aOwnsValue = mUseEditor;
return NS_OK;
}
NS_IMETHODIMP
nsGfxTextControlFrame2::GetTextLength(PRInt32* aTextLength)
@ -3307,10 +3313,19 @@ void nsGfxTextControlFrame2::GetTextControlFrameState(nsAWritableString& aValue)
else
{
// Otherwise get the value from content.
nsCOMPtr<nsITextControlElement> control = do_QueryInterface(mContent);
if (control)
nsCOMPtr<nsIDOMHTMLInputElement> inputControl = do_QueryInterface(mContent);
if (inputControl)
{
control->GetValueInternal(aValue);
inputControl->GetValue(aValue);
}
else
{
nsCOMPtr<nsIDOMHTMLTextAreaElement> textareaControl
= do_QueryInterface(mContent);
if (textareaControl)
{
textareaControl->GetValue(aValue);
}
}
}
}
@ -3386,11 +3401,20 @@ nsGfxTextControlFrame2::SetTextControlFrameState(const nsAReadableString& aValue
}
else
{
// Otherwise get the value from content.
nsCOMPtr<nsITextControlElement> control = do_QueryInterface(mContent);
if (control)
// Otherwise set the value in content.
nsCOMPtr<nsIDOMHTMLInputElement> inputControl = do_QueryInterface(mContent);
if (inputControl)
{
control->SetValueInternal(aValue);
inputControl->SetValue(aValue);
}
else
{
nsCOMPtr<nsIDOMHTMLTextAreaElement> textareaControl
= do_QueryInterface(mContent);
if (textareaControl)
{
textareaControl->SetValue(aValue);
}
}
}
}

View File

@ -153,6 +153,7 @@ public:
//==== NSIGFXTEXTCONTROLFRAME2
NS_IMETHOD GetEditor(nsIEditor **aEditor);
NS_IMETHOD OwnsValue(PRBool* aOwnsValue);
NS_IMETHOD GetTextLength(PRInt32* aTextLength);
NS_IMETHOD SetSelectionStart(PRInt32 aSelectionStart);
NS_IMETHOD SetSelectionEnd(PRInt32 aSelectionEnd);