Bug 1444036: Remove trivial uses of getPropertyCSSValue. r?johannh
MozReview-Commit-ID: HxdSr4749hi
--- a/devtools/client/shared/inplace-editor.js
+++ b/devtools/client/shared/inplace-editor.js
@@ -1521,75 +1521,74 @@ InplaceEditor.prototype = {
};
/**
* Copy text-related styles from one element to another.
*/
function copyTextStyles(from, to) {
let win = from.ownerDocument.defaultView;
let style = win.getComputedStyle(from);
- let getCssText = name => style.getPropertyCSSValue(name).cssText;
- to.style.fontFamily = getCssText("font-family");
- to.style.fontSize = getCssText("font-size");
- to.style.fontWeight = getCssText("font-weight");
- to.style.fontStyle = getCssText("font-style");
+ to.style.fontFamily = style.fontFamily;
+ to.style.fontSize = style.fontSize;
+ to.style.fontWeight = style.fontWeight;
+ to.style.fontStyle = style.fontStyle;
}
/**
* Copy all styles which could have an impact on the element size.
*/
function copyAllStyles(from, to) {
let win = from.ownerDocument.defaultView;
let style = win.getComputedStyle(from);
- let getCssText = name => style.getPropertyCSSValue(name).cssText;
copyTextStyles(from, to);
- to.style.lineHeight = getCssText("line-height");
+ to.style.lineHeight = style.lineHeight;
// If box-sizing is set to border-box, box model styles also need to be
// copied.
- let boxSizing = getCssText("box-sizing");
+ let boxSizing = style.boxSizing;
if (boxSizing === "border-box") {
to.style.boxSizing = boxSizing;
copyBoxModelStyles(from, to);
}
}
/**
* Copy box model styles that can impact width and height measurements when box-
* sizing is set to "border-box" instead of "content-box".
*
* @param {DOMNode} from
* the element from which styles are copied
* @param {DOMNode} to
* the element on which copied styles are applied
*/
function copyBoxModelStyles(from, to) {
+ const properties = [
+ // Copy all paddings.
+ "paddingTop",
+ "paddingRight",
+ "paddingBottom",
+ "paddingLeft",
+ // Copy border styles.
+ "borderTopStyle",
+ "borderRightStyle",
+ "borderBottomStyle",
+ "borderLeftStyle",
+ // Copy border widths.
+ "borderTopWidth",
+ "borderRightWidth",
+ "borderBottomWidth",
+ "borderLeftWidth"
+ ];
+
let win = from.ownerDocument.defaultView;
let style = win.getComputedStyle(from);
- let getCssText = name => style.getPropertyCSSValue(name).cssText;
-
- // Copy all paddings.
- to.style.paddingTop = getCssText("padding-top");
- to.style.paddingRight = getCssText("padding-right");
- to.style.paddingBottom = getCssText("padding-bottom");
- to.style.paddingLeft = getCssText("padding-left");
-
- // Copy border styles.
- to.style.borderTopStyle = getCssText("border-top-style");
- to.style.borderRightStyle = getCssText("border-right-style");
- to.style.borderBottomStyle = getCssText("border-bottom-style");
- to.style.borderLeftStyle = getCssText("border-left-style");
-
- // Copy border widths.
- to.style.borderTopWidth = getCssText("border-top-width");
- to.style.borderRightWidth = getCssText("border-right-width");
- to.style.borderBottomWidth = getCssText("border-bottom-width");
- to.style.borderLeftWidth = getCssText("border-left-width");
+ for (const property of properties)
+ to.style[property] = style[property];
}
/**
* Trigger a focus change similar to pressing tab/shift-tab.
*/
function moveFocus(win, direction) {
return focusManager.moveFocus(win, null, direction, 0);
}
--- a/devtools/client/shared/test/browser_inplace-editor_maxwidth.js
+++ b/devtools/client/shared/test/browser_inplace-editor_maxwidth.js
@@ -92,18 +92,17 @@ let testMaxWidth = Task.async(function*
* Retrieve the current number of lines displayed in the provided textarea.
*
* @param {DOMNode} textarea
* @return {Number} the number of lines
*/
function getLines(textarea) {
let win = textarea.ownerDocument.defaultView;
let style = win.getComputedStyle(textarea);
- let lineHeight = style.getPropertyCSSValue("line-height").cssText;
- return Math.floor(textarea.clientHeight / parseFloat(lineHeight));
+ return Math.floor(textarea.clientHeight / parseFloat(style.lineHeight));
}
/**
* Verify that the provided textarea has no vertical or horizontal scrollbar.
*
* @param {DOMNode} textarea
*/
function checkScrollbars(textarea) {
--- a/devtools/client/webconsole/utils.js
+++ b/devtools/client/webconsole/utils.js
@@ -91,20 +91,20 @@ var WebConsoleUtils = {
* @param nsIDOMNode from
* The target node.
* @param nsIDOMNode to
* The destination node.
*/
copyTextStyles: function (from, to) {
let win = from.ownerDocument.defaultView;
let style = win.getComputedStyle(from);
- to.style.fontFamily = style.getPropertyCSSValue("font-family").cssText;
- to.style.fontSize = style.getPropertyCSSValue("font-size").cssText;
- to.style.fontWeight = style.getPropertyCSSValue("font-weight").cssText;
- to.style.fontStyle = style.getPropertyCSSValue("font-style").cssText;
+ to.style.fontFamily = style.fontFamily;
+ to.style.fontSize = style.fontSize;
+ to.style.fontWeight = style.fontWeight;
+ to.style.fontStyle = style.fontStyle;
},
/**
* Determine if the given request mixes HTTP with HTTPS content.
*
* @param string request
* Location of the requested content.
* @param string location
--- a/toolkit/content/tests/chrome/test_autocomplete2.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete2.xul
@@ -138,44 +138,44 @@ function checkResult() {
// Result was returned, so there should not be a nomatch attribute
is(autocomplete.hasAttribute("nomatch"), false,
"nomatch attribute shouldn't be present here");
// Ensure that the style is set correctly whichever way highlightNonMatches
// is set.
autocomplete.highlightNonMatches = "true";
- isnot(style.getPropertyCSSValue("color").cssText, "rgb(255, 0, 0)",
+ isnot(style.color, "rgb(255, 0, 0)",
"not nomatch and highlightNonMatches - should not be red");
autocomplete.highlightNonMatches = "false";
- isnot(style.getPropertyCSSValue("color").cssText, "rgb(255, 0, 0)",
+ isnot(style.color, "rgb(255, 0, 0)",
"not nomatch and not highlightNonMatches - should not be red");
is (autocomplete.popup.getAttribute("autocompleteinput"), "autocomplete",
"The popup's autocompleteinput attribute is set to the ID of the textbox");
setTimeout(check, 0);
}
else {
// No result was returned, so there should be nomatch attribute
is(autocomplete.getAttribute("nomatch"), "true",
"nomatch attribute not correctly set when expected");
// Ensure that the style is set correctly whichever way highlightNonMatches
// is set.
autocomplete.highlightNonMatches = "true";
- is(style.getPropertyCSSValue("color").cssText, "rgb(255, 0, 0)",
+ is(style.color, "rgb(255, 0, 0)",
"nomatch and highlightNonMatches - should be red");
autocomplete.highlightNonMatches = "false";
- isnot(style.getPropertyCSSValue("color").cssText, "rgb(255, 0, 0)",
+ isnot(style.color, "rgb(255, 0, 0)",
"nomatch and not highlightNonMatches - should not be red");
ok(!autocomplete.popup.hasAttribute("autocompleteinput"),
"autocompleteinput on popup not set when closed");
setTimeout(function() {
// Unregister the factory so that we don't get in the way of other tests
componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple);