Bug 1461522 - Fix some comments in HTMLTooltip.js; r=jdescottes
authorBrian Birtles <birtles@gmail.com>
Thu, 28 Jun 2018 14:56:30 +0900
changeset 814147 924dcb50f6da454045b6ca91ab20bd913396bec2
parent 814146 52628cf763c9dcc0907b8bb54ee6ce82e92038a4
child 814148 95fe4a4625fe6d10e43200ceef5df7df0d521dbb
push id115123
push userjdescottes@mozilla.com
push dateWed, 04 Jul 2018 17:42:29 +0000
reviewersjdescottes
bugs1461522
milestone63.0a1
Bug 1461522 - Fix some comments in HTMLTooltip.js; r=jdescottes MozReview-Commit-ID: F01ofl9u5lR
devtools/client/shared/widgets/tooltip/HTMLTooltip.js
--- a/devtools/client/shared/widgets/tooltip/HTMLTooltip.js
+++ b/devtools/client/shared/widgets/tooltip/HTMLTooltip.js
@@ -53,24 +53,31 @@ const EXTRA_BORDER = {
  *        Bounding rectangle for the anchor, relative to the tooltip document.
  * @param {DOMRect} viewportRect
  *        Bounding rectangle for the viewport. top/left can be different from 0 if some
  *        space should not be used by tooltips (for instance OS toolbars, taskbars etc.).
  * @param {Number} height
  *        Preferred height for the tooltip.
  * @param {String} pos
  *        Preferred position for the tooltip. Possible values: "top" or "bottom".
+ * @param {Number} offset
+ *        Offset between the top of the anchor and the tooltip.
  * @return {Object}
  *         - {Number} top: the top offset for the tooltip.
  *         - {Number} height: the height to use for the tooltip container.
  *         - {String} computedPosition: Can differ from the preferred position depending
  *           on the available height). "top" or "bottom"
  */
-const calculateVerticalPosition =
-function(anchorRect, viewportRect, height, pos, offset) {
+const calculateVerticalPosition = (
+  anchorRect,
+  viewportRect,
+  height,
+  pos,
+  offset
+) => {
   const {TOP, BOTTOM} = POSITION;
 
   let {top: anchorTop, height: anchorHeight} = anchorRect;
 
   // Translate to the available viewport space before calculating dimensions and position.
   anchorTop -= viewportRect.top;
 
   // Calculate available space for the tooltip.
@@ -332,23 +339,27 @@ HTMLTooltip.prototype = {
   },
 
   /**
    * Show the tooltip next to the provided anchor element. A preferred position
    * can be set. The event "shown" will be fired after the tooltip is displayed.
    *
    * @param {Element} anchor
    *        The reference element with which the tooltip should be aligned
-   * @param {Object}
-   *        - {String} position: optional, possible values: top|bottom
-   *          If layout permits, the tooltip will be displayed on top/bottom
-   *          of the anchor. If ommitted, the tooltip will be displayed where
-   *          more space is available.
-   *        - {Number} x: optional, horizontal offset between the anchor and the tooltip
-   *        - {Number} y: optional, vertical offset between the anchor and the tooltip
+   * @param {Object} options
+   *        Settings for positioning the tooltip.
+   * @param {String} options.position
+   *        Optional, possible values: top|bottom
+   *        If layout permits, the tooltip will be displayed on top/bottom
+   *        of the anchor. If omitted, the tooltip will be displayed where
+   *        more space is available.
+   * @param {Number} options.x
+   *        Optional, horizontal offset between the anchor and the tooltip.
+   * @param {Number} options.y
+   *        Optional, vertical offset between the anchor and the tooltip.
    */
   async show(anchor, {position, x = 0, y = 0} = {}) {
     // Get anchor geometry
     let anchorRect = getRelativeRect(anchor, this.doc);
     if (this.useXulWrapper) {
       anchorRect = this._convertToScreenRect(anchorRect);
     }
 
@@ -403,17 +414,17 @@ HTMLTooltip.prototype = {
     this.container.classList.add("tooltip-visible");
 
     // Keep a pointer on the focused element to refocus it when hiding the tooltip.
     this._focusedElement = this.doc.activeElement;
 
     this.doc.defaultView.clearTimeout(this.attachEventsTimer);
     this.attachEventsTimer = this.doc.defaultView.setTimeout(() => {
       this._maybeFocusTooltip();
-      // Updated the top window reference each time in case the host changes.
+      // Update the top window reference each time in case the host changes.
       this.topWindow = this._getTopWindow();
       this.topWindow.addEventListener("click", this._onClick, true);
       this.emit("shown");
     }, 0);
   },
 
   /**
    * Calculate the rect of the viewport that limits the tooltip dimensions. When using a