Commit graph

1354 commits

Author SHA1 Message Date
alwu
565588e2f8 Bug 1655204 - part3 : start listening to media control keys once media starts again. r=chunmin
For media which has been stopped via media key `Stop`, we should start controlling it if it starts playing again.

Differential Revision: https://phabricator.services.mozilla.com/D85102
2020-07-29 22:15:54 +00:00
alwu
1ba14f3e89 Bug 1655204 - part1 : stop being controlled by media control keys when media element receives Stop. r=chunmin
Currently, we treat `pause` and `stop` equally, but `stop` is actully implying more meaning, which should stop controlling media entirely. Therefore, we would pause media and stop controlling it when receiving `stop`.

In addition, removing pause state checking, because it wouldn't happen anything to call `play()` and `pause()` if media is already playing or paused.

Differential Revision: https://phabricator.services.mozilla.com/D84875
2020-07-29 22:15:50 +00:00
emcminn
e256431464 Bug 1655765 - Add media permission for about:welcome privacy page mp4 r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D85192
2020-07-29 08:27:34 +00:00
alwu
0c452b17db Bug 1655175 - avoid to access owner media element after unlink. r=bryce
`mElement` would be reset during CC unlink [1], so we should avoid to access it after unlink happens.

[1] https://searchfox.org/mozilla-central/rev/828f2319c0195d7f561ed35533aef6fe183e68e3/dom/html/HTMLMediaElement.cpp#2027

Differential Revision: https://phabricator.services.mozilla.com/D84890
2020-07-27 19:37:04 +00:00
Emilio Cobos Álvarez
05bbb6ac23 Bug 1652618 - Ensure UA widgets are attached and detached synchronously. r=smaug
This changes the UA widget setup (again). What is going on in this
test-case is that we have a marquee inside a video, two things that have
their own UA widget. Given how the code is currently written, the
runnable to attach and set up the marquee's widget is posted before than
the video one (which is potentially reasonable).

However that means that the marquee one runs before and flushes layout,
and catches the video in an inconsistent state (in the composed doc, but
without a shadow root). That in turn messes up reflow because
nsVideoFrame assumes stuff.

Rather than putting the attach / detach logic in script runners, just
run that bit synchronously, and post only the event async. I audited the
consumers of those events and it seems fine to me, they either already
deal with the possibility of the shadow root being already detached or
they don't care.

For teardown, none of the destructors of the UA widgets rely on the
shadow root being still attached to the element.

Differential Revision: https://phabricator.services.mozilla.com/D84487
2020-07-24 15:43:20 +00:00
alwu
08c44f91ba Bug 1654959 - part2 : start listener when media enters PIP mode. r=bryce
When a media enters PIP mode, we should consider it as an important one which user might want to control. Therefore, start the listener in order to notify the media has been started, then we would update the PIP state [1] which would activate the controller.

As the PIP state changes can happen after `Stop()` is called, so in this patch, we would remove the start check and reset `mControlAgent` in `Stop()` in order to update PIP state after the listener stops. Eg. Reset the PIP video's src, then cancel the PIP.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/html/HTMLMediaElement.cpp#7902

Differential Revision: https://phabricator.services.mozilla.com/D84119
2020-07-24 02:43:25 +00:00
alwu
f54871ea84 Bug 1654959 - part1 : start listener when media enters fullscreen. r=bryce
When a media enters fullscreen mode, we should consider it as an important one which user might want to control. Therefore, start the listener in order to notify the media has been started, then we would update the fullscreen state [1] which would activate the controller.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/base/Document.cpp#13429

Differential Revision: https://phabricator.services.mozilla.com/D84118
2020-07-24 02:43:33 +00:00
alwu
36a2ad0e05 Bug 1653390 - part6 : add audible check back in media element. r=bryce
In D73335, we remove those check which causes a regression where inaudible media is also able to be controlled by media control keys.

In order not to control those inaudible media, we should add the check back. If the media is inaudible, then we should not start the listener that would connect media element to the media control.

In addition, I also found that starting the listener for inaudible media would make the media controller's playback state incorrect, because the playback state is calculated by all controlled media. If an inaudible media is playing, the playback state should not consider that media.

Differential Revision: https://phabricator.services.mozilla.com/D84115
2020-07-24 02:43:33 +00:00
alwu
8e044f4e3a Bug 1653390 - part5 : remove 'StopListeningMediaControlKeyIfNeeded()'. r=bryce
First, rename `Stop()` to `StopIfNeeded()`.

Second, we have already have a check [1] in `StopIfNeeded()` to ensure that that function is only workable when the listener starts, so we don't need `StopListeningMediaControlKeyIfNeeded()` and can call `StopIfNeeded()` directly.

