Bug 1375224 - Remove use of <style scoped> from SelectParentHelper.jsm. r?mconley draft
authorJared Wein <jwein@mozilla.com>
Wed, 21 Jun 2017 15:31:31 -0400
changeset 598524 53cb7a10843e1bb7add428eabfa86e81a5e97dc9
parent 598363 26d34468c8b8af26a753b9fed0aeb1e4ddc3bc07
child 598542 aafa59b2ac12343b8462413e69c36e04e2de2170
push id65225
push userbmo:jaws@mozilla.com
push dateWed, 21 Jun 2017 19:31:48 +0000
reviewersmconley
bugs1375224
milestone56.0a1
Bug 1375224 - Remove use of <style scoped> from SelectParentHelper.jsm. r?mconley MozReview-Commit-ID: HeTSfqFTeVc
toolkit/modules/SelectParentHelper.jsm
--- a/toolkit/modules/SelectParentHelper.jsm
+++ b/toolkit/modules/SelectParentHelper.jsm
@@ -27,27 +27,26 @@ var customStylingEnabled = Services.pref
 var usedSelectBackgroundColor;
 
 this.SelectParentHelper = {
   populate(menulist, items, selectedIndex, zoom, uaBackgroundColor, uaColor,
            uaSelectBackgroundColor, uaSelectColor, selectBackgroundColor, selectColor,
            selectTextShadow) {
     // Clear the current contents of the popup
     menulist.menupopup.textContent = "";
-    let stylesheet = menulist.querySelector("#ContentSelectDropdownScopedStylesheet");
+    let stylesheet = menulist.querySelector("#ContentSelectDropdownStylesheet");
     if (stylesheet) {
       stylesheet.remove();
     }
 
     let doc = menulist.ownerDocument;
     let sheet;
     if (customStylingEnabled) {
       stylesheet = doc.createElementNS("http://www.w3.org/1999/xhtml", "style");
-      stylesheet.setAttribute("id", "ContentSelectDropdownScopedStylesheet");
-      stylesheet.scoped = true;
+      stylesheet.setAttribute("id", "ContentSelectDropdownStylesheet");
       stylesheet.hidden = true;
       stylesheet = menulist.appendChild(stylesheet);
       sheet = stylesheet.sheet;
     }
 
     let ruleBody = "";
 
     // Some webpages set the <select> backgroundColor to transparent,
@@ -70,17 +69,17 @@ this.SelectParentHelper = {
     }
 
     if (customStylingEnabled &&
         selectTextShadow != "none") {
       ruleBody += `text-shadow: ${selectTextShadow};`;
     }
 
     if (ruleBody) {
-      sheet.insertRule(`menupopup {
+      sheet.insertRule(`#ContentSelectDropdown > menupopup {
         ${ruleBody}
       }`, 0);
       menulist.menupopup.setAttribute("customoptionstyling", "true");
     } else {
       menulist.menupopup.removeAttribute("customoptionstyling");
     }
 
     currentZoom = zoom;
@@ -292,25 +291,25 @@ function populateChildren(menulist, opti
     }
 
     if (customStylingEnabled &&
         option.textShadow) {
       ruleBody += `text-shadow: ${option.textShadow};`;
     }
 
     if (ruleBody) {
-      sheet.insertRule(`menupopup > :nth-child(${nthChildIndex}):not([_moz-menuactive="true"]) {
+      sheet.insertRule(`#ContentSelectDropdown > menupopup > :nth-child(${nthChildIndex}):not([_moz-menuactive="true"]) {
         ${ruleBody}
       }`, 0);
 
       if (option.textShadow) {
         // Need to explicitly disable the possibly inherited
         // text-shadow rule when _moz-menuactive=true since
         // _moz-menuactive=true disables custom option styling.
-        sheet.insertRule(`menupopup > :nth-child(${nthChildIndex})[_moz-menuactive="true"] {
+        sheet.insertRule(`#ContentSelectDropdown > menupopup > :nth-child(${nthChildIndex})[_moz-menuactive="true"] {
           text-shadow: none;
         }`, 0);
       }
 
       item.setAttribute("customoptionstyling", "true");
     } else {
       item.removeAttribute("customoptionstyling");
     }