diff --git a/content/html/content/src/nsHTMLFieldSetElement.cpp b/content/html/content/src/nsHTMLFieldSetElement.cpp
index cc8524c8fcb2..76e22814f4a9 100644
--- a/content/html/content/src/nsHTMLFieldSetElement.cpp
+++ b/content/html/content/src/nsHTMLFieldSetElement.cpp
@@ -75,6 +75,17 @@ public:
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
virtual nsXPCClassInfo* GetClassInfo();
+
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLFieldSetElement,
+ nsGenericHTMLFormElement)
+private:
+
+ // This function is used to generate the nsContentList (listed form elements).
+ static PRBool MatchListedElements(nsIContent* aContent, PRInt32 aNamespaceID,
+ nsIAtom* aAtom, void* aData);
+
+ // listed form controls elements.
+ nsRefPtr mElements;
};
// construction, destruction
@@ -96,6 +107,16 @@ nsHTMLFieldSetElement::~nsHTMLFieldSetElement()
// nsISupports
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHTMLFieldSetElement)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mElements)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLFieldSetElement)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLFieldSetElement,
+ nsGenericHTMLFormElement)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mElements, nsIDOMNodeList)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
NS_IMPL_ADDREF_INHERITED(nsHTMLFieldSetElement, nsGenericElement)
NS_IMPL_RELEASE_INHERITED(nsHTMLFieldSetElement, nsGenericElement)
@@ -133,6 +154,27 @@ nsHTMLFieldSetElement::GetType(nsAString& aType)
return NS_OK;
}
+/* static */
+PRBool
+nsHTMLFieldSetElement::MatchListedElements(nsIContent* aContent, PRInt32 aNamespaceID,
+ nsIAtom* aAtom, void* aData)
+{
+ nsCOMPtr formControl = do_QueryInterface(aContent);
+ return formControl && formControl->GetType() != NS_FORM_LABEL;
+}
+
+NS_IMETHODIMP
+nsHTMLFieldSetElement::GetElements(nsIDOMHTMLCollection** aElements)
+{
+ if (!mElements) {
+ mElements = new nsContentList(this, MatchListedElements, nsnull, nsnull, PR_TRUE);
+ }
+
+ NS_ADDREF(*aElements = mElements);
+
+ return NS_OK;
+}
+
// nsIFormControl
nsresult
diff --git a/content/html/content/test/Makefile.in b/content/html/content/test/Makefile.in
index 647a5ab38d3a..24565e82c349 100644
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -227,6 +227,7 @@ _TEST_FILES = \
test_bug589696.html \
test_bug595429.html \
test_bug595447.html \
+ test_bug595449.html \
$(NULL)
libs:: $(_TEST_FILES)
diff --git a/content/html/content/test/test_bug595449.html b/content/html/content/test/test_bug595449.html
new file mode 100644
index 000000000000..6686286597ea
--- /dev/null
+++ b/content/html/content/test/test_bug595449.html
@@ -0,0 +1,101 @@
+
+
+
+
+ Test for Bug 595449
+
+
+
+
+
+Mozilla Bug 595449
+
+
+
+
+
+
diff --git a/dom/interfaces/html/nsIDOMHTMLFieldSetElement.idl b/dom/interfaces/html/nsIDOMHTMLFieldSetElement.idl
index ddf3ac970851..efc238ee89bf 100644
--- a/dom/interfaces/html/nsIDOMHTMLFieldSetElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLFieldSetElement.idl
@@ -49,7 +49,7 @@
interface nsIDOMValidityState;
-[scriptable, uuid(8e89ae21-c666-4027-a1c7-bbc8f3d0a37a)]
+[scriptable, uuid(b38efb33-ec68-487a-bf9b-2920425fa408)]
interface nsIDOMHTMLFieldSetElement : nsIDOMHTMLElement
{
readonly attribute nsIDOMHTMLFormElement form;
@@ -57,6 +57,8 @@ interface nsIDOMHTMLFieldSetElement : nsIDOMHTMLElement
readonly attribute DOMString type;
+ readonly attribute nsIDOMHTMLCollection elements;
+
// The following lines are parte of the constraint validation API, see:
// http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
readonly attribute boolean willValidate;