Bug 748238 - <meter> should not be a form control. r=bz
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 07 Jun 2012 20:42:45 +0200
changeset 100955 525a0b959ef01d15c0439d1f99e1c7915926be63
parent 100954 0f7995b75365508ebf5d32d7133fa1056fc95194
child 100956 89e71d2ea54d93edc9ee82fb3e602f50943a7e3e
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs748238
milestone16.0a1
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 748238 - <meter> should not be a form control. r=bz
content/html/content/public/nsIFormControl.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLFieldSetElement.cpp
content/html/content/src/nsHTMLFormElement.cpp
content/html/content/src/nsHTMLMeterElement.cpp
content/html/content/test/Makefile.in
content/html/content/test/forms/Makefile.in
content/html/content/test/forms/test_form_attribute-1.html
content/html/content/test/forms/test_meter_element.html
content/html/content/test/test_bug657938.html
dom/interfaces/html/nsIDOMHTMLMeterElement.idl
--- a/content/html/content/public/nsIFormControl.h
+++ b/content/html/content/public/nsIFormControl.h
@@ -21,17 +21,16 @@ class Element;
 
 enum FormControlsTypes {
   NS_FORM_FIELDSET = 1,
   NS_FORM_LABEL,
   NS_FORM_OUTPUT,
   NS_FORM_SELECT,
   NS_FORM_TEXTAREA,
   NS_FORM_OBJECT,
-  NS_FORM_METER,
   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.
 
   // Elements with different types, the value is used as a mask.
   // Adding '_ELEMENT' because NS_FORM_INPUT is used for 'oninput' event.
   // When changing the order, adding or removing elements, be sure to update
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -3104,17 +3104,18 @@ nsGenericHTMLElement::GetContextMenu(nsI
   }
 
   return NS_OK;
 }
 
 bool
 nsGenericHTMLElement::IsLabelable() const
 {
-  return Tag() == nsGkAtoms::progress;
+  return Tag() == nsGkAtoms::progress ||
+         Tag() == nsGkAtoms::meter;
 }
 
 //----------------------------------------------------------------------
 
 nsGenericHTMLFormElement::nsGenericHTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo)
   , mForm(nsnull)
   , mFieldSet(nsnull)
@@ -3467,18 +3468,17 @@ nsGenericHTMLFormElement::ForgetFieldSet
 bool
 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_OBJECT &&
-    type != NS_FORM_OUTPUT &&
-    type != NS_FORM_METER;
+    type != NS_FORM_OUTPUT;
 }
 
 bool
 nsGenericHTMLFormElement::IsHTMLFocusable(bool aWithMouse,
                                           bool* aIsFocusable,
                                           PRInt32* aTabIndex)
 {
   if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex)) {
@@ -3765,17 +3765,16 @@ bool
 nsGenericHTMLFormElement::IsLabelable() const
 {
   // TODO: keygen should be in that list, see bug 101019.
   // TODO: NS_FORM_INPUT_HIDDEN should be removed, see bug 597650.
   PRUint32 type = GetType();
   return type & NS_FORM_INPUT_ELEMENT ||
          type & NS_FORM_BUTTON_ELEMENT ||
          // type == NS_FORM_KEYGEN ||
-         type == NS_FORM_METER ||
          type == NS_FORM_OUTPUT ||
          type == NS_FORM_SELECT ||
          type == NS_FORM_TEXTAREA;
 }
 
 //----------------------------------------------------------------------
 
 nsresult
--- a/content/html/content/src/nsHTMLFieldSetElement.cpp
+++ b/content/html/content/src/nsHTMLFieldSetElement.cpp
@@ -123,18 +123,17 @@ nsHTMLFieldSetElement::GetType(nsAString
 }
 
 /* static */
 bool
 nsHTMLFieldSetElement::MatchListedElements(nsIContent* aContent, PRInt32 aNamespaceID,
                                            nsIAtom* aAtom, void* aData)
 {
   nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(aContent);
-  return formControl && formControl->GetType() != NS_FORM_LABEL &&
-                        formControl->GetType() != NS_FORM_METER;
+  return formControl && formControl->GetType() != NS_FORM_LABEL;
 }
 
 NS_IMETHODIMP
 nsHTMLFieldSetElement::GetElements(nsIDOMHTMLCollection** aElements)
 {
   if (!mElements) {
     mElements = new nsContentList(this, MatchListedElements, nsnull, nsnull,
                                   true);
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -186,17 +186,16 @@ ShouldBeInElements(nsIFormControl* aForm
     return true;
   }
 
   // These form control types are not supposed to end up in the
   // form.elements array
   //
   // NS_FORM_INPUT_IMAGE
   // NS_FORM_LABEL
-  // NS_FORM_METER
 
   return false;
 }
 
 // nsHTMLFormElement implementation
 
 // construction, destruction
 nsGenericHTMLElement*
--- a/content/html/content/src/nsHTMLMeterElement.cpp
+++ b/content/html/content/src/nsHTMLMeterElement.cpp
@@ -40,43 +40,38 @@
  
 #include "nsIDOMHTMLMeterElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsAttrValue.h"
 #include "nsEventStateManager.h"
 #include "nsAlgorithm.h"
 
 
-class nsHTMLMeterElement : public nsGenericHTMLFormElement,
+class nsHTMLMeterElement : public nsGenericHTMLElement,
                            public nsIDOMHTMLMeterElement
 {
 public:
   nsHTMLMeterElement(already_AddRefed<nsINodeInfo> aNodeInfo);
   virtual ~nsHTMLMeterElement();
 
   /* 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::)
 
   /* nsIDOMHTMLMeterElement */
   NS_DECL_NSIDOMHTMLMETERELEMENT
 
-  /* nsIFormControl */
-  NS_IMETHOD_(PRUint32) GetType() const { return NS_FORM_METER; }
-  NS_IMETHOD Reset();
-  NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
-
   virtual nsEventStates IntrinsicState() const;
 
   nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
 
   bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
                       const nsAString& aValue, nsAttrValue& aResult);
 
   virtual nsXPCClassInfo* GetClassInfo();
@@ -121,57 +116,43 @@ private:
 const double nsHTMLMeterElement::kDefaultValue =  0.0;
 const double nsHTMLMeterElement::kDefaultMin   =  0.0;
 const double nsHTMLMeterElement::kDefaultMax   =  1.0;
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Meter)
 
 
 nsHTMLMeterElement::nsHTMLMeterElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-  : nsGenericHTMLFormElement(aNodeInfo)
+  : nsGenericHTMLElement(aNodeInfo)
 {
 }
 
 nsHTMLMeterElement::~nsHTMLMeterElement()
 {
 }
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLMeterElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLMeterElement, nsGenericElement)
 
 DOMCI_NODE_DATA(HTMLMeterElement, nsHTMLMeterElement)
 
 NS_INTERFACE_TABLE_HEAD(nsHTMLMeterElement)
   NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLMeterElement,
                                    nsIDOMHTMLMeterElement)
   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLMeterElement,
