From f16c510764eeef95461239f4969ed1ae8d0070b4 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 25 Apr 2016 13:56:04 -0600 Subject: [PATCH] Bug 1267378 - fix eslint errors in css-color.js; r=miker MozReview-Commit-ID: D1MM5Yk9IKv --HG-- extra : amend_source : 9303a23cc67d4499567557140dacb9b74fa6da5d --- .eslintignore | 1 + devtools/shared/css-color.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.eslintignore b/.eslintignore index a598cf92d8a2..d2cef9e4ff6a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -109,6 +109,7 @@ devtools/client/webconsole/** devtools/client/webide/** devtools/server/** devtools/shared/*.js +!devtools/shared/css-color.js devtools/shared/*.jsm devtools/shared/apps/** devtools/shared/client/** diff --git a/devtools/shared/css-color.js b/devtools/shared/css-color.js index 179df2579689..fccfe875d365 100644 --- a/devtools/shared/css-color.js +++ b/devtools/shared/css-color.js @@ -4,7 +4,7 @@ "use strict"; -const {Cc, Ci, Cu} = require("chrome"); +const {Cc, Ci} = require("chrome"); const Services = require("Services"); const COLOR_UNIT_PREF = "devtools.defaultColorUnit"; @@ -35,8 +35,8 @@ const SPECIALVALUES = new Set([ * return this.rgba. * color.longHex === "#ff0000" // If alpha channel is present then we return * this.rgba. - * color.rgb === "rgb(255, 0, 0)" // If alpha channel is present then we return - * this.rgba. + * color.rgb === "rgb(255, 0, 0)" // If alpha channel is present + * // then we return this.rgba. * color.rgba === "rgba(255, 0, 0, 1)" * color.hsl === "hsl(0, 100%, 50%)" * color.hsla === "hsla(0, 100%, 50%, 1)" // If alpha channel is present @@ -128,7 +128,7 @@ CssColor.prototype = { try { let tuple = this._getRGBATuple(); return !(tuple.r || tuple.g || tuple.b || tuple.a); - } catch(e) { + } catch (e) { return false; } }, @@ -151,7 +151,7 @@ CssColor.prototype = { } let {r, g, b} = tuple; return DOMUtils.rgbToColorName(r, g, b); - } catch(e) { + } catch (e) { return this.hex; } }, @@ -184,7 +184,8 @@ CssColor.prototype = { } let tuple = this._getRGBATuple(); - return "#" + ((1 << 24) + (tuple.r << 16) + (tuple.g << 8) + (tuple.b << 0)).toString(16).substr(-6); + return "#" + ((1 << 24) + (tuple.r << 16) + (tuple.g << 8) + + (tuple.b << 0)).toString(16).substr(-6); }, get rgb() { @@ -210,7 +211,7 @@ CssColor.prototype = { } if (this.lowerCased.startsWith("rgba(")) { // The color is valid and begins with rgba(. - return this.authored; + return this.authored; } let components = this._getRGBATuple(); return "rgba(" + components.r + ", " + @@ -311,7 +312,7 @@ CssColor.prototype = { toString: function() { let color; - switch(this.colorUnit) { + switch (this.colorUnit) { case CssColor.COLORUNIT.authored: color = this.authored; break; @@ -358,12 +359,11 @@ CssColor.prototype = { } let {r, g, b} = this._getRGBATuple(); - let [h,s,l] = rgbToHsl([r,g,b]); + let [h, s, l] = rgbToHsl([r, g, b]); if (maybeAlpha !== undefined) { return "hsla(" + h + ", " + s + "%, " + l + "%, " + maybeAlpha + ")"; - } else { - return "hsl(" + h + ", " + s + "%, " + l + "%)"; } + return "hsl(" + h + ", " + s + "%, " + l + "%)"; }, /** @@ -382,7 +382,7 @@ CssColor.prototype = { * @return {array} * Array of hsl values. */ -function rgbToHsl([r,g,b]) { +function rgbToHsl([r, g, b]) { r = r / 255; g = g / 255; b = b / 255; @@ -393,13 +393,13 @@ function rgbToHsl([r,g,b]) { let s; let l = (max + min) / 2; - if (max == min){ + if (max == min) { h = s = 0; } else { let d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - switch(max) { + switch (max) { case r: h = ((g - b) / d) % 6; break; @@ -469,6 +469,6 @@ function classifyColor(value) { return CssColor.COLORUNIT.name; } -loader.lazyGetter(this, "DOMUtils", function () { +loader.lazyGetter(this, "DOMUtils", function() { return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils); });