Bug 1472561 - Provide an option to show alignment in the flexbox highlighter. r=pbro draft
authorGabriel Luong <gabriel.luong@gmail.com>
Sun, 01 Jul 2018 14:46:21 -0400
changeset 812938 a2107214f37d531b82d82abe304f1eef766de828
parent 812937 feb0f13f27cf55ed05d5fa88b78249afb003b086
push id114713
push userbmo:gl@mozilla.com
push dateSun, 01 Jul 2018 19:04:05 +0000
reviewerspbro
bugs1472561
milestone63.0a1
Bug 1472561 - Provide an option to show alignment in the flexbox highlighter. r=pbro MozReview-Commit-ID: 276UgVYiyJe
devtools/server/actors/highlighters/flexbox.js
--- 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);