Make textarea wrap="hard" not wrap text for restore/JS (only submit and edit). bug 74091, r=rods@netscape.com, sr=attinasi@netscape.com

This commit is contained in:
jkeiser%netscape.com 2002-05-16 18:26:05 +00:00
Родитель f2e3ecc2bd
Коммит 4bf9570a63
15 изменённых файлов: 189 добавлений и 108 удалений

Просмотреть файл

@ -2908,13 +2908,11 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
} }
// static // static
nsIFormControlFrame * nsIFrame *
nsGenericHTMLElement::GetFormControlFrameFor(nsIContent *aContent, nsGenericHTMLElement::GetPrimaryFrameFor(nsIContent* aContent,
nsIDocument *aDocument, nsIDocument* aDocument,
PRBool aFlushContent) PRBool aFlushContent)
{ {
nsIFormControlFrame *form_frame = nsnull;
if (aFlushContent) { if (aFlushContent) {
// Cause a flush of content, so we get up-to-date frame // Cause a flush of content, so we get up-to-date frame
// information // information
@ -2928,13 +2926,26 @@ nsGenericHTMLElement::GetFormControlFrameFor(nsIContent *aContent,
if (presShell) { if (presShell) {
nsIFrame *frame = nsnull; nsIFrame *frame = nsnull;
presShell->GetPrimaryFrameFor(aContent, &frame); presShell->GetPrimaryFrameFor(aContent, &frame);
return frame;
if (frame) {
CallQueryInterface(frame, &form_frame);
}
} }
return form_frame; return nsnull;
}
// static
nsIFormControlFrame*
nsGenericHTMLElement::GetFormControlFrameFor(nsIContent* aContent,
nsIDocument* aDocument,
PRBool aFlushContent)
{
nsIFrame* frame = GetPrimaryFrameFor(aContent, aDocument, aFlushContent);
if (frame) {
nsIFormControlFrame* form_frame = nsnull;
CallQueryInterface(frame, &form_frame);
return form_frame;
}
return nsnull;
} }
nsresult nsresult

Просмотреть файл

@ -208,15 +208,37 @@ public:
PRUint32 BaseSizeOf(nsISizeOfHandler* aSizer) const; PRUint32 BaseSizeOf(nsISizeOfHandler* aSizer) const;
#endif #endif
nsIFormControlFrame *GetFormControlFrame(PRBool aFlushContent) /**
* Get the primary form control frame for this content (see
* GetFormControlFrameFor)
*
* @param aFlushContent whether to flush the content sink
* @return the primary form control frame
*/
nsIFormControlFrame* GetFormControlFrame(PRBool aFlushContent)
{ {
if (!mDocument || !mParent) { if (!mDocument) {
return nsnull; return nsnull;
} }
return GetFormControlFrameFor(this, mDocument, aFlushContent); return GetFormControlFrameFor(this, mDocument, aFlushContent);
} }
/**
* Get the primary frame for this content (see GetPrimaryFrameFor)
*
* @param aFlushContent whether to flush the content sink
* @return the primary frame
*/
nsIFrame* GetPrimaryFrame(PRBool aFlushContent)
{
if (!mDocument) {
return nsnull;
}
return GetPrimaryFrameFor(this, mDocument, aFlushContent);
}
//---------------------------------------- //----------------------------------------
// Attribute parsing utilities // Attribute parsing utilities
@ -354,6 +376,29 @@ public:
static PRBool GetBackgroundAttributesImpact(const nsIAtom* aAttribute, static PRBool GetBackgroundAttributesImpact(const nsIAtom* aAttribute,
PRInt32& aHint); PRInt32& aHint);
/**
* Get the primary frame for a piece of content.
*
* @param aContent the content to get the primary frame for
* @param aDocument the document for this content
* @param aFlushContent whether to flush the content sink, which creates
* frames for content that do not already have it. EXPENSIVE.
* @return the primary frame
*/
static nsIFrame* GetPrimaryFrameFor(nsIContent* aContent,
nsIDocument* aDocument,
PRBool aFlushContent);
/**
* Get the primary form control frame for a piece of content. Same as
* GetPrimaryFrameFor, except it QI's to nsIFormControlFrame.
*
* @param aContent the content to get the primary frame for
* @param aDocument the document for this content
* @param aFlushContent whether to flush the content sink, which creates
* frames for content that do not already have it. EXPENSIVE.
* @return the primary frame as nsIFormControlFrame
*/
static nsIFormControlFrame* GetFormControlFrameFor(nsIContent* aContent, static nsIFormControlFrame* GetFormControlFrameFor(nsIContent* aContent,
nsIDocument* aDocument, nsIDocument* aDocument,
PRBool aFlushContent); PRBool aFlushContent);

Просмотреть файл

@ -565,6 +565,7 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor)
// If we don't have an attribute, find the actual color used for // If we don't have an attribute, find the actual color used for
// (generally from the user agent style sheet) for compatibility // (generally from the user agent style sheet) for compatibility
if (rv == NS_CONTENT_ATTR_NOT_THERE) { if (rv == NS_CONTENT_ATTR_NOT_THERE) {
// XXX This should just use nsGenericHTMLElement::GetPrimaryFrame()
if (mDocument) { if (mDocument) {
// Make sure the presentation is up-to-date // Make sure the presentation is up-to-date
rv = mDocument->FlushPendingNotifications(); rv = mDocument->FlushPendingNotifications();

Просмотреть файл

@ -287,35 +287,7 @@ nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
NS_ENSURE_ARG_POINTER(aImageFrame); NS_ENSURE_ARG_POINTER(aImageFrame);
*aImageFrame = nsnull; *aImageFrame = nsnull;
if (!mDocument) { nsIFrame* frame = GetPrimaryFrame(PR_TRUE);
return NS_OK;
}
// Make sure the presentation is up-to-date
nsresult rv = mDocument->FlushPendingNotifications();
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIPresShell> shell;
mDocument->GetShellAt(0, getter_AddRefs(shell));
if (!shell) {
return NS_OK;
}
nsCOMPtr<nsIPresContext> context;
rv = shell->GetPresContext(getter_AddRefs(context));
if (!context) {
return NS_OK;
}
nsIFrame* frame = nsnull;
rv = shell->GetPrimaryFrameFor(this, &frame);
if (!frame || NS_FAILED(rv)) {
return rv;
}
CallQueryInterface(frame, aImageFrame); CallQueryInterface(frame, aImageFrame);
return NS_OK; return NS_OK;

Просмотреть файл

@ -859,21 +859,7 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked)
// //
// Notify the frame // Notify the frame
// //
// If the document or parent is not there, don't even bother looking nsIFrame* frame = GetPrimaryFrame(PR_FALSE);
// for the frame. It won't (shouldn't) be there.
if (!mDocument || !mParent) {
return NS_OK;
}
// Get presentation shell 0
nsCOMPtr<nsIPresShell> presShell;
mDocument->GetShellAt(0, getter_AddRefs(presShell));
if (!presShell) {
return NS_OK;
}
nsIFrame *frame = nsnull;
presShell->GetPrimaryFrameFor(this, &frame);
if (!frame) { if (!frame) {
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -146,10 +146,20 @@ public:
protected: protected:
nsCOMPtr<nsIControllers> mControllers; nsCOMPtr<nsIControllers> mControllers;
/** The current value. This is null if the frame owns the value. */
char* mValue; char* mValue;
/** Whether or not the value has changed since its default value was given. */
PRPackedBool mValueChanged; PRPackedBool mValueChanged;
NS_IMETHOD SelectAll(nsIPresContext* aPresContext); NS_IMETHOD SelectAll(nsIPresContext* aPresContext);
/**
* Get the value, whether it is from the content or the frame.
* @param aValue the value [out]
* @param aIgnoreWrap whether to ignore the wrap attribute when getting the
* value. If this is true, linebreaks will not be inserted even if
* wrap=hard.
*/
void GetValueInternal(nsAString& aValue, PRBool aIgnoreWrap);
}; };
nsresult nsresult
@ -181,7 +191,7 @@ NS_NewHTMLTextAreaElement(nsIHTMLContent** aInstancePtrResult,
nsHTMLTextAreaElement::nsHTMLTextAreaElement() nsHTMLTextAreaElement::nsHTMLTextAreaElement()
{ {
mValue = 0; mValue = nsnull;
mValueChanged = PR_FALSE; mValueChanged = PR_FALSE;
} }
@ -409,23 +419,29 @@ nsHTMLTextAreaElement::GetType(nsAString& aType)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLTextAreaElement::GetValue(nsAString& aValue) nsHTMLTextAreaElement::GetValue(nsAString& aValue)
{ {
GetValueInternal(aValue, PR_TRUE);
return NS_OK;
}
void
nsHTMLTextAreaElement::GetValueInternal(nsAString& aValue, PRBool aIgnoreWrap)
{
// Get the frame.
// No need to flush here, if there is no frame yet for this textarea // No need to flush here, if there is no frame yet for this textarea
// there won't be a value in it we don't already have even if we // there won't be a value in it we don't already have even if we
// force the frame to be created. // force the frame to be created.
nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE); nsIFrame* primaryFrame = GetPrimaryFrame(PR_FALSE);
nsIGfxTextControlFrame2* textControlFrame = nsnull; nsIGfxTextControlFrame2* textControlFrame = nsnull;
if (formControlFrame) { CallQueryInterface(primaryFrame, &textControlFrame);
CallQueryInterface(formControlFrame, &textControlFrame);
}
// If the frame exists and owns the value, get it from the frame. Otherwise
// get it from content.
PRBool frameOwnsValue = PR_FALSE; PRBool frameOwnsValue = PR_FALSE;
if (textControlFrame) { if (textControlFrame) {
textControlFrame->OwnsValue(&frameOwnsValue); textControlFrame->OwnsValue(&frameOwnsValue);
} }
if (frameOwnsValue) { if (frameOwnsValue) {
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue); textControlFrame->GetValue(aValue, aIgnoreWrap);
return NS_OK;
} else { } else {
if (!mValueChanged || !mValue) { if (!mValueChanged || !mValue) {
GetDefaultValue(aValue); GetDefaultValue(aValue);
@ -433,7 +449,6 @@ nsHTMLTextAreaElement::GetValue(nsAString& aValue)
aValue = NS_ConvertUTF8toUCS2(mValue); aValue = NS_ConvertUTF8toUCS2(mValue);
} }
} }
return NS_OK;
} }
@ -913,10 +928,7 @@ nsHTMLTextAreaElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
// Get the value // Get the value
// //
nsAutoString value; nsAutoString value;
rv = GetValue(value); GetValueInternal(value, PR_FALSE);
if (NS_FAILED(rv)) {
return rv;
}
// //
// Submit // Submit
@ -938,7 +950,7 @@ nsHTMLTextAreaElement::SaveState()
rv = GetPrimaryPresState(this, getter_AddRefs(state)); rv = GetPrimaryPresState(this, getter_AddRefs(state));
if (state) { if (state) {
nsAutoString value; nsAutoString value;
GetValue(value); GetValueInternal(value, PR_TRUE);
rv = nsLinebreakConverter::ConvertStringLineBreaks( rv = nsLinebreakConverter::ConvertStringLineBreaks(
value, value,

Просмотреть файл

@ -632,7 +632,7 @@ NS_IMETHODIMP nsFileControlFrame::SetProperty(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (nsHTMLAtoms::value == aName) { if (nsHTMLAtoms::value == aName) {
if (mTextFrame) { if (mTextFrame) {
mTextFrame->SetTextControlFrameState(aValue); mTextFrame->SetValue(aValue);
} else { } else {
if (mCachedState) delete mCachedState; if (mCachedState) delete mCachedState;
mCachedState = new nsString(aValue); mCachedState = new nsString(aValue);
@ -648,7 +648,7 @@ NS_IMETHODIMP nsFileControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
if (nsHTMLAtoms::value == aName) { if (nsHTMLAtoms::value == aName) {
if (mTextFrame) { if (mTextFrame) {
mTextFrame->GetTextControlFrameState(aValue); mTextFrame->GetValue(aValue, PR_FALSE);
} }
else if (mCachedState) { else if (mCachedState) {
aValue.Assign(*mCachedState); aValue.Assign(*mCachedState);

Просмотреть файл

@ -53,7 +53,23 @@ public:
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0; NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
/**
* Tell whether the frame currently owns the value or the content does (for
* edge cases where the frame has just been created or is just going away).
*
* @param aOwnsValue whether the frame owns the value [out]
*/
NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0; NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0;
/**
* Get the current value, either from the editor or from the textarea.
*
* @param aValue the value [out]
* @param aIgnoreWrap whether to ignore the wrap attribute when getting the
* value. If this is true, linebreaks will not be inserted even if
* wrap=hard.
*/
NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap) = 0;
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0; NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;

Просмотреть файл

@ -193,7 +193,7 @@ nsIsIndexFrame::GetInputValue(nsIPresContext* aPresContext,
nsIFormControlFrame* frame = nsnull; nsIFormControlFrame* frame = nsnull;
GetInputFrame(aPresContext, &frame); GetInputFrame(aPresContext, &frame);
if (frame) { if (frame) {
((nsNewFrame*)frame)->GetTextControlFrameState(oString); ((nsNewFrame*)frame)->GetValue(oString, PR_FALSE);
} }
return NS_OK; return NS_OK;
} }
@ -205,7 +205,7 @@ nsIsIndexFrame::SetInputValue(nsIPresContext* aPresContext,
nsIFormControlFrame* frame = nsnull; nsIFormControlFrame* frame = nsnull;
GetInputFrame(aPresContext, &frame); GetInputFrame(aPresContext, &frame);
if (frame) { if (frame) {
((nsNewFrame*)frame)->SetTextControlFrameState(aString); ((nsNewFrame*)frame)->SetValue(aString);
} }
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -53,7 +53,23 @@ public:
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0; NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
/**
* Tell whether the frame currently owns the value or the content does (for
* edge cases where the frame has just been created or is just going away).
*
* @param aOwnsValue whether the frame owns the value [out]
*/
NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0; NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0;
/**
* Get the current value, either from the editor or from the textarea.
*
* @param aValue the value [out]
* @param aIgnoreWrap whether to ignore the wrap attribute when getting the
* value. If this is true, linebreaks will not be inserted even if
* wrap=hard.
*/
NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap) = 0;
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0; NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;

Просмотреть файл

@ -53,7 +53,23 @@ public:
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0; NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
/**
* Tell whether the frame currently owns the value or the content does (for
* edge cases where the frame has just been created or is just going away).
*
* @param aOwnsValue whether the frame owns the value [out]
*/
NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0; NS_IMETHOD OwnsValue(PRBool* aOwnsValue) = 0;
/**
* Get the current value, either from the editor or from the textarea.
*
* @param aValue the value [out]
* @param aIgnoreWrap whether to ignore the wrap attribute when getting the
* value. If this is true, linebreaks will not be inserted even if
* wrap=hard.
*/
NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap) = 0;
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0; NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;

Просмотреть файл

@ -632,7 +632,7 @@ NS_IMETHODIMP nsFileControlFrame::SetProperty(nsIPresContext* aPresContext,
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (nsHTMLAtoms::value == aName) { if (nsHTMLAtoms::value == aName) {
if (mTextFrame) { if (mTextFrame) {
mTextFrame->SetTextControlFrameState(aValue); mTextFrame->SetValue(aValue);
} else { } else {
if (mCachedState) delete mCachedState; if (mCachedState) delete mCachedState;
mCachedState = new nsString(aValue); mCachedState = new nsString(aValue);
@ -648,7 +648,7 @@ NS_IMETHODIMP nsFileControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
if (nsHTMLAtoms::value == aName) { if (nsHTMLAtoms::value == aName) {
if (mTextFrame) { if (mTextFrame) {
mTextFrame->GetTextControlFrameState(aValue); mTextFrame->GetValue(aValue, PR_FALSE);
} }
else if (mCachedState) { else if (mCachedState) {
aValue.Assign(*mCachedState); aValue.Assign(*mCachedState);

Просмотреть файл

@ -1423,14 +1423,14 @@ nsGfxTextControlFrame2::PreDestroy(nsIPresContext* aPresContext)
{ {
// First get the frame state from the editor // First get the frame state from the editor
nsAutoString value; nsAutoString value;
GetTextControlFrameState(value); GetValue(value, PR_TRUE);
mUseEditor = PR_FALSE; mUseEditor = PR_FALSE;
// Next store the frame state in the control // Next store the frame state in the control
// (now that mUseEditor is false values get stored // (now that mUseEditor is false values get stored
// in content). // in content).
SetTextControlFrameState(value); SetValue(value);
} }
mEditor->PreDestroy(); mEditor->PreDestroy();
} }
@ -1836,7 +1836,7 @@ nsGfxTextControlFrame2::SetInitialValue()
// Get the current value of the textfield from the content. // Get the current value of the textfield from the content.
nsAutoString defaultValue; nsAutoString defaultValue;
GetTextControlFrameState(defaultValue); GetValue(defaultValue, PR_TRUE);
// Turn on mUseEditor so that subsequent calls will use the // Turn on mUseEditor so that subsequent calls will use the
// editor. // editor.
@ -1844,8 +1844,8 @@ nsGfxTextControlFrame2::SetInitialValue()
// If we have a default value, insert it under the div we created // If we have a default value, insert it under the div we created
// above, but be sure to use the editor so that '*' characters get // above, but be sure to use the editor so that '*' characters get
// displayed for password fields, etc. SetTextControlFrameState() // displayed for password fields, etc. SetValue() will call the
// will call the editor for us. // editor for us.
if (!defaultValue.IsEmpty()) { if (!defaultValue.IsEmpty()) {
PRUint32 editorFlags = 0; PRUint32 editorFlags = 0;
@ -1866,18 +1866,17 @@ nsGfxTextControlFrame2::SetInitialValue()
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
// Now call SetTextControlFrameState() which will make the // Now call SetValue() which will make the neccessary editor calls to set
// neccessary editor calls to set the default value. // the default value. Make sure to turn off undo before setting the default
// Make sure to turn off undo before setting the default // value, and turn it back on afterwards. This will make sure we can't undo
// value, and turn it back on afterwards. This will make // past the default value.
// sure we can't undo past the default value.
rv = mEditor->EnableUndo(PR_FALSE); rv = mEditor->EnableUndo(PR_FALSE);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
SetTextControlFrameState(defaultValue); SetValue(defaultValue);
rv = mEditor->EnableUndo(PR_TRUE); rv = mEditor->EnableUndo(PR_TRUE);
NS_ASSERTION(!rv,"Transaction Manager must have failed"); NS_ASSERTION(!rv,"Transaction Manager must have failed");
@ -2584,7 +2583,7 @@ NS_IMETHODIMP nsGfxTextControlFrame2::SetProperty(nsIPresContext* aPresContext,
// has changed. // has changed.
SetValueChanged(PR_TRUE); SetValueChanged(PR_TRUE);
} }
SetTextControlFrameState(aValue); // set new text value SetValue(aValue); // set new text value
if (mEditor) { if (mEditor) {
mEditor->EnableUndo(PR_TRUE); // fire up a new txn stack mEditor->EnableUndo(PR_TRUE); // fire up a new txn stack
} }
@ -2599,13 +2598,14 @@ NS_IMETHODIMP nsGfxTextControlFrame2::SetProperty(nsIPresContext* aPresContext,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsGfxTextControlFrame2::GetProperty(nsIAtom* aName, nsAString& aValue) NS_IMETHODIMP
nsGfxTextControlFrame2::GetProperty(nsIAtom* aName, nsAString& aValue)
{ {
// Return the value of the property from the widget it is not null. // Return the value of the property from the widget it is not null.
// If widget is null, assume the widget is GFX-rendered and return a member variable instead. // If widget is null, assume the widget is GFX-rendered and return a member variable instead.
if (nsHTMLAtoms::value == aName) { if (nsHTMLAtoms::value == aName) {
GetTextControlFrameState(aValue); GetValue(aValue, PR_FALSE);
} }
return NS_OK; return NS_OK;
} }
@ -2635,7 +2635,7 @@ nsGfxTextControlFrame2::GetTextLength(PRInt32* aTextLength)
NS_ENSURE_ARG_POINTER(aTextLength); NS_ENSURE_ARG_POINTER(aTextLength);
nsAutoString textContents; nsAutoString textContents;
GetTextControlFrameState(textContents); // this is expensive! GetValue(textContents, PR_FALSE); // this is expensive!
*aTextLength = textContents.Length(); *aTextLength = textContents.Length();
return NS_OK; return NS_OK;
} }
@ -3065,7 +3065,8 @@ nsGfxTextControlFrame2::GetText(nsString* aText)
PRInt32 type; PRInt32 type;
GetType(&type); GetType(&type);
if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) { if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) {
GetTextControlFrameState(*aText); // If we're going to remove newlines anyway, ignore the wrap property
GetValue(*aText, PR_TRUE);
RemoveNewlines(*aText); RemoveNewlines(*aText);
} else { } else {
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(mContent); nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(mContent);
@ -3244,7 +3245,8 @@ nsGfxTextControlFrame2::CallOnChange()
//====== //======
//privates //privates
void nsGfxTextControlFrame2::GetTextControlFrameState(nsAString& aValue) NS_IMETHODIMP
nsGfxTextControlFrame2::GetValue(nsAString& aValue, PRBool aIgnoreWrap)
{ {
aValue.Truncate(); // initialize out param aValue.Truncate(); // initialize out param
@ -3257,14 +3259,16 @@ void nsGfxTextControlFrame2::GetTextControlFrameState(nsAString& aValue)
flags |= nsIDocumentEncoder::OutputBodyOnly; flags |= nsIDocumentEncoder::OutputBodyOnly;
} }
nsFormControlHelper::nsHTMLTextWrap wrapProp;
nsresult rv = nsFormControlHelper::GetWrapPropertyEnum(mContent, wrapProp);
flags |= nsIDocumentEncoder::OutputPreformatted; flags |= nsIDocumentEncoder::OutputPreformatted;
if (NS_CONTENT_ATTR_NOT_THERE != rv)
{ if (!aIgnoreWrap) {
if (wrapProp == nsFormControlHelper::eHTMLTextWrap_Hard) nsFormControlHelper::nsHTMLTextWrap wrapProp;
{ nsresult rv = nsFormControlHelper::GetWrapPropertyEnum(mContent, wrapProp);
flags |= nsIDocumentEncoder::OutputWrap; if (rv != NS_CONTENT_ATTR_NOT_THERE) {
if (wrapProp == nsFormControlHelper::eHTMLTextWrap_Hard)
{
flags |= nsIDocumentEncoder::OutputWrap;
}
} }
} }
@ -3288,18 +3292,20 @@ void nsGfxTextControlFrame2::GetTextControlFrameState(nsAString& aValue)
} }
} }
} }
return NS_OK;
} }
// END IMPLEMENTING NS_IFORMCONTROLFRAME // END IMPLEMENTING NS_IFORMCONTROLFRAME
void void
nsGfxTextControlFrame2::SetTextControlFrameState(const nsAString& aValue) nsGfxTextControlFrame2::SetValue(const nsAString& aValue)
{ {
if (mEditor && mUseEditor) if (mEditor && mUseEditor)
{ {
nsAutoString currentValue; nsAutoString currentValue;
GetTextControlFrameState(currentValue); GetValue(currentValue, PR_FALSE);
if (IsSingleLineTextControl()) if (IsSingleLineTextControl())
{ {
RemoveNewlines(currentValue); RemoveNewlines(currentValue);

Просмотреть файл

@ -116,9 +116,8 @@ public:
NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext, NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext,
nsISupportsArray& aChildList); nsISupportsArray& aChildList);
// Utility methods to get and set current widget state // Utility methods to set current widget state
void GetTextControlFrameState(nsAString& aValue); void SetValue(const nsAString& aValue);
void SetTextControlFrameState(const nsAString& aValue);
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext, NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName, nsIAtom* aListName,
nsIFrame* aChildList); nsIFrame* aChildList);
@ -153,6 +152,7 @@ public:
NS_IMETHOD GetEditor(nsIEditor **aEditor); NS_IMETHOD GetEditor(nsIEditor **aEditor);
NS_IMETHOD OwnsValue(PRBool* aOwnsValue); NS_IMETHOD OwnsValue(PRBool* aOwnsValue);
NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap);
NS_IMETHOD GetTextLength(PRInt32* aTextLength); NS_IMETHOD GetTextLength(PRInt32* aTextLength);
NS_IMETHOD SetSelectionStart(PRInt32 aSelectionStart); NS_IMETHOD SetSelectionStart(PRInt32 aSelectionStart);
NS_IMETHOD SetSelectionEnd(PRInt32 aSelectionEnd); NS_IMETHOD SetSelectionEnd(PRInt32 aSelectionEnd);

Просмотреть файл

@ -193,7 +193,7 @@ nsIsIndexFrame::GetInputValue(nsIPresContext* aPresContext,
nsIFormControlFrame* frame = nsnull; nsIFormControlFrame* frame = nsnull;
GetInputFrame(aPresContext, &frame); GetInputFrame(aPresContext, &frame);
if (frame) { if (frame) {
((nsNewFrame*)frame)->GetTextControlFrameState(oString); ((nsNewFrame*)frame)->GetValue(oString, PR_FALSE);
} }
return NS_OK; return NS_OK;
} }
@ -205,7 +205,7 @@ nsIsIndexFrame::SetInputValue(nsIPresContext* aPresContext,
nsIFormControlFrame* frame = nsnull; nsIFormControlFrame* frame = nsnull;
GetInputFrame(aPresContext, &frame); GetInputFrame(aPresContext, &frame);
if (frame) { if (frame) {
((nsNewFrame*)frame)->SetTextControlFrameState(aString); ((nsNewFrame*)frame)->SetValue(aString);
} }
return NS_OK; return NS_OK;
} }