Bug 1488673 - part6 : remove unused functions. r=heycam
authorAlastor Wu <alwu@mozilla.com>
Tue, 19 Mar 2019 03:30:32 +0000
changeset 464986 3f6a9b725f218a15e79d87f4106b6ac20a1182ef
parent 464985 a1841a4aa3f1188b9ecd9666dcbdab58e1258778
child 464987 5934ef641056cd6a40f4fb487f430de3e1d6ff0e
push id112486
push useropoprus@mozilla.com
push dateTue, 19 Mar 2019 16:41:04 +0000
treeherdermozilla-inbound@ee866fb50236 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1488673
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488673 - part6 : remove unused functions. r=heycam Remove those funcitons which are used to implement the previous way to move the cue box. Differential Revision: https://phabricator.services.mozilla.com/D19610
dom/media/webvtt/vtt.jsm
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -547,27 +547,16 @@ XPCOMUtils.defineLazyPreferenceGetter(th
             this.containerWidth * this._tranferPercentageToFloat(this.div.style.width) :
             this.div.offsetWidth,
           height = isWritingDirectionHorizontal ?
             this.div.offsetHeight :
             this.containerHeight * this._tranferPercentageToFloat(this.div.style.height);
       return { top, left, width, height };
     }
 
-    move(box) {
-      this.applyStyles({
-        top: this.formatStyle(box.top, "px"),
-        bottom: this.formatStyle(box.bottom, "px"),
-        left: this.formatStyle(box.left, "px"),
-        right: this.formatStyle(box.right, "px"),
-        height: this.formatStyle(box.height, "px"),
-        width: this.formatStyle(box.width, "px")
-      });
-    }
-
     /**
      * Following methods are private functions, should not use them outside this
      * class.
      */
     _tranferPercentageToFloat(input) {
       return input.replace("%", "") / 100.0;
     }
 
@@ -876,31 +865,16 @@ XPCOMUtils.defineLazyPreferenceGetter(th
     // Find the percentage of the area that this box is overlapping with another
     // box.
     intersectPercentage(b2) {
       let x = Math.max(0, Math.min(this.right, b2.right) - Math.max(this.left, b2.left)),
           y = Math.max(0, Math.min(this.bottom, b2.bottom) - Math.max(this.top, b2.top)),
           intersectArea = x * y;
       return intersectArea / (this.height * this.width);
     }
-
-    // Convert the positions from this box to CSS compatible positions using
-    // the reference container's positions. This has to be done because this
-    // box's positions are in reference to the viewport origin, whereas, CSS
-    // values are in referecne to their respective edges.
-    toCSSCompatValues(reference) {
-      return {
-        top: this.top - reference.top,
-        bottom: reference.bottom - this.bottom,
-        left: this.left - reference.left,
-        right: reference.right - this.right,
-        height: this.height,
-        width: this.width
-      };
-    }
   }
 
   BoxPosition.prototype.clone = function(){
     return new BoxPosition(this);
   };
 
   function adjustBoxPosition(styleBox, containerBox, controlBarBox, outputBoxes) {
     const cue = styleBox.cue;
@@ -1053,150 +1027,16 @@ XPCOMUtils.defineLazyPreferenceGetter(th
     // cue can stick in the right position.
     function getPercentagePosition(position, fullDimension) {
       return (position / fullDimension) * 100 + "%";
     }
 
     return box;
   }
 
-  // Move a StyleBox to its specified, or next best, position. The containerBox
-  // is the box that contains the StyleBox, such as a div. boxPositions are
-  // a list of other boxes that the styleBox can't overlap with.
-  function moveBoxToLinePosition(window, styleBox, containerBox, boxPositions) {
-
-    // Find the best position for a cue box, b, on the video. The axis parameter
-    // is a list of axis, the order of which, it will move the box along. For example:
-    // Passing ["+x", "-x"] will move the box first along the x axis in the positive
-    // direction. If it doesn't find a good position for it there it will then move
-    // it along the x axis in the negative direction.
-    function findBestPosition(b, axis) {
-      var bestPosition,
-          specifiedPosition = new BoxPosition(b),
-          percentage = 1; // Highest possible so the first thing we get is better.
-
-      for (var i = 0; i < axis.length; i++) {
-        while (b.overlapsOppositeAxis(containerBox, axis[i]) ||
-               (b.within(containerBox) && b.overlapsAny(boxPositions))) {
-          b.move(axis[i]);
-        }
-        // We found a spot where we aren't overlapping anything. This is our
-        // best position.
-        if (b.within(containerBox)) {
-          return b;
-        }
-        var p = b.intersectPercentage(containerBox);
-        // If we're outside the container box less then we were on our last try
-        // then remember this position as the best position.
-        if (percentage > p) {
-          bestPosition = new BoxPosition(b);
-          percentage = p;
-        }
-        // Reset the box position to the specified position.
-        b = new BoxPosition(specifiedPosition);
-      }
-      return bestPosition || specifiedPosition;
-    }
-
-    var boxPosition = new BoxPosition(styleBox),
-        cue = styleBox.cue,
-        linePos = cue.computedLine,
-        axis = [];
-
-    // If we have a line number to align the cue to.
-    if (cue.snapToLines) {
-      var size;
-      switch (cue.vertical) {
-      case "":
-        axis = [ "+y", "-y" ];
-        size = "height";
-        break;
-      case "rl":
-        axis = [ "+x", "-x" ];
-        size = "width";
-        break;
-      case "lr":
-        axis = [ "-x", "+x" ];
-        size = "width";
-        break;
-      }
-
-      var step = boxPosition.lineHeight,
-          position = step * Math.round(linePos),
-          maxPosition = containerBox[size] + step,
-          initialAxis = axis[0];
-
-      if (step == 0) {
-        return;
-      }
-
-      // If the specified intial position is greater then the max position then
-      // clamp the box to the amount of steps it would take for the box to
-      // reach the max position.
-      if (Math.abs(position) > maxPosition) {
-        position = position < 0 ? -1 : 1;
-        position *= Math.ceil(maxPosition / step) * step;
-      }
-
-      // If computed line position returns negative then line numbers are
-      // relative to the bottom of the video instead of the top. Therefore, we
-      // need to increase our initial position by the length or width of the
-      // video, depending on the writing direction, and reverse our axis directions.
-      if (linePos < 0) {
-        position += cue.vertical === "" ? containerBox.height : containerBox.width;
-        axis = axis.reverse();
-      }
-
-      // Move the box to the specified position. This may not be its best
-      // position.
-      boxPosition.move(initialAxis, position);
-
-    } else {
-      // If we have a percentage line value for the cue.
-      var calculatedPercentage = (boxPosition.lineHeight / containerBox.height) * 100;
-
-      switch (cue.lineAlign) {
-      case "center":
-        linePos -= (calculatedPercentage / 2);
-        break;
-      case "end":
-        linePos -= calculatedPercentage;
-        break;
-      }
-
-      // Apply initial line position to the cue box.
-      switch (cue.vertical) {
-      case "":
-        styleBox.applyStyles({
-          top: styleBox.formatStyle(linePos, "%")
-        });
-        break;
-      case "rl":
-        styleBox.applyStyles({
-          left: styleBox.formatStyle(linePos, "%")
-        });
-        break;
-      case "lr":
-        styleBox.applyStyles({
-          right: styleBox.formatStyle(linePos, "%")
-        });
-        break;
-      }
-
-      axis = [ "+y", "-x", "+x", "-y" ];
-
-      // Get the box position again after we've applied the specified positioning
-      // to it.
-      boxPosition = new BoxPosition(styleBox);
-    }
-
-    var bestPosition = findBestPosition(boxPosition, axis);
-    styleBox.move(bestPosition.toCSSCompatValues(containerBox));
-  }
-
   function WebVTT() {
     // Nothing
   }
 
   // Helper to allow strings to be decoded instead of the default binary utf8 data.
   WebVTT.StringDecoder = function() {
     return {
       decode: function(data) {