[1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/html/HTMLMediaElement.cpp#425-427

Differential Revision: https://phabricator.services.mozilla.com/D84117
2020-07-23 21:33:31 +00:00
alwu
ba2335182a Bug 1653390 - part4 : always hold a MediaControlKeyListener until media dies. r=bryce
It seems no much benefit to create `MediaControlKeyListener` lazily, we should create it in the start and destroy it in the end so that we don't need to check if `mMediaControlKeyListener` exists or not when we want to check if the listener starts.

Differential Revision: https://phabricator.services.mozilla.com/D84116
2020-07-23 21:33:23 +00:00
alwu
019c658238 Bug 1653390 - part3 : wrap the detail of updating playback state into Start(). r=bryce
`NotifyMediaControlPlaybackStateChanged()` would be called when `mPaused` changes, but it would only take effect after the listener starts. If the media changes its `mPaused` before we starts listener, then we have to manully update `NotifyMediaControlPlaybackStateChanged()`.

However, I think wrapping this detail into `Start()` itself would be clearer.

Differential Revision: https://phabricator.services.mozilla.com/D84649
2020-07-23 21:32:58 +00:00
alwu
dd84046a02 Bug 1653390 - part2: allow calling 'UpdateMediaAudibleState()' before the listener starts. r=bryce
We already have a check to prevent notifying audible state before the listener starts [1], so we can remove the assertion and call it anytime in order to save the audible state correctly.

[1] https://searchfox.org/mozilla-central/rev/dcd9c2d2bc19d96d487825eb70c2333a4d60994e/dom/html/HTMLMediaElement.cpp#478-486

Differential Revision: https://phabricator.services.mozilla.com/D84650
2020-07-23 21:32:51 +00:00
alwu
07110d9029 Bug 1653390 - part1 : remove start check. r=bryce
The reason of checking those conditions before calling `StartListeningMediaControlKeyIfNeeded()` is because we was only starting the listener after media starts, which has been modified in D79234.  Now we would start the listener before media starts, so we can remove that check.

Differential Revision: https://phabricator.services.mozilla.com/D84114
2020-07-23 21:32:43 +00:00
Narcis Beleuzu
ce05a24710 Backed out changeset 8323b7bb5e1a (bug 1652618) for mochitest failures on test_audiocontrols_dimensions.html . CLOSED TREE 2020-07-23 00:49:31 +03:00
Emilio Cobos Álvarez
312039fb70 Bug 1652618 - Ensure UA widgets are attached and detached synchronously. r=smaug
This changes the UA widget setup (again). What is going on in this
test-case is that we have a marquee inside a video, two things that have
their own UA widget. Given how the code is currently written, the
runnable to attach and set up the marquee's widget is posted before than
the video one (which is potentially reasonable).

However that means that the marquee one runs before and flushes layout,
and catches the video in an inconsistent state (in the composed doc, but
without a shadow root). That in turn messes up reflow because
nsVideoFrame assumes stuff.

Rather than putting the attach / detach logic in script runners, just
run that bit synchronously, and post only the event async. I audited the
consumers of those events and it seems fine to me, they either already
deal with the possibility of the shadow root being already detached or
they don't care.

For teardown, none of the destructors of the UA widgets rely on the
shadow root being still attached to the element.

Differential Revision: https://phabricator.services.mozilla.com/D84487
2020-07-22 19:42:37 +00:00
Sebastian Streich
cffa889f0e Bug 1653563 - Remove nullptr usage in HTMLMediaElement.cpp r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D84538
2020-07-22 16:46:41 +00:00
alwu
6879e655b6 Bug 1647430 - part3 : remove DocTreeHadPlayRevoked related variable and method. r=nika
The telemetry probe, which is related with `mDocTreeHadPlayRevoked`, has already been removed, so we don't need these code anymore.

Differential Revision: https://phabricator.services.mozilla.com/D83163
2020-07-13 15:16:29 +00:00
Sebastian Streich
af8c105fc0 Bug 1450853 - Use Generic Error for 3rdparty MediaElement r=ckerschb,smaug
***
Add test

Differential Revision: https://phabricator.services.mozilla.com/D80080
2020-07-16 12:03:38 +00:00
Frederik Braun
a7153982e8 Bug 1366973: Rename security flags to not contain DATA anymore r=geckoview-reviewers,ckerschb,snorp
Differential Revision: https://phabricator.services.mozilla.com/D83490
2020-07-15 11:20:45 +00:00
alwu
13f51dbfcd Bug 1652460 - part1 : always store the audible state change. r=bryce
Whenever the audible state changes, we should always store the latest state but only notify the change after playing starts.

Differential Revision: https://phabricator.services.mozilla.com/D83549
2020-07-14 22:01:43 +00:00
Razvan Maries
b434fc9008 Backed out changeset 6b518e88bdf9 (bug 1450853) for perma failures on empty-samples.webm. CLOSED TREE 2020-07-14 15:26:22 +03:00
Sebastian Streich
9a66f3e9e3 Bug 1450853 - Use Generic Error for 3rdparty MediaElement r=ckerschb,smaug
***
Add test

Differential Revision: https://phabricator.services.mozilla.com/D80080
2020-07-14 11:16:24 +00:00
Alex Chronopoulos
d4383d4b9d Bug 1651049 - Move the sink change logic in MediaStreamRenderer. r=padenot
The MediaStreamRenderer handles the AudioOutput of an HTMLMediaElement. it register/unregister the AudioOutput according to the rendering status. The sink-change follows the logic of AudioOutput thus it has been moved in it.

The previous way created an error when the element had been muted and the sink had been changed before the source MediaStream was attached to the element. The error occured because it was possible, the same entry to be registered more than once in the AudioOutput's list, which resulted in the track to be unmuted when it should not.

Differential Revision: https://phabricator.services.mozilla.com/D82529
2020-07-09 14:32:21 +00:00
alwu
c3bc9434ee Bug 1647425 - part1 : dispatch chrome event to owner doc. r=kmag
We handle `GloballyAutoplayBlocked` event in `Autoplay` actors which exist in all frames [1], so we can actually dispatch the event directly from any document.

Then, we would find the correct top document in `AutoplayParentActor`[2].

[1] https://searchfox.org/mozilla-central/rev/5a4aaccb28665807a6fd49cf48367d47fbb5a19a/toolkit/modules/ActorManagerParent.jsm#118-130
[2] https://searchfox.org/mozilla-central/source/toolkit/actors/AutoplayParent.jsm#11-18

Differential Revision: https://phabricator.services.mozilla.com/D81764
2020-07-01 21:36:25 +00:00
Simon Giesecke
9364b353d4 Bug 1648010 - Remove NS_NAMED_LITERAL_CSTRING and NS_NAMED_LITERAL_STRING macros. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80631
2020-07-01 08:42:31 +00:00
Simon Giesecke
cd8b8939b9 Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
alwu
2d3813f487 Bug 1645668 - part1 : reset audible state when aborting current load. r=bryce
When aborting the current load, media element is undoubtedly inaudible. Therefore, we should reset its audible state in order to keep the audible state correct. That can help us show the sound indicator on the tab bar correctly.

Differential Revision: https://phabricator.services.mozilla.com/D81631
2020-06-30 16:50:35 +00:00
longsonr
ea442838d3 Bug 1648463 - Move SVGForeignObjectFrame SVGImageFrame and SVGUseFrame to mozilla namespace r=dholbert,jgilbert
stop exposing SVGImageListener as only SVGImageFrame uses it.

Differential Revision: https://phabricator.services.mozilla.com/D81087
2020-06-25 20:42:49 +00:00
Alex Chronopoulos
678687da84 Bug 1648159 - Remove unnecessary redirection of promises when sink changes. r=jya
At the end of `HTMLMediaElement::SetSrcMediaStreamSink` a redirection of MozPromises, from `GenericPromise::AllPromiseType` to `GenericPromise` is taking place. However, this is not necessary since this is an internal method and the returned value of the promise is not useful. Thus the `GenericPromise::AllPromiseType` can be returned directly and avoid the extra thread dispatch.

Differential Revision: https://phabricator.services.mozilla.com/D80908
2020-06-25 14:18:59 +00:00
alwu
84619e1b6b Bug 1642715 - part2 : connect media to media controller after knowing its duration. r=chunmin
This patch would
- build the relationship between a media element and the media controller when media finishes loading, instead of building that after starting playing media

The advantage of doing this is
- the prework of being able to control media before media starts playing

Differential Revision: https://phabricator.services.mozilla.com/D79234
2020-06-24 05:52:33 +00:00
alwu
305a14713f Bug 1642715 - part1 : move timer to media controller. r=chunmin
This patch would
- move the mechanism of creating a stop timer from media element to media controller

The advantage of doing this is
- to remove redundant timers in the content process, because we only need to maintain one global timer for a whole tab

Differential Revision: https://phabricator.services.mozilla.com/D79233
2020-06-24 05:52:30 +00:00
Jean-Yves Avenard
87438519f0 Bug 1637500 - P2. Rename methods as they are not always dealing with "threads". r=froydnj
Before P1, GetCurrentThreadSerialEventTarget would have always returned the same data as NS_GetCurrentThread, making the comment incorrect Now it will properly return the running TaskQueue if any.

This change of name more clearly exposes what they are doing, as we aren't always dealing with threads directly; but a nsISerialEventTarget

Differential Revision: https://phabricator.services.mozilla.com/D80354
2020-06-23 05:05:36 +00:00
alwu
6a60b27685 Bug 1642590 - part1 : run internal pause when unbind media from DOM tree. r=bryce
This patch will
- run internal pause when removing a media from a document, instead of running `pause()` method

The advantage of doing so is
- to follow the spec [1]. In step 3, it mentions we should run internal pause, not pause.

[1] https://html.spec.whatwg.org/#playing-the-media-resource:remove-an-element-from-a-document

Differential Revision: https://phabricator.services.mozilla.com/D79925
2020-06-22 20:54:21 +00:00
Alex Chronopoulos
4e982cf82c Bug 1493990 - Enable sink change in the srcObject of HTMLMediaElement. r=padenot
The SetSinkId method of HTMLMediaElement has been enhanced to handle the sink change when the element is sourced with a MediaObject through the srcObject attribute. It makes use in the corresponding method of AudioStreamTrack taking into account the AudioOutput and Volume that has to be removed and re-added to the right track.

Differential Revision: https://phabricator.services.mozilla.com/D77809
2020-06-18 14:05:28 +00:00
alwu
934302cd0d Bug 1640998 - part9 : use MediaControlKey to replace MediaControlKeysEvent r=chunmin,agi,geckoview-reviewers
This patch will
- remove `MediaControlKeysEvent` and use `MediaControlKey` to replace it
- rename names for all `MediaControlKey` related methods, functions, classes and descriptions

The advantage of doing so are
- remove the duplicated type so that we only need to maintain `MediaControlKey`

Differential Revision: https://phabricator.services.mozilla.com/D78140
2020-06-09 02:59:57 +00:00
alwu
cc64086a9c Bug 1640998 - part1 : make ContentMediaAgent inherit from IMediaInfoUpdater. r=chunmin
This patch will
- make `ContentMediaAgent` inherit from `IMediaInfoUpdater`
- move `MediaPlaybackState` and `MediaAudibleState` to `MediaPlaybackStatus.h`

The advantage of doing so are
- to force all methods which are related with updating information from content process to chrome process to be manged by `IMediaInfoUpdater`. It can help us only put the descriptive comment for methods on one place. (on `IMediaInfoUpdater`)

Differential Revision: https://phabricator.services.mozilla.com/D77196
2020-06-08 22:08:26 +00:00
Simon Giesecke
ebbc7ae838 Bug 1642989 - Use RemoveLastElements instead of RemoveElementsAt where possible. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D78049
2020-06-08 08:50:15 +00:00
Alex Chronopoulos
3e4dc03513 Bug 1636515 - Handle cycle in media element when it is fed with the captured stream. r=padenot
Feeding a media element with the captured stream from the same media element does not make sense. Currently the spec does not mention anything about it. I'll clarify the case in the spec. In the meantime, when a cycle is detected, the setting of the `srcObject` is ignored and a warning is produced in the console.

Differential Revision: https://phabricator.services.mozilla.com/D76821
2020-05-28 13:07:53 +00:00
alwu
386dc9b342 Bug 1627999 - part9 : handle the owner browsing context change for the media element. r=chunmin
This patch will do :
- update the media status when media changes its owner browsing context

The advantage of doing so :
- make the media status in `ContextMediaInfo` correcly

More details :
`ContextMediaInfo` stores the media status of each browsing context, but actually the media doesn't always need to stay in one browsing context. We can move it to other browsing contexts (iframe) by appending it to other browsing context's document body.
For example, in [1], we move the video from the main frame to another iframe.

Therefore, when we move the media to a new browsing context, we should also update its media status (controlledMedia/playing/audio number) for its previous owner browsing context.

[1] https://searchfox.org/mozilla-central/source/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html

Differential Revision: https://phabricator.services.mozilla.com/D75477
2020-05-16 00:26:20 +00:00
alwu
3c416fbc0a Bug 1627999 - part8 : remove audible check in media element. r=bryce
This patch will do :
- remove audible check from the logic of registering controller
- include audio channel affect on the media element's audible state

The advantage of doing so :
- it can help to reduce the intermittent failure during testing by earlier hooking media elements in the content process to the media controller in the chrome process

More details :
In D72497, we have added the audible check to postpone the activation of the media controller, which would ensure that we only control media after it become audible. Therefore, we can remove the previous implementation which we use to achieve that in media element.

When having that audible check in media element, it would postpone the timing of adding media element to `ContentMediaController` that causes some intermitent failures when I was writing test for bug1633565. When removing those checks, we can ensure that the media element would have always been added into `ContentMediaController` after calling `video.play()`. If the element haven't been added into `ContentMediaController`, then it would miss to handle the media key events when test generates a fake media key event, which causes an intermitent failure.

Differential Revision: https://phabricator.services.mozilla.com/D73335
2020-05-15 21:50:10 +00:00
Csoregi Natalia
b6df18cc7a Backed out 9 changesets (bug 1627999) for bustages on HTMLMediaElement.cpp. CLOSED TREE
Backed out changeset 05ba58699a1b (bug 1627999)
Backed out changeset b9025bab4036 (bug 1627999)
Backed out changeset 2e1c8f9e8f88 (bug 1627999)
Backed out changeset 55ac831f54f3 (bug 1627999)
Backed out changeset e0fa806a6942 (bug 1627999)
Backed out changeset f4d85f0b61d9 (bug 1627999)
Backed out changeset 84434656006c (bug 1627999)
Backed out changeset 021c014ba882 (bug 1627999)
Backed out changeset 76c6b64928e9 (bug 1627999)
2020-05-16 00:22:23 +03:00
alwu
e71fdbe9e6 Bug 1627999 - part9 : handle the owner browsing context change for the media element. r=chunmin
This patch will do :
- update the media status when media changes its owner browsing context

The advantage of doing so :
- make the media status in `ContextMediaInfo` correcly

More details :
`ContextMediaInfo` stores the media status of each browsing context, but actually the media doesn't always need to stay in one browsing context. We can move it to other browsing contexts (iframe) by appending it to other browsing context's document body.
For example, in [1], we move the video from the main frame to another iframe.

Therefore, when we move the media to a new browsing context, we should also update its media status (controlledMedia/playing/audio number) for its previous owner browsing context.

[1] https://searchfox.org/mozilla-central/source/testing/web-platform/tests/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html

Differential Revision: https://phabricator.services.mozilla.com/D75477
2020-05-15 21:00:45 +00:00
alwu
8c97b84395 Bug 1627999 - part8 : remove audible check in media element. r=bryce
This patch will do :
- remove audible check from the logic of registering controller
- include audio channel affect on the media element's audible state

The advantage of doing so :
- it can help to reduce the intermittent failure during testing by earlier hooking media elements in the content process to the media controller in the chrome process

More details :
In D72497, we have added the audible check to postpone the activation of the media controller, which would ensure that we only control media after it become audible. Therefore, we can remove the previous implementation which we use to achieve that in media element.

When having that audible check in media element, it would postpone the timing of adding media element to `ContentMediaController` that causes some intermitent failures when I was writing test for bug1633565. When removing those checks, we can ensure that the media element would have always been added into `ContentMediaController` after calling `video.play()`. If the element haven't been added into `ContentMediaController`, then it would miss to handle the media key events when test generates a fake media key event, which causes an intermitent failure.

Differential Revision: https://phabricator.services.mozilla.com/D73335
2020-05-15 21:00:45 +00:00
Cosmin Sabou
3ed8e5317b Backed out 8 changesets (bug 1627999) for wpt failures on MediaPlaybackStatus.h. CLOSED TREE
Backed out changeset 98e98e2ecb56 (bug 1627999)
Backed out changeset 5533b1c9e3ed (bug 1627999)
Backed out changeset c9c9f78e131d (bug 1627999)
Backed out changeset 37b8f7a47ede (bug 1627999)
Backed out changeset 433a0eb70fc6 (bug 1627999)
Backed out changeset 72a1340bc112 (bug 1627999)
Backed out changeset 10e3550226eb (bug 1627999)
Backed out changeset 039ecd63e3fb (bug 1627999)
2020-05-14 12:29:01 +03:00
alwu
d6ea0a004a Bug 1627999 - part8 : remove audible check in media element. r=bryce
This patch will do :
- remove audible check from the logic of registering controller
- include audio channel affect on the media element's audible state

The advantage of doing so :
- it can help to reduce the intermittent failure during testing by earlier hooking media elements in the content process to the media controller in the chrome process

More details :
In D72497, we have added the audible check to postpone the activation of the media controller, which would ensure that we only control media after it become audible. Therefore, we can remove the previous implementation which we use to achieve that in media element.

When having that audible check in media element, it would postpone the timing of adding media element to `ContentMediaController` that causes some intermitent failures when I was writing test for bug1633565. When removing those checks, we can ensure that the media element would have always been added into `ContentMediaController` after calling `video.play()`. If the element haven't been added into `ContentMediaController`, then it would miss to handle the media key events when test generates a fake media key event, which causes an intermitent failure.

Differential Revision: https://phabricator.services.mozilla.com/D73335
2020-05-14 03:20:17 +00:00
Simon Giesecke
7a24ea2236 Bug 1626570 - Improve handling of copying arrays in dom/html/. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D73647
2020-05-07 08:09:51 +00:00
Simon Giesecke
942d6510f3 Bug 1626570 - Improve handling of copying arrays in dom/html/. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D73626
2020-05-05 10:08:15 +00:00
Emilio Cobos Álvarez
761e9dfe4c Bug 1635094 - Cleanup the ReferrerInfo code. r=ckerschb
The cast in InitWithNode is wrong. AsElement() asserts instead of
checking the flag, so we always pass an element (and if we didn't we'd
have type confusion problems). I audited the callers and we're fine.

Anyhow, always require an element, and add two convenience constructors
for C++ code.

Differential Revision: https://phabricator.services.mozilla.com/D73636
2020-05-04 18:50:20 +00:00
Cosmin Sabou
71a40eae48 Backed out 2 changesets (bug 1635094) for build bustages on nsMacShellService.cpp. CLOSED TREE
Backed out changeset 0a2b0c6ea19a (bug 1635094)
Backed out changeset ead4f26f76ee (bug 1635094)
2020-05-04 20:04:06 +03:00
Emilio Cobos Álvarez
6dde680742 Bug 1635094 - Cleanup the ReferrerInfo code. r=ckerschb
The cast in InitWithNode is wrong. AsElement() asserts instead of
checking the flag, so we always pass an element (and if we didn't we'd
have type confusion problems). I audited the callers and we're fine.

Anyhow, always require an element, and add two convenience constructors
for C++ code.

Differential Revision: https://phabricator.services.mozilla.com/D73636
2020-05-04 16:26:51 +00:00
Bobby Holley
216d17b976 Bug 1631304 - Mark the tail dispatcher as unavailable outside of event dispatch. r=jya
This is in preparation for running the tail dispatcher off
nsIThreadObserver callbacks, which only work during regular
event processing.

Differential Revision: https://phabricator.services.mozilla.com/D72264
2020-04-28 21:18:21 +00:00
alwu
b368e58a84 Bug 1632301 - part4 : rename 'ControlledMediaState' to 'MediaPlaybackState'. r=bryce
This patch will do :
- rename `ControlledMediaState` to `MediaPlaybackState`
- rename the related functions

The advantage of doing so :
- more consistent with `MediaAudibleState`

Differential Revision: https://phabricator.services.mozilla.com/D72060
2020-04-28 07:14:05 +00:00
alwu
d1cbaeb672 Bug 1632301 - part3 : use MediaAudibleState to replace boolean value. r=bryce
This patch will do :
- replace `boolean` with enum class `MediaAudibleState`

The advantage of doing so :
- It's easier to understand what actually meaning of the parameter we set

Differential Revision: https://phabricator.services.mozilla.com/D72058
2020-04-28 07:14:05 +00:00
alwu
db7bb9c21e Bug 1632301 - part2 : use ContentControlKeyEventReceiver's browsing context to notify any changes. r=bryce
This patch will do :
- use current broswing context as a parameter when propagate state change to the chrome process.

The advantage of doing so :
- the chrome process can know which browsing context the state change actually comes from.

---

More details about this change :

Currently, when we propagate any controlled media related states, we would find the top level browsing context first, then pass it through IPC in order to get the correct media controller in the chrome process. However, we have implemented [1] which can find the correct media controller even if we are not passing the top level browsing context.

In addition, in bug1627999, we would like to know which browsing context those states come from. Therefore, we should replace the top browsing context with the current browsing context where controlled media exists.

[1] https://searchfox.org/mozilla-central/rev/41c3ea3ee8eab9ce7b82932257cb80b703cbba67/docshell/base/CanonicalBrowsingContext.cpp#511-515

Differential Revision: https://phabricator.services.mozilla.com/D72056
2020-04-28 05:10:21 +00:00
alwu
25b47e1707 Bug 1632301 - part1 : decouple ContentMediaController from MediaControlKeysEventListener/MediaControlKeysEventSource. r=bryce
This patch will do :
- remove the inheritance relationship for `ContentControlKeyEventReceiver` and `ContentMediaAgent` and manually implement the methods we need
- `MediaControlEventListener` will inherit from `ContentControlKeyEventReceiver` directly

The advantage of doing so :
- increase the flexibilty of modification of `ContentMediaAgent` and those modification won't affect other classes inherited from `MediaControlKeysEventListener`

---

More details about this change :

As we would like to extend the class `ContentMediaAgent` and allow the `ContentMediaController` to call its extended method, but if we want to do so in current implementation, the extended method would also affect other classes inherited from `MediaControlKeysEventListener` and that is something we don't want to see.

Considering that, I decided to decouple the inheritance relationship and manually create the function I need (which will be implemented in the next patch)

Differential Revision: https://phabricator.services.mozilla.com/D72054
2020-04-28 05:10:03 +00:00
alwu
f1a19842ed Bug 1631087 - Update the timing of propagating media element's audible state. r=chunmin
After applying this patch,
- notify `inaudible` state only if we already notified `audible` state before
- update `inaudible` state when audible media is paused

Therefore, in the media controller side, it would always see a pair of `audible/inaudible` notifications like what we do for the pair of `ControlledMediaState::ePlayed/ePaused` notifications. That can help us implement a way of maintaining a detailed counting about how many media is audible in bug1627999.

Differential Revision: https://phabricator.services.mozilla.com/D71429
2020-04-25 00:34:02 +00:00
alwu
1933899aff Bug 1625615 - part5 : add test-only attribute and event for media element. r=bryce,emilio
Differential Revision: https://phabricator.services.mozilla.com/D69674
2020-04-20 21:19:57 +00:00
alwu
7cd282b498 Bug 1625615 - part4 : start listener if we haven't started listener yet. r=bryce
There is actually possible to start the listener already while running `SuspendOrResumeElement()`, so we should remove the assertion and use a check instead.

Eg.  JS can call `play()`, which would start the listener, before we run this method. This situation can be found when browsing Youtube on the GeckoView.

Differential Revision: https://phabricator.services.mozilla.com/D69673
2020-04-20 21:19:57 +00:00
alwu
a4a77fb633 Bug 1625615 - part3 : prevent media starting playing when inactive docshell wants to suspend any media. r=bryce
When the docShell's `SuspendMediaWhenInactive` flag is true, no media should be allowed to start playing. Therefore, we add a check in `Play()`, `CanActivateAutoplay()` to prevent media from playing. In addition, we should also prevent the audio channel agant from starting.

Differential Revision: https://phabricator.services.mozilla.com/D69672
2020-04-20 21:19:57 +00:00
alwu
b69e72e2f8 Bug 1625615 - part2 : suspend or resume media element according to docShell's SuspendMediaWhenInactive r=bryce
If docShell's `SuspendMediaWhenInactive` is true, then we should suspend or resume the media element according to the docshell active state when the docshell changes it active state.

Differential Revision: https://phabricator.services.mozilla.com/D69671
2020-04-20 21:19:56 +00:00
Jean-Yves Avenard
d882415a98 Bug 1630802 - P8. Remove unnecessary AutoEnter. r=bholley
AutoEnter was an attempt around a race between AbstractThread and MessageLoopAbstractThreadWrap that would cause AbstractThread::GetCurrent() to return an incorrect value. MessageLoopAbstractThreadWrapper is no more and as such AutoEnter is no longer required.

Differential Revision: https://phabricator.services.mozilla.com/D71279
2020-04-20 02:13:31 +00:00
Csoregi Natalia
de8e762887 Backed out 7 changesets (bug 1625615) for multiple failures e.g. /test_windowedhistoryframes.html. CLOSED TREE
Backed out changeset f239d24658c9 (bug 1625615)
Backed out changeset acea7c78db20 (bug 1625615)
Backed out changeset d709f5a72c35 (bug 1625615)
Backed out changeset 4cd231b1f3fb (bug 1625615)
Backed out changeset 45942c8dc380 (bug 1625615)
Backed out changeset 3f03a8703a8a (bug 1625615)
Backed out changeset e9299fc48796 (bug 1625615)
2020-04-16 00:32:16 +03:00
alwu
3313825099 Bug 1625615 - part5 : add test-only attribute and event for media element. r=bryce,emilio
Differential Revision: https://phabricator.services.mozilla.com/D69674

--HG--
extra : moz-landing-system : lando
2020-04-15 20:14:14 +00:00
alwu
1702ad395a Bug 1625615 - part4 : start listener if we haven't started listener yet. r=bryce
There is actually possible to start the listener already while running `SuspendOrResumeElement()`, so we should remove the assertion and use a check instead.

Eg.  JS can call `play()`, which would start the listener, before we run this method. This situation can be found when browsing Youtube on the GeckoView.

Differential Revision: https://phabricator.services.mozilla.com/D69673

--HG--
extra : moz-landing-system : lando
2020-04-06 17:51:15 +00:00
alwu
7d557acf89 Bug 1625615 - part3 : prevent media starting playing when inactive docshell wants to suspend any media. r=bryce
When the docShell's `SuspendMediaWhenInactive` flag is true, no media should be allowed to start playing. Therefore, we add a check in `Play()`, `CanActivateAutoplay()` to prevent media from playing. In addition, we should also prevent the audio channel agant from starting.

Differential Revision: https://phabricator.services.mozilla.com/D69672

--HG--
extra : moz-landing-system : lando
2020-04-06 21:36:40 +00:00
alwu
19c4e866db Bug 1625615 - part2 : suspend or resume media element according to docShell's SuspendMediaWhenInactive r=bryce
If docShell's `SuspendMediaWhenInactive` is true, then we should suspend or resume the media element according to the docshell active state when the docshell changes it active state.

Differential Revision: https://phabricator.services.mozilla.com/D69671

--HG--
extra : moz-landing-system : lando
2020-04-06 22:30:10 +00:00
alwu
09a518586f Bug 1623486 - part4 : update Picture-in-Picture mode status from media element. r=chunmin,padenot
Video element can start the Picture-in-Picture mode **BEFORE** or **AFTER** we start the listener for the media cotrol, so we have to ensure we always propagate this information to the chrome process via `ContentMediaAgent`.

Differential Revision: https://phabricator.services.mozilla.com/D67712

--HG--
extra : moz-landing-system : lando
2020-04-01 23:04:58 +00:00
André Bargull
73a498ec0c Bug 1625138 - Part 38: Replace mozilla::IsSame with std::is_same in dom/. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D68557

--HG--
extra : moz-landing-system : lando
2020-03-28 13:57:21 +00:00
alwu
7db6ce8171 Bug 1621166 - part2 : do not stop media control for media being used in PIP mode. r=MeFisto94
The media element being used in the PIP mode would always display on the screen even if the the tab it belongs to is in the background, so users would have high chance to interact with it again. Therefore, we don't want to start a stop-timer to cancel media control for that element.

Differential Revision: https://phabricator.services.mozilla.com/D67381

--HG--
extra : moz-landing-system : lando
2020-03-19 18:15:33 +00:00
alwu
86fbf04461 Bug 1621166 - part1 : add a method to know if media element is being used in PIP mode. r=bryce
Differential Revision: https://phabricator.services.mozilla.com/D67380

--HG--
extra : moz-landing-system : lando
2020-03-19 21:01:12 +00:00
Chris Fronk
d5b004443b Bug 1143478 - Rename mozilla::Pair to CompactPair. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D64511

--HG--
rename : mfbt/Pair.h => mfbt/CompactPair.h
extra : moz-landing-system : lando
2020-03-17 12:42:12 +00:00
Alex Chronopoulos
9fb4eecd46 Bug 1617915 - Expose output device id when MediaTrackGraph is created. r=padenot
In order to be able to change the audio output device, the device id is exposed to the constructor of MediaStreamGraph. Any component that gets/creates an MTG will be able to provide the device id in order to determine the desired output device. If the provided device id is null the default device will be used.

Differential Revision: https://phabricator.services.mozilla.com/D64133

--HG--
extra : moz-landing-system : lando
2020-03-16 12:56:20 +00:00
shindli
b02b3a6e1a Backed out changeset a08637fb30c8 (bug 1143478) for causing bustages in /builds/worker/checkouts/gecko/ipc/mscom/Registration.cpp CLOSED TREE
--HG--
rename : mfbt/CompactPair.h => mfbt/Pair.h
2020-03-11 14:30:54 +02:00
Chris Fronk
a27e438c2d Bug 1143478 - Rename mozilla::Pair to CompactPair. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D64511

--HG--
rename : mfbt/Pair.h => mfbt/CompactPair.h
extra : moz-landing-system : lando
2020-03-11 12:18:13 +00:00
alwu
7dc5318e3b Bug 1617033 - part8 : add an eligible media duration value to filter out notification sound. r=chunmin
Intercepting media control keys would also come up with the virtual control interface in most of platforms, and for the notification sound we don't want either to show the interface or control them.

Currently we use 3s as a threshold to filter those short duration media which are possible to be a notification sound.

Differential Revision: https://phabricator.services.mozilla.com/D64478

--HG--
extra : moz-landing-system : lando
2020-03-06 17:52:15 +00:00
alwu
00f2d0c596 Bug 1617033 - part4 : add a timer to stop listening to media control key events. r=chunmin
This patch is used to prevent intercepting media keys from other applications which should really receive media keys. For example, if user finishes watching a video but doesn't close that tab, and switch to other tasks. Then if they have other applications which are playing music, when they press media keys, the application which should receive media keys should be those background music app, not Firefox.

Therefore, if the media has been paused for a while, then that might indicate that user won't need to control this media anymore. Therefore, we create a timer, which default expire time is 60s, to stop listening media control key events for those kinds of media. But if the media starts again during this period, we would destroy timer and continue to control that media.

Differential Revision: https://phabricator.services.mozilla.com/D63918

--HG--
extra : moz-landing-system : lando
2020-03-06 17:47:58 +00:00
alwu
c1a25664ec Bug 1617033 - part3 : add comment to explicitly mention some functions should only be used after starting listener. r=chunmin
Differential Revision: https://phabricator.services.mozilla.com/D63916

--HG--
extra : moz-landing-system : lando
2020-03-06 17:46:44 +00:00
alwu
ef135def22 Bug 1617033 - part2 : only update audible state after starting listener successfully. r=chunmin
It's useless to update the audible state before starting listening to the media control keys event, so we make it consistent with other functions which could only be used after starting the listener.

As the audible change could happen before we start the listener, we have to manually update audible state to the controller after we start the listener.

Differential Revision: https://phabricator.services.mozilla.com/D63943

--HG--
extra : moz-landing-system : lando
2020-03-06 17:46:07 +00:00
alwu
ddbd4e27df Bug 1617033 - part1 : start listening to the event after media becomes audible. r=chunmin
When media is not audible yet, or it's inaudible at all (maybe it's used as a background video or GIF-like image), or the media is in the tab which has been muted totally, we don't want to use media control to control those media, so we should postpone starting listening to the media control keys for them event until they become audible.

