Bug 1451684 - Compute farthest-side / closest-side circle radius as pixels, then resolve to percentages according to formula defined in spec. r=gl
authorRazvan Caliman <rcaliman@mozilla.com>
Fri, 22 Jun 2018 17:40:45 +0200
changeset 480087 33bc3b3133060bd1d31491167d343d792cd23242
parent 480086 745cc7740897b01ebb8ab71cc46c8260a980fed1
child 480088 55e1e865e62682358974cb7929ce5bf5defd04de
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1451684
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451684 - Compute farthest-side / closest-side circle radius as pixels, then resolve to percentages according to formula defined in spec. r=gl MozReview-Commit-ID: 5yE8Q88fZ78
devtools/server/actors/highlighters/shapes.js
--- a/devtools/server/actors/highlighters/shapes.js
+++ b/devtools/server/actors/highlighters/shapes.js
@@ -1878,22 +1878,28 @@ class ShapesHighlighter extends AutoRefr
     let radius = values[0];
     const { width, height } = this.currentDimensions;
     const center = splitCoords(values[1]).map(this.convertCoordsToPercent.bind(this));
 
     // Percentage values for circle() are resolved from the
     // used width and height of the reference box as sqrt(width^2+height^2)/sqrt(2).
     const computedSize = Math.sqrt((width ** 2) + (height ** 2)) / Math.sqrt(2);
 
+    // Position coordinates for circle center in pixels.
+    const cxPx = width * center[0] / 100;
+    const cyPx = height * center[1] / 100;
+
     if (radius === "closest-side") {
       // radius is the distance from center to closest side of reference box
-      radius = Math.min(center[0], center[1], 100 - center[0], 100 - center[1]);
+      radius = Math.min(cxPx, cyPx, width - cxPx, height - cyPx);
+      radius = coordToPercent(`${radius}px`, computedSize);
     } else if (radius === "farthest-side") {
       // radius is the distance from center to farthest side of reference box
-      radius = Math.max(center[0], center[1], 100 - center[0], 100 - center[1]);
+      radius = Math.max(cxPx, cyPx, width - cxPx, height - cyPx);
+      radius = coordToPercent(`${radius}px`, computedSize);
     } else if (radius.includes("calc(")) {
       radius = evalCalcExpression(radius.substring(5, radius.length - 1), computedSize);
     } else {
       radius = coordToPercent(radius, computedSize);
     }
 
     // Scale both radiusX and radiusY to match the radius computed
     // using the above equation.