diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp
index 29d8b3809c5..a186a3aaf67 100644
--- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp
@@ -865,32 +865,46 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
}
- // When a user clicks on a checkbox the value needs to be set after the onmouseup
- // and before the onclick event is processed via script. The EVM always lets script
- // get first crack at the processing, and script can cancel further processing of
- // the event by return null.
+ // Preset the the value of the checkbox or the radiobutton before calling into script
+ // If the event gets "cancelled" then we have to "back out" this change, but the odds
+ // of that are slimmer than it being set each time
//
- // This means the checkbox needs to have it's new value set before it goes to script
- // to process the onclick and then if script cancels the event it needs to be set back.
- // In Nav and IE there is a flash of it being set and then unset
- //
- // We have added this extra method to the checkbox to tell it to temporarily return the
- // opposite value while processing the click event. This way script gets the correct "future"
- // value of the checkbox, but there is no visual updating until after script is done processing.
- // That way if the event is cancelled then the checkbox will not flash.
- //
- // So get the Frame for the checkbox and tell it we are processing an onclick event
- if (aEvent->message == NS_MOUSE_LEFT_CLICK) {
- nsCOMPtr chkBx;
- chkBx = do_QueryInterface(formControlFrame);
- if (chkBx) {
- chkBx->SetIsInClickEvent(PR_TRUE);
- } else {
- nsCOMPtr radio;
- radio = do_QueryInterface(formControlFrame);
- if (radio)
- radio->SetIsInClickEvent(PR_TRUE);
- }
+ // Start by remember the original value and for radio buttons we must get the currently
+ // selected radiobtn. So we go get the content instead of the frame
+ PRBool orginalCheckedValue = PR_FALSE;
+ PRBool checkWasSet = PR_FALSE;
+ nsCOMPtr selectedRadiobtn;
+ if (!(aFlags & NS_EVENT_FLAG_CAPTURE) && aEvent->message == NS_MOUSE_LEFT_CLICK) {
+ GetChecked(&orginalCheckedValue);
+ checkWasSet = PR_TRUE;
+ switch(type) {
+ case NS_FORM_INPUT_CHECKBOX:
+ {
+ PRBool checked;
+ GetChecked(&checked);
+ SetChecked(!checked);
+ }
+ break;
+
+ case NS_FORM_INPUT_RADIO:
+ {
+ // Get the currently selected button from the radio group
+ // we get access to that via the nsIRadioControlFrame interface
+ // because the current grouping is kept in the frame.
+ nsIRadioControlFrame * rb = nsnull;
+ if (formControlFrame != nsnull) {
+ nsresult resv = formControlFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&rb);
+ if (NS_SUCCEEDED(resv) && rb) {
+ rb->GetRadioGroupSelectedContent(getter_AddRefs(selectedRadiobtn));
+ }
+ }
+ SetChecked(PR_TRUE);
+ }
+ break;
+
+ default:
+ break;
+ } //switch
}
// Try script event handlers first if its not a focus/blur event
@@ -898,28 +912,25 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
+ // now check to see if the event was "cancelled"
+ if (nsEventStatus_eConsumeNoDefault != *aEventStatus && checkWasSet &&
+ (type == NS_FORM_INPUT_CHECKBOX || type == NS_FORM_INPUT_RADIO)) {
+ // if it was cancelled and a radio button, then set the old selceted btn to TRUE
+ //. if it is a checkbox then set it to it's original value
+ if (selectedRadiobtn) {
+ nsCOMPtr inputElement = do_QueryInterface(selectedRadiobtn);
+ if (inputElement) {
+ inputElement->SetChecked(PR_TRUE);
+ }
+ } else {
+ SetChecked(orginalCheckedValue);
+ }
+ }
// Bugscape 2369: Frame might have changed during event handler
formControlFrame = nsnull;
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
- // Script is done processing, now tell the checkbox we are no longer doing an onclick
- // and if it was cancelled the checkbox will get the propriate value via the DOM listener
- if (aEvent->message == NS_MOUSE_LEFT_CLICK) {
- nsCOMPtr chkBx;
- nsCOMPtr radio;
- if (NS_SUCCEEDED(rv)) {
- chkBx = do_QueryInterface(formControlFrame);
- if (chkBx) {
- chkBx->SetIsInClickEvent(PR_FALSE);
- } else {
- radio = do_QueryInterface(formControlFrame);
- if (radio)
- radio->SetIsInClickEvent(PR_FALSE);
- }
- }
- }
-
// Finish the special file control processing...
if (oldTarget) {
// If the event is starting here that's fine. If it's not
@@ -1005,17 +1016,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
case NS_MOUSE_LEFT_CLICK:
{
switch(type) {
- case NS_FORM_INPUT_CHECKBOX:
- {
- PRBool checked;
- GetChecked(&checked);
- SetChecked(!checked);
- }
- break;
- case NS_FORM_INPUT_RADIO:
- SetChecked(PR_TRUE);
- break;
-
case NS_FORM_INPUT_BUTTON:
case NS_FORM_INPUT_RESET:
case NS_FORM_INPUT_SUBMIT:
@@ -1028,7 +1028,8 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
break;
-
+ default:
+ break;
} //switch
} break;// NS_MOUSE_LEFT_BUTTON_DOWN
} //switch
diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp
index a6c9260902c..a0034060f11 100644
--- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp
+++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp
@@ -54,8 +54,7 @@ NS_NewGfxCheckboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
// Initialize GFX-rendered state
nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame()
: mChecked(eOff),
- mCheckButtonFaceStyle(nsnull),
- mInClickEvent(PR_FALSE)
+ mCheckButtonFaceStyle(nsnull)
{
}
@@ -95,14 +94,6 @@ nsGfxCheckboxControlFrame::SetCheckboxFaceStyleContext(nsIStyleContext *aCheckbo
return NS_OK;
}
-//--------------------------------------------------------------
-NS_IMETHODIMP
-nsGfxCheckboxControlFrame::SetIsInClickEvent(PRBool aVal)
-{
- mInClickEvent = aVal;
- return NS_OK;
-}
-
//------------------------------------------------------------
//
// Init
@@ -424,22 +415,6 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
nsGfxCheckboxControlFrame::CheckState
nsGfxCheckboxControlFrame::GetCheckboxState ( )
{
- // If we are processing an onclick event then
- // always return the opposite value
- // additional explanantion is in nsICheckboxControlFrame or nsHTMLInputElement.cpp
- if (mInClickEvent) {
- if (!IsTristateCheckbox()) {
- return mChecked == eOn? eOff : eOn;
- } else {
- switch (mChecked) {
- case eOff: return eOn;
- case eOn: return eMixed;
- case eMixed: return eOff;
- default:
- break;
- }
- }
- }
return mChecked;
}
diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.h b/mozilla/layout/forms/nsGfxCheckboxControlFrame.h
index 2d1667d4c51..cecb2616aac 100644
--- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.h
+++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.h
@@ -65,7 +65,6 @@ public:
//nsICheckboxControlFrame methods
NS_IMETHOD SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext);
- NS_IMETHOD SetIsInClickEvent(PRBool aVal);
void InitializeControl(nsIPresContext* aPresContext);
diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp
index 90edcc0874c..742b5c84c05 100644
--- a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp
+++ b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp
@@ -205,9 +205,10 @@ nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioBu
//--------------------------------------------------------------
NS_IMETHODIMP
-nsGfxRadioControlFrame::SetIsInClickEvent(PRBool aVal)
+nsGfxRadioControlFrame::GetRadioGroupSelectedContent(nsIContent ** aRadioBtn)
{
- mInClickEvent = aVal;
+ NS_ENSURE_ARG_POINTER(aRadioBtn);
+ nsFormFrame::GetRadioGroupSelectedContent(this, aRadioBtn);
return NS_OK;
}
@@ -333,12 +334,6 @@ nsGfxRadioControlFrame::Paint(nsIPresContext* aPresContext,
//--------------------------------------------------------------
PRBool nsGfxRadioControlFrame::GetRadioState()
{
- // If we are processing an onclick event then
- // always return the opposite value
- // additional explanantion is in nsIRadioControlFrame or nsHTMLInputElement.cpp
- if (mInClickEvent) {
- return !mChecked;
- }
return mChecked;
}
diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.h b/mozilla/layout/forms/nsGfxRadioControlFrame.h
index 1594f1aa79a..44d09ce3869 100644
--- a/mozilla/layout/forms/nsGfxRadioControlFrame.h
+++ b/mozilla/layout/forms/nsGfxRadioControlFrame.h
@@ -46,8 +46,7 @@ public:
//nsIRadioControlFrame methods
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext);
- NS_IMETHOD SetIsInClickEvent(PRBool aVal);
-
+ NS_IMETHOD GetRadioGroupSelectedContent(nsIContent ** aRadioBtn);
virtual PRBool GetChecked();
virtual PRBool GetDefaultChecked();
@@ -110,7 +109,6 @@ protected:
virtual void SetRadioState(nsIPresContext* aPresContext, PRBool aValue);
//GFX-rendered state variables
- PRBool mInClickEvent;
PRBool mChecked;
nsIStyleContext* mRadioButtonFaceStyle;
PRBool mRestoredChecked;
diff --git a/mozilla/layout/forms/nsICheckboxControlFrame.h b/mozilla/layout/forms/nsICheckboxControlFrame.h
index cf375a96dbc..0794adaffdc 100644
--- a/mozilla/layout/forms/nsICheckboxControlFrame.h
+++ b/mozilla/layout/forms/nsICheckboxControlFrame.h
@@ -46,27 +46,6 @@ public:
*
*/
NS_IMETHOD SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext) = 0;
-
- /**
- * When a user clicks on a checkbox the value needs to be set after the onmouseup
- * and before the onclick event is processed via script. The EVM always lets script
- * get first crack at the processing, and script can cancel further processing of
- * the event by return null.
- *
- * This means the checkbox needs to have it's new value set before it goes to script
- * to process the onclick and then if script cancels the event it needs to be set back.
- * In Nav and IE there is a flash of it being set and then unset
- *
- * We have added this extra method to the checkbox to tell it to temporarily return the
- * opposite value while processing the click event. This way script gets the correct "future"
- * value of the checkbox, but there is no visual updating until after script is done processing.
- * That way if the event is cancelled then the checkbox will not flash.
- *
- * So get the Frame for the checkbox and tell it we are processing an onclick event
- * (see also: nsHTMLInputElement.cpp)
- */
- NS_IMETHOD SetIsInClickEvent(PRBool aVal) = 0;
-
};
diff --git a/mozilla/layout/forms/nsIRadioControlFrame.h b/mozilla/layout/forms/nsIRadioControlFrame.h
index f0c3bfa8729..a795af9a63a 100644
--- a/mozilla/layout/forms/nsIRadioControlFrame.h
+++ b/mozilla/layout/forms/nsIRadioControlFrame.h
@@ -48,6 +48,7 @@ public:
*/
NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext) = 0;
+
/**
* When a user clicks on a radiobutton the value needs to be set after the onmouseup
* and before the onclick event is processed via script. The EVM always lets script
@@ -58,15 +59,15 @@ public:
* to process the onclick and then if script cancels the event it needs to be set back.
* In Nav and IE there is a flash of it being set and then unset
*
- * We have added this extra method to the radiobutton to tell it to temporarily return the
- * opposite value while processing the click event. This way script gets the correct "future"
- * value of the radiobutton, but there is no visual updating until after script is done processing.
- * That way if the event is cancelled then the radiobutton will not flash.
+ * We have added this extra method to the radiobutton so nsHTMLInputElement can get
+ * the content of the currently selected radiobutton for that radio group
*
- * So get the Frame for the radiobutton and tell it we are processing an onclick event
- * (see also: nsHTMLInputElement.cpp)
+ * That way if it is cancelled then the original radiobutton can be set back
*/
- NS_IMETHOD SetIsInClickEvent(PRBool aVal) = 0;
+
+ NS_IMETHOD GetRadioGroupSelectedContent(nsIContent ** aRadioBtn) = 0;
+
+
};
#endif
diff --git a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
index 29d8b3809c5..a186a3aaf67 100644
--- a/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
+++ b/mozilla/layout/html/content/src/nsHTMLInputElement.cpp
@@ -865,32 +865,46 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
}
- // When a user clicks on a checkbox the value needs to be set after the onmouseup
- // and before the onclick event is processed via script. The EVM always lets script
- // get first crack at the processing, and script can cancel further processing of
- // the event by return null.
+ // Preset the the value of the checkbox or the radiobutton before calling into script
+ // If the event gets "cancelled" then we have to "back out" this change, but the odds
+ // of that are slimmer than it being set each time
//
- // This means the checkbox needs to have it's new value set before it goes to script
- // to process the onclick and then if script cancels the event it needs to be set back.
- // In Nav and IE there is a flash of it being set and then unset
- //
- // We have added this extra method to the checkbox to tell it to temporarily return the
- // opposite value while processing the click event. This way script gets the correct "future"
- // value of the checkbox, but there is no visual updating until after script is done processing.
- // That way if the event is cancelled then the checkbox will not flash.
- //
- // So get the Frame for the checkbox and tell it we are processing an onclick event
- if (aEvent->message == NS_MOUSE_LEFT_CLICK) {
- nsCOMPtr chkBx;
- chkBx = do_QueryInterface(formControlFrame);
- if (chkBx) {
- chkBx->SetIsInClickEvent(PR_TRUE);
- } else {
- nsCOMPtr radio;
- radio = do_QueryInterface(formControlFrame);
- if (radio)
- radio->SetIsInClickEvent(PR_TRUE);
- }
+ // Start by remember the original value and for radio buttons we must get the currently
+ // selected radiobtn. So we go get the content instead of the frame
+ PRBool orginalCheckedValue = PR_FALSE;
+ PRBool checkWasSet = PR_FALSE;
+ nsCOMPtr selectedRadiobtn;
+ if (!(aFlags & NS_EVENT_FLAG_CAPTURE) && aEvent->message == NS_MOUSE_LEFT_CLICK) {
+ GetChecked(&orginalCheckedValue);
+ checkWasSet = PR_TRUE;
+ switch(type) {
+ case NS_FORM_INPUT_CHECKBOX:
+ {
+ PRBool checked;
+ GetChecked(&checked);
+ SetChecked(!checked);
+ }
+ break;
+
+ case NS_FORM_INPUT_RADIO:
+ {
+ // Get the currently selected button from the radio group
+ // we get access to that via the nsIRadioControlFrame interface
+ // because the current grouping is kept in the frame.
+ nsIRadioControlFrame * rb = nsnull;
+ if (formControlFrame != nsnull) {
+ nsresult resv = formControlFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&rb);
+ if (NS_SUCCEEDED(resv) && rb) {
+ rb->GetRadioGroupSelectedContent(getter_AddRefs(selectedRadiobtn));
+ }
+ }
+ SetChecked(PR_TRUE);
+ }
+ break;
+
+ default:
+ break;
+ } //switch
}
// Try script event handlers first if its not a focus/blur event
@@ -898,28 +912,25 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
+ // now check to see if the event was "cancelled"
+ if (nsEventStatus_eConsumeNoDefault != *aEventStatus && checkWasSet &&
+ (type == NS_FORM_INPUT_CHECKBOX || type == NS_FORM_INPUT_RADIO)) {
+ // if it was cancelled and a radio button, then set the old selceted btn to TRUE
+ //. if it is a checkbox then set it to it's original value
+ if (selectedRadiobtn) {
+ nsCOMPtr inputElement = do_QueryInterface(selectedRadiobtn);
+ if (inputElement) {
+ inputElement->SetChecked(PR_TRUE);
+ }
+ } else {
+ SetChecked(orginalCheckedValue);
+ }
+ }
// Bugscape 2369: Frame might have changed during event handler
formControlFrame = nsnull;
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
- // Script is done processing, now tell the checkbox we are no longer doing an onclick
- // and if it was cancelled the checkbox will get the propriate value via the DOM listener
- if (aEvent->message == NS_MOUSE_LEFT_CLICK) {
- nsCOMPtr chkBx;
- nsCOMPtr radio;
- if (NS_SUCCEEDED(rv)) {
- chkBx = do_QueryInterface(formControlFrame);
- if (chkBx) {
- chkBx->SetIsInClickEvent(PR_FALSE);
- } else {
- radio = do_QueryInterface(formControlFrame);
- if (radio)
- radio->SetIsInClickEvent(PR_FALSE);
- }
- }
- }
-
// Finish the special file control processing...
if (oldTarget) {
// If the event is starting here that's fine. If it's not
@@ -1005,17 +1016,6 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
case NS_MOUSE_LEFT_CLICK:
{
switch(type) {
- case NS_FORM_INPUT_CHECKBOX:
- {
- PRBool checked;
- GetChecked(&checked);
- SetChecked(!checked);
- }
- break;
- case NS_FORM_INPUT_RADIO:
- SetChecked(PR_TRUE);
- break;
-
case NS_FORM_INPUT_BUTTON:
case NS_FORM_INPUT_RESET:
case NS_FORM_INPUT_SUBMIT:
@@ -1028,7 +1028,8 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
break;
-
+ default:
+ break;
} //switch
} break;// NS_MOUSE_LEFT_BUTTON_DOWN
} //switch
diff --git a/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h b/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h
index cf375a96dbc..0794adaffdc 100644
--- a/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h
+++ b/mozilla/layout/html/forms/public/nsICheckboxControlFrame.h
@@ -46,27 +46,6 @@ public:
*
*/
NS_IMETHOD SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext) = 0;
-
- /**
- * When a user clicks on a checkbox the value needs to be set after the onmouseup
- * and before the onclick event is processed via script. The EVM always lets script
- * get first crack at the processing, and script can cancel further processing of
- * the event by return null.
- *
- * This means the checkbox needs to have it's new value set before it goes to script
- * to process the onclick and then if script cancels the event it needs to be set back.
- * In Nav and IE there is a flash of it being set and then unset
- *
- * We have added this extra method to the checkbox to tell it to temporarily return the
- * opposite value while processing the click event. This way script gets the correct "future"
- * value of the checkbox, but there is no visual updating until after script is done processing.
- * That way if the event is cancelled then the checkbox will not flash.
- *
- * So get the Frame for the checkbox and tell it we are processing an onclick event
- * (see also: nsHTMLInputElement.cpp)
- */
- NS_IMETHOD SetIsInClickEvent(PRBool aVal) = 0;
-
};
diff --git a/mozilla/layout/html/forms/public/nsIRadioControlFrame.h b/mozilla/layout/html/forms/public/nsIRadioControlFrame.h
index f0c3bfa8729..a795af9a63a 100644
--- a/mozilla/layout/html/forms/public/nsIRadioControlFrame.h
+++ b/mozilla/layout/html/forms/public/nsIRadioControlFrame.h
@@ -48,6 +48,7 @@ public:
*/
NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext) = 0;
+
/**
* When a user clicks on a radiobutton the value needs to be set after the onmouseup
* and before the onclick event is processed via script. The EVM always lets script
@@ -58,15 +59,15 @@ public:
* to process the onclick and then if script cancels the event it needs to be set back.
* In Nav and IE there is a flash of it being set and then unset
*
- * We have added this extra method to the radiobutton to tell it to temporarily return the
- * opposite value while processing the click event. This way script gets the correct "future"
- * value of the radiobutton, but there is no visual updating until after script is done processing.
- * That way if the event is cancelled then the radiobutton will not flash.
+ * We have added this extra method to the radiobutton so nsHTMLInputElement can get
+ * the content of the currently selected radiobutton for that radio group
*
- * So get the Frame for the radiobutton and tell it we are processing an onclick event
- * (see also: nsHTMLInputElement.cpp)
+ * That way if it is cancelled then the original radiobutton can be set back
*/
- NS_IMETHOD SetIsInClickEvent(PRBool aVal) = 0;
+
+ NS_IMETHOD GetRadioGroupSelectedContent(nsIContent ** aRadioBtn) = 0;
+
+
};
#endif
diff --git a/mozilla/layout/html/forms/src/nsFormFrame.cpp b/mozilla/layout/html/forms/src/nsFormFrame.cpp
index 59c15a95309..b63cff7187d 100644
--- a/mozilla/layout/html/forms/src/nsFormFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsFormFrame.cpp
@@ -118,24 +118,13 @@ static NS_DEFINE_CID(kPlatformCharsetCID, NS_PLATFORMCHARSET_CID);
//----------------------------------------------------------------------
-static NS_DEFINE_IID(kIFormManagerIID, NS_IFORMMANAGER_IID);
-static NS_DEFINE_IID(kIFormIID, NS_IFORM_IID);
-static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
-static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
-static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
-static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
-static NS_DEFINE_IID(kIDOMHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
-static NS_DEFINE_IID(kIDOMNSHTMLFormElementIID, NS_IDOMNSHTMLFORMELEMENT_IID);
-static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
-static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
-static NS_DEFINE_IID(kIDOMHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
NS_IMETHODIMP
nsFormFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
- if (aIID.Equals(kIFormManagerIID)) {
+ if (aIID.Equals(NS_GET_IID(nsIFormManager))) {
*aInstancePtr = (void*)(nsIFormManager*)this;
return NS_OK;
}
@@ -196,7 +185,7 @@ nsFormFrame::GetAction(nsString* aAction)
nsresult result = NS_OK;
if (mContent) {
nsIDOMHTMLFormElement* form = nsnull;
- result = mContent->QueryInterface(kIDOMHTMLFormElementIID, (void**)&form);
+ result = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLFormElement), (void**)&form);
if ((NS_OK == result) && form) {
form->GetAction(*aAction);
NS_RELEASE(form);
@@ -211,7 +200,7 @@ nsFormFrame::GetTarget(nsString* aTarget)
nsresult result = NS_OK;
if (mContent) {
nsIDOMHTMLFormElement* form = nsnull;
- result = mContent->QueryInterface(kIDOMHTMLFormElementIID, (void**)&form);
+ result = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLFormElement), (void**)&form);
if ((NS_OK == result) && form) {
form->GetTarget(*aTarget);
if ((*aTarget).Length() == 0) {
@@ -299,7 +288,7 @@ void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFrame& aF
{
// Make sure we have a form control
nsIFormControlFrame* fcFrame = nsnull;
- nsresult result = aFrame.QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
+ nsresult result = aFrame.QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
if ((NS_OK != result) || (nsnull == fcFrame)) {
return;
}
@@ -309,7 +298,7 @@ void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFrame& aF
result = aFrame.GetContent(getter_AddRefs(iContent));
if (NS_SUCCEEDED(result) && iContent) {
nsCOMPtr formControl;
- result = iContent->QueryInterface(kIFormControlIID, getter_AddRefs(formControl));
+ result = iContent->QueryInterface(NS_GET_IID(nsIFormControl), getter_AddRefs(formControl));
if (NS_SUCCEEDED(result) && formControl) {
nsCOMPtr formElem;
result = formControl->GetForm(getter_AddRefs(formElem));
@@ -318,7 +307,7 @@ void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFrame& aF
result = aPresContext->GetShell(getter_AddRefs(presShell));
if (NS_SUCCEEDED(result) && presShell) {
nsIContent* formContent;
- result = formElem->QueryInterface(kIContentIID, (void**)&formContent);
+ result = formElem->QueryInterface(NS_GET_IID(nsIContent), (void**)&formContent);
if (NS_SUCCEEDED(result) && formContent) {
nsFormFrame* formFrame = nsnull;
result = presShell->GetPrimaryFrameFor(formContent, (nsIFrame**)&formFrame);
@@ -370,7 +359,7 @@ nsFormFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIFrame* aOldFrame)
{
nsIFormControlFrame* fcFrame = nsnull;
- nsresult result = aOldFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
+ nsresult result = aOldFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
if ((NS_OK == result) || (nsnull != fcFrame)) {
PRInt32 type;
fcFrame->GetType(&type);
@@ -571,7 +560,41 @@ void nsFormFrame::RemoveRadioControlFrame(nsIFormControlFrame * aFrame)
}
}
}
+
+//--------------------------------------------------------
+// Return the content of the currently selected item in
+// the radio group of the incoming radiobutton.
+//--------------------------------------------------------
+nsresult
+nsFormFrame::GetRadioGroupSelectedContent(nsGfxRadioControlFrame* aControl,
+ nsIContent ** aRadiobtn)
+{
+ NS_ASSERTION(aControl, "nsGfxRadioControlFrame can't be null");
+
+ // first get correct interface
+ nsIFormControlFrame* fcFrame = nsnull;
+ nsresult result = aControl->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
+ if (NS_SUCCEEDED(result)) {
+ // get the form frame for the radio btn
+ nsFormFrame * formFrame = ((nsFormControlFrame *)aControl)->GetFormFrame();
+ if (formFrame != nsnull) {
+ // now get the radio group by name
+ nsAutoString groupName;
+ nsRadioControlGroup * group = nsnull;
+ result = formFrame->GetRadioInfo(fcFrame, groupName, group);
+ if (NS_SUCCEEDED(result) && nsnull != group) {
+ // get the currently checked radio button
+ nsGfxRadioControlFrame* currentCheckBtn = group->GetCheckedRadio();
+ if (currentCheckBtn != nsnull) {
+ currentCheckBtn->GetContent(aRadiobtn);
+ }
+ }
+ }
+ }
+ return NS_OK;
+}
+
//--------------------------------------------------------
// returns NS_ERROR_FAILURE if the radiobtn doesn't have a group
// returns NS_OK is it did have a radio group
@@ -581,21 +604,17 @@ nsFormFrame::OnRadioChecked(nsIPresContext* aPresContext,
nsGfxRadioControlFrame& aControl,
PRBool aNewCheckedVal)
{
- nsString radioName;
- aControl.GetName(&radioName);
- if (0 == radioName.Length()) { // don't consider a radio without a name
- return NS_ERROR_FAILURE;
- }
-
- // locate the radio group with the name of aRadio
- int numGroups = mRadioGroups.Count();
- for (int j = 0; j < numGroups; j++) {
- nsRadioControlGroup* group = (nsRadioControlGroup *) mRadioGroups.ElementAt(j);
- nsString groupName;
- group->GetName(groupName);
- // get the currently checked radio button
- nsGfxRadioControlFrame* currentCheckBtn = group->GetCheckedRadio();
- if (groupName.Equals(radioName)) {
+ // first get correct interface
+ nsIFormControlFrame* fcFrame = nsnull;
+ nsresult result = aControl.QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
+ if (NS_SUCCEEDED(result)) {
+ // now get the radio group by name
+ nsAutoString groupName;
+ nsRadioControlGroup * group = nsnull;
+ result = GetRadioInfo(fcFrame, groupName, group);
+ if (NS_SUCCEEDED(result) && nsnull != group) {
+ // get the currently checked radio button
+ nsGfxRadioControlFrame* currentCheckBtn = group->GetCheckedRadio();
// is the new checked btn different than the current button?
if (&aControl != currentCheckBtn) {
// if the new button is being set to false
@@ -612,11 +631,13 @@ nsFormFrame::OnRadioChecked(nsIPresContext* aPresContext,
// here we are setting the same radio button
// as the one that is currently checked
//
- currentCheckBtn->SetChecked(aPresContext, aNewCheckedVal, PR_FALSE);
- // So if we are setting the current btn to be 0 or off
- // then we must set a default selction
- if (!aNewCheckedVal) {
- DoDefaultSelection(aPresContext, group, currentCheckBtn);
+ if (currentCheckBtn != nsnull) {
+ currentCheckBtn->SetChecked(aPresContext, aNewCheckedVal, PR_FALSE);
+ // So if we are setting the current btn to be 0 or off
+ // then we must set a default selction
+ if (!aNewCheckedVal) {
+ DoDefaultSelection(aPresContext, group, currentCheckBtn);
+ }
}
}
}
@@ -666,7 +687,7 @@ nsFormFrame::ProcessValue(nsIFormProcessor& aFormProcessor, nsIFormControlFrame*
nsresult rv = frame->GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && content) {
nsCOMPtr formElement;
- res = content->QueryInterface(kIDOMHTMLElementIID, getter_AddRefs(formElement));
+ res = content->QueryInterface(NS_GET_IID(nsIDOMHTMLElement), getter_AddRefs(formElement));
if (NS_SUCCEEDED(res) && formElement) {
res = aFormProcessor.ProcessValue(formElement, aName, aValue);
NS_ASSERTION(NS_SUCCEEDED(res), "unable Notify form process observer");
@@ -709,7 +730,7 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
// Since JS Submit() calls are not linked to an element, aFrame is null.
// fcframe will remain null, but IsSuccess will return succes in this case.
if (aFrame != nsnull) {
- aFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
+ aFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
}
nsIFileSpec* multipartDataFile = nsnull;
@@ -754,7 +775,7 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
if (href.IsEmpty()) {
nsCOMPtr htmlDoc;
- if (PR_FALSE == NS_SUCCEEDED(document->QueryInterface(kIHTMLDocumentIID,
+ if (PR_FALSE == NS_SUCCEEDED(document->QueryInterface(NS_GET_IID(nsIHTMLDocument),
getter_AddRefs(htmlDoc)))) {
// Must be a XML, XUL or other non-HTML document type
// so do nothing.
@@ -912,6 +933,23 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
/* The postBuffer is now owned by the IPostData instance */
}
if (handler) {
+#if defined(DEBUG_rods) || defined(DEBUG_pollmann)
+ {
+ printf("******\n");
+ char * str = data.ToNewCString();
+ printf("postBuffer[%s]\n", str);
+ Recycle(str);
+
+ str = absURLSpec.ToNewCString();
+ printf("absURLSpec[%s]\n", str);
+ Recycle(str);
+
+ str = target.ToNewCString();
+ printf("target [%s]\n", str);
+ Recycle(str);
+ printf("******\n");
+ }
+#endif
handler->OnLinkClick(mContent, eLinkVerb_Replace,
absURLSpec.GetUnicode(),
target.GetUnicode(), postDataStream);
diff --git a/mozilla/layout/html/forms/src/nsFormFrame.h b/mozilla/layout/html/forms/src/nsFormFrame.h
index 43bc34de178..7cf0857b9fe 100644
--- a/mozilla/layout/html/forms/src/nsFormFrame.h
+++ b/mozilla/layout/html/forms/src/nsFormFrame.h
@@ -92,6 +92,8 @@ public:
static nsresult GetValue(nsIFrame* aChildFrame, nsString& aValue, nsIContent* aContent = 0);
static void StyleChangeReflow(nsIPresContext* aPresContext,
nsIFrame* aFrame);
+ static nsresult GetRadioGroupSelectedContent(nsGfxRadioControlFrame* aControl,
+ nsIContent ** aRadiobtn);
void SetFlags(PRUint32 aFlags) {
mState &= ~NS_BLOCK_FLAGS_MASK;
mState |= aFlags;
diff --git a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp
index a6c9260902c..a0034060f11 100644
--- a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.cpp
@@ -54,8 +54,7 @@ NS_NewGfxCheckboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
// Initialize GFX-rendered state
nsGfxCheckboxControlFrame::nsGfxCheckboxControlFrame()
: mChecked(eOff),
- mCheckButtonFaceStyle(nsnull),
- mInClickEvent(PR_FALSE)
+ mCheckButtonFaceStyle(nsnull)
{
}
@@ -95,14 +94,6 @@ nsGfxCheckboxControlFrame::SetCheckboxFaceStyleContext(nsIStyleContext *aCheckbo
return NS_OK;
}
-//--------------------------------------------------------------
-NS_IMETHODIMP
-nsGfxCheckboxControlFrame::SetIsInClickEvent(PRBool aVal)
-{
- mInClickEvent = aVal;
- return NS_OK;
-}
-
//------------------------------------------------------------
//
// Init
@@ -424,22 +415,6 @@ nsGfxCheckboxControlFrame::Paint(nsIPresContext* aPresContext,
nsGfxCheckboxControlFrame::CheckState
nsGfxCheckboxControlFrame::GetCheckboxState ( )
{
- // If we are processing an onclick event then
- // always return the opposite value
- // additional explanantion is in nsICheckboxControlFrame or nsHTMLInputElement.cpp
- if (mInClickEvent) {
- if (!IsTristateCheckbox()) {
- return mChecked == eOn? eOff : eOn;
- } else {
- switch (mChecked) {
- case eOff: return eOn;
- case eOn: return eMixed;
- case eMixed: return eOff;
- default:
- break;
- }
- }
- }
return mChecked;
}
diff --git a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h
index 2d1667d4c51..cecb2616aac 100644
--- a/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h
+++ b/mozilla/layout/html/forms/src/nsGfxCheckboxControlFrame.h
@@ -65,7 +65,6 @@ public:
//nsICheckboxControlFrame methods
NS_IMETHOD SetCheckboxFaceStyleContext(nsIStyleContext *aCheckboxFaceStyleContext);
- NS_IMETHOD SetIsInClickEvent(PRBool aVal);
void InitializeControl(nsIPresContext* aPresContext);
diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp
index 90edcc0874c..742b5c84c05 100644
--- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.cpp
@@ -205,9 +205,10 @@ nsGfxRadioControlFrame::SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioBu
//--------------------------------------------------------------
NS_IMETHODIMP
-nsGfxRadioControlFrame::SetIsInClickEvent(PRBool aVal)
+nsGfxRadioControlFrame::GetRadioGroupSelectedContent(nsIContent ** aRadioBtn)
{
- mInClickEvent = aVal;
+ NS_ENSURE_ARG_POINTER(aRadioBtn);
+ nsFormFrame::GetRadioGroupSelectedContent(this, aRadioBtn);
return NS_OK;
}
@@ -333,12 +334,6 @@ nsGfxRadioControlFrame::Paint(nsIPresContext* aPresContext,
//--------------------------------------------------------------
PRBool nsGfxRadioControlFrame::GetRadioState()
{
- // If we are processing an onclick event then
- // always return the opposite value
- // additional explanantion is in nsIRadioControlFrame or nsHTMLInputElement.cpp
- if (mInClickEvent) {
- return !mChecked;
- }
return mChecked;
}
diff --git a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h
index 1594f1aa79a..44d09ce3869 100644
--- a/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h
+++ b/mozilla/layout/html/forms/src/nsGfxRadioControlFrame.h
@@ -46,8 +46,7 @@ public:
//nsIRadioControlFrame methods
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD SetRadioButtonFaceStyleContext(nsIStyleContext *aRadioButtonFaceStyleContext);
- NS_IMETHOD SetIsInClickEvent(PRBool aVal);
-
+ NS_IMETHOD GetRadioGroupSelectedContent(nsIContent ** aRadioBtn);
virtual PRBool GetChecked();
virtual PRBool GetDefaultChecked();
@@ -110,7 +109,6 @@ protected:
virtual void SetRadioState(nsIPresContext* aPresContext, PRBool aValue);
//GFX-rendered state variables
- PRBool mInClickEvent;
PRBool mChecked;
nsIStyleContext* mRadioButtonFaceStyle;
PRBool mRestoredChecked;