Once they become audible, we would keep control them all the time even if they become inaudible again.

Differential Revision: https://phabricator.services.mozilla.com/D63915

--HG--
extra : moz-landing-system : lando
2020-03-06 17:45:29 +00:00
Alastor Wu
dcb5adabb7 Bug 1577890 - part8 : remove fennec media control related logic from HTMLMediaElement r=baku
Those suspend and resume related logic were used for implemeting media control and audio focus on Fennec. After removing those things, the only purpose of `AudioChannelAgentCallback` would be muting and unmuting media element from audio channel (eg. clicking sound indicator to mute/unmute tab)

Differential Revision: https://phabricator.services.mozilla.com/D65264

--HG--
extra : moz-landing-system : lando
2020-03-05 06:17:08 +00:00
Alastor Wu
afd7e10439 Bug 1577890 - part7 : remove 'computedSuspended' which is a testing-only attribute. r=baku
This attribute is used to expose the internal suspend state of media element to see if we set `SUSPENDED_PAUSE` and `SUSPENDED_PAUSE_DISPOSABLE` correctly. As we don't use those suspend state anymore and have removed the related tests, no need to keep this attribute anymore.

Differential Revision: https://phabricator.services.mozilla.com/D65263

--HG--
extra : moz-landing-system : lando
2020-03-05 06:17:48 +00:00
Alastor Wu
e3f41d5cf0 Bug 1577890 - part2 : remove 'media-playback-resumed' notification. r=baku
`media-playback-resumed` was a notification we used on Fennec to indicate media playback state changes and we should update the UI button on the virtual control interface. As it's not being used by anyone since we deprecate Fennec, we can remove all related code.

Differential Revision: https://phabricator.services.mozilla.com/D65258

--HG--
extra : moz-landing-system : lando
2020-03-05 06:09:59 +00:00
Alastor Wu
4c509693cc Bug 1618717 - stop and clear the listener during CC unlink process. r=bryce
At the time CC unlink happens, we would no longer need to listen to the media control key events. Therefore, we should remember to stop and clear the listener to avoid its any method ran after CC.

Differential Revision: https://phabricator.services.mozilla.com/D64787

--HG--
extra : moz-landing-system : lando
2020-02-28 23:39:29 +00:00
Andrew McCreight
4babb2b5ab Bug 1609815 - Remove Web Replay C++ implementation. r=jgilbert,jandem,gbrown
Patch by bhackett and jlaster. Also reviewed by mccr8.

Differential Revision: https://phabricator.services.mozilla.com/D60197

--HG--
extra : moz-landing-system : lando
2020-02-27 17:39:15 +00:00
Ciure Andrei
00dd87f6f4 Backed out changeset d407a28318e6 (bug 1609815) for causing windows ming bustages CLOSED TREE
--HG--
extra : histedit_source : b2c748e31e0f6ba8fcf9960a336e0bbd361b07e6
2020-02-27 07:05:19 +02:00
Andrew McCreight
b197e1f783 Bug 1609815 - Remove Web Replay C++ implementation. r=jgilbert,jandem,gbrown
Patch by bhackett and jlaster. Also reviewed by mccr8.

Differential Revision: https://phabricator.services.mozilla.com/D60197

--HG--
extra : moz-landing-system : lando
2020-02-27 04:43:48 +00:00
Kris Maglione
c31aa68fb4 Bug 1535617: Part 2 - Clear weak references for most cycle collected objects on unlink. r=mccr8
This covers most cycle collected objects which support weak references, but
not the ones which inherit from a cycle collected class and don't do any cycle
collection on their own.

Differential Revision: https://phabricator.services.mozilla.com/D63962

--HG--
extra : moz-landing-system : lando
2020-02-25 19:44:39 +00:00
Simon Giesecke
aaf6cb4e75 Bug 1617628 - Hide nsBaseHashtable Put overloads in nsRefPtrHashtable subclass. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D63899

--HG--
extra : moz-landing-system : lando
2020-02-25 17:03:36 +00:00
Simon Giesecke
1ed2ba9764 Bug 1613985 - Use default for equivalent-to-default constructors/destructors in dom/html. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D63171

--HG--
extra : moz-landing-system : lando
2020-02-20 16:19:15 +00:00
Simon Giesecke
b50347f917 Bug 1611415 - Prefer using std::move over forget. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D60980

--HG--
extra : moz-landing-system : lando
2020-02-13 14:38:48 +00:00
shindli
91aa0518dd Backed out changeset 0c982bc69cb3 (bug 1611415) for causing build bustages in /builds/worker/workspace/build/src/obj-firefox/dist/include/nsCOMPtr CLOSED TREE 2020-02-12 20:13:29 +02:00
Simon Giesecke
f604a47fa5 Bug 1611415 - Applied FixItHints from mozilla-non-std-move. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D60980

