зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1100535 - Do not assume that the radio required status changed when the attribute changes. r=smaug
--HG-- extra : rebase_source : 5f6b36ba8a05507638d5ab4513864a308fa939c7
This commit is contained in:
Родитель
19a23b3d8b
Коммит
95cb83384e
|
@ -8376,13 +8376,11 @@ nsDocument::GetRequiredRadioCount(const nsAString& aName) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDocument::RadioRequiredChanged(const nsAString& aName, nsIFormControl* aRadio)
|
nsDocument::RadioRequiredWillChange(const nsAString& aName, bool aRequiredAdded)
|
||||||
{
|
{
|
||||||
nsRadioGroupStruct* radioGroup = GetOrCreateRadioGroup(aName);
|
nsRadioGroupStruct* radioGroup = GetOrCreateRadioGroup(aName);
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
|
if (aRequiredAdded) {
|
||||||
NS_ASSERTION(element, "radio controls have to be content elements");
|
|
||||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
|
|
||||||
radioGroup->mRequiredRadioCount++;
|
radioGroup->mRequiredRadioCount++;
|
||||||
} else {
|
} else {
|
||||||
NS_ASSERTION(radioGroup->mRequiredRadioCount != 0,
|
NS_ASSERTION(radioGroup->mRequiredRadioCount != 0,
|
||||||
|
|
|
@ -930,8 +930,8 @@ public:
|
||||||
virtual void RemoveFromRadioGroup(const nsAString& aName,
|
virtual void RemoveFromRadioGroup(const nsAString& aName,
|
||||||
nsIFormControl* aRadio) MOZ_OVERRIDE;
|
nsIFormControl* aRadio) MOZ_OVERRIDE;
|
||||||
virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const MOZ_OVERRIDE;
|
virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const MOZ_OVERRIDE;
|
||||||
virtual void RadioRequiredChanged(const nsAString& aName,
|
virtual void RadioRequiredWillChange(const nsAString& aName,
|
||||||
nsIFormControl* aRadio) MOZ_OVERRIDE;
|
bool aRequiredAdded) MOZ_OVERRIDE;
|
||||||
virtual bool GetValueMissingState(const nsAString& aName) const MOZ_OVERRIDE;
|
virtual bool GetValueMissingState(const nsAString& aName) const MOZ_OVERRIDE;
|
||||||
virtual void SetValueMissingState(const nsAString& aName, bool aValue) MOZ_OVERRIDE;
|
virtual void SetValueMissingState(const nsAString& aName, bool aValue) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
|
|
@ -2196,13 +2196,10 @@ HTMLFormElement::GetRequiredRadioCount(const nsAString& aName) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HTMLFormElement::RadioRequiredChanged(const nsAString& aName,
|
HTMLFormElement::RadioRequiredWillChange(const nsAString& aName,
|
||||||
nsIFormControl* aRadio)
|
bool aRequiredAdded)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aRadio);
|
if (aRequiredAdded) {
|
||||||
NS_ASSERTION(element, "radio controls have to be content elements!");
|
|
||||||
|
|
||||||
if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
|
|
||||||
mRequiredRadioButtonCounts.Put(aName,
|
mRequiredRadioButtonCounts.Put(aName,
|
||||||
mRequiredRadioButtonCounts.Get(aName)+1);
|
mRequiredRadioButtonCounts.Get(aName)+1);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -76,8 +76,8 @@ public:
|
||||||
void AddToRadioGroup(const nsAString& aName, nsIFormControl* aRadio) MOZ_OVERRIDE;
|
void AddToRadioGroup(const nsAString& aName, nsIFormControl* aRadio) MOZ_OVERRIDE;
|
||||||
void RemoveFromRadioGroup(const nsAString& aName, nsIFormControl* aRadio) MOZ_OVERRIDE;
|
void RemoveFromRadioGroup(const nsAString& aName, nsIFormControl* aRadio) MOZ_OVERRIDE;
|
||||||
virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const MOZ_OVERRIDE;
|
virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const MOZ_OVERRIDE;
|
||||||
virtual void RadioRequiredChanged(const nsAString& aName,
|
virtual void RadioRequiredWillChange(const nsAString& aName,
|
||||||
nsIFormControl* aRadio) MOZ_OVERRIDE;
|
bool aRequiredAdded) MOZ_OVERRIDE;
|
||||||
virtual bool GetValueMissingState(const nsAString& aName) const MOZ_OVERRIDE;
|
virtual bool GetValueMissingState(const nsAString& aName) const MOZ_OVERRIDE;
|
||||||
virtual void SetValueMissingState(const nsAString& aName, bool aValue) MOZ_OVERRIDE;
|
virtual void SetValueMissingState(const nsAString& aName, bool aValue) MOZ_OVERRIDE;
|
||||||
|
|
||||||
|
|
|
@ -1332,6 +1332,16 @@ HTMLInputElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||||
AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
||||||
nsGkAtoms::_auto, eIgnoreCase)) {
|
nsGkAtoms::_auto, eIgnoreCase)) {
|
||||||
SetDirectionIfAuto(false, aNotify);
|
SetDirectionIfAuto(false, aNotify);
|
||||||
|
} else if (mType == NS_FORM_INPUT_RADIO && aName == nsGkAtoms::required) {
|
||||||
|
nsCOMPtr<nsIRadioGroupContainer> container = GetRadioGroupContainer();
|
||||||
|
|
||||||
|
if (container &&
|
||||||
|
((aValue && !HasAttr(aNameSpaceID, aName)) ||
|
||||||
|
(!aValue && HasAttr(aNameSpaceID, aName)))) {
|
||||||
|
nsAutoString name;
|
||||||
|
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
||||||
|
container->RadioRequiredWillChange(name, !!aValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,16 +1415,6 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mType == NS_FORM_INPUT_RADIO && aName == nsGkAtoms::required) {
|
|
||||||
nsCOMPtr<nsIRadioGroupContainer> container = GetRadioGroupContainer();
|
|
||||||
|
|
||||||
if (container) {
|
|
||||||
nsAutoString name;
|
|
||||||
GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
|
||||||
container->RadioRequiredChanged(name, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||
|
if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||
|
||||||
aName == nsGkAtoms::readonly) {
|
aName == nsGkAtoms::readonly) {
|
||||||
UpdateValueMissingValidityState();
|
UpdateValueMissingValidityState();
|
||||||
|
|
|
@ -18,8 +18,8 @@ class HTMLInputElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NS_IRADIOGROUPCONTAINER_IID \
|
#define NS_IRADIOGROUPCONTAINER_IID \
|
||||||
{ 0x22924a01, 0x4360, 0x401b, \
|
{ 0x800320a0, 0x733f, 0x11e4, \
|
||||||
{ 0xb1, 0xd1, 0x56, 0x8d, 0xf5, 0xa3, 0xda, 0x71 } }
|
{ 0x82, 0xf8, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A container that has multiple radio groups in it, defined by name.
|
* A container that has multiple radio groups in it, defined by name.
|
||||||
|
@ -91,8 +91,8 @@ public:
|
||||||
virtual void RemoveFromRadioGroup(const nsAString& aName, nsIFormControl* aRadio) = 0;
|
virtual void RemoveFromRadioGroup(const nsAString& aName, nsIFormControl* aRadio) = 0;
|
||||||
|
|
||||||
virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const = 0;
|
virtual uint32_t GetRequiredRadioCount(const nsAString& aName) const = 0;
|
||||||
virtual void RadioRequiredChanged(const nsAString& aName,
|
virtual void RadioRequiredWillChange(const nsAString& aName,
|
||||||
nsIFormControl* aRadio) = 0;
|
bool aRequiredAdded) = 0;
|
||||||
virtual bool GetValueMissingState(const nsAString& aName) const = 0;
|
virtual bool GetValueMissingState(const nsAString& aName) const = 0;
|
||||||
virtual void SetValueMissingState(const nsAString& aName, bool aValue) = 0;
|
virtual void SetValueMissingState(const nsAString& aName, bool aValue) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@ support-files =
|
||||||
[test_bug1039548.html]
|
[test_bug1039548.html]
|
||||||
[test_button_attributes_reflection.html]
|
[test_button_attributes_reflection.html]
|
||||||
[test_input_radio_radiogroup.html]
|
[test_input_radio_radiogroup.html]
|
||||||
|
[test_input_radio_required.html]
|
||||||
[test_change_event.html]
|
[test_change_event.html]
|
||||||
skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
|
skip-if = buildapp == 'mulet' || (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
|
||||||
[test_datalist_element.html]
|
[test_datalist_element.html]
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id={BUGNUMBER}
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 1100535</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1100535">Mozilla Bug 1100535</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
<form>
|
||||||
|
<input type="radio" name="a">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
var input = document.querySelector("input");
|
||||||
|
input.setAttribute("required", "x");
|
||||||
|
input.setAttribute("required", "y");
|
||||||
|
is(document.forms[0].checkValidity(), false);
|
||||||
|
input.required = false;
|
||||||
|
is(document.forms[0].checkValidity(), true);
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче