зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
f2e3ecc2bd
Коммит
4bf9570a63
|
@ -2908,13 +2908,11 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
|
|||
}
|
||||
|
||||
// static
|
||||
nsIFormControlFrame *
|
||||
nsGenericHTMLElement::GetFormControlFrameFor(nsIContent *aContent,
|
||||
nsIDocument *aDocument,
|
||||
PRBool aFlushContent)
|
||||
nsIFrame *
|
||||
nsGenericHTMLElement::GetPrimaryFrameFor(nsIContent* aContent,
|
||||
nsIDocument* aDocument,
|
||||
PRBool aFlushContent)
|
||||
{
|
||||
nsIFormControlFrame *form_frame = nsnull;
|
||||
|
||||
if (aFlushContent) {
|
||||
// Cause a flush of content, so we get up-to-date frame
|
||||
// information
|
||||
|
@ -2928,13 +2926,26 @@ nsGenericHTMLElement::GetFormControlFrameFor(nsIContent *aContent,
|
|||
if (presShell) {
|
||||
nsIFrame *frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(aContent, &frame);
|
||||
|
||||
if (frame) {
|
||||
CallQueryInterface(frame, &form_frame);
|
||||
}
|
||||
return 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
|
||||
|
|
|
@ -208,15 +208,37 @@ public:
|
|||
PRUint32 BaseSizeOf(nsISizeOfHandler* aSizer) const;
|
||||
#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 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
|
||||
|
@ -354,6 +376,29 @@ public:
|
|||
static PRBool GetBackgroundAttributesImpact(const nsIAtom* aAttribute,
|
||||
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,
|
||||
nsIDocument* aDocument,
|
||||
PRBool aFlushContent);
|
||||
|
|
|
@ -565,6 +565,7 @@ nsHTMLBodyElement::GetBgColor(nsAString& aBgColor)
|
|||
// If we don't have an attribute, find the actual color used for
|
||||
// (generally from the user agent style sheet) for compatibility
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
// XXX This should just use nsGenericHTMLElement::GetPrimaryFrame()
|
||||
if (mDocument) {
|
||||
// Make sure the presentation is up-to-date
|
||||
rv = mDocument->FlushPendingNotifications();
|
||||
|
|
|
@ -287,35 +287,7 @@ nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
|
|||
NS_ENSURE_ARG_POINTER(aImageFrame);
|
||||
*aImageFrame = nsnull;
|
||||
|
||||
if (!mDocument) {
|
||||
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;
|
||||
}
|
||||
|
||||
nsIFrame* frame = GetPrimaryFrame(PR_TRUE);
|
||||
CallQueryInterface(frame, aImageFrame);
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -859,21 +859,7 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked)
|
|||
//
|
||||
// Notify the frame
|
||||
//
|
||||
// If the document or parent is not there, don't even bother looking
|
||||
// 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);
|
||||
nsIFrame* frame = GetPrimaryFrame(PR_FALSE);
|
||||
if (!frame) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -146,10 +146,20 @@ public:
|
|||
|
||||
protected:
|
||||
nsCOMPtr<nsIControllers> mControllers;
|
||||
/** The current value. This is null if the frame owns the value. */
|
||||
char* mValue;
|
||||
/** Whether or not the value has changed since its default value was given. */
|
||||
PRPackedBool mValueChanged;
|
||||
|
||||
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
|
||||
|
@ -181,7 +191,7 @@ NS_NewHTMLTextAreaElement(nsIHTMLContent** aInstancePtrResult,
|
|||
|
||||
nsHTMLTextAreaElement::nsHTMLTextAreaElement()
|
||||
{
|
||||
mValue = 0;
|
||||
mValue = nsnull;
|
||||
mValueChanged = PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -409,23 +419,29 @@ nsHTMLTextAreaElement::GetType(nsAString& aType)
|
|||
NS_IMETHODIMP
|
||||
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
|
||||
// there won't be a value in it we don't already have even if we
|
||||
// force the frame to be created.
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE);
|
||||
|
||||
nsIFrame* primaryFrame = GetPrimaryFrame(PR_FALSE);
|
||||
nsIGfxTextControlFrame2* textControlFrame = nsnull;
|
||||
if (formControlFrame) {
|
||||
CallQueryInterface(formControlFrame, &textControlFrame);
|
||||
}
|
||||
CallQueryInterface(primaryFrame, &textControlFrame);
|
||||
|
||||
// If the frame exists and owns the value, get it from the frame. Otherwise
|
||||
// get it from content.
|
||||
PRBool frameOwnsValue = PR_FALSE;
|
||||
if (textControlFrame) {
|
||||
textControlFrame->OwnsValue(&frameOwnsValue);
|
||||
}
|
||||
if (frameOwnsValue) {
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue);
|
||||
return NS_OK;
|
||||
textControlFrame->GetValue(aValue, aIgnoreWrap);
|
||||
} else {
|
||||
if (!mValueChanged || !mValue) {
|
||||
GetDefaultValue(aValue);
|
||||
|
@ -433,7 +449,6 @@ nsHTMLTextAreaElement::GetValue(nsAString& aValue)
|
|||
aValue = NS_ConvertUTF8toUCS2(mValue);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -913,10 +928,7 @@ nsHTMLTextAreaElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
|||
// Get the value
|
||||
//
|
||||
nsAutoString value;
|
||||
rv = GetValue(value);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
GetValueInternal(value, PR_FALSE);
|
||||
|
||||
//
|
||||
// Submit
|
||||
|
@ -938,7 +950,7 @@ nsHTMLTextAreaElement::SaveState()
|
|||
rv = GetPrimaryPresState(this, getter_AddRefs(state));
|
||||
if (state) {
|
||||
nsAutoString value;
|
||||
GetValue(value);
|
||||
GetValueInternal(value, PR_TRUE);
|
||||
|
||||
rv = nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
value,
|
||||
|
|
|
@ -632,7 +632,7 @@ NS_IMETHODIMP nsFileControlFrame::SetProperty(nsIPresContext* aPresContext,
|
|||
nsresult rv = NS_OK;
|
||||
if (nsHTMLAtoms::value == aName) {
|
||||
if (mTextFrame) {
|
||||
mTextFrame->SetTextControlFrameState(aValue);
|
||||
mTextFrame->SetValue(aValue);
|
||||
} else {
|
||||
if (mCachedState) delete mCachedState;
|
||||
mCachedState = new nsString(aValue);
|
||||
|
@ -648,7 +648,7 @@ NS_IMETHODIMP nsFileControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
|
|||
|
||||
if (nsHTMLAtoms::value == aName) {
|
||||
if (mTextFrame) {
|
||||
mTextFrame->GetTextControlFrameState(aValue);
|
||||
mTextFrame->GetValue(aValue, PR_FALSE);
|
||||
}
|
||||
else if (mCachedState) {
|
||||
aValue.Assign(*mCachedState);
|
||||
|
|
|
@ -53,7 +53,23 @@ public:
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ nsIsIndexFrame::GetInputValue(nsIPresContext* aPresContext,
|
|||
nsIFormControlFrame* frame = nsnull;
|
||||
GetInputFrame(aPresContext, &frame);
|
||||
if (frame) {
|
||||
((nsNewFrame*)frame)->GetTextControlFrameState(oString);
|
||||
((nsNewFrame*)frame)->GetValue(oString, PR_FALSE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ nsIsIndexFrame::SetInputValue(nsIPresContext* aPresContext,
|
|||
nsIFormControlFrame* frame = nsnull;
|
||||
GetInputFrame(aPresContext, &frame);
|
||||
if (frame) {
|
||||
((nsNewFrame*)frame)->SetTextControlFrameState(aString);
|
||||
((nsNewFrame*)frame)->SetValue(aString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,23 @@ public:
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -53,7 +53,23 @@ public:
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -632,7 +632,7 @@ NS_IMETHODIMP nsFileControlFrame::SetProperty(nsIPresContext* aPresContext,
|
|||
nsresult rv = NS_OK;
|
||||
if (nsHTMLAtoms::value == aName) {
|
||||
if (mTextFrame) {
|
||||
mTextFrame->SetTextControlFrameState(aValue);
|
||||
mTextFrame->SetValue(aValue);
|
||||
} else {
|
||||
if (mCachedState) delete mCachedState;
|
||||
mCachedState = new nsString(aValue);
|
||||
|
@ -648,7 +648,7 @@ NS_IMETHODIMP nsFileControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
|
|||
|
||||
if (nsHTMLAtoms::value == aName) {
|
||||
if (mTextFrame) {
|
||||
mTextFrame->GetTextControlFrameState(aValue);
|
||||
mTextFrame->GetValue(aValue, PR_FALSE);
|
||||
}
|
||||
else if (mCachedState) {
|
||||
aValue.Assign(*mCachedState);
|
||||
|
|
|
@ -1423,14 +1423,14 @@ nsGfxTextControlFrame2::PreDestroy(nsIPresContext* aPresContext)
|
|||
{
|
||||
// First get the frame state from the editor
|
||||
nsAutoString value;
|
||||
GetTextControlFrameState(value);
|
||||
GetValue(value, PR_TRUE);
|
||||
|
||||
mUseEditor = PR_FALSE;
|
||||
|
||||
// Next store the frame state in the control
|
||||
// (now that mUseEditor is false values get stored
|
||||
// in content).
|
||||
SetTextControlFrameState(value);
|
||||
SetValue(value);
|
||||
}
|
||||
mEditor->PreDestroy();
|
||||
}
|
||||
|
@ -1836,7 +1836,7 @@ nsGfxTextControlFrame2::SetInitialValue()
|
|||
|
||||
// Get the current value of the textfield from the content.
|
||||
nsAutoString defaultValue;
|
||||
GetTextControlFrameState(defaultValue);
|
||||
GetValue(defaultValue, PR_TRUE);
|
||||
|
||||
// Turn on mUseEditor so that subsequent calls will use the
|
||||
// editor.
|
||||
|
@ -1844,8 +1844,8 @@ nsGfxTextControlFrame2::SetInitialValue()
|
|||
|
||||
// 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
|
||||
// displayed for password fields, etc. SetTextControlFrameState()
|
||||
// will call the editor for us.
|
||||
// displayed for password fields, etc. SetValue() will call the
|
||||
// editor for us.
|
||||
|
||||
if (!defaultValue.IsEmpty()) {
|
||||
PRUint32 editorFlags = 0;
|
||||
|
@ -1866,18 +1866,17 @@ nsGfxTextControlFrame2::SetInitialValue()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Now call SetTextControlFrameState() which will make the
|
||||
// neccessary editor calls to set the default value.
|
||||
// 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 past the default value.
|
||||
// Now call SetValue() which will make the neccessary editor calls to set
|
||||
// the default value. 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
|
||||
// past the default value.
|
||||
|
||||
rv = mEditor->EnableUndo(PR_FALSE);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
SetTextControlFrameState(defaultValue);
|
||||
SetValue(defaultValue);
|
||||
|
||||
rv = mEditor->EnableUndo(PR_TRUE);
|
||||
NS_ASSERTION(!rv,"Transaction Manager must have failed");
|
||||
|
@ -2584,7 +2583,7 @@ NS_IMETHODIMP nsGfxTextControlFrame2::SetProperty(nsIPresContext* aPresContext,
|
|||
// has changed.
|
||||
SetValueChanged(PR_TRUE);
|
||||
}
|
||||
SetTextControlFrameState(aValue); // set new text value
|
||||
SetValue(aValue); // set new text value
|
||||
if (mEditor) {
|
||||
mEditor->EnableUndo(PR_TRUE); // fire up a new txn stack
|
||||
}
|
||||
|
@ -2599,13 +2598,14 @@ NS_IMETHODIMP nsGfxTextControlFrame2::SetProperty(nsIPresContext* aPresContext,
|
|||
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.
|
||||
// If widget is null, assume the widget is GFX-rendered and return a member variable instead.
|
||||
|
||||
if (nsHTMLAtoms::value == aName) {
|
||||
GetTextControlFrameState(aValue);
|
||||
GetValue(aValue, PR_FALSE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2635,7 +2635,7 @@ nsGfxTextControlFrame2::GetTextLength(PRInt32* aTextLength)
|
|||
NS_ENSURE_ARG_POINTER(aTextLength);
|
||||
|
||||
nsAutoString textContents;
|
||||
GetTextControlFrameState(textContents); // this is expensive!
|
||||
GetValue(textContents, PR_FALSE); // this is expensive!
|
||||
*aTextLength = textContents.Length();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3065,7 +3065,8 @@ nsGfxTextControlFrame2::GetText(nsString* aText)
|
|||
PRInt32 type;
|
||||
GetType(&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);
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(mContent);
|
||||
|
@ -3244,7 +3245,8 @@ nsGfxTextControlFrame2::CallOnChange()
|
|||
//======
|
||||
//privates
|
||||
|
||||
void nsGfxTextControlFrame2::GetTextControlFrameState(nsAString& aValue)
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::GetValue(nsAString& aValue, PRBool aIgnoreWrap)
|
||||
{
|
||||
aValue.Truncate(); // initialize out param
|
||||
|
||||
|
@ -3257,14 +3259,16 @@ void nsGfxTextControlFrame2::GetTextControlFrameState(nsAString& aValue)
|
|||
flags |= nsIDocumentEncoder::OutputBodyOnly;
|
||||
}
|
||||
|
||||
nsFormControlHelper::nsHTMLTextWrap wrapProp;
|
||||
nsresult rv = nsFormControlHelper::GetWrapPropertyEnum(mContent, wrapProp);
|
||||
flags |= nsIDocumentEncoder::OutputPreformatted;
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != rv)
|
||||
{
|
||||
if (wrapProp == nsFormControlHelper::eHTMLTextWrap_Hard)
|
||||
{
|
||||
flags |= nsIDocumentEncoder::OutputWrap;
|
||||
|
||||
if (!aIgnoreWrap) {
|
||||
nsFormControlHelper::nsHTMLTextWrap wrapProp;
|
||||
nsresult rv = nsFormControlHelper::GetWrapPropertyEnum(mContent, wrapProp);
|
||||
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
|
||||
|
||||
void
|
||||
nsGfxTextControlFrame2::SetTextControlFrameState(const nsAString& aValue)
|
||||
nsGfxTextControlFrame2::SetValue(const nsAString& aValue)
|
||||
{
|
||||
if (mEditor && mUseEditor)
|
||||
{
|
||||
nsAutoString currentValue;
|
||||
GetTextControlFrameState(currentValue);
|
||||
GetValue(currentValue, PR_FALSE);
|
||||
if (IsSingleLineTextControl())
|
||||
{
|
||||
RemoveNewlines(currentValue);
|
||||
|
|
|
@ -116,9 +116,8 @@ public:
|
|||
NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext,
|
||||
nsISupportsArray& aChildList);
|
||||
|
||||
// Utility methods to get and set current widget state
|
||||
void GetTextControlFrameState(nsAString& aValue);
|
||||
void SetTextControlFrameState(const nsAString& aValue);
|
||||
// Utility methods to set current widget state
|
||||
void SetValue(const nsAString& aValue);
|
||||
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
|
||||
nsIAtom* aListName,
|
||||
nsIFrame* aChildList);
|
||||
|
@ -153,6 +152,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor);
|
||||
NS_IMETHOD OwnsValue(PRBool* aOwnsValue);
|
||||
NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap);
|
||||
NS_IMETHOD GetTextLength(PRInt32* aTextLength);
|
||||
NS_IMETHOD SetSelectionStart(PRInt32 aSelectionStart);
|
||||
NS_IMETHOD SetSelectionEnd(PRInt32 aSelectionEnd);
|
||||
|
|
|
@ -193,7 +193,7 @@ nsIsIndexFrame::GetInputValue(nsIPresContext* aPresContext,
|
|||
nsIFormControlFrame* frame = nsnull;
|
||||
GetInputFrame(aPresContext, &frame);
|
||||
if (frame) {
|
||||
((nsNewFrame*)frame)->GetTextControlFrameState(oString);
|
||||
((nsNewFrame*)frame)->GetValue(oString, PR_FALSE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ nsIsIndexFrame::SetInputValue(nsIPresContext* aPresContext,
|
|||
nsIFormControlFrame* frame = nsnull;
|
||||
GetInputFrame(aPresContext, &frame);
|
||||
if (frame) {
|
||||
((nsNewFrame*)frame)->SetTextControlFrameState(aString);
|
||||
((nsNewFrame*)frame)->SetValue(aString);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче