Bug 1279703 - use theme body-color for devtools font-preview;r=pbro
MozReview-Commit-ID: 23KqLhfpWuj
--- a/devtools/client/inspector/rules/test/head.js
+++ b/devtools/client/inspector/rules/test/head.js
@@ -212,34 +212,16 @@ var waitForSuccess = Task.async(function
ok(false, "Failure: " + desc);
break;
}
yield new Promise(r => setTimeout(r, 200));
}
});
/**
- * Get the dataURL for the font family tooltip.
- *
- * @param {String} font
- * The font family value.
- * @param {object} nodeFront
- * The NodeActor that will used to retrieve the dataURL for the
- * font family tooltip contents.
- */
-var getFontFamilyDataURL = Task.async(function* (font, nodeFront) {
- let fillStyle = (Services.prefs.getCharPref("devtools.theme") === "light") ?
- "black" : "white";
-
- let {data} = yield nodeFront.getFontFamilyDataURL(font, fillStyle);
- let dataURL = yield data.string();
- return dataURL;
-});
-
-/**
* Get the DOMNode for a css rule in the rule-view that corresponds to the given
* selector
*
* @param {CssRuleView} view
* The instance of the rule-view panel
* @param {String} selectorText
* The selector in the rule-view for which the rule
* object is wanted
--- a/devtools/client/inspector/shared/style-inspector-overlays.js
+++ b/devtools/client/inspector/shared/style-inspector-overlays.js
@@ -7,17 +7,17 @@
"use strict";
// The style-inspector overlays are:
// - tooltips that appear when hovering over property values
// - editor tooltips that appear when clicking color swatches, etc.
// - in-content highlighters that appear when hovering over property values
// - etc.
-const {getTheme} = require("devtools/client/shared/theme");
+const {getColor} = require("devtools/client/shared/theme");
const {HTMLTooltip} = require("devtools/client/shared/widgets/HTMLTooltip");
const {
getImageDimensions,
setImageTooltip,
setBrokenImageTooltip,
} = require("devtools/client/shared/widgets/tooltip/ImageTooltipHelper");
const {
SwatchColorPickerTooltip,
@@ -467,17 +467,17 @@ TooltipsOverlay.prototype = {
if (!font || !nodeFront || typeof nodeFront.getFontFamilyDataURL !== "function") {
throw new Error("Unable to create font preview tooltip content.");
}
font = font.replace(/"/g, "'");
font = font.replace("!important", "");
font = font.trim();
- let fillStyle = getTheme() === "light" ? "black" : "white";
+ let fillStyle = getColor("body-color");
let {data, size: maxDim} = yield nodeFront.getFontFamilyDataURL(font, fillStyle);
let imageUrl = yield data.string();
let doc = this.view.inspector.panelDoc;
let {naturalWidth, naturalHeight} = yield getImageDimensions(doc, imageUrl);
yield setImageTooltip(this.previewTooltip, doc, imageUrl,
{hideDimensionLabel: true, maxDim, naturalWidth, naturalHeight});
--- a/devtools/client/inspector/shared/test/head.js
+++ b/devtools/client/inspector/shared/test/head.js
@@ -1,24 +1,24 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint no-unused-vars: [2, {"vars": "local"}] */
/* import-globals-from ../../test/head.js */
-
"use strict";
// Import the inspector's head.js first (which itself imports shared-head.js).
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/inspector/test/head.js",
this);
var {CssRuleView} = require("devtools/client/inspector/rules/rules");
var {getInplaceEditorForSpan: inplaceEditor} =
require("devtools/client/shared/inplace-editor");
+const {getColor: getThemeColor} = require("devtools/client/shared/theme");
const TEST_URL_ROOT =
"http://example.com/browser/devtools/client/inspector/shared/test/";
const TEST_URL_ROOT_SSL =
"https://example.com/browser/devtools/client/inspector/shared/test/";
const ROOT_TEST_DIR = getRootDirectory(gTestPath);
const FRAME_SCRIPT_URL = ROOT_TEST_DIR + "doc_frame_script.js";
const _STRINGS = Services.strings.createBundle(
@@ -235,18 +235,17 @@ function waitForSuccess(validatorFn, nam
*
* @param {String} font
* The font family value.
* @param {object} nodeFront
* The NodeActor that will used to retrieve the dataURL for the
* font family tooltip contents.
*/
var getFontFamilyDataURL = Task.async(function* (font, nodeFront) {
- let fillStyle = (Services.prefs.getCharPref("devtools.theme") === "light") ?
- "black" : "white";
+ let fillStyle = getThemeColor("body-color");
let {data} = yield nodeFront.getFontFamilyDataURL(font, fillStyle);
let dataURL = yield data.string();
return dataURL;
});
/* *********************************************
* RULE-VIEW