Changeset 226796 in webkit


Ignore:
Timestamp:
Jan 11, 2018 12:29:25 PM (6 years ago)
Author:
graouts@webkit.org
Message:

Only listen to webkitplaybacktargetavailabilitychanged when media controls are visible to the user
https://bugs.webkit.org/show_bug.cgi?id=181547
<rdar://problem/35947650>

Reviewed by Eric Carlson.

Source/WebCore:

Because listening to "webkitplaybacktargetavailabilitychanged" events incurs some higher power usage on iOS,
we only listen to such events when controls are visible to the user. In other words, the MediaControls need to
have both "visible" set to "true" and "faded" set to "false". To support this, we add a delegate method on
MediaControls such that it can tell the MediaController that the "visible" property changed. With this message,
MediaController can inform its MediaControllerSupport objects that user visibility of the controls changed, which
lets AirplaySupport disable itself when controls are no longer visible.

Test: media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-with-hidden-controls.html

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

(MediaControls.prototype.set visible):

  • Modules/modern-media-controls/media/airplay-support.js:

(AirplaySupport.prototype.controlsUserVisibilityDidChange):

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

(MediaControllerSupport.prototype.controlsUserVisibilityDidChange):

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

(MediaController.prototype.mediaControlsVisibilityDidChange):
(MediaController.prototype.mediaControlsFadedStateDidChange):
(MediaController.prototype._controlsUserVisibilityDidChange):

LayoutTests:

Add a test that checks that enabling AirPlay routes when the controls are not visible to the user
does not incur any change, and that making the controls visible again shows the controls in the
expected state.

  • media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-with-hidden-controls-expected.txt: Added.
  • media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-with-hidden-controls.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r226795 r226796  
     12018-01-11  Antoine Quint  <graouts@apple.com>
     2
     3        Only listen to webkitplaybacktargetavailabilitychanged when media controls are visible to the user
     4        https://bugs.webkit.org/show_bug.cgi?id=181547
     5        <rdar://problem/35947650>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Add a test that checks that enabling AirPlay routes when the controls are not visible to the user
     10        does not incur any change, and that making the controls visible again shows the controls in the
     11        expected state.
     12
     13        * media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-with-hidden-controls-expected.txt: Added.
     14        * media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-with-hidden-controls.html: Added.
     15
    1162018-01-11  Antoine Quint  <graouts@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r226795 r226796  
     12018-01-11  Antoine Quint  <graouts@apple.com>
     2
     3        Only listen to webkitplaybacktargetavailabilitychanged when media controls are visible to the user
     4        https://bugs.webkit.org/show_bug.cgi?id=181547
     5        <rdar://problem/35947650>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Because listening to "webkitplaybacktargetavailabilitychanged" events incurs some higher power usage on iOS,
     10        we only listen to such events when controls are visible to the user. In other words, the MediaControls need to
     11        have both "visible" set to "true" and "faded" set to "false". To support this, we add a delegate method on
     12        MediaControls such that it can tell the MediaController that the "visible" property changed. With this message,
     13        MediaController can inform its MediaControllerSupport objects that user visibility of the controls changed, which
     14        lets AirplaySupport disable itself when controls are no longer visible.
     15
     16        Test: media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-with-hidden-controls.html
     17
     18        * Modules/modern-media-controls/controls/media-controls.js:
     19        (MediaControls.prototype.set visible):
     20        * Modules/modern-media-controls/media/airplay-support.js:
     21        (AirplaySupport.prototype.controlsUserVisibilityDidChange):
     22        * Modules/modern-media-controls/media/media-controller-support.js:
     23        (MediaControllerSupport.prototype.controlsUserVisibilityDidChange):
     24        * Modules/modern-media-controls/media/media-controller.js:
     25        (MediaController.prototype.mediaControlsVisibilityDidChange):
     26        (MediaController.prototype.mediaControlsFadedStateDidChange):
     27        (MediaController.prototype._controlsUserVisibilityDidChange):
     28
    1292018-01-11  Antoine Quint  <graouts@apple.com>
    230
  • trunk/Source/WebCore/Modules/modern-media-controls/controls/media-controls.js

    r219552 r226796  
    8787        if (flag)
    8888            this.layout();
     89
     90        if (this.delegate && typeof this.delegate.mediaControlsVisibilityDidChange === "function")
     91            this.delegate.mediaControlsVisibilityDidChange();
    8992    }
    9093
  • trunk/Source/WebCore/Modules/modern-media-controls/media/airplay-support.js

    r218891 r226796  
    4444    }
    4545
     46    controlsUserVisibilityDidChange()
     47    {
     48        const controls = this.mediaController.controls;
     49        if (controls.visible && !controls.faded)
     50            this.enable();
     51        else
     52            this.disable();
     53    }
     54
    4655    handleEvent(event)
    4756    {
  • trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js

    r225279 r226796  
    9191    }
    9292
     93    controlsUserVisibilityDidChange()
     94    {
     95        // Implement by subclasses.
     96    }
     97
    9398    handleEvent(event)
    9499    {
  • trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js

    r226795 r226796  
    125125    }
    126126
     127    mediaControlsVisibilityDidChange()
     128    {
     129        this._controlsUserVisibilityDidChange();
     130    }
     131
    127132    mediaControlsFadedStateDidChange()
    128133    {
     134        this._controlsUserVisibilityDidChange();
    129135        this._updateTextTracksClassList();
    130136    }
     
    287293    }
    288294
     295    _controlsUserVisibilityDidChange()
     296    {
     297        if (!this.controls || !this._supportingObjects)
     298            return;
     299
     300        this._supportingObjects.forEach(supportingObject => supportingObject.controlsUserVisibilityDidChange());
     301    }
     302
    289303    _updateiOSFullscreenProperties()
    290304    {
Note: See TracChangeset for help on using the changeset viewer.