зеркало из https://github.com/mozilla/gecko-dev.git
Removed nsGfxButtonControlFrame's MouseClick method. It uses it's base classes (nsHTMLButtonControlFrame)
MouseClick instead. Reworked nsHTMLButton::MouseClick factoring out code to get Reset and Submit button types so MouseClick can be re-used by the nsGfxButtonControlFrame. Fix for bug 13462. Set the nsHTMLButtonControlFrame's mForm in the initial reflow.
This commit is contained in:
Родитель
afbd510ee3
Коммит
8f9cf9d3bc
|
@ -99,43 +99,28 @@ NS_NewGfxButtonControlFrame(nsIFrame** aNewFrame)
|
|||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(&formContent);
|
||||
|
||||
switch(type) {
|
||||
case NS_FORM_INPUT_RESET:
|
||||
event.message = NS_FORM_RESET;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnReset();
|
||||
}
|
||||
break;
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(formContent);
|
||||
}
|
||||
if (NS_FORM_INPUT_RESET == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::IsSubmit(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_INPUT_SUBMIT == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
const nsIID&
|
||||
nsGfxButtonControlFrame::GetIID()
|
||||
{
|
||||
|
@ -178,9 +163,7 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
// The mFormFrame is set in the initial reflow within nsHTMLButtonControlFrame
|
||||
|
||||
if ((kSuggestedNotSet != mSuggestedWidth) ||
|
||||
(kSuggestedNotSet != mSuggestedHeight)) {
|
||||
|
|
|
@ -51,11 +51,12 @@ public:
|
|||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
|
||||
protected:
|
||||
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aSuggestedReflowState);
|
||||
virtual PRBool IsReset(PRInt32 type);
|
||||
virtual PRBool IsSubmit(PRInt32 type);
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
|
|
|
@ -166,6 +166,7 @@ nsHTMLButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumVal
|
|||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,32 +238,62 @@ nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
|||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_BUTTON_RESET == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_BUTTON_SUBMIT == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsHTMLButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (nsnull != mFormFrame) {
|
||||
if (NS_FORM_BUTTON_RESET == type) {
|
||||
//Send DOM event
|
||||
nsEventStatus mStatus;
|
||||
nsEvent mEvent;
|
||||
mEvent.eventStructType = NS_EVENT;
|
||||
mEvent.message = NS_FORM_RESET;
|
||||
mContent->HandleDOMEvent(*aPresContext, &mEvent, nsnull, NS_EVENT_FLAG_INIT, mStatus);
|
||||
|
||||
mFormFrame->OnReset();
|
||||
} else if (NS_FORM_BUTTON_SUBMIT == type) {
|
||||
//Send DOM event
|
||||
nsEventStatus mStatus;
|
||||
nsEvent mEvent;
|
||||
mEvent.eventStructType = NS_EVENT;
|
||||
mEvent.message = NS_FORM_SUBMIT;
|
||||
mContent->HandleDOMEvent(*aPresContext, &mEvent, nsnull, NS_EVENT_FLAG_INIT, mStatus);
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(&formContent);
|
||||
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
if (IsReset(type) == PR_TRUE) {
|
||||
event.message = NS_FORM_RESET;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (IsSubmit(type) == PR_TRUE) {
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(formContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -424,6 +455,10 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
|
||||
// XXX remove the following when the reflow state is fixed
|
||||
ButtonHack((nsHTMLReflowState&)aReflowState, "html4 button");
|
||||
|
||||
|
|
|
@ -139,6 +139,8 @@ public:
|
|||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
|
||||
protected:
|
||||
virtual PRBool IsReset(PRInt32 type);
|
||||
virtual PRBool IsSubmit(PRInt32 type);
|
||||
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aSuggestedReflowState);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
|
|
|
@ -178,6 +178,8 @@ nsButtonControlFrame::GetHorizontalInsidePadding(nsIPresContext& aPresContext,
|
|||
void
|
||||
nsButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
{
|
||||
//XXX: This method should probably go away. The nsHTMLButtonControl frame's
|
||||
//mouse click should be sufficient.
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
|
|
|
@ -99,43 +99,28 @@ NS_NewGfxButtonControlFrame(nsIFrame** aNewFrame)
|
|||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(&formContent);
|
||||
|
||||
switch(type) {
|
||||
case NS_FORM_INPUT_RESET:
|
||||
event.message = NS_FORM_RESET;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnReset();
|
||||
}
|
||||
break;
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(formContent);
|
||||
}
|
||||
if (NS_FORM_INPUT_RESET == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::IsSubmit(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_INPUT_SUBMIT == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
const nsIID&
|
||||
nsGfxButtonControlFrame::GetIID()
|
||||
{
|
||||
|
@ -178,9 +163,7 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
// The mFormFrame is set in the initial reflow within nsHTMLButtonControlFrame
|
||||
|
||||
if ((kSuggestedNotSet != mSuggestedWidth) ||
|
||||
(kSuggestedNotSet != mSuggestedHeight)) {
|
||||
|
|
|
@ -51,11 +51,12 @@ public:
|
|||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
|
||||
|
||||
protected:
|
||||
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aSuggestedReflowState);
|
||||
virtual PRBool IsReset(PRInt32 type);
|
||||
virtual PRBool IsSubmit(PRInt32 type);
|
||||
private:
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
|
|
|
@ -166,6 +166,7 @@ nsHTMLButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumVal
|
|||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,32 +238,62 @@ nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
|||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_BUTTON_RESET == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
|
||||
{
|
||||
if (NS_FORM_BUTTON_SUBMIT == type) {
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsHTMLButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (nsnull != mFormFrame) {
|
||||
if (NS_FORM_BUTTON_RESET == type) {
|
||||
//Send DOM event
|
||||
nsEventStatus mStatus;
|
||||
nsEvent mEvent;
|
||||
mEvent.eventStructType = NS_EVENT;
|
||||
mEvent.message = NS_FORM_RESET;
|
||||
mContent->HandleDOMEvent(*aPresContext, &mEvent, nsnull, NS_EVENT_FLAG_INIT, mStatus);
|
||||
|
||||
mFormFrame->OnReset();
|
||||
} else if (NS_FORM_BUTTON_SUBMIT == type) {
|
||||
//Send DOM event
|
||||
nsEventStatus mStatus;
|
||||
nsEvent mEvent;
|
||||
mEvent.eventStructType = NS_EVENT;
|
||||
mEvent.message = NS_FORM_SUBMIT;
|
||||
mContent->HandleDOMEvent(*aPresContext, &mEvent, nsnull, NS_EVENT_FLAG_INIT, mStatus);
|
||||
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
nsIContent *formContent = nsnull;
|
||||
mFormFrame->GetContent(&formContent);
|
||||
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
if (IsReset(type) == PR_TRUE) {
|
||||
event.message = NS_FORM_RESET;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (IsSubmit(type) == PR_TRUE) {
|
||||
event.message = NS_FORM_SUBMIT;
|
||||
if (nsnull != formContent) {
|
||||
formContent->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
if (nsEventStatus_eConsumeNoDefault != status) {
|
||||
mFormFrame->OnSubmit(aPresContext, this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(formContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -424,6 +455,10 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
||||
nsFormFrame::AddFormControlFrame(aPresContext, *this);
|
||||
}
|
||||
|
||||
// XXX remove the following when the reflow state is fixed
|
||||
ButtonHack((nsHTMLReflowState&)aReflowState, "html4 button");
|
||||
|
||||
|
|
|
@ -139,6 +139,8 @@ public:
|
|||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
|
||||
protected:
|
||||
virtual PRBool IsReset(PRInt32 type);
|
||||
virtual PRBool IsSubmit(PRInt32 type);
|
||||
NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aSuggestedReflowState);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
|
|
Загрузка…
Ссылка в новой задаче