зеркало из https://github.com/mozilla/gecko-dev.git
added <input type=image>, fixed bug where multiple submit buttons sent data
This commit is contained in:
Родитель
1a4f03769f
Коммит
0af793f7f1
|
@ -69,10 +69,18 @@ public:
|
|||
* @param aNumValues the actual number of values set (out parm)
|
||||
* @param aValues an array of nsString which contains the values (out parm
|
||||
* that is allocated by the caller)
|
||||
* @param aNames an array of nsString which contains the names (out parm
|
||||
* that is allocated by the caller)
|
||||
* @return PR_TRUE if any values were set, PR_FALSE otherwise
|
||||
*/
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues) = 0;
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames) = 0;
|
||||
|
||||
/**
|
||||
* Return true if this control should have its data submitted
|
||||
* @param aSubmitter the submit button or text field that caused the submit
|
||||
*/
|
||||
virtual PRBool IsSuccessful(nsIFormControl* aSubmitter) const = 0;
|
||||
|
||||
/**
|
||||
* Set this control back to its initial value
|
||||
|
|
|
@ -63,8 +63,10 @@ public:
|
|||
* method attributes. This in response to a submit button being clicked.
|
||||
* @param aPresContext the presentation context
|
||||
* @param aFrame the frame of the submit button
|
||||
* @param aSubmitter the control that caused the submit
|
||||
*/
|
||||
virtual void OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) = 0;
|
||||
virtual void OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame,
|
||||
nsIFormControl* aSubmitter) = 0;
|
||||
|
||||
/**
|
||||
* This is tbd and is in repsonse to a tab key being entered in one
|
||||
|
|
|
@ -31,7 +31,6 @@ CPPSRCS = \
|
|||
nsInputCheckbox.cpp \
|
||||
nsInputFile.cpp \
|
||||
nsInputFrame.cpp \
|
||||
nsInputImage.cpp \
|
||||
nsInputRadio.cpp \
|
||||
nsInputText.cpp \
|
||||
nsSelect.cpp \
|
||||
|
|
|
@ -25,13 +25,13 @@ MODULE=raptor
|
|||
REQUIRES=xpcom raptor
|
||||
|
||||
CPPSRCS=nsForm.cpp nsInput.cpp nsInputButton.cpp nsInputCheckbox.cpp \
|
||||
nsInputFile.cpp nsInputFrame.cpp nsInputImage.cpp \
|
||||
nsInputFile.cpp nsInputFrame.cpp \
|
||||
nsInputRadio.cpp nsInputText.cpp nsSelect.cpp
|
||||
|
||||
CPP_OBJS=.\$(OBJDIR)\nsForm.obj .\$(OBJDIR)\nsInput.obj \
|
||||
.\$(OBJDIR)\nsInputButton.obj .\$(OBJDIR)\nsInputCheckbox.obj \
|
||||
.\$(OBJDIR)\nsInputFile.obj .\$(OBJDIR)\nsInputFrame.obj \
|
||||
.\$(OBJDIR)\nsInputImage.obj .\$(OBJDIR)\nsInputRadio.obj \
|
||||
.\$(OBJDIR)\nsInputRadio.obj \
|
||||
.\$(OBJDIR)\nsInputText.obj .\$(OBJDIR)\nsSelect.obj
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
|
|
|
@ -111,7 +111,8 @@ public:
|
|||
virtual void OnReturn();
|
||||
|
||||
// callback for submit button controls.
|
||||
virtual void OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame);
|
||||
virtual void OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame,
|
||||
nsIFormControl* aSubmitter);
|
||||
|
||||
// callback for tabs on controls that can gain focus. This will
|
||||
// eventually need to be handled at the document level to support
|
||||
|
@ -257,7 +258,8 @@ nsForm::OnReturn()
|
|||
}
|
||||
|
||||
void
|
||||
nsForm::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||
nsForm::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame,
|
||||
nsIFormControl* aSubmitter)
|
||||
{
|
||||
printf("\n YYYYYYYYYYYYY \n");
|
||||
// right now we only do "get"
|
||||
|
@ -274,22 +276,22 @@ nsForm::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
// collect and encode the data from the children controls
|
||||
for (PRInt32 childX = 0; childX < numChildren; childX++) {
|
||||
nsIFormControl* child = (nsIFormControl*) mChildren.ElementAt(childX);
|
||||
nsString childName;
|
||||
if (PR_TRUE == child->GetName(childName)) {
|
||||
if (child->IsSuccessful(aSubmitter)) {
|
||||
PRInt32 numValues = 0;
|
||||
PRInt32 maxNumValues = child->GetMaxNumValues();
|
||||
if (maxNumValues <= 0) {
|
||||
continue;
|
||||
}
|
||||
nsString* names = new nsString[maxNumValues];
|
||||
nsString* values = new nsString[maxNumValues];
|
||||
if (PR_TRUE == child->GetValues(maxNumValues, numValues, values)) {
|
||||
if (PR_TRUE == child->GetNamesValues(maxNumValues, numValues, values, names)) {
|
||||
for (int valueX = 0; valueX < numValues; valueX++) {
|
||||
if (PR_TRUE == firstTime) {
|
||||
firstTime = PR_FALSE;
|
||||
} else {
|
||||
data += "&";
|
||||
}
|
||||
nsString* convName = EscapeURLString(childName);
|
||||
nsString* convName = EscapeURLString(names[valueX]);
|
||||
data += *convName;
|
||||
delete convName;
|
||||
data += "=";
|
||||
|
|
|
@ -49,7 +49,11 @@ nsInput::nsInput(nsIAtom* aTag, nsIFormManager* aManager)
|
|||
mFormMan->AddFormControl(&mControl);
|
||||
}
|
||||
mSize = ATTR_NOTSET;
|
||||
mAlign = ATTR_NOTSET;
|
||||
mAlign = nsnull;
|
||||
mWidth = ATTR_NOTSET;
|
||||
mHeight= ATTR_NOTSET;
|
||||
mLastClickPoint.x = -1;
|
||||
mLastClickPoint.y = -1;
|
||||
}
|
||||
|
||||
nsInput::~nsInput()
|
||||
|
@ -68,10 +72,17 @@ nsInput::~nsInput()
|
|||
}
|
||||
}
|
||||
|
||||
void nsInput::SetClickPoint(nscoord aX, nscoord aY)
|
||||
{
|
||||
mLastClickPoint.x = aX;
|
||||
mLastClickPoint.y = aY;
|
||||
}
|
||||
|
||||
void nsInput::MapAttributesInto(nsIStyleContext* aContext,
|
||||
nsIPresContext* aPresContext)
|
||||
{
|
||||
#if 0
|
||||
XXX
|
||||
if (ATTR_NOTSET != mAlign) {
|
||||
nsStyleDisplay* display = (nsStyleDisplay*)
|
||||
aContext->GetData(kStyleDisplaySID);
|
||||
|
@ -106,6 +117,16 @@ nsresult nsInput::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
return nsHTMLContainer::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
PRBool nsInput::IsSuccessful(nsIFormControl* aSubmitter) const
|
||||
{
|
||||
if (nsnull == mName) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
else {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsrefcnt nsInput::Release()
|
||||
{
|
||||
--mRefCnt;
|
||||
|
@ -222,7 +243,8 @@ nsInput::GetMaxNumValues()
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsInput::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsString* aValues)
|
||||
nsInput::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
|
@ -256,6 +278,12 @@ void nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
|
|||
else if (aAttribute == nsHTMLAtoms::size) {
|
||||
CacheAttribute(aValue, ATTR_NOTSET, mSize);
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::width) {
|
||||
CacheAttribute(aValue, ATTR_NOTSET, mWidth);
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::height) {
|
||||
CacheAttribute(aValue, ATTR_NOTSET, mHeight);
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::value) {
|
||||
CacheAttribute(aValue, mValue);
|
||||
}
|
||||
|
@ -263,7 +291,7 @@ void nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
|
|||
CacheAttribute(aValue, ATTR_NOTSET, mAlign);
|
||||
}
|
||||
else {
|
||||
super::SetAttribute(aAttribute, aValue);
|
||||
nsInputSuper::SetAttribute(aAttribute, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,24 +328,10 @@ nsContentAttr nsInput::GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHT
|
|||
else {
|
||||
aValue.SetIntValue(aLoc, aUnit);
|
||||
}
|
||||
return eContentAttr_HasValue;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Replaced by using eHTMLUnit_Empty in above method
|
||||
nsContentAttr nsInput::GetCacheAttribute(PRBool aLoc, nsHTMLValue& aValue) const
|
||||
{
|
||||
aValue.Reset();
|
||||
if (aLoc) {
|
||||
aValue.Set(1);
|
||||
return eContentAttr_HasValue;
|
||||
}
|
||||
else {
|
||||
return eContentAttr_NotThere;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute, nsString& aValue) const
|
||||
{
|
||||
|
@ -356,22 +370,6 @@ nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute, PRBool& aValue) const
|
||||
{
|
||||
PRInt32 intVal;
|
||||
nsContentAttr result = GetAttribute(aAttribute, intVal);
|
||||
if ((eContentAttr_HasValue == result) && (intVal > 0)) {
|
||||
aValue = PR_TRUE;
|
||||
return eContentAttr_HasValue;
|
||||
}
|
||||
else {
|
||||
aValue = PR_FALSE;
|
||||
return eContentAttr_NoValue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const
|
||||
{
|
||||
|
@ -392,6 +390,12 @@ nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute,
|
|||
else if (aAttribute == nsHTMLAtoms::size) {
|
||||
return GetCacheAttribute(mSize, aValue, eHTMLUnit_Pixel); // XXX pixel or percent??
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::width) {
|
||||
return GetCacheAttribute(mWidth, aValue, eHTMLUnit_Pixel); // XXX pixel or percent??
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::height) {
|
||||
return GetCacheAttribute(mHeight, aValue, eHTMLUnit_Pixel); // XXX pixel or percent??
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::value) {
|
||||
return GetCacheAttribute(mValue, aValue);
|
||||
}
|
||||
|
@ -399,7 +403,7 @@ nsContentAttr nsInput::GetAttribute(nsIAtom* aAttribute,
|
|||
return GetCacheAttribute(mAlign, aValue, eHTMLUnit_Enumerated);
|
||||
}
|
||||
else {
|
||||
return super::GetAttribute(aAttribute, aValue);
|
||||
return nsInputSuper::GetAttribute(aAttribute, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,11 +454,10 @@ PRInt32 nsInput::AggInputControl::GetMaxNumValues()
|
|||
return GET_OUTER()->GetMaxNumValues();
|
||||
}
|
||||
|
||||
PRBool nsInput::AggInputControl::GetValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues)
|
||||
PRBool nsInput::AggInputControl::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
return GET_OUTER()->GetValues(aMaxNumValues, aNumValues, aValues);
|
||||
return GET_OUTER()->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);
|
||||
}
|
||||
|
||||
void nsInput::AggInputControl::Reset()
|
||||
|
@ -492,3 +495,7 @@ void nsInput::AggInputControl::GetType(nsString& aName) const
|
|||
GET_OUTER()->GetType(aName);
|
||||
}
|
||||
|
||||
PRBool nsInput::AggInputControl::IsSuccessful(nsIFormControl* aSubmitter) const
|
||||
{
|
||||
return GET_OUTER()->IsSuccessful(aSubmitter);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,13 @@
|
|||
|
||||
#include "nsHTMLContainer.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsPoint.h"
|
||||
class nsIFormManager;
|
||||
class nsIWidget;
|
||||
class nsIView;
|
||||
class nsIPresContext;
|
||||
|
||||
|
||||
/**
|
||||
* nsInput represents an html Input element. This is a base class for
|
||||
* the various Input types (button, checkbox, file, hidden, password,
|
||||
|
@ -33,7 +35,7 @@ class nsIPresContext;
|
|||
*/
|
||||
class nsInput : public nsHTMLContainer {
|
||||
public:
|
||||
typedef nsHTMLContainer super;
|
||||
typedef nsHTMLContainer nsInputSuper;
|
||||
/**
|
||||
* main constructor
|
||||
* @param aTag the html tag associated with this object
|
||||
|
@ -80,11 +82,13 @@ public:
|
|||
/**
|
||||
* @see nsIFormControl GetFormManager
|
||||
*/
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
virtual PRBool IsHidden();
|
||||
|
||||
virtual PRBool IsSuccessful(nsIFormControl* aSubmitter) const;
|
||||
|
||||
/**
|
||||
* @see nsIFormControl GetFormManager
|
||||
*/
|
||||
|
@ -110,9 +114,6 @@ public:
|
|||
|
||||
virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, nsString& aValue) const;
|
||||
virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const;
|
||||
#if 0
|
||||
virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, PRBool& aValue) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the named attribute of this input
|
||||
|
@ -150,6 +151,7 @@ public:
|
|||
virtual void GetType(nsString& aResult) const = 0;
|
||||
virtual PRBool GetChecked(PRBool aGetInitialValue) const;
|
||||
virtual void SetChecked(PRBool aState, PRBool aSetInitialValue);
|
||||
virtual void SetClickPoint(nscoord aX, nscoord aY);
|
||||
|
||||
protected:
|
||||
virtual ~nsInput();
|
||||
|
@ -159,20 +161,20 @@ protected:
|
|||
*/
|
||||
nsIWidget* mWidget;
|
||||
nsIFormManager* mFormMan;
|
||||
nsPoint mLastClickPoint;
|
||||
|
||||
void CacheAttribute(const nsString& aValue, nsString*& aLoc);
|
||||
void CacheAttribute(const nsString& aValue, PRInt32 aMinValue, PRInt32& aLoc);
|
||||
nsContentAttr GetCacheAttribute(nsString* const& aLoc, nsHTMLValue& aValue) const;
|
||||
nsContentAttr GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHTMLUnit aUnit) const;
|
||||
#if 0
|
||||
nsContentAttr GetCacheAttribute(PRBool aLoc, nsHTMLValue& aValue) const;
|
||||
#endif
|
||||
|
||||
// Attributes common to all html form elements
|
||||
nsString* mName;
|
||||
nsString* mValue;
|
||||
PRInt32 mSize;
|
||||
PRInt32 mAlign;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
|
||||
// Aggregator class and instance variable used to aggregate in the
|
||||
// nsIFormControl interface to nsInput w/o using multiple
|
||||
|
@ -189,14 +191,15 @@ protected:
|
|||
virtual PRBool GetName(nsString& aName) const;
|
||||
virtual void GetType(nsString& aType) const;
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void Reset();
|
||||
virtual void SetFormManager(nsIFormManager* aFormMan, PRBool aDecrementRef = PR_TRUE);
|
||||
virtual nsIFormManager* GetFormManager() const;
|
||||
virtual nsrefcnt GetRefCount() const;
|
||||
virtual PRBool GetChecked(PRBool aGetInitialValue) const;
|
||||
virtual void SetChecked(PRBool aState, PRBool aSetInitialValue);
|
||||
virtual PRBool IsSuccessful(nsIFormControl* aSubmitter) const;
|
||||
};
|
||||
AggInputControl mControl;
|
||||
};
|
||||
|
|
|
@ -39,19 +39,29 @@
|
|||
#include "nsIFontCache.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIFormManager.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsHTMLForms.h"
|
||||
|
||||
enum nsInputButtonType {
|
||||
kButton_InputButton,
|
||||
enum nsButtonTagType {
|
||||
kButtonTag_Button,
|
||||
kButtonTag_Input
|
||||
};
|
||||
|
||||
enum nsButtonType {
|
||||
kButton_Button,
|
||||
kButton_InputReset,
|
||||
kButton_InputSubmit,
|
||||
kButton_InputHidden
|
||||
kButton_Reset,
|
||||
kButton_Submit,
|
||||
kButton_Image,
|
||||
kButton_Hidden
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
|
||||
|
||||
class nsInputButton : public nsInput {
|
||||
public:
|
||||
typedef nsInput nsInputButtonSuper;
|
||||
nsInputButton (nsIAtom* aTag, nsIFormManager* aManager,
|
||||
nsInputButtonType aType);
|
||||
nsButtonType aType);
|
||||
|
||||
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndexInParent,
|
||||
|
@ -59,28 +69,44 @@ public:
|
|||
|
||||
virtual void GetDefaultLabel(nsString& aLabel);
|
||||
|
||||
nsInputButtonType GetButtonType() { return mType; }
|
||||
nsButtonType GetButtonType() { return mType; }
|
||||
nsButtonTagType GetButtonTagType() { return mTagType; }
|
||||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
virtual PRBool IsHidden();
|
||||
|
||||
virtual PRBool IsSuccessful(nsIFormControl* aSubmitter) const;
|
||||
|
||||
protected:
|
||||
virtual ~nsInputButton();
|
||||
|
||||
virtual void GetType(nsString& aResult) const;
|
||||
|
||||
nsInputButtonType mType;
|
||||
nsButtonType mType;
|
||||
nsButtonTagType mTagType;
|
||||
};
|
||||
|
||||
class nsInputButtonFrame : public nsInputFrame {
|
||||
public:
|
||||
typedef nsInputFrame nsInputButtonFrameSuper;
|
||||
nsInputButtonFrame(nsIContent* aContent,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame);
|
||||
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
NS_IMETHOD ResizeReflow(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsSize& aMaxSize,
|
||||
nsSize* aMaxElementSize,
|
||||
ReflowStatus& aStatus);
|
||||
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext, nsIView* aView);
|
||||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
@ -89,7 +115,10 @@ public:
|
|||
|
||||
virtual const nsIID& GetIID();
|
||||
|
||||
nsInputButtonType GetButtonType() const;
|
||||
nsButtonType GetButtonType() const;
|
||||
nsButtonTagType GetButtonTagType() const;
|
||||
|
||||
nsIImage* GetImage(nsIPresContext& aPresContext);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -105,9 +134,12 @@ protected:
|
|||
// nsInputButton Implementation
|
||||
|
||||
nsInputButton::nsInputButton(nsIAtom* aTag, nsIFormManager* aManager,
|
||||
nsInputButtonType aType)
|
||||
nsButtonType aType)
|
||||
: nsInput(aTag, aManager), mType(aType)
|
||||
{
|
||||
nsAutoString tagName;
|
||||
aTag->ToString(tagName);
|
||||
mTagType = (tagName.EqualsIgnoreCase("input")) ? kButtonTag_Input : kButtonTag_Button;
|
||||
}
|
||||
|
||||
nsInputButton::~nsInputButton()
|
||||
|
@ -117,10 +149,18 @@ nsInputButton::~nsInputButton()
|
|||
}
|
||||
}
|
||||
|
||||
PRBool nsInputButton::IsSuccessful(nsIFormControl* aSubmitter) const
|
||||
{
|
||||
if ((void*)&mControl == (void*)aSubmitter) {
|
||||
return nsInputButtonSuper::IsSuccessful(aSubmitter);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsInputButton::IsHidden()
|
||||
{
|
||||
if (kButton_InputHidden == mType) {
|
||||
if (kButton_Hidden == mType) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -131,27 +171,38 @@ nsInputButton::IsHidden()
|
|||
void nsInputButton::GetType(nsString& aResult) const
|
||||
{
|
||||
aResult.SetLength(0);
|
||||
switch (mType) {
|
||||
case kButton_InputButton:
|
||||
case kButton_Button:
|
||||
|
||||
if (kButtonTag_Button == mTagType) {
|
||||
aResult.Append("button");
|
||||
break;
|
||||
case kButton_InputReset:
|
||||
aResult.Append("reset");
|
||||
break;
|
||||
default:
|
||||
case kButton_InputSubmit:
|
||||
aResult.Append("submit");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mType) {
|
||||
case kButton_Button:
|
||||
aResult.Append("button");
|
||||
break;
|
||||
case kButton_Reset:
|
||||
aResult.Append("reset");
|
||||
break;
|
||||
case kButton_Image:
|
||||
aResult.Append("image");
|
||||
break;
|
||||
case kButton_Hidden:
|
||||
aResult.Append("hidden");
|
||||
break;
|
||||
case kButton_Submit:
|
||||
default:
|
||||
aResult.Append("submit");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsInputButton::GetDefaultLabel(nsString& aString)
|
||||
{
|
||||
if (kButton_InputReset == mType) {
|
||||
if (kButton_Reset == mType) {
|
||||
aString = "Reset";
|
||||
} else if (kButton_InputSubmit == mType) {
|
||||
} else if (kButton_Submit == mType) {
|
||||
aString = "Submit";
|
||||
} else {
|
||||
aString = "noname";
|
||||
|
@ -163,7 +214,7 @@ nsInputButton::CreateFrame(nsIPresContext* aPresContext,
|
|||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame)
|
||||
{
|
||||
if (kButton_InputHidden == mType) {
|
||||
if (kButton_Hidden == mType) {
|
||||
nsIFrame* frame;
|
||||
nsFrame::NewFrame(&frame, this, aIndexInParent, aParentFrame);
|
||||
return frame;
|
||||
|
@ -177,8 +228,10 @@ nsInputButton::CreateFrame(nsIPresContext* aPresContext,
|
|||
PRInt32
|
||||
nsInputButton::GetMaxNumValues()
|
||||
{
|
||||
if ((kButton_InputSubmit == mType) || (kButton_InputHidden)) {
|
||||
if ((kButton_Submit == mType) || (kButton_Hidden == mType)) {
|
||||
return 1;
|
||||
} else if ((kButton_Image == mType) && (kButtonTag_Input == mTagType)) {
|
||||
return 2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -186,21 +239,36 @@ nsInputButton::GetMaxNumValues()
|
|||
|
||||
|
||||
PRBool
|
||||
nsInputButton::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues)
|
||||
nsInputButton::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
if ((aMaxNumValues <= 0) || (nsnull == mName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if ((kButton_InputSubmit != mType) && (kButton_InputHidden != mType)) {
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
if ((kButton_Image == mType) && (kButtonTag_Input == mTagType)) {
|
||||
char buf[20];
|
||||
aNumValues = 2;
|
||||
|
||||
if (nsnull != mValue) {
|
||||
aValues[0].SetLength(0);
|
||||
aValues[0].Append(*mValue);
|
||||
sprintf(&buf[0], "%d", mLastClickPoint.x);
|
||||
aValues[0].Append(&buf[0]);
|
||||
|
||||
aNames[0] = *mName;
|
||||
aNames[0].Append(".x");
|
||||
|
||||
aValues[1].SetLength(0);
|
||||
sprintf(&buf[0], "%d", mLastClickPoint.y);
|
||||
aValues[1].Append(&buf[0]);
|
||||
|
||||
aNames[1] = *mName;
|
||||
aNames[1].Append(".y");
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if ((kButton_Submit == mType) || (kButton_Hidden == mType) && (nsnull != mValue)) {
|
||||
aValues[0] = *mValue;
|
||||
aNames[0] = *mName;
|
||||
aNumValues = 1;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
|
@ -223,65 +291,163 @@ nsInputButtonFrame::~nsInputButtonFrame()
|
|||
{
|
||||
}
|
||||
|
||||
nsInputButtonType
|
||||
nsButtonType
|
||||
nsInputButtonFrame::GetButtonType() const
|
||||
{
|
||||
nsInputButton* button = (nsInputButton *)mContent;
|
||||
return button->GetButtonType();
|
||||
}
|
||||
|
||||
nsButtonTagType
|
||||
nsInputButtonFrame::GetButtonTagType() const
|
||||
{
|
||||
nsInputButton* button = (nsInputButton *)mContent;
|
||||
return button->GetButtonTagType();
|
||||
}
|
||||
|
||||
nsIImage* nsInputButtonFrame::GetImage(nsIPresContext& aPresContext)
|
||||
{
|
||||
if (kButton_Image != GetButtonType()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsAutoString src;
|
||||
if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) {
|
||||
return aPresContext.LoadImage(src, this);
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_METHOD nsInputButtonFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
// let super do processing if there is no image
|
||||
if (kButton_Image != GetButtonType()) {
|
||||
return nsInputButtonFrameSuper::Paint(aPresContext, aRenderingContext, aDirtyRect);
|
||||
}
|
||||
|
||||
nsIImage* image = GetImage(aPresContext);
|
||||
if (nsnull == image) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// First paint background and borders
|
||||
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect);
|
||||
|
||||
// Now render the image into our inner area (the area without the
|
||||
nsRect inner;
|
||||
GetInnerArea(&aPresContext, inner);
|
||||
aRenderingContext.DrawImage(image, inner);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsInputButtonFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsInputButton* button = (nsInputButton *)mContent;
|
||||
nsIFormManager* formMan = button->GetFormManager();
|
||||
if (nsnull != formMan) {
|
||||
if (kButton_InputReset == button->GetButtonType()) {
|
||||
nsButtonType butType = button->GetButtonType();
|
||||
nsButtonTagType butTagType = button->GetButtonTagType();
|
||||
if (kButton_Reset == butType) {
|
||||
formMan->OnReset();
|
||||
} else if (kButton_InputSubmit == button->GetButtonType()) {
|
||||
} else if ((kButton_Submit == butType) ||
|
||||
((kButton_Image == butType) && (kButtonTag_Input == butTagType))) {
|
||||
//NS_ADDREF(this);
|
||||
formMan->OnSubmit(aPresContext, this);
|
||||
nsIFormControl* control;
|
||||
mContent->QueryInterface(kIFormControlIID, (void**)&control);
|
||||
formMan->OnSubmit(aPresContext, this, control);
|
||||
//NS_RELEASE(this);
|
||||
}
|
||||
NS_RELEASE(formMan);
|
||||
}
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsInputButtonFrame::ResizeReflow(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredSize,
|
||||
const nsSize& aMaxSize,
|
||||
nsSize* aMaxElementSize,
|
||||
ReflowStatus& aStatus)
|
||||
{
|
||||
if ((kButtonTag_Input == GetButtonTagType()) && (kButton_Image == GetButtonType())) {
|
||||
nsSize ignore;
|
||||
GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, ignore);
|
||||
AddBordersAndPadding(aPresContext, aDesiredSize);
|
||||
if (nsnull != aMaxElementSize) {
|
||||
aMaxElementSize->width = aDesiredSize.width;
|
||||
aMaxElementSize->height = aDesiredSize.height;
|
||||
}
|
||||
mCacheBounds.width = aDesiredSize.width;
|
||||
mCacheBounds.height = aDesiredSize.height;
|
||||
aStatus = frComplete;
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return nsInputButtonFrameSuper::
|
||||
ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsInputButtonFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsSize& aMaxSize,
|
||||
nsReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
if (kButton_InputHidden == GetButtonType()) {
|
||||
|
||||
if (kButton_Hidden == GetButtonType()) { // there is no physical rep
|
||||
aDesiredLayoutSize.width = 0;
|
||||
aDesiredLayoutSize.height = 0;
|
||||
aDesiredWidgetSize.width = 0;
|
||||
aDesiredWidgetSize.height = 0;
|
||||
return;
|
||||
}
|
||||
nsSize styleSize;
|
||||
GetStyleSize(*aPresContext, aMaxSize, styleSize);
|
||||
else {
|
||||
nsSize styleSize;
|
||||
GetStyleSize(*aPresContext, aMaxSize, styleSize);
|
||||
|
||||
nsSize size;
|
||||
PRBool widthExplicit, heightExplicit;
|
||||
PRInt32 ignore;
|
||||
nsInputDimensionSpec spec(nsHTMLAtoms::size, PR_TRUE, nsHTMLAtoms::value, 1,
|
||||
PR_FALSE, nsnull, 1);
|
||||
CalculateSize(aPresContext, this, styleSize, spec, size,
|
||||
widthExplicit, heightExplicit, ignore);
|
||||
if (kButton_Image == GetButtonType()) { // there is an image
|
||||
float p2t = aPresContext->GetPixelsToTwips();
|
||||
if ((0 < styleSize.width) && (0 < styleSize.height)) {
|
||||
// Use dimensions from style attributes
|
||||
aDesiredLayoutSize.width = nscoord(styleSize.width * p2t);
|
||||
aDesiredLayoutSize.height = nscoord(styleSize.height * p2t);
|
||||
} else {
|
||||
nsIImage* image = GetImage(*aPresContext);
|
||||
if (nsnull == image) {
|
||||
// XXX Here is where we trigger a resize-reflow later on; or block
|
||||
// layout or whatever our policy wants to be
|
||||
aDesiredLayoutSize.width = nscoord(50 * p2t);
|
||||
aDesiredLayoutSize.height = nscoord(50 * p2t);
|
||||
} else {
|
||||
aDesiredLayoutSize.width = nscoord(image->GetWidth() * p2t);
|
||||
aDesiredLayoutSize.height = nscoord(image->GetHeight() * p2t);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // there is a widget
|
||||
nsSize size;
|
||||
PRBool widthExplicit, heightExplicit;
|
||||
PRInt32 ignore;
|
||||
nsInputDimensionSpec spec(nsHTMLAtoms::size, PR_TRUE, nsHTMLAtoms::value, 1,
|
||||
PR_FALSE, nsnull, 1);
|
||||
CalculateSize(aPresContext, this, styleSize, spec, size,
|
||||
widthExplicit, heightExplicit, ignore);
|
||||
|
||||
if (!widthExplicit) {
|
||||
size.width += 100;
|
||||
}
|
||||
if (!heightExplicit) {
|
||||
size.height += 100;
|
||||
}
|
||||
if (!widthExplicit) {
|
||||
size.width += 100;
|
||||
}
|
||||
if (!heightExplicit) {
|
||||
size.height += 100;
|
||||
}
|
||||
|
||||
aDesiredLayoutSize.width = size.width;
|
||||
aDesiredLayoutSize.height= size.height;
|
||||
aDesiredWidgetSize.width = size.width;
|
||||
aDesiredWidgetSize.height= size.height;
|
||||
aDesiredLayoutSize.width = size.width;
|
||||
aDesiredLayoutSize.height= size.height;
|
||||
}
|
||||
}
|
||||
|
||||
aDesiredWidgetSize.width = aDesiredLayoutSize.width;
|
||||
aDesiredWidgetSize.height= aDesiredLayoutSize.height;
|
||||
}
|
||||
|
||||
|
||||
|
@ -328,7 +494,7 @@ nsInputButtonFrame::GetCID()
|
|||
nsresult
|
||||
CreateButton(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager,
|
||||
nsInputButtonType aType)
|
||||
nsButtonType aType)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
|
@ -347,7 +513,7 @@ nsresult
|
|||
NS_NewHTMLInputButton(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager)
|
||||
{
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_InputButton);
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_Button);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -361,19 +527,26 @@ nsresult
|
|||
NS_NewHTMLInputSubmit(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager)
|
||||
{
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_InputSubmit);
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_Submit);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLInputReset(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager)
|
||||
{
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_InputReset);
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_Reset);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLInputImage(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager)
|
||||
{
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_Image);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLInputHidden(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager)
|
||||
{
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_InputHidden);
|
||||
return CreateButton(aInstancePtrResult, aTag, aManager, kButton_Hidden);
|
||||
}
|
||||
|
|
|
@ -165,10 +165,10 @@ nsInputCheckbox::GetMaxNumValues()
|
|||
|
||||
|
||||
PRBool
|
||||
nsInputCheckbox::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues)
|
||||
nsInputCheckbox::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
if ((aMaxNumValues <= 0) || (nsnull == mName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsICheckButton* checkBox = (nsICheckButton *)GetWidget();
|
||||
|
@ -182,6 +182,7 @@ nsInputCheckbox::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|||
} else {
|
||||
aValues[0] = *mValue;
|
||||
}
|
||||
aNames[0] = *mName;
|
||||
aNumValues = 1;
|
||||
|
||||
return PR_TRUE;
|
||||
|
@ -217,7 +218,7 @@ void nsInputCheckbox::SetAttribute(nsIAtom* aAttribute,
|
|||
mChecked = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
super::SetAttribute(aAttribute, aValue);
|
||||
nsInputCheckboxSuper::SetAttribute(aAttribute, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +230,7 @@ nsContentAttr nsInputCheckbox::GetAttribute(nsIAtom* aAttribute,
|
|||
return GetCacheAttribute(mChecked, aResult, eHTMLUnit_Empty);
|
||||
}
|
||||
else {
|
||||
return super::GetAttribute(aAttribute, aResult);
|
||||
return nsInputCheckboxSuper::GetAttribute(aAttribute, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class nsString;
|
|||
|
||||
class nsInputCheckbox : public nsInput {
|
||||
public:
|
||||
typedef nsInput super;
|
||||
typedef nsInput nsInputCheckboxSuper;
|
||||
nsInputCheckbox (nsIAtom* aTag, nsIFormManager* aManager);
|
||||
|
||||
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
|
||||
|
@ -39,8 +39,8 @@ public:
|
|||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
virtual void Reset();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class nsString;
|
|||
|
||||
class nsInputFile : public nsInput {
|
||||
public:
|
||||
typedef nsInput super;
|
||||
typedef nsInput nsInputFileSuper;
|
||||
nsInputFile (nsIAtom* aTag, nsIFormManager* aManager);
|
||||
|
||||
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -76,7 +76,7 @@ nsInputFrame::~nsInputFrame()
|
|||
|
||||
NS_METHOD nsInputFrame::SetRect(const nsRect& aRect)
|
||||
{
|
||||
return super::SetRect(aRect);
|
||||
return nsInputFrameSuper::SetRect(aRect);
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,32 +320,30 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
static NS_DEFINE_IID(kSupportsIID, NS_ISUPPORTS_IID);
|
||||
nsIWidget* thisWidget;
|
||||
|
||||
nsIView* view;
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (view == nsnull) {
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
if (view != nsnull) {
|
||||
nsresult result = GetWidget(view, &thisWidget);
|
||||
nsISupports* thisWidgetSup;
|
||||
result = thisWidget->QueryInterface(kSupportsIID, (void **)&thisWidgetSup);
|
||||
if (thisWidget == nsnull) {
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
nsISupports* eventWidgetSup;
|
||||
result = aEvent->widget->QueryInterface(kSupportsIID, (void **)&eventWidgetSup);
|
||||
|
||||
nsresult result = GetWidget(view, &thisWidget);
|
||||
nsISupports* thisWidgetSup;
|
||||
result = thisWidget->QueryInterface(kSupportsIID, (void **)&thisWidgetSup);
|
||||
if (thisWidget == nsnull) {
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
nsISupports* eventWidgetSup;
|
||||
result = aEvent->widget->QueryInterface(kSupportsIID, (void **)&eventWidgetSup);
|
||||
|
||||
PRBool isOurEvent = (thisWidgetSup == eventWidgetSup) ? PR_TRUE : PR_FALSE;
|
||||
PRBool isOurEvent = (thisWidgetSup == eventWidgetSup) ? PR_TRUE : PR_FALSE;
|
||||
|
||||
NS_RELEASE(eventWidgetSup);
|
||||
NS_RELEASE(thisWidgetSup);
|
||||
NS_IF_RELEASE(view);
|
||||
NS_IF_RELEASE(thisWidget);
|
||||
NS_RELEASE(eventWidgetSup);
|
||||
NS_RELEASE(thisWidgetSup);
|
||||
NS_IF_RELEASE(view);
|
||||
NS_IF_RELEASE(thisWidget);
|
||||
|
||||
if (!isOurEvent) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
if (!isOurEvent) {
|
||||
aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
switch (aEvent->message) {
|
||||
case NS_MOUSE_ENTER:
|
||||
|
@ -359,11 +357,14 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext,
|
|||
if (eMouseDown == mLastMouseState) {
|
||||
/*nsIView* view = GetView();
|
||||
nsIWidget *widget = view->GetWindow();
|
||||
widget->SetFocus();
|
||||
NS_RELEASE(widget);
|
||||
widget->SetFocus();
|
||||
NS_RELEASE(widget);
|
||||
NS_RELEASE(view); */
|
||||
MouseClicked(&aPresContext);
|
||||
//return PR_FALSE;
|
||||
float conv = aPresContext.GetTwipsToPixels();
|
||||
((nsInput*)mContent)->SetClickPoint(NS_TO_INT_ROUND(conv * aEvent->point.x),
|
||||
NS_TO_INT_ROUND(conv * aEvent->point.y));
|
||||
MouseClicked(&aPresContext);
|
||||
//return PR_FALSE;
|
||||
}
|
||||
mLastMouseState = eMouseEnter;
|
||||
break;
|
||||
|
@ -384,6 +385,7 @@ void nsInputFrame::GetStyleSize(nsIPresContext& aPresContext,
|
|||
|
||||
aSize.width = GetStyleDim(aPresContext, aMaxSize.width, aMaxSize.width, pos->mWidth);
|
||||
aSize.height = GetStyleDim(aPresContext, aMaxSize.height, aMaxSize.width, pos->mHeight);
|
||||
|
||||
NS_RELEASE(input);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ struct nsInputDimensionSpec
|
|||
* @see nsLeafFrame and its base classes for more info
|
||||
*/
|
||||
class nsInputFrame : public nsLeafFrame {
|
||||
typedef nsLeafFrame super;
|
||||
typedef nsLeafFrame nsInputFrameSuper;
|
||||
public:
|
||||
/**
|
||||
* Main constructor
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsInputImage.h"
|
||||
#include "nsInputFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
||||
class nsInputImageFrame : public nsInputFrame {
|
||||
public:
|
||||
nsInputImageFrame(nsIContent* aContent,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame);
|
||||
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView);
|
||||
|
||||
protected:
|
||||
virtual ~nsInputImageFrame();
|
||||
};
|
||||
|
||||
nsInputImageFrame::nsInputImageFrame(nsIContent* aContent,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame)
|
||||
: nsInputFrame(aContent, aIndexInParent, aParentFrame)
|
||||
{
|
||||
}
|
||||
|
||||
nsInputImageFrame::~nsInputImageFrame()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsInputImageFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsInputImage
|
||||
|
||||
nsInputImage::nsInputImage(nsIAtom* aTag, nsIFormManager* aManager)
|
||||
: nsInput(aTag, aManager)
|
||||
{
|
||||
}
|
||||
|
||||
nsInputImage::~nsInputImage()
|
||||
{
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsInputImage::CreateFrame(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame)
|
||||
{
|
||||
nsIFrame* rv = new nsInputImageFrame(this, aIndexInParent, aParentFrame);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsInputImage::GetType(nsString& aResult) const
|
||||
{
|
||||
aResult = "image";
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLInputImage(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag, nsIFormManager* aManager)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsIHTMLContent* it = new nsInputImage(aTag, aManager);
|
||||
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsInputImage_h___
|
||||
#define nsInputImage_h___
|
||||
|
||||
#include "nsInput.h"
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
|
||||
// this class definition will move to nsInputImage.cpp
|
||||
|
||||
class nsInputImage : public nsInput {
|
||||
public:
|
||||
typedef nsInput super;
|
||||
nsInputImage (nsIAtom* aTag, nsIFormManager* aManager);
|
||||
|
||||
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndexInParent,
|
||||
nsIFrame* aParentFrame);
|
||||
protected:
|
||||
|
||||
virtual ~nsInputImage();
|
||||
|
||||
virtual void GetType(nsString& aResult) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ void nsInputRadio::SetAttribute(nsIAtom* aAttribute,
|
|||
mChecked = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
super::SetAttribute(aAttribute, aValue);
|
||||
nsInputRadioSuper::SetAttribute(aAttribute, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,15 +221,15 @@ nsContentAttr nsInputRadio::GetAttribute(nsIAtom* aAttribute,
|
|||
return GetCacheAttribute(mChecked, aResult, eHTMLUnit_Empty);
|
||||
}
|
||||
else {
|
||||
return super::GetAttribute(aAttribute, aResult);
|
||||
return nsInputRadioSuper::GetAttribute(aAttribute, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsInputRadio::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues)
|
||||
nsInputRadio::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
if ((aMaxNumValues <= 0) || (nsnull == mName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsIRadioButton* radio = (nsIRadioButton *)GetWidget();
|
||||
|
@ -243,6 +243,7 @@ nsInputRadio::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|||
} else {
|
||||
aValues[0] = *mValue;
|
||||
}
|
||||
aNames[0] = *mName;
|
||||
aNumValues = 1;
|
||||
|
||||
return PR_TRUE;
|
||||
|
|
|
@ -29,7 +29,7 @@ class nsString;
|
|||
class nsInputRadio : public nsInput
|
||||
{
|
||||
public:
|
||||
typedef nsInput super;
|
||||
typedef nsInput nsInputRadioSuper;
|
||||
nsInputRadio (nsIAtom* aTag, nsIFormManager* aManager);
|
||||
|
||||
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
|
||||
|
@ -48,8 +48,8 @@ public:
|
|||
|
||||
virtual PRInt32 GetMaxNumValues() { return 1; }
|
||||
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
virtual void Reset();
|
||||
|
||||
|
|
|
@ -217,15 +217,17 @@ nsInputText::GetMaxNumValues()
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsInputText::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues)
|
||||
nsInputText::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
if ((aMaxNumValues <= 0) || (nsnull == mName)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsITextWidget* text = (nsITextWidget *)GetWidget();
|
||||
nsString value;
|
||||
text->GetText(aValues[0], 0); // the last parm is not used
|
||||
text->GetText(aValues[0], 0); // the last parm is not used
|
||||
aNames[0] = *mName;
|
||||
|
||||
aNumValues = 1;
|
||||
|
||||
return PR_TRUE;
|
||||
|
@ -268,7 +270,7 @@ void nsInputText::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
|
|||
CacheAttribute(aValue, ATTR_NOTSET, mNumCols);
|
||||
}
|
||||
else {
|
||||
super::SetAttribute(aAttribute, aValue);
|
||||
nsInputTextSuper::SetAttribute(aAttribute, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +287,7 @@ nsContentAttr nsInputText::GetAttribute(nsIAtom* aAttribute,
|
|||
return GetCacheAttribute(mNumCols, aResult, eHTMLUnit_Integer);
|
||||
}
|
||||
else {
|
||||
return super::GetAttribute(aAttribute, aResult);
|
||||
return nsInputTextSuper::GetAttribute(aAttribute, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ enum nsInputTextType {
|
|||
|
||||
class nsInputText : public nsInput {
|
||||
public:
|
||||
typedef nsInput super;
|
||||
typedef nsInput nsInputTextSuper;
|
||||
nsInputText (nsIAtom* aTag, nsIFormManager* aManager, nsInputTextType aType);
|
||||
|
||||
virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext,
|
||||
|
@ -51,8 +51,8 @@ public:
|
|||
|
||||
nsInputTextType GetTextType() const;
|
||||
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
virtual void Reset();
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "nsIComboBox.h"
|
||||
#include "nsIListBox.h"
|
||||
#include "nsInput.h"
|
||||
#include "nsHTMLForms.h"
|
||||
|
||||
static NS_DEFINE_IID(kListWidgetIID, NS_ILISTWIDGET_IID);
|
||||
static NS_DEFINE_IID(kComboBoxIID, NS_ICOMBOBOX_IID);
|
||||
|
@ -86,8 +87,8 @@ public:
|
|||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
PRBool IsMultiple() { return mMultiple; }
|
||||
|
||||
|
@ -121,8 +122,8 @@ public:
|
|||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues);
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
PRBool GetText(nsString& aString) const;
|
||||
|
||||
|
@ -277,7 +278,6 @@ nsSelectFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView)
|
|||
// printf("\n ** text = %s", text.ToNewCString());
|
||||
// list->AddItemAt(text, 1);
|
||||
// }
|
||||
printf("\n item=%s\n", text.ToNewCString());
|
||||
list->AddItemAt(text, i);
|
||||
}
|
||||
|
||||
|
@ -363,10 +363,10 @@ nsSelect::GetMaxNumValues()
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsSelect::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues)
|
||||
nsSelect::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
if ((aMaxNumValues <= 0) || (nsnull == mName)) {
|
||||
NS_ASSERTION(0, "invalid max num values");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -379,7 +379,8 @@ nsSelect::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|||
PRInt32 index = list->GetSelectedIndex();
|
||||
if (index >= 0) {
|
||||
nsOption* selected = (nsOption*)ChildAt(index);
|
||||
selected->GetValues(aMaxNumValues, aNumValues, aValues);
|
||||
selected->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);
|
||||
aNames[0] = *mName;
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -400,7 +401,9 @@ nsSelect::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|||
aNumValues = 0;
|
||||
for (int i = 0; i < numSelections; i++) {
|
||||
nsOption* selected = (nsOption*)ChildAt(selections[i]);
|
||||
selected->GetValues(aMaxNumValues - i, numValues, aValues + i); // options can only have 1 value
|
||||
selected->GetNamesValues(aMaxNumValues - i, numValues,
|
||||
aValues + i, aNames + i); // options can only have 1 value
|
||||
aNames[i] = *mName;
|
||||
aNumValues += 1;
|
||||
}
|
||||
return PR_TRUE;
|
||||
|
@ -429,9 +432,9 @@ nsSelect::Reset()
|
|||
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
nsOption* option = (nsOption*)ChildAt(i); // YYY this had better be an option
|
||||
PRBool selAttr;
|
||||
PRInt32 selAttr;
|
||||
((nsInput *)option)->GetAttribute(nsHTMLAtoms::selected, selAttr);
|
||||
if (selAttr) {
|
||||
if (ATTR_NOTSET != selAttr) {
|
||||
list->SelectItem(i);
|
||||
if (!mMultiple) {
|
||||
break;
|
||||
|
@ -523,7 +526,8 @@ void nsOption::SetText(nsString& aString)
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsOption::GetValues(PRInt32 aMaxNumValues, PRInt32& aNumValues, nsString* aValues)
|
||||
nsOption::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
NS_ASSERTION(aMaxNumValues > 0, "invalid max num values");
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<textarea name=a textarea rows=4 cols=20 value="a text area in need of some clearing"></textarea>
|
||||
a checkbox: <input type=checkbox name=check1 checked>
|
||||
radio buttons:
|
||||
<input type=radio name=group1 checked> radio1
|
||||
<input type=radio name=group1> radio2
|
||||
<input type=radio name=group1> radio1
|
||||
<input type=radio name=group1 checked> radio2
|
||||
<BR>
|
||||
<P>select/option hacks; why don't these line up</P>
|
||||
<input type=select1>
|
||||
|
@ -28,6 +28,7 @@
|
|||
<BR>
|
||||
<input type=reset name=reset value="RESET">
|
||||
<input type=submit name=submit value="SUBMIT">
|
||||
<input type=image src=raptor.jpg width=50 height=50 name=imageSubmit> an image submit. For now, click twice.
|
||||
|
||||
</form>
|
||||
</body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче