Bug 1571908 - part2 : return null if we can't place the cue box inside the video rendering area. r=heycam
authorAlastor Wu <alwu@mozilla.com>
Wed, 21 Aug 2019 07:10:25 +0000
changeset 489129 151d5da82d2e3c1843e9e793556891f305ccda85
parent 489128 3d4dda3a5f347193a8c277adc83bf4d153036fd1
child 489130 d98a9a24c1708016cd84faa1a47979c94c655e91
push id36465
push userdvarga@mozilla.com
push dateWed, 21 Aug 2019 16:47:43 +0000
treeherdermozilla-central@4ab60925635c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1571908
milestone70.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 1571908 - part2 : return null if we can't place the cue box inside the video rendering area. r=heycam When adjusting the position of the cue box, if we can't find a proper place to display the cue within the video rendering area, we should return `null` and not to show it on the screen. Differential Revision: https://phabricator.services.mozilla.com/D40901
dom/media/webvtt/vtt.jsm
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -1060,16 +1060,21 @@ XPCOMUtils.defineLazyPreferenceGetter(th
         if (outsideAreaPercentage > p) {
           bestPosition = box.clone();
           outsideAreaPercentage = p;
         }
         // Reset the box position to the specified position.
         box = specifiedPosition.clone();
       }
 
+      // Can not find a place to place this box inside the rendering area.
+      if (!box.within(containerBox)) {
+        return null;
+      }
+
       styleBox.applyStyles({
         top: getPercentagePosition(box.top, containerBox.height),
         left: getPercentagePosition(box.left, containerBox.width),
       });
     }
 
     // In order to not be affected by CSS scale, so we use '%' to make sure the
     // cue can stick in the right position.