Bug 565611 - ""ASSERTION: How did that happen?: 'form == aThisForm'" with <legend>" [r=bz, sr=smaug]
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 19 May 2010 16:33:00 -0400
changeset 43117 0c87f407797d
parent 43116 0388c837c986
child 43118 8406214f84c8
push id13625
push userCallek@gmail.com
push dateSat, 05 Jun 2010 02:02:21 +0000
treeherdermozilla-central@63b89b311461 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, smaug
bugs565611
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 565611 - ""ASSERTION: How did that happen?: 'form == aThisForm'" with <legend>" [r=bz, sr=smaug]
content/base/src/nsContentAreaDragDrop.cpp
content/html/content/public/nsIFormControl.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLFormElement.cpp
content/html/content/src/nsHTMLLegendElement.cpp
dom/base/nsDOMClassInfo.cpp
embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
--- a/content/base/src/nsContentAreaDragDrop.cpp
+++ b/content/base/src/nsContentAreaDragDrop.cpp
@@ -453,17 +453,16 @@ DragDataProducer::Produce(nsDOMDataTrans
   // handled in editor code (nsPlaintextDataTransfer::DoDrag). Don't set
   // aCanDrag to false however, as we still want to allow the drag.
   nsCOMPtr<nsIContent> findFormNode = mSelectionTargetNode;
   nsIContent* findFormParent = findFormNode->GetParent();
   while (findFormParent) {
     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;
     findFormParent = findFormParent->GetParent();
   }
     
   // if set, serialize the content under this node
   nsCOMPtr<nsIContent> nodeToSerialize;
--- a/content/html/content/public/nsIFormControl.h
+++ b/content/html/content/public/nsIFormControl.h
@@ -46,17 +46,16 @@ class nsIFormProcessor;
 class nsFormSubmission;
 
 enum FormControlsTypes {
   NS_FORM_FIELDSET = 1,
   NS_FORM_LABEL,
   NS_FORM_OPTION,
   NS_FORM_OPTGROUP,
   NS_FORM_OUTPUT,
-  NS_FORM_LEGEND,
   NS_FORM_SELECT,
   NS_FORM_TEXTAREA,
   NS_FORM_OBJECT,
   eFormControlsWithoutSubTypesMax,
   // After this, all types will have sub-types which introduce new enum lists.
   // eFormControlsWithoutSubTypesMax let us know if the previous types values
   // are not overlapping with sub-types/masks.
 
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -2680,17 +2680,16 @@ nsGenericHTMLFormElement::PreHandleEvent
 
 PRBool
 nsGenericHTMLFormElement::CanBeDisabled() const
 {
   PRInt32 type = GetType();
   // 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;
 }
 
 PRBool
 nsGenericHTMLFormElement::IsSubmitControl() const
 {
@@ -2723,18 +2722,17 @@ nsGenericHTMLFormElement::IsLabelableCon
 {
   // Check for non-labelable form controls as they are not numerous.
   // TODO: datalist should be added to this list.
   PRInt32 type = GetType();
   return type != NS_FORM_FIELDSET &&
          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
 nsGenericHTMLFormElement::IntrinsicState() const
 {
   // If you add attribute-dependent states here, you need to add them them to
   // AfterSetAttr too.  And add them to AfterSetAttr for all subclasses that
   // implement IntrinsicState() and are affected by that attribute.
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -199,17 +199,16 @@ ShouldBeInElements(nsIFormControl* aForm
 
   // These form control types are not supposed to end up in the
   // form.elements array
   //
   // NS_FORM_INPUT_IMAGE
   // NS_FORM_LABEL
   // NS_FORM_OPTION
   // NS_FORM_OPTGROUP
-  // NS_FORM_LEGEND
 
   return PR_FALSE;
 }
 
 // nsHTMLFormElement implementation
 
 // construction, destruction
 nsGenericHTMLElement*
--- a/content/html/content/src/nsHTMLLegendElement.cpp
+++ b/content/html/content/src/nsHTMLLegendElement.cpp
@@ -44,44 +44,39 @@
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsIEventStateManager.h"
 #include "nsIDocument.h"
 #include "nsPIDOMWindow.h"
 #include "nsFocusManager.h"
 #include "nsIFrame.h"
 
-class nsHTMLLegendElement : public nsGenericHTMLFormElement,
+class nsHTMLLegendElement : public nsGenericHTMLElement,
                             public nsIDOMHTMLLegendElement
 {
 public:
   nsHTMLLegendElement(nsINodeInfo *aNodeInfo);
   virtual ~nsHTMLLegendElement();
 
   // nsISupports
   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,
                                 PRBool aIsTrustedEvent);
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
@@ -115,17 +110,17 @@ protected:
   nsIContent* GetFieldSet();
 };
 
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
 
 
 nsHTMLLegendElement::nsHTMLLegendElement(nsINodeInfo *aNodeInfo)
-  : nsGenericHTMLFormElement(aNodeInfo)
+  : nsGenericHTMLElement(aNodeInfo)
 {
 }
 
 nsHTMLLegendElement::~nsHTMLLegendElement()
 {
 }
 
 
@@ -134,17 +129,17 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLLegendEl
 
 
 DOMCI_DATA(HTMLLegendElement, nsHTMLLegendElement)
 
 // QueryInterface implementation for 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)
 
 
 // nsIDOMHTMLLegendElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLLegendElement)
 
@@ -199,17 +194,17 @@ nsHTMLLegendElement::ParseAttribute(PRIn
                                               aResult);
 }
 
 nsChangeHint
 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);
   }
   return retval;
 }
 
 nsresult
 nsHTMLLegendElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