--HG--
extra : moz-landing-system : lando
2020-02-12 17:24:41 +00:00
Boris Zbarsky
9b0b56bfc7 Bug 1612213 part 3. Switch Promise::RejectWithDOMException consumers to new convenience methods. r=smaug,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D61269

--HG--
extra : moz-landing-system : lando
2020-02-03 20:37:32 +00:00
alwu
7bfc3e2bf5 Bug 1611031 - always trigger corespending controller method when receving media control key events. r=chunmin
The check here was used to prevent calling play or pause during playing or pausing.

However, according to the spec [1], even if media session is playing, we would still want to trigger its play action handler when play action happens. So we should forward all media control key events to the content, not to block any of them.

[1] https://w3c.github.io/mediasession/#handle-media-session-action

Differential Revision: https://phabricator.services.mozilla.com/D60918

--HG--
extra : moz-landing-system : lando
2020-01-24 21:31:34 +00:00
alwu
c2d2ecbd96 Bug 1595603 - part2 : delay seeking task when media is inactive r=bryce
When media element is inactive, asking MDSM to seek is actually useless, because all the data we decode won't be showed to user. In addition, we have to store extra pending events for `seeking` and `seeked`, which might result in memory overflow if the inactive page is calling `seek()` all the time.

Therfore, we should delay all seeking tasks while media is inactive, and perform the latest seeking task when media becomes active.

