Bug 565611 - ""ASSERTION: How did that happen?: 'form == aThisForm'" with <legend>" [r=bz, sr=smaug]

This commit is contained in:
Mounir Lamouri 2010-05-19 16:33:00 -04:00
parent 250a5b4b27
commit e8d689713a
7 changed files with 40 additions and 49 deletions

View File

@ -458,7 +458,6 @@ DragDataProducer::Produce(nsDOMDataTransfer* aDataTransfer,
nsCOMPtr<nsIFormControl> form(do_QueryInterface(findFormParent)); nsCOMPtr<nsIFormControl> form(do_QueryInterface(findFormParent));
if (form && form->GetType() != NS_FORM_OBJECT && if (form && form->GetType() != NS_FORM_OBJECT &&
form->GetType() != NS_FORM_FIELDSET && form->GetType() != NS_FORM_FIELDSET &&
form->GetType() != NS_FORM_LEGEND &&
form->GetType() != NS_FORM_LABEL && form->GetType() != NS_FORM_LABEL &&
form->GetType() != NS_FORM_OUTPUT) form->GetType() != NS_FORM_OUTPUT)
return NS_OK; return NS_OK;

View File

@ -51,7 +51,6 @@ enum FormControlsTypes {
NS_FORM_OPTION, NS_FORM_OPTION,
NS_FORM_OPTGROUP, NS_FORM_OPTGROUP,
NS_FORM_OUTPUT, NS_FORM_OUTPUT,
NS_FORM_LEGEND,
NS_FORM_SELECT, NS_FORM_SELECT,
NS_FORM_TEXTAREA, NS_FORM_TEXTAREA,
NS_FORM_OBJECT, NS_FORM_OBJECT,

View File

@ -2685,7 +2685,6 @@ nsGenericHTMLFormElement::CanBeDisabled() const
// It's easier to test the types that _cannot_ be disabled // It's easier to test the types that _cannot_ be disabled
return return
type != NS_FORM_LABEL && type != NS_FORM_LABEL &&
type != NS_FORM_LEGEND &&
type != NS_FORM_FIELDSET && type != NS_FORM_FIELDSET &&
type != NS_FORM_OBJECT && type != NS_FORM_OBJECT &&
type != NS_FORM_OUTPUT; type != NS_FORM_OUTPUT;
@ -2728,8 +2727,7 @@ nsGenericHTMLFormElement::IsLabelableControl() const
type != NS_FORM_LABEL && type != NS_FORM_LABEL &&
type != NS_FORM_OPTION && type != NS_FORM_OPTION &&
type != NS_FORM_OPTGROUP && type != NS_FORM_OPTGROUP &&
type != NS_FORM_OBJECT && type != NS_FORM_OBJECT;
type != NS_FORM_LEGEND;
} }
PRInt32 PRInt32

View File

@ -204,7 +204,6 @@ ShouldBeInElements(nsIFormControl* aFormControl)
// NS_FORM_LABEL // NS_FORM_LABEL
// NS_FORM_OPTION // NS_FORM_OPTION
// NS_FORM_OPTGROUP // NS_FORM_OPTGROUP
// NS_FORM_LEGEND
return PR_FALSE; return PR_FALSE;
} }

View File

