Bug 1557252 - add missing style for in-content dialogs, r=bgrins
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 07 Jun 2019 11:33:26 +0000
changeset 477818 98973168545ee1f46e32fb758ce71fb5aa76cf3b
parent 477793 0c2b0dd884cce2c67fc713867efd194163bc70e6
child 477819 340e24683868094821c4c719b3da31144cca8001
push id36125
push userapavel@mozilla.com
push dateFri, 07 Jun 2019 22:00:07 +0000
treeherdermozilla-central@d820bbb356aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1557252
milestone69.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 1557252 - add missing style for in-content dialogs, r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D34012
toolkit/content/widgets/dialog.js
--- a/toolkit/content/widgets/dialog.js
+++ b/toolkit/content/widgets/dialog.js
@@ -52,23 +52,45 @@ class MozDialog extends MozXULElement {
     });
 
     // for things that we need to initialize after onload fires
     window.addEventListener("load", (event) => this.postLoadInit(event));
 
     this.attachShadow({mode: "open"});
   }
 
+  static get observedAttributes() {
+    return super.observedAttributes.concat("subdialog");
+  }
+
+  attributeChangedCallback(name, oldValue, newValue) {
+    if (name == "subdialog") {
+      console.assert(newValue, `Turning off subdialog style is not supported`);
+      if (this.isConnectedAndReady && !oldValue && newValue) {
+        this.shadowRoot.appendChild(
+          MozXULElement.parseXULToFragment(this.inContentStyle));
+      }
+      return;
+    }
+    super.attributeChangedCallback(name, oldValue, newValue);
+  }
+
   static get inheritedAttributes() {
     return {
       ".dialog-button-box": "pack=buttonpack,align=buttonalign,dir=buttondir,orient=buttonorient",
       "[dlgtype='accept']": "disabled=buttondisabledaccept",
     };
   }
 
+  get inContentStyle() {
+    return `
+      <html:link rel="stylesheet" href="chrome://global/skin/in-content/common.css" />
+    `;
+  }
+
   get _markup() {
     let buttons = AppConstants.platform == "linux" ? `
       <hbox class="dialog-button-box">
         <button dlgtype="disclosure" class="dialog-button" hidden="true"/>
         <button dlgtype="help" class="dialog-button" hidden="true"/>
         <button dlgtype="extra2" class="dialog-button" hidden="true"/>
         <button dlgtype="extra1" class="dialog-button" hidden="true"/>
         <spacer class="spacer" flex="1"/>
@@ -90,16 +112,17 @@ class MozDialog extends MozXULElement {
             oncommand="document.documentElement.openHelp(event)"
             key="&openHelpMac.commandkey;" modifiers="accel"/>` :
       `<key phase="capturing"
             oncommand="document.documentElement.openHelp(event)"
             keycode="&openHelp.commandkey;"/>`;
 
     return `
       <html:link rel="stylesheet" href="chrome://global/content/widgets.css" />
+      ${this.hasAttribute("subdialog") ? this.inContentStyle : ""}
       <html:style>
         :host([nobuttonspacer]) .spacer {
           display: none;
         }
         :host([subdialog]) > .dialog-content-box {
           /* This allows the focus ring to display fully when scrolling is enabled.
             See matching style in dialog.inc.css.
           */