Differential Revision: https://phabricator.services.mozilla.com/D58918

--HG--
extra : moz-landing-system : lando
2020-01-09 17:10:08 +00:00
alwu
25786bc918 Bug 1595603 - part1 : remove duplicate parameter and rename variable r=bryce
Two parameters in `SuspendOrResumeElement()` are acutally the same, they are both related with `IsActive()`, so using one parameter is enough.
In addition, we only suspend or resume element by checking element's active state, so rename `mPausedForInactiveDocumentOrChannel` to `mSuspendedForInactiveDocument` which fits the actual situation more.

Differential Revision: https://phabricator.services.mozilla.com/D58749

--HG--
extra : moz-landing-system : lando
2020-01-09 06:10:02 +00:00
alwu
2d2b857325 Bug 1571493 - part3 : notify media state and audible state changes. r=chunmin
Modify IPC method to support notify `ControlledMediaState` to the media controller, and remove the previous implementation.

Differential Revision: https://phabricator.services.mozilla.com/D57572

--HG--
extra : moz-landing-system : lando
2020-01-03 01:34:34 +00:00
alwu
f5053f5850 Bug 1571493 - part2 : use 'MediaControlAgent' in media element. r=chunmin
We create `MediaControlEventListener` to register itself to the `MediaControlAgent` that is an event source, so that we can receive the media control event from the evnet source and operate media according to different types of event.

 `MediaControlEventListener` is also used to notify controlled media state to the media controller. When media first starts playing, or leaves bfcache and  has created listener before, we would notify `eStarted`. Notify `eStopped` when media destroys, or enter bfcache and has created listener before. When media's playing state changes, we would notifty `ePlayed` or `ePaused` depeding on media's `mPaused`.

Differential Revision: https://phabricator.services.mozilla.com/D57571

--HG--
extra : moz-landing-system : lando
2020-01-03 01:20:01 +00:00
Alastor Wu
6305f6935f Bug 1588138 - reset blessed state when media aborting current load. r=bryce
This patch is used to change the blessed state for media element under `click-to-play` blocking autoplay policy, which only allows play invocation called from user input handler, eg. `onclick`.

When media aborts current load, we should regard it as a new media. One example is on Youtube they always reuse same media element but replace its url for different video. Therefore, we should reset media's blessed state so that the media with new url can be blocked again.

Differential Revision: https://phabricator.services.mozilla.com/D57192

--HG--
extra : moz-landing-system : lando
2019-12-18 04:11:12 +00:00
Andrew McCreight
058daef5d2 Bug 1603879 - Add a memory reporter for HTMLMediaElement::mPendingEvents. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D57376

--HG--
extra : moz-landing-system : lando
2019-12-17 02:55:15 +00:00