Bug 555567. Make <legend>.form follow HTML5 spec. r=jst

This commit is contained in:
Mounir Lamouri 2010-05-12 15:01:25 -04:00
Родитель 868ddbaf9c
Коммит 4ad5f93833
1 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -106,6 +106,13 @@ public:
PRBool aNotify);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected:
/**
* Get the fieldset content element that contains this legend.
* Returns null if there is no fieldset containing this legend.
*/
nsIContent* GetFieldSet();
};
@ -145,7 +152,11 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLLegendElement)
NS_IMETHODIMP
nsHTMLLegendElement::GetForm(nsIDOMHTMLFormElement** aForm)
{
return nsGenericHTMLFormElement::GetForm(aForm);
*aForm = nsnull;
nsCOMPtr<nsIFormControl> fieldsetControl = do_QueryInterface(GetFieldSet());
return fieldsetControl ? fieldsetControl->GetForm(aForm) : NS_OK;
}
@ -162,6 +173,18 @@ static const nsAttrValue::EnumTable kAlignTable[] = {
{ 0 }
};
nsIContent*
nsHTMLLegendElement::GetFieldSet()
{
nsIContent* parent = GetParent();
if (parent && parent->IsHTML() && parent->Tag() == nsGkAtoms::fieldset) {
return parent;
}
return nsnull;
}
PRBool
nsHTMLLegendElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,