Bug 603141 (1/2) - Make select.size returns 0 by default. r=bz a=blocking-b8
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 09 Nov 2010 15:23:50 +0100
changeset 57155 73fce728315708a9e90d3cfe78b47468f0fd0e1c
parent 57154 4ef3abd2012c5751e95e58decb79e990227919de
child 57156 5c43321021b16b7bca886c0785427ce9f9242a44
push id16816
push usermlamouri@mozilla.com
push dateTue, 09 Nov 2010 14:25:41 +0000
treeherdermozilla-central@5c43321021b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, blocking-b8
bugs603141
milestone2.0b8pre
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 603141 (1/2) - Make select.size returns 0 by default. r=bz a=blocking-b8
content/html/content/src/nsHTMLSelectElement.cpp
content/html/content/src/nsHTMLSelectElement.h
content/html/content/test/test_bug551846.html
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -1212,18 +1212,17 @@ nsHTMLSelectElement::SetValue(const nsAS
   return rv;
 }
 
 
 NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Autofocus, autofocus)
 NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Disabled, disabled)
 NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Multiple, multiple)
 NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Name, name)
-NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, Size, size,
-                                        GetDefaultSize())
+NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, Size, size, 0)
 NS_IMPL_INT_ATTR(nsHTMLSelectElement, TabIndex, tabindex)
 
 NS_IMETHODIMP
 nsHTMLSelectElement::Blur()
 {
   return nsGenericHTMLElement::Blur();
 }
 
--- a/content/html/content/src/nsHTMLSelectElement.h
+++ b/content/html/content/src/nsHTMLSelectElement.h
@@ -490,24 +490,16 @@ protected:
   void VerifyOptionsArray();
 #endif
 
   virtual PRBool AcceptAutofocus() const
   {
     return PR_TRUE;
   }
 
-  /**
-   * Helper method to get the default size.
-   */
-  PRInt32 GetDefaultSize() const
-  {
-    return HasAttr(kNameSpaceID_None, nsGkAtoms::multiple) ? 4 : 1;
-  }
-
   /** The options[] array */
   nsRefPtr<nsHTMLOptionCollection> mOptions;
   /** false if the parser is in the middle of adding children. */
   PRPackedBool    mIsDoneAddingChildren;
   /** true if our disabled state has changed from the default **/
   PRPackedBool    mDisabledChanged;
   /** true if child nodes are being added or removed.
    *  Used by nsSafeOptionListMutation.
--- a/content/html/content/test/test_bug551846.html
+++ b/content/html/content/test/test_bug551846.html
@@ -117,43 +117,43 @@ function checkSetSizeException(element)
     caught = true;
   }
   ok(!caught, "Setting an invalid size in the content attribute shouldn't throw an exception");
 
   // reverting to defalut
   element.removeAttribute('size');
 }
 
-function checkSizeWhenChangeMultiple(element)
+function checkSizeWhenChangeMultiple(element, aDefaultNonMultiple, aDefaultMultiple)
 {
   s.setAttribute('size', -1)
-  is(s.size, 1, "Size IDL attribute should be 1");
+  is(s.size, aDefaultNonMultiple, "Size IDL attribute should be 1");
 
   s.multiple = true;
-  is(s.size, 4, "Size IDL attribute should be 4");
+  is(s.size, aDefaultMultiple, "Size IDL attribute should be 4");
 
   is(s.getAttribute('size'), -1, "Size content attribute should be -1");
 
   s.setAttribute('size', -2);
-  is(s.size, 4, "Size IDL attribute should be 4");
+  is(s.size, aDefaultMultiple, "Size IDL attribute should be 4");
 
   s.multiple = false;
-  is(s.size, 1, "Size IDL attribute should be 1");
+  is(s.size, aDefaultNonMultiple, "Size IDL attribute should be 1");
 
   is(s.getAttribute('size'), -2, "Size content attribute should be -2");
 }
 
 var s = document.getElementById('s');
 
-checkSizeReflection(s, 1);
+checkSizeReflection(s, 0);
 checkSetSizeException(s);
 
 s.setAttribute('multiple', 'true');
-checkSizeReflection(s, 4);
+checkSizeReflection(s, 0);
 checkSetSizeException(s);
 s.removeAttribute('multiple');
 
-checkSizeWhenChangeMultiple(s);
+checkSizeWhenChangeMultiple(s, 0, 0);
 
 </script>
 </pre>
 </body>
 </html>