Bug 893909 - Part n: Cleanup HTMLSelectElement::IsValueMissing; r=dzbarsky
authorMs2ger <ms2ger@gmail.com>
Wed, 24 Jul 2013 09:37:36 +0200
changeset 151952 c8619b95ee10753718cfb18e2df6a5fd93f6c320
parent 151951 0820c5ec7117dbca491efb5071e3feca76404035
child 151953 5f52bfd63082f0e81114924f07c68e6684cb6f63
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdzbarsky
bugs893909
milestone25.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 893909 - Part n: Cleanup HTMLSelectElement::IsValueMissing; r=dzbarsky
content/html/content/src/HTMLSelectElement.cpp
--- a/content/html/content/src/HTMLSelectElement.cpp
+++ b/content/html/content/src/HTMLSelectElement.cpp
@@ -1739,40 +1739,34 @@ HTMLSelectElement::RebuildOptionsArray(b
   mOptions->Clear();
   AddOptionsRecurse(this, mOptions);
   FindSelectedIndex(0, aNotify);
 }
 
 bool
 HTMLSelectElement::IsValueMissing()
 {
-  if (!HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
+  if (!Required()) {
     return false;
   }
 
-  uint32_t length;
-  mOptions->GetLength(&length);
+  uint32_t length = Length();
 
   for (uint32_t i = 0; i < length; ++i) {
-    nsIDOMHTMLOptionElement* option = mOptions->ItemAsOption(i);
-    bool selected;
-    NS_ENSURE_SUCCESS(option->GetSelected(&selected), false);
-
-    if (!selected) {
+    nsRefPtr<HTMLOptionElement> option = Item(i);
+    if (!option->Selected()) {
       continue;
     }
 
-    bool disabled;
-    IsOptionDisabled(i, &disabled);
-    if (disabled) {
+    if (IsOptionDisabled(option)) {
       continue;
     }
 
     nsAutoString value;
-    NS_ENSURE_SUCCESS(option->GetValue(value), false);
+    MOZ_ALWAYS_TRUE(NS_SUCCEEDED(option->GetValue(value)));
     if (!value.IsEmpty()) {
       return false;
     }
   }
 
   return true;
 }