Bug 1352307 - [Form Autofill] Open the edit profile dialog on top of the manage profiles dialog. r=MattN draft
authorScott Wu <scottcwwu@gmail.com>
Wed, 29 Mar 2017 00:12:31 +0800
changeset 591432 503700ea26a58c55c97942b3c64a24749abcc016
parent 590317 a49112c7a5765802096b3fc298069b9495436107
child 632517 6e7bf6f5bbd145417e5ace0bfe3285e400516a2f
push id63057
push userbmo:scwwu@mozilla.com
push dateFri, 09 Jun 2017 03:07:15 +0000
reviewersMattN
bugs1352307
milestone55.0a1
Bug 1352307 - [Form Autofill] Open the edit profile dialog on top of the manage profiles dialog. r=MattN MozReview-Commit-ID: 4m3Z1YYz1oO
browser/extensions/formautofill/content/editProfile.js
browser/extensions/formautofill/content/editProfile.xhtml
browser/extensions/formautofill/content/manageProfiles.js
browser/extensions/formautofill/skin/linux/editProfile.css
browser/extensions/formautofill/skin/shared/editProfile.css
--- a/browser/extensions/formautofill/content/editProfile.js
+++ b/browser/extensions/formautofill/content/editProfile.js
@@ -4,18 +4,18 @@
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://formautofill/FormAutofillUtils.jsm");
 
-function EditDialog(address) {
-  this._address = address;
+function EditDialog() {
+  this._address = window.arguments && window.arguments[0];
   window.addEventListener("DOMContentLoaded", this, {once: true});
 }
 
 EditDialog.prototype = {
   init() {
     this.refs = {
       controlsContainer: document.getElementById("controls-container"),
       cancel: document.getElementById("cancel"),
@@ -132,9 +132,9 @@ EditDialog.prototype = {
    */
   detachEventListeners() {
     this.refs.controlsContainer.removeEventListener("click", this);
     document.removeEventListener("input", this);
   },
 };
 
 // Pass in argument from openDialog
-new EditDialog(window.arguments[0]);
+new EditDialog();
--- a/browser/extensions/formautofill/content/editProfile.xhtml
+++ b/browser/extensions/formautofill/content/editProfile.xhtml
@@ -1,20 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <title>Profile Autofill - Edit Profile</title>
-  <!-- common.css and dialog.css need to be included until this file can be
-     - loaded as a stacked subdialog. -->
-  <link rel="stylesheet" href="chrome://global/skin/in-content/common.css" />
-  <link rel="stylesheet" href="chrome://browser/skin/preferences/in-content-new/dialog.css" />
   <link rel="stylesheet" href="chrome://formautofill-shared/skin/editProfile.css" />
   <link rel="stylesheet" href="chrome://formautofill/skin/editProfile.css" />
   <script src="chrome://formautofill/content/editProfile.js"></script>
 </head>
 <body>
   <form>
     <label id="given-name-container">
       <span>First Name</span>
--- a/browser/extensions/formautofill/content/manageProfiles.js
+++ b/browser/extensions/formautofill/content/manageProfiles.js
@@ -10,16 +10,17 @@ const EDIT_PROFILE_URL = "chrome://forma
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://formautofill/FormAutofillUtils.jsm");
 
 this.log = null;
 FormAutofillUtils.defineLazyLogGetter(this, "manageProfiles");
 
 function ManageProfileDialog() {
+  this.prefWin = window.opener;
   window.addEventListener("DOMContentLoaded", this, {once: true});
 }
 
 ManageProfileDialog.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
 
   _elements: {},
 
@@ -164,19 +165,17 @@ ManageProfileDialog.prototype = {
   },
 
   /**
    * Open the edit address dialog to create/edit an address.
    *
    * @param  {object} address [optional]
    */
   openEditDialog(address) {
-    window.openDialog(EDIT_PROFILE_URL, null,
-                      "chrome,centerscreen,modal,width=600,height=450",
-                      address);
+    this.prefWin.gSubDialog.open(EDIT_PROFILE_URL, null, address);
   },
 
   /**
    * Enable/disable the Edit and Remove buttons based on number of selected
    * options.
    *
    * @param  {number} selectedCount
    */
--- a/browser/extensions/formautofill/skin/linux/editProfile.css
+++ b/browser/extensions/formautofill/skin/linux/editProfile.css
@@ -1,5 +1,8 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Linux specific rules */
+body {
+  font-size: 0.85rem;
+}
\ No newline at end of file
--- a/browser/extensions/formautofill/skin/shared/editProfile.css
+++ b/browser/extensions/formautofill/skin/shared/editProfile.css
@@ -1,17 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 body {
   font-size: 1rem;
-  /* body needs padding until the edit profile dialog could be loaded as a
-     stacked subdialog */
-  padding: 2em;
 }
 
 form,
 label,
 div {
   display: flex;
 }
 
@@ -19,44 +16,42 @@ form {
   flex-wrap: wrap;
 }
 
 label {
   margin: 0 0 0.5em;
 }
 
 label > span {
+  box-sizing: border-box;
   flex: 0 0 8em;
   padding-inline-end: 0.5em;
   align-self: center;
   text-align: end;
 }
 
 input,
 select {
+  box-sizing: border-box;
   flex: 1 0 auto;
-  width: 9em;
+  width: calc(50% - 8em);
 }
 
 option {
   padding: 6px;
 }
 
 textarea {
   resize: none;
 }
 
 button {
   padding: 3px 2em;
 }
 
-#country-container {
-  width: 15em;
-}
-
 #given-name-container,
 #additional-name-container,
 #address-level1-container,
 #postal-code-container,
 #country-container {
   flex: 0 1 50%;
 }
 
@@ -74,15 +69,14 @@ button {
   justify-content: end;
 }
 
 #family-name,
 #organization,
 #address-level2,
 #tel{
   flex: 0 0 auto;
-  width: calc(50% - 10em);
 }
 
 #street-address,
 #email {
   flex: 1 0 auto;
 }