Bug 1536762 - part1 : use unscaled bounding box'size as a cue box's size. r=baku,heycam
authoralwu <alwu@mozilla.com>
Thu, 09 May 2019 18:26:17 +0000
changeset 532129 2d810269b72e198765af3d997f3b117d832afd38
parent 532128 e28c51cc8100164c7817a8516b110af91d5b8da7
child 532130 1fa720d18b38e35831de185ac2f55356c88a7d21
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, heycam
bugs1536762
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 1536762 - part1 : use unscaled bounding box'size as a cue box's size. r=baku,heycam When adjusting cue's position, the goal is to place cue boxes fully inside the rendering area, and place in the right place. In order to check whether the box is correctly inside the rendering area, we have to know the correct size of the cue box. Therefore, we implement the new chrome-only APIs to acquire this information (box's height and width), and this returned value won't be affected by CSS transformation, which is good for positioning. Differential Revision: https://phabricator.services.mozilla.com/D27178
dom/base/Element.h
dom/media/webvtt/vtt.jsm
dom/webidl/Element.webidl
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1295,16 +1295,26 @@ class Element : public FragmentOrElement
   }
   MOZ_CAN_RUN_SCRIPT int32_t ScrollLeftMax() {
     nsIScrollableFrame* sf = GetScrollFrame();
     return sf ? nsPresContext::AppUnitsToIntCSSPixels(
                     sf->GetScrollRange().XMost())
               : 0;
   }
 
+  MOZ_CAN_RUN_SCRIPT double ClientHeightDouble() {
+    return nsPresContext::AppUnitsToDoubleCSSPixels(
+        GetClientAreaRect().Height());
+  }
+
+  MOZ_CAN_RUN_SCRIPT double ClientWidthDouble() {
+    return nsPresContext::AppUnitsToDoubleCSSPixels(
+        GetClientAreaRect().Width());
+  }
+
   already_AddRefed<Flex> GetAsFlexContainer();
   void GetGridFragments(nsTArray<RefPtr<Grid>>& aResult);
 
   already_AddRefed<DOMMatrixReadOnly> GetTransformToAncestor(
       Element& aAncestor);
   already_AddRefed<DOMMatrixReadOnly> GetTransformToParent();
   already_AddRefed<DOMMatrixReadOnly> GetTransformToViewport();
 
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -543,19 +543,19 @@ XPCOMUtils.defineLazyPreferenceGetter(th
       // number according to the container's size.
       const isWritingDirectionHorizontal = this.cue.vertical == "";
       let top =
             this.containerHeight * this._tranferPercentageToFloat(this.div.style.top),
           left =
             this.containerWidth * this._tranferPercentageToFloat(this.div.style.left),
           width = isWritingDirectionHorizontal ?
             this.containerWidth * this._tranferPercentageToFloat(this.div.style.width) :
-            this.div.offsetWidth,
+            this.div.clientWidthDouble,
           height = isWritingDirectionHorizontal ?
-            this.div.offsetHeight :
+            this.div.clientHeightDouble :
             this.containerHeight * this._tranferPercentageToFloat(this.div.style.height);
       return { top, left, width, height };
     }
 
     /**
      * Following methods are private functions, should not use them outside this
      * class.
      */
--- a/dom/webidl/Element.webidl
+++ b/dom/webidl/Element.webidl
@@ -308,8 +308,18 @@ partial interface Element {
   /**
    * Returns a sequence of all the descendent elements of this element
    * that have display:grid or display:inline-grid style and generate
    * a frame.
    */
   [ChromeOnly, Pure]
   sequence<Element> getElementsWithGrid();
 };
+
+// These variables are used in vtt.js, they are used for positioning vtt cues.
+partial interface Element {
+  // These two attributes are a double version of the clientHeight and the
+  // clientWidth.
+  [ChromeOnly]
+  readonly attribute double clientHeightDouble;
+  [ChromeOnly]
+  readonly attribute double clientWidthDouble;
+};