Bug 893909 - Part m: Cleanup HTMLSelectElement::SubmitNamesValues; r=dzbarsky
authorMs2ger <ms2ger@gmail.com>
Wed, 24 Jul 2013 09:37:32 +0200
changeset 151951 0820c5ec7117dbca491efb5071e3feca76404035
parent 151950 ba2e6e147d30ab12f4a20546f37ff0e716e09509
child 151952 c8619b95ee10753718cfb18e2df6a5fd93f6c320
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 m: Cleanup HTMLSelectElement::SubmitNamesValues; r=dzbarsky
content/html/content/src/HTMLSelectElement.cpp
--- a/content/html/content/src/HTMLSelectElement.cpp
+++ b/content/html/content/src/HTMLSelectElement.cpp
@@ -1655,60 +1655,48 @@ HTMLSelectElement::SubmitNamesValues(nsF
   GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
   if (name.IsEmpty()) {
     return NS_OK;
   }
 
   //
   // Submit
   //
-  uint32_t len;
-  GetLength(&len);
+  uint32_t len = Length();
 
   nsAutoString mozType;
   nsCOMPtr<nsIFormProcessor> keyGenProcessor;
   if (GetAttr(kNameSpaceID_None, nsGkAtoms::_moz_type, mozType) &&
       mozType.EqualsLiteral("-mozilla-keygen")) {
     keyGenProcessor = do_GetService(kFormProcessorCID);
   }
 
   for (uint32_t optIndex = 0; optIndex < len; optIndex++) {
+    HTMLOptionElement* option = Item(optIndex);
+
     // Don't send disabled options
-    bool disabled;
-    nsresult rv = IsOptionDisabled(optIndex, &disabled);
-    if (NS_FAILED(rv) || disabled) {
+    if (!option || IsOptionDisabled(option)) {
       continue;
     }
 
-    nsIDOMHTMLOptionElement* option = mOptions->ItemAsOption(optIndex);
-    NS_ENSURE_TRUE(option, NS_ERROR_UNEXPECTED);
-
-    bool isSelected;
-    rv = option->GetSelected(&isSelected);
-    NS_ENSURE_SUCCESS(rv, rv);
-    if (!isSelected) {
+    if (!option->Selected()) {
       continue;
     }
 
-    nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = do_QueryInterface(option);
-    NS_ENSURE_TRUE(optionElement, NS_ERROR_UNEXPECTED);
-
-    nsAutoString value;
-    rv = optionElement->GetValue(value);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsString value;
+    MOZ_ALWAYS_TRUE(NS_SUCCEEDED(option->GetValue(value)));
 
     if (keyGenProcessor) {
-      nsAutoString tmp(value);
-      rv = keyGenProcessor->ProcessValue(this, name, tmp);
-      if (NS_SUCCEEDED(rv)) {
+      nsString tmp(value);
+      if (NS_SUCCEEDED(keyGenProcessor->ProcessValue(this, name, tmp))) {
         value = tmp;
       }
     }
 
-    rv = aFormSubmission->AddNameValuePair(name, value);
+    aFormSubmission->AddNameValuePair(name, value);
   }
 
   return NS_OK;
 }
 
 void
 HTMLSelectElement::DispatchContentReset()
 {