@@ -217,18 +212,18 @@ nsHTMLLegendElement::SetAttr(PRInt32 aNa
                              PRBool aNotify)
 {
   PRBool accesskey = (aAttribute == nsGkAtoms::accesskey &&
                       aNameSpaceID == kNameSpaceID_None);
   if (accesskey) {
     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);
     RegAccessKey();
   }
 
   return rv;
 }
@@ -239,50 +234,44 @@ nsHTMLLegendElement::UnsetAttr(PRInt32 a
 {
   if (aAttribute == nsGkAtoms::accesskey &&
       aNameSpaceID == kNameSpaceID_None) {
     // Have to unregister before clearing flag. See UnregAccessKey
     UnregAccessKey();
     UnsetFlags(NODE_HAS_ACCESSKEY);
   }
 
-  return nsGenericHTMLFormElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
-}
-
-nsresult
-nsHTMLLegendElement::Reset()
-{
-  return NS_OK;
+  return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify);
 }
 
 nsresult
 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) {
     RegAccessKey();
   }
 
   return rv;
 }
 
 void
 nsHTMLLegendElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
 {
   if (IsInDoc()) {
     UnregAccessKey();
   }
 
-  nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
+  nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
 }
 
 NS_IMETHODIMP
 nsHTMLLegendElement::Focus()
 {
   nsIFrame* frame = GetPrimaryFrame();
   if (!frame)
     return NS_OK;
@@ -305,14 +294,8 @@ nsHTMLLegendElement::Focus()
 void
 nsHTMLLegendElement::PerformAccesskey(PRBool aKeyCausesActivation,
                                       PRBool aIsTrustedEvent)
 {
   // just use the same behaviour as the focus method
   Focus();
 }
 
-NS_IMETHODIMP
-nsHTMLLegendElement::SubmitNamesValues(nsFormSubmission* aFormSubmission,
-                                       nsIContent* aSubmitElement)
-{
-  return NS_OK;
-}
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -7297,27 +7297,42 @@ nsNodeSH::PreCreate(nsISupports *nativeO
     NS_ASSERTION(node->IsNodeOfType(nsINode::eCONTENT) ||
                  node->IsNodeOfType(nsINode::eATTRIBUTE),
                  "Unexpected node type");
                  
     // For attributes and non-XUL content, use the document as scope parent.
     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 (form_control) {
-        nsCOMPtr<nsIDOMHTMLFormElement> form;
-        form_control->GetForm(getter_AddRefs(form));
-
-        if (form) {
-          // Found a form, use it.
-          native_parent = form;
+    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) {
+            // 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;
+          }
         }
       }
     }
   } else {
     // We're called for a document object; set the parent to be the
     // document's global object, if there is one
 
     // Get the scope object from the document.
--- a/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
+++ b/embedding/browser/gtk/src/EmbedContextMenuInfo.cpp
@@ -223,18 +223,16 @@ EmbedContextMenuInfo::SetFormControlType
         mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
         break;
       case NS_FORM_LABEL:
         break;
       case NS_FORM_OPTION:
         break;
       case NS_FORM_OPTGROUP:
         break;
-      case NS_FORM_LEGEND:
-        break;
       case NS_FORM_SELECT:
         break;
       case NS_FORM_TEXTAREA:
         mEmbedCtxType |= GTK_MOZ_EMBED_CTX_INPUT;
         break;
       case NS_FORM_OBJECT:
         break;
       case NS_FORM_OUTPUT: