Bug 1135451 - fillForm() cleanup part F: use early return instead of else blocks. r=MattN
authorJustin Dolske <dolske@mozilla.com>
Fri, 27 Feb 2015 15:47:37 -0800
changeset 231347 a71d846d255caff98022b0ef2e8267b529adf3d0
parent 231346 d4f4f8cf938bb878083fee8b8d3264027db694b9
child 231348 c918b8a2b9c0aa6277728f36882db829cd1aa7d8
push id28349
push userkwierso@gmail.com
push dateMon, 02 Mar 2015 20:41:54 +0000
treeherdermozilla-central@eaaa45f32e9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1135451
milestone39.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 1135451 - fillForm() cleanup part F: use early return instead of else blocks. r=MattN
toolkit/components/passwordmgr/LoginManagerContent.jsm
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -737,47 +737,49 @@ var LoginManagerContent = {
         return;
       }
 
       selectedLogin = matchingLogins[0];
     }
 
     // We will always have a selectedLogin at this point.
 
-    if (autofillForm && !isFormDisabled) {
-      // Fill the form
-
-      if (usernameField) {
-        // Don't modify the username field if it's disabled or readOnly so we preserve its case.
-        let disabledOrReadOnly = usernameField.disabled || usernameField.readOnly;
-
-        let userNameDiffers = selectedLogin.username != usernameField.value;
-        // Don't replace the username if it differs only in case, and the user triggered
-        // this autocomplete. We assume that if it was user-triggered the entered text
-        // is desired.
-        let userEnteredDifferentCase = userTriggered && userNameDiffers &&
-               usernameField.value.toLowerCase() == selectedLogin.username.toLowerCase();
-
-        if (!disabledOrReadOnly && !userEnteredDifferentCase && userNameDiffers) {
-          usernameField.setUserInput(selectedLogin.username);
-        }
-      }
-      if (passwordField.value != selectedLogin.password) {
-        passwordField.setUserInput(selectedLogin.password);
-      }
-    } else if (!autofillForm) {
+    if (!autofillForm) {
       log("autofillForms=false but form can be filled; notified observers");
       recordAutofillResult(AUTOFILL_RESULT.NO_AUTOFILL_FORMS);
       return;
-    } else if (isFormDisabled) {
+    }
+
+    if (isFormDisabled) {
       log("autocomplete=off but form can be filled; notified observers");
       recordAutofillResult(AUTOFILL_RESULT.AUTOCOMPLETE_OFF);
       return;
     }
 
+    // Fill the form
+
+    if (usernameField) {
+      // Don't modify the username field if it's disabled or readOnly so we preserve its case.
+      let disabledOrReadOnly = usernameField.disabled || usernameField.readOnly;
+
+      let userNameDiffers = selectedLogin.username != usernameField.value;
+      // Don't replace the username if it differs only in case, and the user triggered
+      // this autocomplete. We assume that if it was user-triggered the entered text
+      // is desired.
+      let userEnteredDifferentCase = userTriggered && userNameDiffers &&
+             usernameField.value.toLowerCase() == selectedLogin.username.toLowerCase();
+
+      if (!disabledOrReadOnly && !userEnteredDifferentCase && userNameDiffers) {
+        usernameField.setUserInput(selectedLogin.username);
+      }
+    }
+    if (passwordField.value != selectedLogin.password) {
+      passwordField.setUserInput(selectedLogin.password);
+    }
+
     recordAutofillResult(AUTOFILL_RESULT.FILLED);
   },
 
 };
 
 var LoginUtils = {
   /*
    * _getPasswordOrigin