Bug 1310681 - do not use devtools colorUtils in browser draft
authorTom Tromey <tom@tromey.com>
Tue, 18 Oct 2016 13:32:30 -0600
changeset 426570 f464803fca9e747419d4349df81c77f7c475c085
parent 426420 dc89484d4b45abf442162e5ea2dd46f9de40197d
child 426571 87f4c7053c2ca2b6f0a202ab5f73dcb34dbfa26b
push id32748
push userbmo:ttromey@mozilla.com
push dateTue, 18 Oct 2016 20:09:14 +0000
bugs1310681
milestone52.0a1
Bug 1310681 - do not use devtools colorUtils in browser MozReview-Commit-ID: BBsa0hIm2T0
browser/components/extensions/ext-browserAction.js
browser/components/extensions/ext-utils.js
--- a/browser/components/extensions/ext-browserAction.js
+++ b/browser/components/extensions/ext-browserAction.js
@@ -4,19 +4,19 @@
 
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
                                   "resource:///modules/CustomizableUI.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "clearTimeout",
                                   "resource://gre/modules/Timer.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
                                   "resource://gre/modules/Timer.jsm");
 
-XPCOMUtils.defineLazyGetter(this, "colorUtils", () => {
-  return require("devtools/shared/css/color").colorUtils;
-});
+XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils",
+                                   "@mozilla.org/inspector/dom-utils;1",
+                                   "inIDOMUtils");
 
 Cu.import("resource://devtools/shared/event-emitter.js");
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 
 var {
   EventManager,
   IconDetails,
@@ -483,17 +483,17 @@ extensions.registerSchemaAPI("browserAct
         let popup = BrowserAction.for(extension).getProperty(tab, "popup");
         return Promise.resolve(popup);
       },
 
       setBadgeBackgroundColor: function(details) {
         let tab = details.tabId !== null ? TabManager.getTab(details.tabId, context) : null;
         let color = details.color;
         if (!Array.isArray(color)) {
-          let col = colorUtils.colorToRGBA(color);
+          let col = DOMUtils.colorToRGBA(color);
           color = col && [col.r, col.g, col.b, Math.round(col.a * 255)];
         }
         BrowserAction.for(extension).setProperty(tab, "badgeBackgroundColor", color);
       },
 
       getBadgeBackgroundColor: function(details, callback) {
         let tab = details.tabId !== null ? TabManager.getTab(details.tabId, context) : null;
 
--- a/browser/components/extensions/ext-utils.js
+++ b/browser/components/extensions/ext-utils.js
@@ -12,19 +12,19 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
                                   "resource://gre/modules/Timer.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "styleSheetService",
                                    "@mozilla.org/content/style-sheet-service;1",
                                    "nsIStyleSheetService");
 
-XPCOMUtils.defineLazyGetter(this, "colorUtils", () => {
-  return require("devtools/shared/css/color").colorUtils;
-});
+XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils",
+                                   "@mozilla.org/inspector/dom-utils;1",
+                                   "inIDOMUtils");
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 Cu.import("resource://gre/modules/AppConstants.jsm");
 
 const POPUP_LOAD_TIMEOUT_MS = 200;
 
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
@@ -376,17 +376,17 @@ class BasePopup {
     } else {
       // Copy the background color of the document's body to the panel if it's
       // fully opaque.
       let panelBackground = "";
       let panelArrow = "";
 
       let background = doc.defaultView.getComputedStyle(body).backgroundColor;
       if (background != "transparent") {
-        let bgColor = colorUtils.colorToRGBA(background);
+        let bgColor = DOMUtils.colorToRGBA(background);
         if (bgColor.a == 1) {
           panelBackground = background;
           let borderColor = this.borderColor || background;
 
           panelArrow = `url("data:image/svg+xml,${encodeURIComponent(`<?xml version="1.0" encoding="UTF-8"?>
             <svg xmlns="http://www.w3.org/2000/svg" width="20" height="10">
               <path d="M 0,10 L 10,0 20,10 z" fill="${borderColor}"/>
               <path d="M 1,10 L 10,1 19,10 z" fill="${background}"/>