@ -49,7 +49,7 @@
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsIFrame.h" #include "nsIFrame.h"
class nsHTMLLegendElement : public nsGenericHTMLFormElement, class nsHTMLLegendElement : public nsGenericHTMLElement,
public nsIDOMHTMLLegendElement public nsIDOMHTMLLegendElement
{ {
public: public:
@ -60,23 +60,18 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIDOMNode // nsIDOMNode
NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::) NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
// nsIDOMElement // nsIDOMElement
NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::) NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
// nsIDOMHTMLElement // nsIDOMHTMLElement
NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::) NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
// nsIDOMHTMLLegendElement // nsIDOMHTMLLegendElement
NS_DECL_NSIDOMHTMLLEGENDELEMENT NS_DECL_NSIDOMHTMLLEGENDELEMENT
// nsIFormControl // nsGenericHTMLElement
NS_IMETHOD_(PRUint32) GetType() const { return NS_FORM_LEGEND; }
NS_IMETHOD Reset();
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission,
nsIContent* aSubmitElement);
NS_IMETHODIMP Focus(); NS_IMETHODIMP Focus();
virtual void PerformAccesskey(PRBool aKeyCausesActivation, virtual void PerformAccesskey(PRBool aKeyCausesActivation,
@ -120,7 +115,7 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
nsHTMLLegendElement::nsHTMLLegendElement(nsINodeInfo *aNodeInfo) nsHTMLLegendElement::nsHTMLLegendElement(nsINodeInfo *aNodeInfo)
: nsGenericHTMLFormElement(aNodeInfo) : nsGenericHTMLElement(aNodeInfo)
{ {
} }
@ -139,7 +134,7 @@ DOMCI_DATA(HTMLLegendElement, nsHTMLLegendElement)
NS_INTERFACE_TABLE_HEAD(nsHTMLLegendElement) NS_INTERFACE_TABLE_HEAD(nsHTMLLegendElement)
NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLegendElement, nsIDOMHTMLLegendElement) NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLegendElement, nsIDOMHTMLLegendElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLegendElement, NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLegendElement,
nsGenericHTMLFormElement) nsGenericHTMLElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLegendElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLegendElement)
@ -204,7 +199,7 @@ nsHTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const PRInt32 aModType) const
{ {
nsChangeHint retval = nsChangeHint retval =
nsGenericHTMLFormElement::GetAttributeChangeHint(aAttribute, aModType); nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
if (aAttribute == nsGkAtoms::align) { if (aAttribute == nsGkAtoms::align) {
NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW); NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
} }
@ -222,8 +217,8 @@ nsHTMLLegendElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
UnregAccessKey(); UnregAccessKey();
} }
nsresult rv = nsGenericHTMLFormElement::SetAttr(aNameSpaceID, aAttribute, nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute,
aPrefix, aValue, aNotify); aPrefix, aValue, aNotify);
if (accesskey && !aValue.IsEmpty()) { if (accesskey && !aValue.IsEmpty()) {
SetFlags(NODE_HAS_ACCESSKEY); SetFlags(NODE_HAS_ACCESSKEY);
@ -244,13 +239,7 @@ nsHTMLLegendElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
UnsetFlags(NODE_HAS_ACCESSKEY); UnsetFlags(NODE_HAS_ACCESSKEY);
} }
return nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify); return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
}
nsresult
nsHTMLLegendElement::Reset()
{
return NS_OK;
} }
nsresult nsresult
@ -258,9 +247,9 @@ nsHTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent, nsIContent* aBindingParent,
PRBool aCompileEventHandlers) PRBool aCompileEventHandlers)
{ {
nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent, nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent, aBindingParent,
aCompileEventHandlers); aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) { if (aDocument) {
@ -277,7 +266,7 @@ nsHTMLLegendElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
UnregAccessKey(); UnregAccessKey();
} }
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent); nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -310,9 +299,3 @@ nsHTMLLegendElement::PerformAccesskey(PRBool aKeyCausesActivation,
Focus(); Focus();
} }
NS_IMETHODIMP
nsHTMLLegendElement::SubmitNamesValues(nsFormSubmission* aFormSubmission,
nsIContent* aSubmitElement)
{
return NS_OK;
}

View File

@ -7302,17 +7302,32 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
native_parent = doc; native_parent = doc;
// But for HTML form controls, use the form as scope parent. // But for HTML form controls, use the form as scope parent.
if (nodeIsElement && if (nodeIsElement) {
node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) { if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node)); nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
if (form_control) { if (form_control) {
nsCOMPtr<nsIDOMHTMLFormElement> form; nsCOMPtr<nsIDOMHTMLFormElement> form;
form_control->GetForm(getter_AddRefs(form)); form_control->GetForm(getter_AddRefs(form));
if (form) { if (form) {
// Found a form, use it. // Found a form, use it.
native_parent = form; native_parent = form;
}
}
// Legend isn't an HTML form control but should have its fieldset form
// as scope parent at least for backward compatibility.
} else if (node->AsElement()->IsHTML() &&
node->AsElement()->Tag() == nsGkAtoms::legend) {
nsCOMPtr<nsIDOMHTMLLegendElement> legend(do_QueryInterface(node));
if (legend) {
nsCOMPtr<nsIDOMHTMLFormElement> form;
legend->GetForm(getter_AddRefs(form));
if (form) {
native_parent = form;
}
} }
} }
} }

View File

@ -228,8 +228,6 @@ EmbedContextMenuInfo::SetFormControlType(nsIDOMEventTarget *originalTarget)
break; break;
case NS_FORM_OPTGROUP: case NS_FORM_OPTGROUP:
break; break;
case NS_FORM_LEGEND:
break;
case NS_FORM_SELECT: case NS_FORM_SELECT:
break; break;
case NS_FORM_TEXTAREA: case NS_FORM_TEXTAREA: