B2G/gecko/browser/devtools/highlighter/highlighter.jsm
/**
   * Move the Infobar to the right place in the highlighter.
   */
Move the Infobar to the right place in the highlighter.
Move the Infobar to the right place in the highlighter .
function Highlighter_moveInfobar()
  {
    if (this._highlightRect) {
      let winHeight = this.win.innerHeight * this.zoom;
      let winWidth = this.win.innerWidth * this.zoom;
      let rect = {top: this._highlightRect.top,
                  left: this._highlightRect.left,
                  width: this._highlightRect.width,
                  height: this._highlightRect.height};
      rect.top = Math.max(rect.top, 0);
      rect.left = Math.max(rect.left, 0);
      rect.width = Math.max(rect.width, 0);
      rect.height = Math.max(rect.height, 0);
      rect.top = Math.min(rect.top, winHeight);
      rect.left = Math.min(rect.left, winWidth);
      this.nodeInfo.container.removeAttribute("disabled");
      if (rect.top < this.nodeInfo.barHeight) {
        if (rect.top + rect.height +
            this.nodeInfo.barHeight > winHeight) {
          this.nodeInfo.container.style.top = rect.top + "px";
          this.nodeInfo.container.setAttribute("position", "overlap");
        } else {
          this.nodeInfo.container.style.top = rect.top + rect.height + "px";
          this.nodeInfo.container.setAttribute("position", "bottom");
        }
      } else {
        this.nodeInfo.container.style.top =
          rect.top - this.nodeInfo.barHeight + "px";
        this.nodeInfo.container.setAttribute("position", "top");
      }
      let barWidth = this.nodeInfo.container.getBoundingClientRect().width;
      let left = rect.left + rect.width / 2 - barWidth / 2;
      if (left < 0) {
        left = 0;
        this.nodeInfo.container.setAttribute("hide-arrow", "true");
      } else {
        if (left + barWidth > winWidth) {
          left = winWidth - barWidth;
          this.nodeInfo.container.setAttribute("hide-arrow", "true");
        } else {
          this.nodeInfo.container.removeAttribute("hide-arrow");
        }
      }
      this.nodeInfo.container.style.left = left + "px";
    } else {
      this.nodeInfo.container.style.left = "0";
      this.nodeInfo.container.style.top = "0";
      this.nodeInfo.container.setAttribute("position", "top");
      this.nodeInfo.container.setAttribute("hide-arrow", "true");
    }
  }
function Highlighter_moveInfobar ( ) { if ( this . _highlightRect ) { let winHeight = this . win . innerHeight * this . zoom ; let winWidth = this . win . innerWidth * this . zoom ; let rect = { top : this . _highlightRect . top , left : this . _highlightRect . left , width : this . _highlightRect . width , height : this . _highlightRect . height } ; rect . top = Math . max ( rect . top , 0 ) ; rect . left = Math . max ( rect . left , 0 ) ; rect . width = Math . max ( rect . width , 0 ) ; rect . height = Math . max ( rect . height , 0 ) ; rect . top = Math . min ( rect . top , winHeight ) ; rect . left = Math . min ( rect . left , winWidth ) ; this . nodeInfo . container . removeAttribute ( "disabled" ) ; if ( rect . top < this . nodeInfo . barHeight ) { if ( rect . top + rect . height + this . nodeInfo . barHeight > winHeight ) { this . nodeInfo . container . style . top = rect . top + "px" ; this . nodeInfo . container . setAttribute ( "position" , "overlap" ) ; } else { this . nodeInfo . container . style . top = rect . top + rect . height + "px" ; this . nodeInfo . container . setAttribute ( "position" , "bottom" ) ; } } else { this . nodeInfo . container . style . top = rect . top - this . nodeInfo . barHeight + "px" ; this . nodeInfo . container . setAttribute ( "position" , "top" ) ; } let barWidth = this . nodeInfo . container . getBoundingClientRect ( ) . width ; let left = rect . left + rect . width / 2 - barWidth / 2 ; if ( left < 0 ) { left = 0 ; this . nodeInfo . container . setAttribute ( "hide-arrow" , "true" ) ; } else { if ( left + barWidth > winWidth ) { left = winWidth - barWidth ; this . nodeInfo . container . setAttribute ( "hide-arrow" , "true" ) ; } else { this . nodeInfo . container . removeAttribute ( "hide-arrow" ) ; } } this . nodeInfo . container . style . left = left + "px" ; } else { this . nodeInfo . container . style . left = "0" ; this . nodeInfo . container . style . top = "0" ; this . nodeInfo . container . setAttribute ( "position" , "top" ) ; this . nodeInfo . container . setAttribute ( "hide-arrow" , "true" ) ; } }
Move the Infobar to the right place in the highlighter.
Move the Infobar to the right place in the highlighter .
// Can the bar be above the node? // No. Can we move the toolbar under the node? // No. Let's move it inside. // Yes. Let's move it under the node. // Yes. Let's move it on top of the node. // Make sure the whole infobar is visible