1999-08-06 05:13:07 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-08-06 05:13:07 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-08-06 05:13:07 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-08-06 05:13:07 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-08-06 05:13:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsGfxButtonControlFrame.h"
|
|
|
|
#include "nsIButton.h"
|
1999-08-10 19:13:57 +00:00
|
|
|
#include "nsWidgetsCID.h"
|
1999-11-22 22:04:53 +00:00
|
|
|
#include "nsIFontMetrics.h"
|
2000-01-09 02:07:00 +00:00
|
|
|
#include "nsFormControlFrame.h"
|
2000-02-21 05:55:25 +00:00
|
|
|
#include "nsISupportsArray.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-02-19 21:50:04 +00:00
|
|
|
#include "nsContentCID.h"
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
|
2001-02-19 21:50:04 +00:00
|
|
|
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
1999-08-06 05:13:07 +00:00
|
|
|
|
2001-02-06 01:31:18 +00:00
|
|
|
// Saving PresState
|
|
|
|
#include "nsIPresState.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
const nscoord kSuggestedNotSet = -1;
|
|
|
|
|
|
|
|
nsGfxButtonControlFrame::nsGfxButtonControlFrame()
|
|
|
|
{
|
|
|
|
mRenderer.SetNameSpace(kNameSpaceID_None);
|
|
|
|
mSuggestedWidth = kSuggestedNotSet;
|
|
|
|
mSuggestedHeight = kSuggestedNotSet;
|
2001-03-14 07:36:01 +00:00
|
|
|
mDefaultValueWasChanged = PR_FALSE;
|
1999-08-10 19:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsGfxButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
|
|
|
{
|
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
2000-08-03 23:32:02 +00:00
|
|
|
PRBool successful = PR_TRUE;
|
1999-08-10 19:13:57 +00:00
|
|
|
if ((NS_FORM_INPUT_HIDDEN == type) || (this == aSubmitter)) {
|
1999-08-12 22:06:09 +00:00
|
|
|
// Can not use the nsHTMLButtonControlFrame::IsSuccessful because
|
|
|
|
// it will fail it's test of (this==aSubmitter)
|
|
|
|
nsAutoString name;
|
2000-08-03 23:32:02 +00:00
|
|
|
PRBool disabled = PR_FALSE;
|
|
|
|
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
|
|
|
successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
1999-08-10 19:13:57 +00:00
|
|
|
} else {
|
2000-08-03 23:32:02 +00:00
|
|
|
successful = PR_FALSE;
|
1999-08-10 19:13:57 +00:00
|
|
|
}
|
2000-08-03 23:32:02 +00:00
|
|
|
return successful;
|
1999-08-10 19:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsGfxButtonControlFrame::GetMaxNumValues()
|
|
|
|
{
|
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
|
|
|
if ((NS_FORM_INPUT_SUBMIT == type) || (NS_FORM_INPUT_HIDDEN == type)) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsGfxButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
|
|
nsString* aValues, nsString* aNames)
|
|
|
|
{
|
|
|
|
nsAutoString name;
|
|
|
|
nsresult result = GetName(&name);
|
|
|
|
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
|
|
|
|
|
|
|
if (NS_FORM_INPUT_RESET == type) {
|
|
|
|
aNumValues = 0;
|
|
|
|
return PR_FALSE;
|
|
|
|
} else {
|
|
|
|
nsAutoString value;
|
|
|
|
GetValue(&value);
|
|
|
|
aValues[0] = value;
|
|
|
|
aNames[0] = name;
|
|
|
|
aNumValues = 1;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-06 05:13:07 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1999-08-06 05:13:07 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsGfxButtonControlFrame* it = new (aPresShell) nsGfxButtonControlFrame;
|
1999-08-06 05:13:07 +00:00
|
|
|
if (!it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-13 20:40:59 +00:00
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
|
1999-09-13 20:40:59 +00:00
|
|
|
PRBool
|
|
|
|
nsGfxButtonControlFrame::IsReset(PRInt32 type)
|
|
|
|
{
|
|
|
|
if (NS_FORM_INPUT_RESET == type) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
|
|
|
|
1999-09-13 20:40:59 +00:00
|
|
|
PRBool
|
|
|
|
nsGfxButtonControlFrame::IsSubmit(PRInt32 type)
|
|
|
|
{
|
|
|
|
if (NS_FORM_INPUT_SUBMIT == type) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-21 05:55:25 +00:00
|
|
|
// Special check for the browse button of a file input.
|
|
|
|
//
|
|
|
|
// Since this is actually type "NS_FORM_INPUT_BUTTON", we
|
|
|
|
// can't tell if it is part of a file input by the type.
|
|
|
|
// We'll return PR_TRUE if either:
|
|
|
|
// (a) type is NS_FORM_BROWSE or
|
|
|
|
// (b) type is NS_FORM_INPUT_BUTTON and our parent is a file input
|
|
|
|
PRBool
|
|
|
|
nsGfxButtonControlFrame::IsBrowse(PRInt32 type)
|
|
|
|
{
|
2000-02-23 20:56:39 +00:00
|
|
|
PRBool rv = PR_FALSE;
|
2000-02-21 05:55:25 +00:00
|
|
|
if (NS_FORM_BROWSE == type) {
|
2000-02-23 20:56:39 +00:00
|
|
|
rv = PR_TRUE;
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
2000-02-23 20:56:39 +00:00
|
|
|
else if (NS_FORM_INPUT_BUTTON == type) {
|
2000-02-21 05:55:25 +00:00
|
|
|
|
|
|
|
// Check to see if parent is a file input
|
2000-02-23 20:56:39 +00:00
|
|
|
nsresult result;
|
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
|
|
|
result = mContent->GetParent(*getter_AddRefs(parentContent));
|
|
|
|
if (NS_SUCCEEDED(result) && parentContent) {
|
|
|
|
nsCOMPtr<nsIAtom> atom;
|
|
|
|
result = parentContent->GetTag(*getter_AddRefs(atom));
|
|
|
|
if (NS_SUCCEEDED(result) && atom) {
|
|
|
|
if (atom.get() == nsHTMLAtoms::input) {
|
|
|
|
|
|
|
|
// It's an input, is it a file input?
|
|
|
|
nsAutoString value;
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == parentContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
|
|
|
|
if (value.EqualsIgnoreCase("file")) {
|
|
|
|
rv = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-02-23 20:56:39 +00:00
|
|
|
return rv;
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 22:24:56 +00:00
|
|
|
/*
|
|
|
|
* FIXME: this ::GetIID() method has no meaning in life and should be
|
|
|
|
* removed.
|
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
|
|
*/
|
1999-08-10 19:13:57 +00:00
|
|
|
const nsIID&
|
|
|
|
nsGfxButtonControlFrame::GetIID()
|
1999-08-06 05:13:07 +00:00
|
|
|
{
|
2001-01-04 20:44:42 +00:00
|
|
|
return NS_GET_IID(nsIButton);
|
1999-08-10 19:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsIID&
|
|
|
|
nsGfxButtonControlFrame::GetCID()
|
|
|
|
{
|
|
|
|
static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID);
|
|
|
|
return kButtonCID;
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1999-08-06 05:13:07 +00:00
|
|
|
NS_IMETHODIMP
|
1999-08-10 19:13:57 +00:00
|
|
|
nsGfxButtonControlFrame::GetFrameName(nsString& aResult) const
|
1999-08-06 05:13:07 +00:00
|
|
|
{
|
1999-08-10 19:13:57 +00:00
|
|
|
return MakeFrameName("ButtonControl", aResult);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-08-06 05:13:07 +00:00
|
|
|
|
1999-08-31 13:03:38 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aSuggestedReflowState)
|
|
|
|
{
|
|
|
|
if (kSuggestedNotSet == mSuggestedWidth) {
|
|
|
|
aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kSuggestedNotSet == mSuggestedHeight) {
|
|
|
|
aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-22 22:04:53 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsGfxButtonControlFrame::DoNavQuirksReflow(nsIPresContext* aPresContext,
|
1999-11-22 22:04:53 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFontMetrics> fontMet;
|
2000-01-25 15:25:07 +00:00
|
|
|
nsresult res = nsFormControlHelper::GetFrameFontFM(aPresContext, (nsIFormControlFrame *)this, getter_AddRefs(fontMet));
|
1999-11-22 22:04:53 +00:00
|
|
|
nsSize desiredSize;
|
2000-01-25 15:25:07 +00:00
|
|
|
if (NS_SUCCEEDED(res) && fontMet) {
|
1999-11-22 22:04:53 +00:00
|
|
|
aReflowState.rendContext->SetFont(fontMet);
|
|
|
|
|
|
|
|
// Get the text from the "value" attribute
|
|
|
|
// for measuring the height, width of the text
|
|
|
|
nsAutoString value;
|
|
|
|
GetValue(&value);
|
|
|
|
|
2000-02-23 20:56:39 +00:00
|
|
|
if (value.Length() == 0) {
|
|
|
|
// Generate localized label.
|
|
|
|
// We can't make any assumption as to what the default would be
|
|
|
|
// because the value is localized for non-english platforms, thus
|
|
|
|
// it might not be the string "Reset", "Submit Query", or "Browse..."
|
|
|
|
res = GetDefaultLabel(value);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-05 20:48:37 +00:00
|
|
|
const nsStyleText* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_Text, (const nsStyleStruct *&)textStyle);
|
|
|
|
if (!textStyle->WhiteSpaceIsSignificant()) {
|
|
|
|
value.CompressWhitespace();
|
|
|
|
if (value.Length() == 0) {
|
2000-04-16 11:19:26 +00:00
|
|
|
value.AssignWithConversion(" ");
|
1999-12-05 20:48:37 +00:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 22:04:53 +00:00
|
|
|
|
|
|
|
nsInputDimensionSpec btnSpec(NULL, PR_FALSE, nsnull,
|
|
|
|
&value,0,
|
|
|
|
PR_FALSE, NULL, 1);
|
|
|
|
nsFormControlHelper::CalcNavQuirkSizing(aPresContext, aReflowState.rendContext,
|
|
|
|
fontMet, (nsIFormControlFrame*)this,
|
|
|
|
btnSpec, desiredSize);
|
|
|
|
|
|
|
|
// This calculates the reflow size
|
|
|
|
// get the css size and let the frame use or override it
|
|
|
|
nsSize styleSize;
|
|
|
|
nsFormControlFrame::GetStyleSize(aPresContext, aReflowState, styleSize);
|
|
|
|
|
|
|
|
if (CSS_NOTSET != styleSize.width) { // css provides width
|
2000-12-20 15:09:55 +00:00
|
|
|
NS_ASSERTION(styleSize.width+aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right >= 0, "form control's computed width is < 0");
|
1999-11-22 22:04:53 +00:00
|
|
|
if (NS_INTRINSICSIZE != styleSize.width) {
|
|
|
|
desiredSize.width = styleSize.width;
|
|
|
|
desiredSize.width += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CSS_NOTSET != styleSize.height) { // css provides height
|
|
|
|
NS_ASSERTION(styleSize.height > 0, "form control's computed height is <= 0");
|
|
|
|
if (NS_INTRINSICSIZE != styleSize.height) {
|
|
|
|
desiredSize.height = styleSize.height;
|
|
|
|
desiredSize.height += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aDesiredSize.width = desiredSize.width;
|
|
|
|
aDesiredSize.height = desiredSize.height;
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
} else {
|
|
|
|
// XXX ASSERT HERE
|
|
|
|
desiredSize.width = 0;
|
|
|
|
desiredSize.height = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove it from the the desired size
|
|
|
|
// because the content need to fit inside of it
|
|
|
|
desiredSize.width -= (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
|
|
|
desiredSize.height -= (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
|
|
|
|
2000-12-20 15:09:55 +00:00
|
|
|
// Ok, now we think we know what size we are so we can reflow our contents
|
|
|
|
// But we need to make sure we aren't smaller or larger then the min/max
|
|
|
|
if (desiredSize.width < aReflowState.mComputedMinWidth) {
|
|
|
|
desiredSize.width = aReflowState.mComputedMinWidth - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
|
|
|
} else if (desiredSize.width > aReflowState.mComputedMaxWidth) {
|
|
|
|
desiredSize.width = aReflowState.mComputedMaxWidth - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desiredSize.height < aReflowState.mComputedMinHeight) {
|
|
|
|
desiredSize.height = aReflowState.mComputedMinHeight - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
|
|
|
} else if (desiredSize.height > aReflowState.mComputedMaxHeight) {
|
|
|
|
desiredSize.height = aReflowState.mComputedMaxHeight - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
|
|
|
}
|
|
|
|
|
1999-11-22 22:04:53 +00:00
|
|
|
// now reflow the first child (genertaed content)
|
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, firstKid, desiredSize);
|
|
|
|
reflowState.mComputedWidth = desiredSize.width;
|
|
|
|
reflowState.mComputedHeight = desiredSize.height;
|
|
|
|
// XXX Proper handling of incremental reflow...
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
|
|
|
|
// See if it's targeted at us
|
|
|
|
aReflowState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
if (this == targetFrame) {
|
1999-11-24 06:03:41 +00:00
|
|
|
Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
|
1999-11-22 22:04:53 +00:00
|
|
|
|
|
|
|
nsIReflowCommand::ReflowType reflowType;
|
|
|
|
aReflowState.reflowCommand->GetType(reflowType);
|
|
|
|
if (nsIReflowCommand::StyleChanged == reflowType) {
|
|
|
|
reflowState.reason = eReflowReason_StyleChange;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
reflowState.reason = eReflowReason_Resize;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
|
|
|
|
// Remove the next frame from the reflow path
|
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
}
|
|
|
|
}
|
1999-11-24 20:59:49 +00:00
|
|
|
|
1999-11-22 22:04:53 +00:00
|
|
|
nsHTMLReflowMetrics childReflowMetrics(aDesiredSize);
|
|
|
|
nsRect kidRect;
|
|
|
|
firstKid->GetRect(kidRect);
|
|
|
|
ReflowChild(firstKid, aPresContext, childReflowMetrics, reflowState, kidRect.x, kidRect.y, 0, aStatus);
|
|
|
|
|
|
|
|
// Now do the reverse calculation of the
|
|
|
|
// NavQuirks button to get the size of the text
|
2000-01-18 23:23:52 +00:00
|
|
|
//nscoord textWidth = (2 * aDesiredSize.width) / 3;
|
1999-11-22 22:04:53 +00:00
|
|
|
nscoord textHeight = (2 * aDesiredSize.height) / 3;
|
|
|
|
|
|
|
|
// Center the child and add back in the border and badding
|
2000-01-18 20:29:22 +00:00
|
|
|
// our inner area frame is already doing centering so we only need to center vertically.
|
|
|
|
nsRect rect = nsRect(aReflowState.mComputedBorderPadding.left,
|
1999-11-22 22:04:53 +00:00
|
|
|
((desiredSize.height - textHeight)/2) + aReflowState.mComputedBorderPadding.top,
|
|
|
|
desiredSize.width,
|
|
|
|
desiredSize.height);
|
1999-11-24 06:03:41 +00:00
|
|
|
firstKid->SetRect(aPresContext, rect);
|
1999-11-22 22:04:53 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-21 05:55:25 +00:00
|
|
|
// Create the text content used as label for the button.
|
|
|
|
// The frame will be generated by the frame constructor.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
|
|
|
nsISupportsArray& aChildList)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
|
|
|
|
// Get the text from the "value" attribute.
|
|
|
|
// If it is zero length, set it to a default value (localized)
|
|
|
|
nsAutoString initvalue, value;
|
|
|
|
GetValue(&initvalue);
|
|
|
|
value = initvalue;
|
|
|
|
if (value.Length() == 0) {
|
|
|
|
// Generate localized label.
|
|
|
|
// We can't make any assumption as to what the default would be
|
|
|
|
// because the value is localized for non-english platforms, thus
|
|
|
|
// it might not be the string "Reset", "Submit Query", or "Browse..."
|
|
|
|
result = GetDefaultLabel(value);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compress whitespace out of label if needed.
|
|
|
|
const nsStyleText* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_Text, (const nsStyleStruct *&)textStyle);
|
|
|
|
if (!textStyle->WhiteSpaceIsSignificant()) {
|
|
|
|
value.CompressWhitespace();
|
|
|
|
if (value.Length() == 0) {
|
2000-04-16 11:19:26 +00:00
|
|
|
value.AssignWithConversion(" ");
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add a child text content node for the label
|
2001-02-19 21:50:04 +00:00
|
|
|
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
|
2000-02-21 05:55:25 +00:00
|
|
|
if (NS_SUCCEEDED(result) && labelContent) {
|
2000-02-23 20:56:39 +00:00
|
|
|
// set the value of the text node and add it to the child list
|
|
|
|
mTextContent = do_QueryInterface(labelContent, &result);
|
|
|
|
if (NS_SUCCEEDED(result) && mTextContent) {
|
|
|
|
mTextContent->SetText(value.GetUnicode(), value.Length(), PR_TRUE);
|
|
|
|
aChildList.AppendElement(mTextContent);
|
|
|
|
}
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-08-23 10:38:42 +00:00
|
|
|
// Create the text content used as label for the button.
|
|
|
|
// The frame will be generated by the frame constructor.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext,
|
|
|
|
nsIContent * aContent,
|
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
nsIFrame * newFrame = nsnull;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
*aFrame = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mTextContent));
|
|
|
|
if (aContent == content.get()) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
|
|
|
|
nsIFrame * parentFrame = mFrames.FirstChild();
|
|
|
|
nsCOMPtr<nsIStyleContext> styleContext;
|
|
|
|
parentFrame->GetStyleContext(getter_AddRefs(styleContext));
|
|
|
|
|
|
|
|
rv = NS_NewTextFrame(shell, &newFrame);
|
|
|
|
if (NS_FAILED(rv)) { return rv; }
|
|
|
|
if (!newFrame) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
nsCOMPtr<nsIStyleContext> textStyleContext;
|
|
|
|
rv = aPresContext->ResolvePseudoStyleContextFor(content,
|
|
|
|
nsHTMLAtoms::textPseudo,
|
|
|
|
styleContext,
|
|
|
|
PR_FALSE,
|
|
|
|
getter_AddRefs(textStyleContext));
|
|
|
|
if (NS_FAILED(rv)) { return rv; }
|
|
|
|
if (!textStyleContext) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
|
|
|
|
if (styleContext) {
|
|
|
|
// initialize the text frame
|
|
|
|
newFrame->Init(aPresContext, content, parentFrame, textStyleContext, nsnull);
|
|
|
|
newFrame->SetInitialChildList(aPresContext, nsnull, nsnull);
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aFrame) {
|
|
|
|
*aFrame = newFrame;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-02-21 05:55:25 +00:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
2001-02-06 01:31:18 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIAnonymousContentCreator*, this);
|
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIStatefulFrame*, this);
|
2001-04-01 01:01:33 +00:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
|
|
|
|
if (accService) {
|
2001-04-17 23:06:38 +00:00
|
|
|
nsIAccessible* acc = nsnull;
|
|
|
|
accService->CreateHTMLButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), &acc);
|
2001-04-01 01:01:33 +00:00
|
|
|
*aInstancePtr = acc;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2001-04-17 23:06:38 +00:00
|
|
|
|
2001-04-01 01:01:33 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-02-06 01:31:18 +00:00
|
|
|
return nsHTMLButtonControlFrame::QueryInterface(aIID, aInstancePtr);
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
2001-02-06 01:31:18 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initially we hardcoded the default strings here.
|
|
|
|
// Next, we used html.css to store the default label for various types
|
|
|
|
// of buttons. (nsGfxButtonControlFrame::DoNavQuirksReflow rev 1.20)
|
|
|
|
// However, since html.css is not internationalized, we now grab the default
|
|
|
|
// label from a string bundle as is done for all other UI strings.
|
|
|
|
// See bug 16999 for further details.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString)
|
|
|
|
{
|
2001-01-27 14:09:34 +00:00
|
|
|
const char * propname = nsFormControlHelper::GetHTMLPropertiesFileName();
|
2000-02-21 05:55:25 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
|
|
|
if (IsReset(type)) {
|
2001-01-27 14:09:34 +00:00
|
|
|
rv = nsFormControlHelper::GetLocalizedString(propname, "Reset", aString);
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
else if (IsSubmit(type)) {
|
2001-01-27 14:09:34 +00:00
|
|
|
rv = nsFormControlHelper::GetLocalizedString(propname, "Submit", aString);
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
else if (IsBrowse(type)) {
|
2001-01-27 14:09:34 +00:00
|
|
|
rv = nsFormControlHelper::GetLocalizedString(propname, "Browse", aString);
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-04-16 11:19:26 +00:00
|
|
|
aString.AssignWithConversion(" ");
|
2000-02-21 05:55:25 +00:00
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
2000-02-23 20:56:39 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-02-21 05:55:25 +00:00
|
|
|
// If the value attribute is set, update the text of the label
|
|
|
|
if (nsHTMLAtoms::value == aAttribute) {
|
2000-02-23 20:56:39 +00:00
|
|
|
nsAutoString value;
|
|
|
|
if (mTextContent && mContent) {
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE != mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value)) {
|
2000-04-16 11:19:26 +00:00
|
|
|
value.SetLength(0);
|
2000-02-23 20:56:39 +00:00
|
|
|
}
|
|
|
|
rv = mTextContent->SetText(value.GetUnicode(), value.Length(), PR_TRUE);
|
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
2001-03-14 07:36:01 +00:00
|
|
|
mDefaultValueWasChanged = PR_TRUE;
|
2000-02-21 05:55:25 +00:00
|
|
|
|
2000-02-23 20:56:39 +00:00
|
|
|
// defer to HTMLButtonControlFrame
|
|
|
|
} else {
|
|
|
|
rv = nsHTMLButtonControlFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint);
|
|
|
|
}
|
|
|
|
return rv;
|
2000-02-21 05:55:25 +00:00
|
|
|
}
|
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
1999-10-07 21:07:38 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-08-06 05:13:07 +00:00
|
|
|
{
|
2000-04-21 21:51:35 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", aReflowState.reason);
|
|
|
|
|
1999-09-13 20:40:59 +00:00
|
|
|
// The mFormFrame is set in the initial reflow within nsHTMLButtonControlFrame
|
1999-10-07 21:07:38 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-02-21 05:55:25 +00:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
if (!mFormFrame) {
|
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
|
|
|
}
|
1999-11-24 21:37:34 +00:00
|
|
|
}
|
1999-08-06 05:13:07 +00:00
|
|
|
|
2000-02-09 19:34:39 +00:00
|
|
|
#if 0
|
2000-01-09 02:07:00 +00:00
|
|
|
nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementSize, aPresContext,
|
|
|
|
aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(skiprv)) {
|
|
|
|
return skiprv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-02-29 13:17:33 +00:00
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
|
|
|
// hidden inputs are zero width/height and are finished here
|
|
|
|
if (NS_FORM_INPUT_HIDDEN == type) {
|
|
|
|
aDesiredSize.width = aDesiredSize.height = aDesiredSize.ascent = aDesiredSize.descent = 0;
|
|
|
|
if (aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
// just in case the hidden input is the target of an incremental reflow
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
aReflowState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
if (this == targetFrame) {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
// Remove the next frame from the reflow path
|
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
if ((kSuggestedNotSet != mSuggestedWidth) ||
|
1999-08-31 13:03:38 +00:00
|
|
|
(kSuggestedNotSet != mSuggestedHeight)) {
|
1999-08-10 19:13:57 +00:00
|
|
|
nsHTMLReflowState suggestedReflowState(aReflowState);
|
1999-08-31 13:03:38 +00:00
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
// Honor the suggested width and/or height.
|
|
|
|
if (kSuggestedNotSet != mSuggestedWidth) {
|
|
|
|
suggestedReflowState.mComputedWidth = mSuggestedWidth;
|
|
|
|
}
|
1999-08-06 05:13:07 +00:00
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
if (kSuggestedNotSet != mSuggestedHeight) {
|
|
|
|
suggestedReflowState.mComputedHeight = mSuggestedHeight;
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
|
|
|
|
1999-10-07 21:07:38 +00:00
|
|
|
rv = nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus);
|
1999-08-06 05:13:07 +00:00
|
|
|
|
1999-08-31 13:03:38 +00:00
|
|
|
} else { // Normal reflow.
|
1999-11-22 22:04:53 +00:00
|
|
|
|
|
|
|
nsCompatibility mode;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
1999-11-22 22:04:53 +00:00
|
|
|
|
|
|
|
if (mode == eCompatibility_NavQuirks) {
|
2000-02-09 19:34:39 +00:00
|
|
|
// nsHTMLButtonControlFrame::Reflow registers it for Standard Mode
|
|
|
|
// and sets up mPresContext
|
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
|
|
|
}
|
1999-11-22 22:04:53 +00:00
|
|
|
// Do NavQuirks Sizing and layout
|
2000-12-20 15:09:55 +00:00
|
|
|
rv = DoNavQuirksReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
// Make sure we obey min/max-width and min/max-height
|
|
|
|
if (aDesiredSize.width > aReflowState.mComputedMaxWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedMaxWidth;
|
|
|
|
}
|
|
|
|
if (aDesiredSize.width < aReflowState.mComputedMinWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedMinWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDesiredSize.height > aReflowState.mComputedMaxHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedMaxHeight;
|
|
|
|
}
|
|
|
|
if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedMinHeight;
|
|
|
|
}
|
|
|
|
|
1999-11-22 22:04:53 +00:00
|
|
|
} else {
|
|
|
|
// Do Standard mode sizing and layout
|
|
|
|
rv = nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
1999-10-07 21:07:38 +00:00
|
|
|
|
1999-11-24 20:59:49 +00:00
|
|
|
#ifdef DEBUG_rodsXXXX
|
1999-11-22 22:04:53 +00:00
|
|
|
COMPARE_QUIRK_SIZE("nsGfxButtonControlFrame", 84, 24) // with the text "Press Me" in it
|
|
|
|
#endif
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-10-07 21:07:38 +00:00
|
|
|
|
2000-01-09 02:07:00 +00:00
|
|
|
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize);
|
|
|
|
|
2000-03-14 14:25:05 +00:00
|
|
|
if (aDesiredSize.maxElementSize != nsnull) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
1999-10-07 21:07:38 +00:00
|
|
|
return rv;
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
1999-08-06 05:13:07 +00:00
|
|
|
{
|
1999-08-10 19:13:57 +00:00
|
|
|
mSuggestedWidth = aWidth;
|
|
|
|
mSuggestedHeight = aHeight;
|
2000-03-07 15:54:31 +00:00
|
|
|
//mState |= NS_FRAME_IS_DIRTY;
|
1999-08-10 19:13:57 +00:00
|
|
|
return NS_OK;
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-08-10 19:13:57 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-08-06 05:13:07 +00:00
|
|
|
{
|
1999-08-10 19:13:57 +00:00
|
|
|
// Override the HandleEvent to prevent the nsFrame::HandleEvent
|
|
|
|
// from being called. The nsFrame::HandleEvent causes the button label
|
|
|
|
// to be selected (Drawn with an XOR rectangle over the label)
|
|
|
|
|
2000-05-31 02:24:48 +00:00
|
|
|
// Do nothing here, nsHTMLInputElement::HandleDOMEvent
|
|
|
|
// takes cares of calling MouseClicked for us.
|
1999-08-10 19:13:57 +00:00
|
|
|
|
2000-08-08 23:38:00 +00:00
|
|
|
// do we have user-input style?
|
|
|
|
const nsStyleUserInterface* uiStyle;
|
2000-08-09 00:52:02 +00:00
|
|
|
GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct *&)uiStyle);
|
2000-08-08 23:38:00 +00:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
1999-08-10 19:13:57 +00:00
|
|
|
return NS_OK;
|
1999-08-06 05:13:07 +00:00
|
|
|
}
|
1999-08-10 19:13:57 +00:00
|
|
|
|
2001-02-06 01:31:18 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::GetStateType(nsIPresContext* aPresContext, nsIStatefulFrame::StateType* aStateType)
|
|
|
|
{
|
|
|
|
*aStateType = nsIStatefulFrame::eTextType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
|
|
|
// Get the value string
|
|
|
|
nsAutoString stateString;
|
|
|
|
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
|
|
|
|
// Compare to default value, and only save if needed (Bug 62713)
|
|
|
|
nsAutoString defaultStateString;
|
2001-03-14 07:36:01 +00:00
|
|
|
if (!mDefaultValueWasChanged) {
|
|
|
|
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
|
|
|
|
if (formControl) {
|
|
|
|
formControl->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, defaultStateString);
|
|
|
|
}
|
2001-02-06 01:31:18 +00:00
|
|
|
}
|
|
|
|
|
2001-03-14 07:36:01 +00:00
|
|
|
if (mDefaultValueWasChanged || !stateString.Equals(defaultStateString)) {
|
2001-02-06 01:31:18 +00:00
|
|
|
|
|
|
|
// Construct a pres state and store value in it.
|
|
|
|
res = NS_NewPresState(aState);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
|
|
|
// Set the value to the stored state.
|
|
|
|
nsAutoString stateString;
|
|
|
|
nsresult res = aState->GetStateProperty(NS_LITERAL_STRING("value"), stateString);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
1999-08-10 19:13:57 +00:00
|
|
|
|
2001-02-06 01:31:18 +00:00
|
|
|
return SetProperty(aPresContext, nsHTMLAtoms::value, stateString);
|
|
|
|
}
|