commit 102fdd80fb6c1abe3b2e8ed1f87d9198d45f95ea
parent 7b4f31cd7e83c6253160b7b0b036b05b70723c38
Author: Lorenz A <me@lorenzackermann.xyz>
Date: Mon, 15 Dec 2025 10:22:12 +0000
Bug 2004262 - [devtools] Turn devtools/client/shared/css-angle.js into an ES class. r=devtools-reviewers,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D276357
Diffstat:
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/devtools/client/shared/css-angle.js b/devtools/client/shared/css-angle.js
@@ -35,39 +35,34 @@ loader.lazyRequireGetter(
* angle.newAngle("-1TURN") === "-1TURN"; // true
*/
-function CssAngle(angleValue) {
- this.newAngle(angleValue);
-}
-
-module.exports.angleUtils = {
- CssAngle,
- classifyAngle,
-};
+class CssAngle {
+ constructor(angleValue) {
+ this.newAngle(angleValue);
+ }
-CssAngle.prototype = {
// Still keep trying to lazy load properties-db by lazily getting ANGLEUNIT
get ANGLEUNIT() {
return CSS_ANGLEUNIT;
- },
+ }
- _angleUnit: null,
- _angleUnitUppercase: false,
+ _angleUnit = null;
+ _angleUnitUppercase = false;
// The value as-authored.
- authored: null,
+ authored = null;
// A lower-cased copy of |authored|.
- lowerCased: null,
+ lowerCased = null;
get angleUnit() {
if (this._angleUnit === null) {
this._angleUnit = classifyAngle(this.authored);
}
return this._angleUnit;
- },
+ }
set angleUnit(unit) {
this._angleUnit = unit;
- },
+ }
get valid() {
const token = new InspectorCSSParserWrapper(this.authored).nextToken();
@@ -79,11 +74,11 @@ CssAngle.prototype = {
token.tokenType === "Dimension" &&
token.unit.toLowerCase() in this.ANGLEUNIT
);
- },
+ }
get specialValue() {
return SPECIALVALUES.has(this.lowerCased) ? this.authored : null;
- },
+ }
get deg() {
const invalidOrSpecialValue = this._getInvalidOrSpecialValue();
@@ -118,7 +113,7 @@ CssAngle.prototype = {
unitStr = unitStr.toUpperCase();
}
return `${Math.round(degValue * 100) / 100}${unitStr}`;
- },
+ }
get rad() {
const invalidOrSpecialValue = this._getInvalidOrSpecialValue();
@@ -153,7 +148,7 @@ CssAngle.prototype = {
unitStr = unitStr.toUpperCase();
}
return `${Math.round(radValue * 10000) / 10000}${unitStr}`;
- },
+ }
get grad() {
const invalidOrSpecialValue = this._getInvalidOrSpecialValue();
@@ -188,7 +183,7 @@ CssAngle.prototype = {
unitStr = unitStr.toUpperCase();
}
return `${Math.round(gradValue * 100) / 100}${unitStr}`;
- },
+ }
get turn() {
const invalidOrSpecialValue = this._getInvalidOrSpecialValue();
@@ -223,7 +218,7 @@ CssAngle.prototype = {
unitStr = unitStr.toUpperCase();
}
return `${Math.round(turnValue * 100) / 100}${unitStr}`;
- },
+ }
/**
* Check whether the angle value is in the special list e.g.
@@ -244,7 +239,7 @@ CssAngle.prototype = {
return "";
}
return false;
- },
+ }
/**
* Change angle
@@ -266,7 +261,7 @@ CssAngle.prototype = {
this.authoredAngleUnit = angle.substring(unitStartIdx, angle.length);
return this;
- },
+ }
nextAngleUnit() {
// Get a reordered array from the formats object
@@ -283,7 +278,7 @@ CssAngle.prototype = {
}
}
return this.toString();
- },
+ }
/**
* Return a string representing a angle
@@ -312,15 +307,15 @@ CssAngle.prototype = {
angle = angle.toUpperCase();
}
return angle;
- },
+ }
/**
* This method allows comparison of CssAngle objects using ===.
*/
valueOf() {
return this.deg;
- },
-};
+ }
+}
/**
* Given a color, classify its type as one of the possible angle
@@ -350,3 +345,8 @@ function classifyAngle(value) {
return CSS_ANGLEUNIT.deg;
}
+
+module.exports.angleUtils = {
+ CssAngle,
+ classifyAngle,
+};