-                                               nsGenericHTMLFormElement)
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLMeterElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLMeterElement)
 
 
-NS_IMETHODIMP
-nsHTMLMeterElement::Reset()
-{
-  /* The meter element is not resettable. */
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsHTMLMeterElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
-{
-  /* The meter element is not submittable. */
-  return NS_OK;
-}
-
 nsEventStates
 nsHTMLMeterElement::IntrinsicState() const
 {
-  nsEventStates state = nsGenericHTMLFormElement::IntrinsicState();
+  nsEventStates state = nsGenericHTMLElement::IntrinsicState();
 
   state |= GetOptimumState();
 
   return state;
 }
 
 bool
 nsHTMLMeterElement::ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
@@ -180,26 +161,20 @@ nsHTMLMeterElement::ParseAttribute(PRInt
   if (aNamespaceID == kNameSpaceID_None) {
     if (aAttribute == nsGkAtoms::value || aAttribute == nsGkAtoms::max ||
         aAttribute == nsGkAtoms::min   || aAttribute == nsGkAtoms::low ||
         aAttribute == nsGkAtoms::high  || aAttribute == nsGkAtoms::optimum) {
       return aResult.ParseDoubleValue(aValue);
     }
   }
 
-  return nsGenericHTMLFormElement::ParseAttribute(aNamespaceID, aAttribute,
+  return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute,
                                                   aValue, aResult);
 }
 
-NS_IMETHODIMP
-nsHTMLMeterElement::GetForm(nsIDOMHTMLFormElement** aForm)
-{
-  return nsGenericHTMLFormElement::GetForm(aForm);
-}
-
 /*
  * Value getters :
  * const getters used by XPCOM methods and by IntrinsicState
  */
 
 double
 nsHTMLMeterElement::GetMin() const
 {
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -259,17 +259,16 @@ include $(topsrcdir)/config/rules.mk
 		test_li_attributes_reflection.html \
 		test_ol_attributes_reflection.html \
 		test_bug651956.html \
 		test_bug694503.html \
 		test_object_plugin_nav.html \
 		test_bug742030.html \
 		test_bug742549.html \
 		test_bug745685.html \
-		test_bug657938.html \
 		test_bug660238.html \
 		test_input_file_picker.html \
 		$(NULL)
 
 _BROWSER_TEST_FILES = \
 		browser_bug649778.js \
 		file_bug649778.html \
 		file_bug649778.html^headers^ \
--- a/content/html/content/test/forms/Makefile.in
+++ b/content/html/content/test/forms/Makefile.in
@@ -35,13 +35,14 @@ include $(topsrcdir)/config/rules.mk
 		test_form_attributes_reflection.html \
 		test_option_index_attribute.html \
 		test_progress_element.html \
 		test_form_attribute-1.html \
 		test_form_attribute-2.html \
 		test_form_attribute-3.html \
 		test_form_attribute-4.html \
 		test_option_disabled.html \
+		test_meter_element.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
--- a/content/html/content/test/forms/test_form_attribute-1.html
+++ b/content/html/content/test/forms/test_form_attribute-1.html
@@ -395,17 +395,17 @@ var content = document.getElementById('c
 var forms = [
   document.createElement('form'),
   document.createElement('form'),
   document.createElement('form'),
 ];
 
 var elementNames = [
   'button', 'fieldset', 'input', 'label', 'object', 'output', 'select',
-  'textarea', 'meter'
+  'textarea'
 ];
 
 var todoElements = [
   ['keygen', 'Keygen'],
 ];
 
 for each(var e in todoElements) {
   var node = document.createElement(e[0]);
rename from content/html/content/test/test_bug657938.html
rename to content/html/content/test/forms/test_meter_element.html
--- a/content/html/content/test/test_bug657938.html
+++ b/content/html/content/test/forms/test_meter_element.html
@@ -1,46 +1,36 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=657938
 -->
 <head>
-  <title>Test for Bug 657938</title>
+  <title>Test for <meter></title>
   <script type="application/javascript" src="/MochiKit/packed.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657938">Mozilla Bug 657938</a>
 <p id="display"></p>
 <iframe name="submit_frame" style="visibility: hidden;"></iframe>
 <div id="content" style="visibility: hidden;">
   <form id='f' method='get' target='submit_frame' action='foo'>
     <meter id='m' value=0.5></meter>
   </form>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
-/** Test for Bug 657938 **/
+/** Test for <meter> **/
 
 function checkFormIDLAttribute(aElement)
 {
-  var form = document.forms[0];
-  var content = document.getElementById('content');
-  is(aElement.form, form, "The form IDL attribute should be the parent form");
-
-  content.removeChild(form);
-  content.appendChild(aElement);
-  is(aElement.form, null, "The form IDL attribute should be null");
-
-  // Cleaning-up.
-  content.appendChild(form);
-  form.appendChild(aElement);
+  is('form' in aElement, false, "<meter> shouldn't have a form attribute");
 }
 
 function checkAttribute(aElement, aAttribute, aNewValue, aExpectedValueForIDL)
 {
   var expectedValueForIDL = aNewValue;
   var expectedValueForContent = aNewValue;
 
   if (aExpectedValueForIDL !== undefined) {
@@ -325,17 +315,17 @@ function checkNotResetableAndFormSubmiss
     document.getElementsByName('submit_frame')[0].removeEventListener("load", arguments.callee, false);
 
     /**
      * All elements values have been set just before the submission.
      * The input element value should be in the submit url but the meter
      * element value should not appear.
      */
     is(frames['submit_frame'].location.href,
-      'http://mochi.test:8888/tests/content/html/content/test/foo?a=tulip',
+      'http://mochi.test:8888/tests/content/html/content/test/forms/foo?a=tulip',
        "The meter element value should not be submitted");
 
     checkNotResetable();
   }, false);
 
   form.submit();
 }
 
@@ -362,16 +352,17 @@ SimpleTest.waitForExplicitFinish();
 
 var m = document.getElementById('m');
 
 ok(m instanceof HTMLMeterElement,
    "The meter element should be instance of HTMLMeterElement");
 is(m.constructor, HTMLMeterElement,
    "The meter element constructor should be HTMLMeterElement");
 
+// There is no such attribute.
 checkFormIDLAttribute(m);
 
 checkValueAttribute();
 
 checkMinAttribute();
 
 checkMaxAttribute();
 
--- a/dom/interfaces/html/nsIDOMHTMLMeterElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLMeterElement.idl
@@ -51,14 +51,14 @@
 interface nsIDOMHTMLMeterElement : nsIDOMHTMLElement
 {
            attribute double value;
            attribute double min;
            attribute double max;
            attribute double low;
            attribute double high;
            attribute double optimum;
-  readonly attribute nsIDOMHTMLFormElement form;
+
   /**
    * The labels attribute will be done with bug 556743.
    */
   //readonly attribute NodeList labels;
 };