mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 775049 - DeCOMtaminate nsIRadioGroupContainer; f=Ms2ger r=mounir
This commit is contained in:
parent
54bd98e36a
commit
f71f7ae597
@ -6461,23 +6461,18 @@ nsDocument::GetOrCreateRadioGroup(const nsAString& aName)
|
||||
return newRadioGroup.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsDocument::SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio)
|
||||
{
|
||||
nsRadioGroupStruct* radioGroup = GetOrCreateRadioGroup(aName);
|
||||
radioGroup->mSelectedRadioButton = aRadio;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement** aRadio)
|
||||
nsIDOMHTMLInputElement*
|
||||
nsDocument::GetCurrentRadioButton(const nsAString& aName)
|
||||
{
|
||||
nsRadioGroupStruct* radioGroup = GetOrCreateRadioGroup(aName);
|
||||
*aRadio = radioGroup->mSelectedRadioButton;
|
||||
NS_IF_ADDREF(*aRadio);
|
||||
return NS_OK;
|
||||
return GetOrCreateRadioGroup(aName)->mSelectedRadioButton;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -6533,12 +6528,11 @@ nsDocument::GetNextRadioButton(const nsAString& aName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsDocument::AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio)
|
||||
{
|
||||
nsRadioGroupStruct* radioGroup = GetOrCreateRadioGroup(aName);
|
||||
|
||||
radioGroup->mRadioButtons.AppendObject(aRadio);
|
||||
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
|
||||
@ -6546,15 +6540,13 @@ nsDocument::AddToRadioGroup(const nsAString& aName,
|
||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
|
||||
radioGroup->mRequiredRadioCount++;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsDocument::RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio)
|
||||
{
|
||||
nsRadioGroupStruct* radioGroup = GetOrCreateRadioGroup(aName);
|
||||
|
||||
radioGroup->mRadioButtons.RemoveObject(aRadio);
|
||||
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
|
||||
@ -6564,7 +6556,6 @@ nsDocument::RemoveFromRadioGroup(const nsAString& aName,
|
||||
"mRequiredRadioCount about to wrap below 0!");
|
||||
radioGroup->mRequiredRadioCount--;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -704,18 +704,17 @@ public:
|
||||
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
|
||||
nsIRadioVisitor* aVisitor,
|
||||
bool aFlushContent);
|
||||
NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio);
|
||||
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement** aRadio);
|
||||
virtual void SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio);
|
||||
virtual nsIDOMHTMLInputElement* GetCurrentRadioButton(const nsAString& aName);
|
||||
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
||||
const bool aPrevious,
|
||||
nsIDOMHTMLInputElement* aFocusedRadio,
|
||||
nsIDOMHTMLInputElement** aRadioOut);
|
||||
NS_IMETHOD AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
virtual void AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
virtual void RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const;
|
||||
virtual void RadioRequiredChanged(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
|
@ -41,16 +41,15 @@ public:
|
||||
* @param aName the group name
|
||||
* @param aRadio the currently selected radio button
|
||||
*/
|
||||
NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio) = 0;
|
||||
virtual void SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio) = 0;
|
||||
|
||||
/**
|
||||
* Get the current radio button in a group
|
||||
* @param aName the group name
|
||||
* @param aRadio the currently selected radio button [OUT]
|
||||
* @return the currently selected radio button
|
||||
*/
|
||||
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement** aRadio) = 0;
|
||||
virtual nsIDOMHTMLInputElement* GetCurrentRadioButton(const nsAString& aName) = 0;
|
||||
|
||||
/**
|
||||
* Get the next/prev radio button in a group
|
||||
@ -73,8 +72,7 @@ public:
|
||||
* @param aName radio group's name
|
||||
* @param aRadio radio button's pointer
|
||||
*/
|
||||
NS_IMETHOD AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio) = 0;
|
||||
virtual void AddToRadioGroup(const nsAString& aName, nsIFormControl* aRadio) = 0;
|
||||
|
||||
/**
|
||||
* Remove radio button from radio group
|
||||
@ -85,8 +83,7 @@ public:
|
||||
* @param aName radio group's name
|
||||
* @param aRadio radio button's pointer
|
||||
*/
|
||||
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio) = 0;
|
||||
virtual void RemoveFromRadioGroup(const nsAString& aName, nsIFormControl* aRadio) = 0;
|
||||
|
||||
virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const = 0;
|
||||
virtual void RadioRequiredChanged(const nsAString& aName,
|
||||
|
@ -1867,22 +1867,17 @@ nsHTMLFormElement::IndexOfControl(nsIFormControl* aControl)
|
||||
return mControls->IndexOfControl(aControl, &index) == NS_OK ? index : 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLFormElement::SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio)
|
||||
{
|
||||
mSelectedRadioButtons.Put(aName, aRadio);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFormElement::GetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement** aRadio)
|
||||
nsIDOMHTMLInputElement*
|
||||
nsHTMLFormElement::GetCurrentRadioButton(const nsAString& aName)
|
||||
{
|
||||
mSelectedRadioButtons.Get(aName, aRadio);
|
||||
|
||||
return NS_OK;
|
||||
return mSelectedRadioButtons.GetWeak(aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -2008,7 +2003,7 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLFormElement::AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio)
|
||||
{
|
||||
@ -2019,11 +2014,9 @@ nsHTMLFormElement::AddToRadioGroup(const nsAString& aName,
|
||||
mRequiredRadioButtonCounts.Put(aName,
|
||||
mRequiredRadioButtonCounts.Get(aName)+1);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLFormElement::RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio)
|
||||
{
|
||||
@ -2041,8 +2034,6 @@ nsHTMLFormElement::RemoveFromRadioGroup(const nsAString& aName,
|
||||
mRequiredRadioButtonCounts.Put(aName, requiredNb-1);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
|
@ -62,20 +62,17 @@ public:
|
||||
NS_IMETHOD_(nsIFormControl*) GetDefaultSubmitElement() const;
|
||||
|
||||
// nsIRadioGroupContainer
|
||||
NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio);
|
||||
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement** aRadio);
|
||||
void SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio);
|
||||
nsIDOMHTMLInputElement* GetCurrentRadioButton(const nsAString& aName);
|
||||
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
||||
const bool aPrevious,
|
||||
nsIDOMHTMLInputElement* aFocusedRadio,
|
||||
nsIDOMHTMLInputElement** aRadioOut);
|
||||
NS_IMETHOD WalkRadioGroup(const nsAString& aName, nsIRadioVisitor* aVisitor,
|
||||
bool aFlushContent);
|
||||
NS_IMETHOD AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
void AddToRadioGroup(const nsAString& aName, nsIFormControl* aRadio);
|
||||
void RemoveFromRadioGroup(const nsAString& aName, nsIFormControl* aRadio);
|
||||
virtual PRUint32 GetRequiredRadioCount(const nsAString& aName) const;
|
||||
virtual void RadioRequiredChanged(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
|
@ -1655,10 +1655,11 @@ nsHTMLInputElement::SetCheckedChangedInternal(bool aCheckedChanged)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SetChecked(bool aChecked)
|
||||
{
|
||||
return DoSetChecked(aChecked, true, true);
|
||||
DoSetChecked(aChecked, true, true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsHTMLInputElement::DoSetChecked(bool aChecked, bool aNotify,
|
||||
bool aSetValueChanged)
|
||||
{
|
||||
@ -1673,18 +1674,19 @@ nsHTMLInputElement::DoSetChecked(bool aChecked, bool aNotify,
|
||||
// screw up state actually, especially when you are setting radio button to
|
||||
// false)
|
||||
if (mChecked == aChecked) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set checked
|
||||
if (mType != NS_FORM_INPUT_RADIO) {
|
||||
SetCheckedInternal(aChecked, aNotify);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// For radio button, we need to do some extra fun stuff
|
||||
if (aChecked) {
|
||||
return RadioSetChecked(aNotify);
|
||||
RadioSetChecked(aNotify);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIRadioGroupContainer* container = GetRadioGroupContainer();
|
||||
@ -1697,10 +1699,9 @@ nsHTMLInputElement::DoSetChecked(bool aChecked, bool aNotify,
|
||||
// validity state. We have to be sure the radio group container knows
|
||||
// the currently selected radio.
|
||||
SetCheckedInternal(false, aNotify);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsHTMLInputElement::RadioSetChecked(bool aNotify)
|
||||
{
|
||||
// Find the selected radio button so we can deselect it
|
||||
@ -1715,22 +1716,16 @@ nsHTMLInputElement::RadioSetChecked(bool aNotify)
|
||||
}
|
||||
|
||||
// Let the group know that we are now the One True Radio Button
|
||||
nsresult rv = NS_OK;
|
||||
nsIRadioGroupContainer* container = GetRadioGroupContainer();
|
||||
if (container) {
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
rv = container->SetCurrentRadioButton(name, this);
|
||||
container->SetCurrentRadioButton(name, this);
|
||||
}
|
||||
|
||||
// SetCheckedInternal is going to ask all radios to update their
|
||||
// validity state. We have to be sure the radio group container knows
|
||||
// the currently selected radio.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetCheckedInternal(true, aNotify);
|
||||
}
|
||||
|
||||
return rv;
|
||||
// validity state.
|
||||
SetCheckedInternal(true, aNotify);
|
||||
}
|
||||
|
||||
nsIRadioGroupContainer*
|
||||
@ -1764,8 +1759,7 @@ nsHTMLInputElement::GetSelectedRadioButton()
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> selected;
|
||||
container->GetCurrentRadioButton(name, getter_AddRefs(selected));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> selected = container->GetCurrentRadioButton(name);
|
||||
return selected.forget();
|
||||
}
|
||||
|
||||
@ -3142,7 +3136,8 @@ nsHTMLInputElement::Reset()
|
||||
case VALUE_MODE_VALUE:
|
||||
return SetDefaultValueAsValue();
|
||||
case VALUE_MODE_DEFAULT_ON:
|
||||
return DoSetChecked(DefaultChecked(), true, false);
|
||||
DoSetChecked(DefaultChecked(), true, false);
|
||||
return NS_OK;
|
||||
case VALUE_MODE_FILENAME:
|
||||
ClearFiles(false);
|
||||
return NS_OK;
|
||||
@ -3658,8 +3653,7 @@ nsHTMLInputElement::IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32
|
||||
nsAutoString name;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> currentRadio;
|
||||
container->GetCurrentRadioButton(name, getter_AddRefs(currentRadio));
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> currentRadio = container->GetCurrentRadioButton(name);
|
||||
if (currentRadio) {
|
||||
*aTabIndex = -1;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ protected:
|
||||
* Do all the work that |SetChecked| does (radio button handling, etc.), but
|
||||
* take an |aNotify| parameter.
|
||||
*/
|
||||
nsresult DoSetChecked(bool aValue, bool aNotify, bool aSetValueChanged);
|
||||
void DoSetChecked(bool aValue, bool aNotify, bool aSetValueChanged);
|
||||
|
||||
/**
|
||||
* Do all the work that |SetCheckedChanged| does (radio button handling,
|
||||
@ -415,7 +415,7 @@ protected:
|
||||
*/
|
||||
void SetCheckedInternal(bool aValue, bool aNotify);
|
||||
|
||||
nsresult RadioSetChecked(bool aNotify);
|
||||
void RadioSetChecked(bool aNotify);
|
||||
void SetCheckedChanged(bool aCheckedChanged);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user