Bug 1472561 - Provide an option to show alignment in the flexbox highlighter. r=pbro
MozReview-Commit-ID: 276UgVYiyJe
--- a/devtools/server/actors/highlighters/flexbox.js
+++ b/devtools/server/actors/highlighters/flexbox.js
@@ -50,16 +50,25 @@ const BASIS_FILL_COLOR = "rgb(109, 184,
/**
* Cached used by `FlexboxHighlighter.getFlexContainerPattern`.
*/
const gCachedFlexboxPattern = new Map();
const FLEXBOX = "flexbox";
const JUSTIFY_CONTENT = "justify-content";
+/**
+ * The FlexboxHighlighter is the class that overlays a visual canvas on top of
+ * display: [inline-]flex elements.
+ *
+ * Available Options:
+ * - showAlignment(isShown)
+ * @param {Boolean} isShown
+ * Shows the alignment in the flexbox highlighter.
+ */
class FlexboxHighlighter extends AutoRefreshHighlighter {
constructor(highlighterEnv) {
super(highlighterEnv);
this.ID_CLASS_PREFIX = "flexbox-";
this.markup = new CanvasFrameAnonymousContentHelper(this.highlighterEnv,
this._buildMarkup.bind(this));
@@ -358,17 +367,18 @@ class FlexboxHighlighter extends AutoRef
this.clearCache();
if (isTopLevel) {
this.hide();
}
}
renderAlignItemLine() {
- if (!this.flexData || !this.currentQuads.content || !this.currentQuads.content[0]) {
+ if (!this.options.showAlignment || !this.flexData ||
+ !this.currentQuads.content || !this.currentQuads.content[0]) {
return;
}
const { devicePixelRatio } = this.win;
const lineWidth = getDisplayPixelRatio(this.win);
const offset = (lineWidth / 2) % 1;
const canvasX = Math.round(this._canvasPosition.x * devicePixelRatio);
const canvasY = Math.round(this._canvasPosition.y * devicePixelRatio);