Bug 1321467 - display grid line numbers with extended grid lines;r=zer0
Clamp the x and y positions for the grid line numbers to make sure they
are always visible, even if extended grid lines is turned on.
MozReview-Commit-ID: 3sxdWtKyXKN
--- a/devtools/server/actors/highlighters/css-grid.js
+++ b/devtools/server/actors/highlighters/css-grid.js
@@ -626,21 +626,26 @@ CssGridHighlighter.prototype = extend(Au
* @param {Number} startPos
* The start position of the cross side of the grid line.
* @param {String} dimensionType
* The grid dimension type which is either the constant COLUMNS or ROWS.
*/
renderGridLineNumber(lineNumber, linePos, startPos, dimensionType) {
this.ctx.save();
+ let textWidth = this.ctx.measureText(lineNumber).width;
+ // Guess the font height based on the measured width
+ let textHeight = textWidth * 2;
+
if (dimensionType === COLUMNS) {
- this.ctx.fillText(lineNumber, linePos, startPos);
+ let yPos = Math.max(startPos, textHeight);
+ this.ctx.fillText(lineNumber, linePos, yPos);
} else {
- let textWidth = this.ctx.measureText(lineNumber).width;
- this.ctx.fillText(lineNumber, startPos - textWidth, linePos);
+ let xPos = Math.max(startPos, textWidth);
+ this.ctx.fillText(lineNumber, xPos - textWidth, linePos);
}
this.ctx.restore();
},
/**
* Render the grid gap area on the css grid highlighter canvas.
*