Changeset 209291 in webkit


Ignore:
Timestamp:
Dec 2, 2016 6:40:30 PM (7 years ago)
Author:
graouts@webkit.org
Message:

[Modern Media Controls] Update the media controls size as the media element is resized
https://bugs.webkit.org/show_bug.cgi?id=165346

Reviewed by Dean Jackson.

The "resize" event dispatched by HTMLMediaElement indicates a change in the media's
intrinsic size, while the "resize" event dispatched by the HTMLMediaElement's ShadowRoot
indicates that the layout size of the media element has changed. We now use the latter.

  • Modules/modern-media-controls/media/media-controller.js:

(MediaController):
(MediaController.prototype.handleEvent):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r209290 r209291  
     12016-12-02  Antoine Quint  <graouts@apple.com>
     2
     3        [Modern Media Controls] Update the media controls size as the media element is resized
     4        https://bugs.webkit.org/show_bug.cgi?id=165346
     5
     6        Reviewed by Dean Jackson.
     7
     8        Write an accurate test to check for media controls updating their size to match the
     9        media's layout size and no longer mark that test as flaky.
     10
     11        * TestExpectations:
     12        * media/modern-media-controls/media-controller/media-controller-resize-expected.txt:
     13        * media/modern-media-controls/media-controller/media-controller-resize.html:
     14        * platform/ios-simulator/TestExpectations:
     15
    1162016-12-02  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/LayoutTests/TestExpectations

    r209286 r209291  
    972972imported/blink/http/tests/security/shape-image-cors-port.html [ ImageOnlyFailure ]
    973973
    974 webkit.org/b/163636 media/modern-media-controls/media-controller/media-controller-resize.html [ Pass Failure Timeout ]
    975 
    976974webkit.org/b/163887 svg/as-image/svg-image-with-data-uri-use-data-uri.svg [ Pass Crash ]
    977975
  • trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-resize-expected.txt

    r207436 r209291  
    55
    66Checking initial size
    7 PASS mediaController.controls.width is 320
    8 PASS mediaController.controls.height is 240
     7PASS mediaControls.style.width is "320px"
     8PASS mediaControls.style.height is "240px"
    99
    1010Resizing to 400x300
    11 PASS mediaController.controls.width is 400
    12 PASS mediaController.controls.height is 300
     11
     12Shadow root received a resize event
     13PASS mediaControls.style.width is "400px"
     14PASS mediaControls.style.height is "300px"
    1315
    1416PASS successfullyParsed is true
  • trunk/LayoutTests/media/modern-media-controls/media-controller/media-controller-resize.html

    r208226 r209291  
     1<!DOCTYPE html><!-- webkit-test-runner [ enableModernMediaControls=true ] -->
    12<script src="../../../resources/js-test-pre.js"></script>
    2 <script src="../resources/media-controls-loader.js" type="text/javascript"></script>
    33<body>
    4 <video src="../../content/test.mp4" style="width: 320px; height: 240px;"></video>
    5 <div id="shadow"></div>
     4<video src="../../content/test.mp4" style="width: 320px; height: 240px;" controls></video>
    65<script type="text/javascript">
    76
     
    109description("Testing the <code>MediaController</code> resizing behavior.");
    1110
    12 const shadowRoot = document.querySelector("div#shadow").attachShadow({ mode: "open" });
    1311const media = document.querySelector("video");
    14 const mediaController = createControls(shadowRoot, media, null);
     12const shadowRoot = window.internals.shadowRoot(media);
     13const mediaControls = shadowRoot.lastChild;
    1514
    16 let numberOfFrames = 0;
    17 scheduler.frameDidFire = function()
    18 {
    19     numberOfFrames++;
     15debug("Checking initial size");
     16shouldBeEqualToString("mediaControls.style.width", "320px");
     17shouldBeEqualToString("mediaControls.style.height", "240px");
    2018
    21     if (numberOfFrames == 1) {
    22         debug("Checking initial size");
    23         shouldBe("mediaController.controls.width", "320");
    24         shouldBe("mediaController.controls.height", "240");
    25        
    26         debug("");
    27         debug("Resizing to 400x300");
    28         media.style.width = "400px";
    29         media.style.height = "300px";
    30     } else {
    31         shouldBe("mediaController.controls.width", "400");
    32         shouldBe("mediaController.controls.height", "300");
     19window.requestAnimationFrame(() => {
     20    shadowRoot.addEventListener("resize", () => {
     21        window.requestAnimationFrame(() => {
     22            debug("");
     23            debug("Shadow root received a resize event");
     24            shouldBeEqualToString("mediaControls.style.width", "400px");
     25            shouldBeEqualToString("mediaControls.style.height", "300px");
    3326
    34         debug("");
    35         shadowRoot.host.remove();
    36         media.remove();
    37         finishJSTest();
    38     }
    39 };
     27            debug("");
     28            media.remove();
     29            finishJSTest();
     30        });
     31    });
     32
     33    debug("");
     34    debug("Resizing to 400x300");
     35    media.style.width = "400px";
     36    media.style.height = "300px";
     37});
    4038
    4139</script>
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r209271 r209291  
    27592759media/modern-media-controls/tracks-panel
    27602760
     2761# We don't enable media controls on iOS yet and this test requires them
     2762webkit.org/b/165353 media/modern-media-controls/media-controller/media-controller-resize.html [ Skip ]
     2763
    27612764webkit.org/b/164594 http/tests/cache/disk-cache/disk-cache-request-headers.html [ Pass Timeout ]
    27622765
  • trunk/Source/WebCore/ChangeLog

    r209288 r209291  
     12016-12-02  Antoine Quint  <graouts@apple.com>
     2
     3        [Modern Media Controls] Update the media controls size as the media element is resized
     4        https://bugs.webkit.org/show_bug.cgi?id=165346
     5
     6        Reviewed by Dean Jackson.
     7
     8        The "resize" event dispatched by HTMLMediaElement indicates a change in the media's
     9        intrinsic size, while the "resize" event dispatched by the HTMLMediaElement's ShadowRoot
     10        indicates that the layout size of the media element has changed. We now use the latter.
     11
     12        * Modules/modern-media-controls/media/media-controller.js:
     13        (MediaController):
     14        (MediaController.prototype.handleEvent):
     15
    1162016-12-02  Andy Estes  <aestes@apple.com>
    217
  • trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js

    r209271 r209291  
    4040        this._updateControlsIfNeeded();
    4141
    42         media.addEventListener("resize", this);
     42        shadowRoot.addEventListener("resize", this);
    4343
    4444        media.addEventListener("webkitfullscreenchange", this);
     
    6767    handleEvent(event)
    6868    {
    69         if (event.currentTarget !== this.media)
     69        if (event.type === "resize" && event.currentTarget === this.shadowRoot)
     70            this._updateControlsSize();
     71        else if (event.currentTarget !== this.media)
    7072            return;
    71 
    72         switch (event.type) {
    73         case "resize":
    74             this._updateControlsSize();
    75             break;
    76         case "webkitfullscreenchange":
     73        else if (event.type === "webkitfullscreenchange")
    7774            this._updateControlsIfNeeded();
    78             break;
    79         case "webkitpresentationmodechanged":
     75        else if (event.type === "webkitpresentationmodechanged")
    8076            this._returnMediaLayerToInlineIfNeeded();
    81             break;
    82         }
    8377    }
    8478
Note: See TracChangeset for help on using the changeset viewer.