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));
if (form && form->GetType() != NS_FORM_OBJECT &&
form->GetType() != NS_FORM_FIELDSET &&
form->GetType() != NS_FORM_LEGEND &&
form->GetType() != NS_FORM_LABEL &&
form->GetType() != NS_FORM_OUTPUT)
return NS_OK;

View File

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

View File

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

View File

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

View File

@ -49,7 +49,7 @@
#include "nsFocusManager.h"
#include "nsIFrame.h"
class nsHTMLLegendElement : public nsGenericHTMLFormElement,
class nsHTMLLegendElement : public nsGenericHTMLElement,
public nsIDOMHTMLLegendElement
{
public:
@ -60,23 +60,18 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMNode
NS_FORWARD_NSIDOMNODE(nsGenericHTMLFormElement::)
NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
// nsIDOMElement
NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFormElement::)
NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
// nsIDOMHTMLElement
NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
// nsIDOMHTMLLegendElement
NS_DECL_NSIDOMHTMLLEGENDELEMENT
// nsIFormControl
NS_IMETHOD_(PRUint32) GetType() const { return NS_FORM_LEGEND; }
NS_IMETHOD Reset();
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission,
nsIContent* aSubmitElement);
// nsGenericHTMLElement
NS_IMETHODIMP Focus();
virtual void PerformAccesskey(PRBool aKeyCausesActivation,
@ -120,7 +115,7 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
nsHTMLLegendElement::nsHTMLLegendElement(nsINodeInfo *aNodeInfo)
: nsGenericHTMLFormElement(aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
}
@ -139,7 +134,7 @@ DOMCI_DATA(HTMLLegendElement, nsHTMLLegendElement)
NS_INTERFACE_TABLE_HEAD(nsHTMLLegendElement)
NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLegendElement, nsIDOMHTMLLegendElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLegendElement,
nsGenericHTMLFormElement)
nsGenericHTMLElement)
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLegendElement)
@ -204,7 +199,7 @@ nsHTMLLegendElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
PRInt32 aModType) const
{
nsChangeHint retval =
nsGenericHTMLFormElement::GetAttributeChangeHint(aAttribute, aModType);
nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType);
if (aAttribute == nsGkAtoms::align) {
NS_UpdateHint(retval, NS_STYLE_HINT_REFLOW);
}
@ -222,8 +217,8 @@ nsHTMLLegendElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
UnregAccessKey();
}
nsresult rv = nsGenericHTMLFormElement::SetAttr(aNameSpaceID, aAttribute,
aPrefix, aValue, aNotify);
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aAttribute,
aPrefix, aValue, aNotify);
if (accesskey && !aValue.IsEmpty()) {
SetFlags(NODE_HAS_ACCESSKEY);
@ -244,13 +239,7 @@ nsHTMLLegendElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
UnsetFlags(NODE_HAS_ACCESSKEY);
}
return nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
}
nsresult
nsHTMLLegendElement::Reset()
{
return NS_OK;
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
}
nsresult
@ -258,9 +247,9 @@ nsHTMLLegendElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
PRBool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
@ -277,7 +266,7 @@ nsHTMLLegendElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
UnregAccessKey();
}
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}
NS_IMETHODIMP
@ -310,9 +299,3 @@ nsHTMLLegendElement::PerformAccesskey(PRBool aKeyCausesActivation,
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;
// But for HTML form controls, use the form as scope parent.
if (nodeIsElement &&
node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
if (nodeIsElement) {
if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
if (form_control) {
nsCOMPtr<nsIDOMHTMLFormElement> form;
form_control->GetForm(getter_AddRefs(form));
if (form_control) {
nsCOMPtr<nsIDOMHTMLFormElement> form;
form_control->GetForm(getter_AddRefs(form));
if (form) {
// Found a form, use it.
native_parent = form;
if (form) {
// Found a form, use it.
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;
case NS_FORM_OPTGROUP:
break;
case NS_FORM_LEGEND:
break;
case NS_FORM_SELECT:
break;
case NS_FORM_TEXTAREA: