зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1435373 - Minor refactor for shape output string guarding against empty this.geometryBox. Round values in getDistance() util function to avoid verbose precision. r=gl
MozReview-Commit-ID: IBB4mkvAu6h --HG-- extra : rebase_source : 85fadc5f52717a61a936ae1f6b9870d7d9a43cdd extra : source : 8c0b9a89288353152e8409c53bbb41461240c317
This commit is contained in:
Родитель
0494a7c88a
Коммит
0292f7ce0b
|
@ -841,8 +841,7 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
|
||||
return `${newX}${unitX} ${newY}${unitY}`;
|
||||
}).join(", ");
|
||||
polygonDef = (this.geometryBox) ? `polygon(${polygonDef}) ${this.geometryBox}` :
|
||||
`polygon(${polygonDef})`;
|
||||
polygonDef = `polygon(${polygonDef}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, polygonDef, "important");
|
||||
}
|
||||
|
@ -865,11 +864,9 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
radius = `${Math.abs((newCx - transX) * ratioRad)}${unitRad}`;
|
||||
}
|
||||
|
||||
let circleDef = (this.geometryBox) ?
|
||||
`circle(${radius} at ${newCx * ratioX}${unitX} ` +
|
||||
`${newCy * ratioY}${unitY} ${this.geometryBox}` :
|
||||
`circle(${radius} at ${newCx * ratioX}${unitX} ${newCy * ratioY}${unitY}`;
|
||||
this.currentNode.style.setProperty(this.property, circleDef, "important");
|
||||
let circleDef = `circle(${radius} at ${newCx * ratioX}${unitX} ` +
|
||||
`${newCy * ratioY}${unitY}) ${this.geometryBox}`.trim();
|
||||
this.emit("highlighter-event", { type: "shape-change", value: circleDef });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -893,12 +890,9 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
ry = `${Math.abs((newCy - transY) * ratioRY)}${unitRY}`;
|
||||
}
|
||||
|
||||
let ellipseDef = (this.geometryBox) ?
|
||||
`ellipse(${rx} ${ry} at ${newCx * ratioX}${unitX} ` +
|
||||
`${newCy * ratioY}${unitY}) ${this.geometryBox}` :
|
||||
`ellipse(${rx} ${ry} at ${newCx * ratioX}${unitX} ` +
|
||||
`${newCy * ratioY}${unitY})`;
|
||||
this.currentNode.style.setProperty(this.property, ellipseDef, "important");
|
||||
let ellipseDef = `ellipse(${rx} ${ry} at ${newCx * ratioX}${unitX} ` +
|
||||
`${newCy * ratioY}${unitY}) ${this.geometryBox}`.trim();
|
||||
this.emit("highlighter-event", { type: "shape-change", value: ellipseDef });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -980,8 +974,7 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
return (i === point) ?
|
||||
`${newX}${unitX} ${newY}${unitY}` : `${coords[0]} ${coords[1]}`;
|
||||
}).join(", ");
|
||||
polygonDef = (this.geometryBox) ? `polygon(${polygonDef}) ${this.geometryBox}` :
|
||||
`polygon(${polygonDef})`;
|
||||
polygonDef = `polygon(${polygonDef}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, polygonDef, "important");
|
||||
}
|
||||
|
@ -1001,8 +994,7 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
return (i === after) ? `${coords[0]} ${coords[1]}, ${x}% ${y}%` :
|
||||
`${coords[0]} ${coords[1]}`;
|
||||
}).join(", ");
|
||||
polygonDef = (this.geometryBox) ? `polygon(${polygonDef}) ${this.geometryBox}` :
|
||||
`polygon(${polygonDef})`;
|
||||
polygonDef = `polygon(${polygonDef}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.hoveredPoint = after + 1;
|
||||
this._emitHoverEvent(this.hoveredPoint);
|
||||
|
@ -1020,8 +1012,7 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
polygonDef += coordinates.map((coords, i) => {
|
||||
return `${coords[0]} ${coords[1]}`;
|
||||
}).join(", ");
|
||||
polygonDef = (this.geometryBox) ? `polygon(${polygonDef}) ${this.geometryBox}` :
|
||||
`polygon(${polygonDef})`;
|
||||
polygonDef = `polygon(${polygonDef}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.hoveredPoint = null;
|
||||
this._emitHoverEvent(this.hoveredPoint);
|
||||
|
@ -1086,9 +1077,8 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
let deltaY = (pageY - y) * ratioY;
|
||||
let newCx = `${valueX + deltaX}${unitX}`;
|
||||
let newCy = `${valueY + deltaY}${unitY}`;
|
||||
let circleDef = (this.geometryBox) ?
|
||||
`circle(${radius} at ${newCx} ${newCy}) ${this.geometryBox}` :
|
||||
`circle(${radius} at ${newCx} ${newCy})`;
|
||||
// if not defined by the user, geometryBox will be an empty string; trim() cleans up
|
||||
let circleDef = `circle(${radius} at ${newCx} ${newCy}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, circleDef, "important");
|
||||
} else if (point === "radius") {
|
||||
|
@ -1101,9 +1091,7 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
let delta = (newRadiusPx - origRadius) * ratio;
|
||||
let newRadius = `${value + delta}${unit}`;
|
||||
|
||||
let circleDef = (this.geometryBox) ?
|
||||
`circle(${newRadius} at ${cx} ${cy} ${this.geometryBox}` :
|
||||
`circle(${newRadius} at ${cx} ${cy}`;
|
||||
let circleDef = `circle(${newRadius} at ${cx} ${cy}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, circleDef, "important");
|
||||
}
|
||||
|
@ -1177,9 +1165,8 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
let deltaY = (pageY - y) * ratioY;
|
||||
let newCx = `${valueX + deltaX}${unitX}`;
|
||||
let newCy = `${valueY + deltaY}${unitY}`;
|
||||
let ellipseDef = (this.geometryBox) ?
|
||||
`ellipse(${rx} ${ry} at ${newCx} ${newCy}) ${this.geometryBox}` :
|
||||
`ellipse(${rx} ${ry} at ${newCx} ${newCy})`;
|
||||
let ellipseDef =
|
||||
`ellipse(${rx} ${ry} at ${newCx} ${newCy}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, ellipseDef, "important");
|
||||
} else if (point === "rx") {
|
||||
|
@ -1189,9 +1176,8 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
let delta = ((newRadiusPercent / 100 * width) - origRadius) * ratio;
|
||||
let newRadius = `${value + delta}${unit}`;
|
||||
|
||||
let ellipseDef = (this.geometryBox) ?
|
||||
`ellipse(${newRadius} ${ry} at ${cx} ${cy}) ${this.geometryBox}` :
|
||||
`ellipse(${newRadius} ${ry} at ${cx} ${cy})`;
|
||||
let ellipseDef =
|
||||
`ellipse(${newRadius} ${ry} at ${cx} ${cy}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, ellipseDef, "important");
|
||||
} else if (point === "ry") {
|
||||
|
@ -1201,9 +1187,8 @@ class ShapesHighlighter extends AutoRefreshHighlighter {
|
|||
let delta = ((newRadiusPercent / 100 * height) - origRadius) * ratio;
|
||||
let newRadius = `${value + delta}${unit}`;
|
||||
|
||||
let ellipseDef = (this.geometryBox) ?
|
||||
`ellipse(${rx} ${newRadius} at ${cx} ${cy}) ${this.geometryBox}` :
|
||||
`ellipse(${rx} ${newRadius} at ${cx} ${cy})`;
|
||||
let ellipseDef =
|
||||
`ellipse(${rx} ${newRadius} at ${cx} ${cy}) ${this.geometryBox}`.trim();
|
||||
|
||||
this.currentNode.style.setProperty(this.property, ellipseDef, "important");
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* @returns {Number} the distance between the two points
|
||||
*/
|
||||
const getDistance = (x1, y1, x2, y2) => {
|
||||
return Math.hypot(x2 - x1, y2 - y1);
|
||||
return Math.round(Math.hypot(x2 - x1, y2 - y1));
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче