import changes from `dev' branch of rmottola/Arctic-Fox:

- Use CompositorWidgetProxy for dispatching vsync to the compositor. (bug 1269037 part 1, r=mchang) (c8b7a4240c)
- Remove unused null widget checks. (bug 1269037 part 2, r=mchang) (4f4cc9952b)
- Bug 1269422: Wrap Gonk widget in |CompositorWidgetProxyWrapper|. r=dvander (4513035cbf)
- Remove nsBaseWidget::NewCompositorBridgeParent. (bug 1272472 part 1, r=kats) (ca813c1f2b)
- Use IPDL to schedule composites on GTK. (bug 1272472 part 2, r=nical) (7402cf834e)
- Use IPC to schedule composites on Windows. (bug 1272472 part 3, r=jimm) (e5d7281dd7)
- Don't use nsIWidget to check APZ in LayerManagerComposite. (bug 1269653 part 1, r=kats) (79a1644111)
- Restrict SetDispAcquireFence's nsIWidget access to Gonk. (bug 1269653 part 2, r=kats) (72110b7bc7)
- Bug 1264764 - Move PTexture under PCompositorBridge r=nical,dvander (17e6ec7fc1)
- Move CompositorThreadHolder into its own file. (bug 1273017 part 1, r=mattwoodrow) (464ede8be1)
- Move CompositorBridgeParent::CompositorLoop to CompositorThreadHolder. (bug 1273017 part 2, r=mattwoodrow) (85708f3cde)
- Bug 1268313: Part 1 - Be explicit about which NewRunnableMethod callers want to be able to cancel. r=froydnj (faa07aa139)
- Bug 1268313: Part 2 - Replace some NewRunnableMethods with NS_NewNonOwningRunnableMethod. r=froydnj (010c43d000)
- Bug 1268313: Part 3 - Replace some NewCancelableRunnableMethod with NS_NewNonOwningCancelableRunnableMethod. r=froydnj (55018ef234)
- Bug 1268313: Part 4 - Replace NewCancelableRunnableMethod with NS_NewCancelableRunnableMethod. r=froydnj (c22711b35d)
- Bug 1268313: Part 5 - Make NS_NewRunnableMethod able to call const functions. r=froydnj (b0f60963a3)
- Bug 1268313: Part 6 - Replace NewRunnableMethod with NS_NewRunnableMethod. r=froydnj (18d40def2c)
- Bug 1260950 - Set mInitialSizeFound to true when the initial size id found. r=jesup, r=pehrsons a=kwierso (5d6abe57e0)
- Bug 1237176 - Notify synth start if we get a finished event without a blocking-changed event. r=roc (c1aebe903a)
- Bug 911546, use a runnable so that popups don't rollup during a grab, r=karlt (a06bd44e6c)
- Bug 1237617 - Call nsWindow::ForcePresent during going active r=bas.schouten (066cad8f89)
- Bug 1268313: Part 7 - Move NS_NewRunnableMethod and friends to mozilla::NewRunnableMethod. r=froydnj (8b4bf34961)
- Bug 1266595: Followup to fix IPDL tests. r=billm (216f2dcff5)
- Bug 1268313: Fix up IPDL tests. r=billm (228348d642)
- Add WinCompositorWidgetProxy. (bug 1265975 part 1, r=jimm) (bfafe7a8e2)
- Implement WinCompositorWidgetProxy::GetClientSize. (bug 1265975 part 2, r=jimm) (a8710a3259)
- Move the WM_SETTEXT present lock to CompositorWidgetProxy. (bug 1265975 part 3, r=jimm) (297ce28c8a)
- Move transparency handling to WinCompositorWigetProxy. (bug 1265975 part 4, r=jimm) (46ba0c6d01)
- Remove Windows-specific compositor calls to nsIWidget. (bug 1265975 part 5, r=jimm) (3ef157c160)
- Remove plugin-related CompositorBridgeParent use of nsIWidget. (bug 1265975 part 6, r=jimm) (6d80cdd6fd)
- Hide top-level CompositorBridgeParents behind a new API. (bug 1272472 part 4, r=mattwoodrow,kats,gwagner) (228c0efdb7)
- Bug 1253424 - part 1 - add a already_AddRefed nsTransactionStack::Push overload; r=erahm (7059e20914)
- Bug 1253424 - part 2 - add nsTransactionStack::IsEmpty; r=erahm (7e9764a146)
- Bug 1254618 - modify nsTransactionStack to use nsDeque rather than std::deque; r=ehsan (5e47ea431e)
- Bug 1136857 - Make DOMStorageCache::mLoaded flag atomic to prevent potential races, r=nfroyd (39aaea1de3)
- Bug 1265408 - Add webidl for IIRFilterNode; r=smaug (040ce9aa43)
- Bug 1265408 - Implement IIRFilterNode; r=padenot (6bf569a412)
- Bug 1265408 - Import IIRFilter from blink; r=padenot (71b28c0ad2)
- Bug 1265408 - Use IIRFilter from blink; r=padenot (5d058d8568)
- Bug 1265408 - Add buffersAreZero to IIRFilter; r=karlt (45edba3e13)
- Bug 1265408 - Avoid subnormals in IIRFilter; r=karlt (0e1ae93f0b)
- Bug 1265408 - Add LogToDeveloperConsole to WebAudioUtils; r=padenot (88d5f0222a)
- Bug 1268984 - Store GMPStorage on GMPServiceParent so that it persists inside the same PB session. r=gerald (17d4d0abaf)
- Bug 1267905 - Replace uses of ScopedCERTCertList with UniqueCERTCertList. r=keeler (783bf11b2a)
- Bug 1270005 - Replace uses of ScopedPK11SlotInfo with UniquePK11SlotInfo in PSM. r=keeler (ea9a4011aa)
- Bug 1271501 - Remove unnecessary uses of reinterpret_cast in PSM. r=keeler (6be40f0a85)
- Bug 1271501 - Downgrade unnecessarily strong reinterpret_casts in PSM. r=keeler (95245f00ce)
- Bug 1082346 - 01. Convert PKCS12 password endian using copyAndSwapToBigEndian. r=keeler (9cc58fc550)
- Bug 1082346 - 02. Test case. r=keeler r=Cykesiopka (7fb0e8abc4)
- Bug 160122 - Stop using PR_smprintf in PSM. r=keeler (1e5b68819c)
- Bug 1271501 - Use mozilla::BitwiseCast instead of reinterpret_cast in PSM. r=keeler (894966a2ef)
- Bug 1273855: TraceLogger - Include PID in the log names in order to support browser with e10s, r=bbouvier (8cf2233db3)
- Bug 1274189. Part 1 - rename some functions to be consistent with other MediaDataDecoder sub-classes. r=jya. (4511b3d3f7)
- Bug 1274189. Part 2 - remove use of FlushableTaskQueue::Flush(). r=jya. (77e745fdd1)
- Bug 1274189. Part 3 - remove use of FlushableTaskQueue. r=jya (aac61dcd02)
- Bug 1269963. Part 1 - Add a SyncRunnable::DispatchToThread() overload for AbstractThread. r=bobbyholley. (839752aff4)
- Bug 1269672 - part1 : revert sampling rate changing of the bug1235612. (9015782e13)
- Bug 1270698 - check if we need to enter buffering periodically to ensure we start buffering when running out of decoded audio/video data. r=cpearce. (16734549b7)
- Bug 1271581 - use newCurrentTime, instead of GetMediaTime() to decide the nextState; r=jwwang (9c5075eada)
- Bug 1224973 - Part 1: Remove MediaDecoderOwner->IsHidden(). r=cpearce,jwwang (4fde3ede5a)
- Bug 1224973 - Part 2: Set MediaDecoder visibility via NotifyOwnerActivityChanged. r=cpearce,jwwang (be917202eb)
- Bug 1224973 - Part 3: Plumb element visibility into MDSM. r=jya,jwwang (9ec83fa243)
- Bug 1224973 - Part 4: Pref media.suspend-bkgnd-video.enabled. r=cpearce,jwwang (43413a025f)
- Bug 1269408: P1. Retry InternalSeek if previous attempt failed once more data is available. r=gerald (05db58dc7c)
- crude fix (0097068989)
- Bug 1269408: P2. Update mochitest. r=gerald (464b4c0724)
- Bug 1269408: P3. Ensure a new seek request will cancel the previous internal seek. r=gerald (6ed4b8dc95)
- Bug 1269408: P4. Ensure the decoders are flushed prior performing an internal seek. r=gerald (074234067b)
- Bug 1269408: P5. Only drop the seek target if it's exactly the seek target. r=gerald (88701eb05a)
- Bug 1269408: P6. Add debugging information, useful when a mochitest timeout. r=gerald (ef0270ab0d)
- Bug 1269408: P7. Start skip to next keyframe logic when resume point is behind current time. r=gerald (bd40ebf3bc)
- Bug 1269408: P8. Add debugging log. r=gerald (e6dbd1f0a6)
- Bug 1269408: P9. Move handling logic of skip to next keyframe to its own function. r=gerald (3c8039e417)
- Bug 1269408: P10. Reject promise early if in error state. r=me (8af54c574e)
- Bug 1224973 - Part 5: Implement suspend decoding for background video. r=cpearce,jwwang,jya (22081521e3)
- Bug 1242874 - part1 : create suspened types. r=baku (d3ac9548e5)
- Bug 1242874 - part2 : window's suspend attribute. r=baku, r=ehsan (1fd9dc2647)
- remove allowscirpted (39ab523036)
- Bug 1242874 - part3 : implement different suspended methods. r=baku, r=jwwang (25d1f27a03)
- Bug 1242874 - part4 : wrap the volume/mute/suspend for notifyStartedPlaying. r=baku (b8ba3238c2)
- bug 1242874 - part5 : add test. r=baku, r=ehsan (f840139b5a)
- Bug 1235612 - Part 1: Implement notify media-playback. r=baku (b5ec29da20)
- Bug 1235612 - Part 2: Notify audible state in NotifyStartedPlaying. r=baku (dc38583a62)
- Bug 1235612 - Part 3: Implement the logic of audible state notification for agent owners. r=baku (f65b3952fa)
- Bug 1235612 - Part 4: Modify check audible method. r=jwwang (73457e39eb)
- Bug 1269672 - part2 : move audible data checking from MDSM to DecodedAudioDataSink. (d2c3b6874c)
- Bug 1269936 - Introduce and call a runtime-wide servo initialization hook. r=heycam (d4d505d4c2)
- Bug 1263778 - Rename a bunch of low-level [[Prototype]] access methods to make their interactions with statically-known and dynamically-computed [[Prototype]]s clearer. r=efaust (66bbe8e7db)
- Bug 888969 - Permit a cyclic [[Prototype]] chain to be created through a Location object. r=bz, r=efaust (3e3b9cbb16)
- re-apply Bug 1054906 - Implement ES6 Symbol.hasInstance 2/2; r=jandem (8d5c7573ff)
- Bug 1054906 - Implement ES6 Symbol.hasInstance 1/2; r=evilpie,bz (a836904e5d)
- fix misspatch (54a5f2d708)
- Bug 1270349 part 1. Add IDL parser support for [LegacyUnenumerableNamedProperties]. r=peterv (8c836bc74a)
- Bug 1270349 part 2. Add [LegacyUnenumerableNamedProperties] to the interfaces that specify it in DOM and HTML. r=peterv (25d3cc1377)
- Bug 1270349 part 3. Add a way to ask an interface descriptor for a proxy whether its named props should be enumerable. r=peterv (0a9f804867)
- Bug 1270349 part 4. Use LegacyUnenumerableNamedProperties instead of NameIsEnumerable() calls to determine whether named props on DOM proxies should be enumerable. r=peterv (82f5158963)
- Bug 1270349 part 5. Use LegacyUnenumerableNamedProperties instead of passing flags to GetSupportedNames to determine whether named props on DOM proxies should be reflected in ownPropertyKeys. r=peterv (3984176834)
- Bug 1270349 followup to address a review comment. r=peterv (b49f4c5335)
This commit is contained in:
2024-10-03 21:48:48 +08:00
parent 6bedaf2149
commit b564bd67d3
529 changed files with 7378 additions and 4223 deletions
Binary file not shown.
+2 -2
View File
@@ -1390,8 +1390,8 @@ nsSHistory::RemoveEntries(nsTArray<uint64_t>& aIDs, int32_t aStartIndex)
}
if (didRemove && mRootDocShell) {
nsCOMPtr<nsIRunnable> ev =
NS_NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell),
&nsDocShell::FireDummyOnLocationChange);
NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell),
&nsDocShell::FireDummyOnLocationChange);
NS_DispatchToCurrentThread(ev);
}
}
+1 -1
View File
@@ -1236,7 +1236,7 @@ Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag)
DoFinishNotificationImmediately();
} else if (!mFinishNotificationTask.IsPending()) {
RefPtr<nsRunnableMethod<Animation>> runnable =
NS_NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately);
NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately);
runtime->DispatchToMicroTask(runnable);
mFinishNotificationTask = runnable;
}
+1 -2
View File
@@ -86,8 +86,7 @@ ArchiveReaderEvent::RunShare(nsresult aStatus)
{
mStatus = aStatus;
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread);
NS_DispatchToMainThread(event);
NS_DispatchToMainThread(NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread));
return NS_OK;
}
+71 -23
View File
@@ -207,17 +207,12 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
return NS_OK;
}
NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(float *aVolume,
bool* aMuted)
NS_IMETHODIMP
AudioChannelAgent::NotifyStartedPlaying(AudioPlaybackConfig* aConfig,
bool aAudible)
{
MOZ_ASSERT(aVolume);
MOZ_ASSERT(aMuted);
// Window-less AudioChannelAgents are muted by default.
if (!mWindow) {
*aVolume = 0;
*aMuted = true;
return NS_OK;
if (NS_WARN_IF(!aConfig)) {
return NS_ERROR_FAILURE;
}
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
@@ -226,20 +221,26 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStartedPlaying(float *aVolume,
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(AudioChannelService::AudibleState::eAudible == true &&
AudioChannelService::AudibleState::eNotAudible == false);
service->RegisterAudioChannelAgent(this,
static_cast<AudioChannel>(mAudioChannelType));
static_cast<AudioChannelService::AudibleState>(aAudible));
service->GetState(mWindow, mAudioChannelType, aVolume, aMuted);
AudioPlaybackConfig config = service->GetMediaConfig(mWindow,
mAudioChannelType);
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, NotifyStartedPlaying, this = %p, mute = %d, "
"volume = %f\n", this, *aMuted, *aVolume));
("AudioChannelAgent, NotifyStartedPlaying, this = %p, "
"mute = %d, volume = %f, suspend = %d\n", this,
config.mMuted, config.mVolume, config.mSuspend));
aConfig->SetConfig(config.mVolume, config.mMuted, config.mSuspend);
mIsRegToService = true;
return NS_OK;
}
NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying()
NS_IMETHODIMP
AudioChannelAgent::NotifyStoppedPlaying()
{
if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
!mIsRegToService) {
@@ -258,6 +259,23 @@ NS_IMETHODIMP AudioChannelAgent::NotifyStoppedPlaying()
return NS_OK;
}
NS_IMETHODIMP
AudioChannelAgent::NotifyStartedAudible(bool aAudible)
{
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, NotifyStartedAudible, this = %p, "
"audible = %d\n", this, aAudible));
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (NS_WARN_IF(!service)) {
return NS_ERROR_FAILURE;
}
service->AudioAudibleChanged(
this, static_cast<AudioChannelService::AudibleState>(aAudible));
return NS_OK;
}
already_AddRefed<nsIAudioChannelAgentCallback>
AudioChannelAgent::GetCallback()
{
@@ -276,19 +294,49 @@ AudioChannelAgent::WindowVolumeChanged()
return;
}
float volume = 1.0;
bool muted = false;
AudioPlaybackConfig config = GetMediaConfig();
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, "
"volume = %f\n", this, config.mMuted, config.mVolume));
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (service) {
service->GetState(mWindow, mAudioChannelType, &volume, &muted);
callback->WindowVolumeChanged(config.mVolume, config.mMuted);
}
void
AudioChannelAgent::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
nsCOMPtr<nsIAudioChannelAgentCallback> callback = GetCallback();
if (!callback) {
return;
}
if (!IsDisposableSuspend(aSuspend)) {
aSuspend = GetMediaConfig().mSuspend;
}
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelAgent, WindowVolumeChanged, this = %p, mute = %d, "
"volume = %f\n", this, muted, volume));
("AudioChannelAgent, WindowSuspendChanged, this = %p, "
"suspended = %d\n", this, aSuspend));
callback->WindowVolumeChanged(volume, muted);
callback->WindowSuspendChanged(aSuspend);
}
AudioPlaybackConfig
AudioChannelAgent::GetMediaConfig()
{
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
AudioPlaybackConfig config(1.0, false, nsISuspendedTypes::NONE_SUSPENDED);
if (service) {
config = service->GetMediaConfig(mWindow, mAudioChannelType);
}
return config;
}
bool
AudioChannelAgent::IsDisposableSuspend(nsSuspendedTypes aSuspend) const
{
return (aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
aSuspend == nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
}
uint64_t
+6
View File
@@ -22,6 +22,8 @@ class nsPIDOMWindow;
namespace mozilla {
namespace dom {
class AudioPlaybackConfig;
/* Header file */
class AudioChannelAgent : public nsIAudioChannelAgent
{
@@ -34,6 +36,7 @@ public:
AudioChannelAgent();
void WindowVolumeChanged();
void WindowSuspendChanged(nsSuspendedTypes aSuspend);
void WindowAudioCaptureChanged(uint64_t aInnerWindowID, bool aCapture);
nsPIDOMWindow* Window() const
@@ -47,6 +50,9 @@ public:
private:
virtual ~AudioChannelAgent();
AudioPlaybackConfig GetMediaConfig();
bool IsDisposableSuspend(nsSuspendedTypes aSuspend) const;
// Returns mCallback if that's non-null, or otherwise tries to get an
// nsIAudioChannelAgentCallback out of mWeakCallback.
already_AddRefed<nsIAudioChannelAgentCallback> GetCallback();
+220 -86
View File
@@ -94,15 +94,6 @@ private:
const bool mActive;
};
void
NotifyChannelActive(uint64_t aWindowID, AudioChannel aAudioChannel,
bool aActive)
{
RefPtr<Runnable> runnable =
new NotifyChannelActiveRunnable(aWindowID, aAudioChannel, aActive);
NS_DispatchToCurrentThread(runnable);
}
already_AddRefed<nsPIDOMWindow>
GetTopWindow(nsPIDOMWindow* aWindow)
{
@@ -122,10 +113,10 @@ IsParentProcess()
return XRE_GetProcessType() == GeckoProcessType_Default;
}
class MediaPlaybackRunnable : public Runnable
class AudioPlaybackRunnable final : public Runnable
{
public:
MediaPlaybackRunnable(nsIDOMWindow* aWindow, bool aActive)
AudioPlaybackRunnable(nsPIDOMWindow* aWindow, bool aActive)
: mWindow(aWindow)
, mActive(aActive)
{}
@@ -134,14 +125,17 @@ public:
{
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(
ToSupports(mWindow),
"media-playback",
mActive ? MOZ_UTF16("active")
: MOZ_UTF16("inactive"));
if (NS_WARN_IF(!observerService)) {
return NS_ERROR_FAILURE;
}
observerService->NotifyObservers(ToSupports(mWindow),
"audio-playback",
mActive ? MOZ_UTF16("active")
: MOZ_UTF16("inactive"));
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("AudioPlaybackRunnable, active = %d\n", mActive));
return NS_OK;
}
@@ -268,8 +262,10 @@ AudioChannelService::~AudioChannelService()
void
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudioChannel aChannel)
AudibleState aAudible)
{
MOZ_ASSERT(aAgent);
uint64_t windowID = aAgent->WindowID();
AudioChannelWindow* winData = GetWindowData(windowID);
if (!winData) {
@@ -277,29 +273,11 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
mWindows.AppendElement(winData);
}
MOZ_ASSERT(!winData->mAgents.Contains(aAgent));
winData->mAgents.AppendElement(aAgent);
++winData->mChannels[(uint32_t)aChannel].mNumberOfAgents;
// The first one, we must inform the BrowserElementAudioChannel.
if (winData->mChannels[(uint32_t)aChannel].mNumberOfAgents == 1) {
NotifyChannelActive(aAgent->WindowID(), aChannel, true);
}
// If this is the first agent for this window, we must notify the observers.
if (winData->mAgents.Length() == 1) {
RefPtr<MediaPlaybackRunnable> runnable =
new MediaPlaybackRunnable(aAgent->Window(), true /* active */);
NS_DispatchToCurrentThread(runnable);
}
// If the window has already been captured, the agent of that window should
// also be captured.
if (winData->mIsAudioCaptured) {
aAgent->WindowAudioCaptureChanged(aAgent->InnerWindowID(),
winData->mIsAudioCaptured);
}
// To make sure agent would be alive because AppendAgent() would trigger the
// callback function of AudioChannelAgentOwner that means the agent might be
// released in their callback.
RefPtr<AudioChannelAgent> kungFuDeathGrip(aAgent);
winData->AppendAgent(aAgent, aAudible);
MaybeSendStatusUpdate();
}
@@ -307,27 +285,18 @@ AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
void
AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
AudioChannelWindow* winData = GetWindowData(aAgent->WindowID());
if (!winData) {
return;
}
if (winData->mAgents.Contains(aAgent)) {
int32_t channel = aAgent->AudioChannelType();
uint64_t windowID = aAgent->WindowID();
// aAgent can be freed after this call.
winData->mAgents.RemoveElement(aAgent);
MOZ_ASSERT(winData->mChannels[channel].mNumberOfAgents > 0);
--winData->mChannels[channel].mNumberOfAgents;
// The last one, we must inform the BrowserElementAudioChannel.
if (winData->mChannels[channel].mNumberOfAgents == 0) {
NotifyChannelActive(windowID, static_cast<AudioChannel>(channel), false);
}
}
// To make sure agent would be alive because AppendAgent() would trigger the
// callback function of AudioChannelAgentOwner that means the agent might be
// released in their callback.
RefPtr<AudioChannelAgent> kungFuDeathGrip(aAgent);
winData->RemoveAgent(aAgent);
#ifdef MOZ_WIDGET_GONK
bool active = AnyAudioChannelIsActive();
@@ -336,18 +305,6 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
}
#endif
// If this is the last agent for this window, we must notify the observers.
if (winData->mAgents.IsEmpty()) {
RefPtr<MediaPlaybackRunnable> runnable =
new MediaPlaybackRunnable(aAgent->Window(), false /* active */);
NS_DispatchToCurrentThread(runnable);
}
// No need to capture non-audible object.
if (winData->mIsAudioCaptured) {
aAgent->WindowAudioCaptureChanged(aAgent->InnerWindowID(), false);
}
MaybeSendStatusUpdate();
}
@@ -366,24 +323,22 @@ AudioChannelService::UnregisterTabParent(TabParent* aTabParent)
mTabParents.RemoveElement(aTabParent);
}
void
AudioChannelService::GetState(nsPIDOMWindow* aWindow, uint32_t aAudioChannel,
float* aVolume, bool* aMuted)
AudioPlaybackConfig
AudioChannelService::GetMediaConfig(nsPIDOMWindow* aWindow,
uint32_t aAudioChannel) const
{
MOZ_ASSERT(!aWindow || aWindow->IsOuterWindow());
MOZ_ASSERT(aVolume && aMuted);
MOZ_ASSERT(aAudioChannel < NUMBER_OF_AUDIO_CHANNELS);
AudioPlaybackConfig config(1.0, false,
nsISuspendedTypes::NONE_SUSPENDED);
if (!aWindow || !aWindow->IsOuterWindow()) {
*aVolume = 0.0;
*aMuted = true;
return;
config.SetConfig(0.0, true,
nsISuspendedTypes::SUSPENDED_BLOCK);
return config;
}
*aVolume = 1.0;
*aMuted = false;
AudioChannelWindow* winData = nullptr;
nsCOMPtr<nsPIDOMWindow> window = aWindow;
@@ -392,13 +347,16 @@ AudioChannelService::GetState(nsPIDOMWindow* aWindow, uint32_t aAudioChannel,
do {
winData = GetWindowData(window->WindowID());
if (winData) {
*aVolume *= winData->mChannels[aAudioChannel].mVolume;
*aMuted = *aMuted || winData->mChannels[aAudioChannel].mMuted;
config.mVolume *= winData->mChannels[aAudioChannel].mVolume;
config.mMuted = config.mMuted || winData->mChannels[aAudioChannel].mMuted;
}
*aVolume *= window->GetAudioVolume();
// TODO : distiguish between suspend and mute, it would be done in bug1242874.
*aMuted = *aMuted || window->GetMediaSuspended() || window->GetAudioMuted();
config.mVolume *= window->GetAudioVolume();
config.mMuted = config.mMuted || window->GetAudioMuted();
// If the mSuspend is already suspended, we don't need to set it again.
config.mSuspend = (config.mSuspend == nsISuspendedTypes::NONE_SUSPENDED) ?
window->GetMediaSuspend() : config.mSuspend;
nsCOMPtr<nsPIDOMWindow> win = window->GetScriptableParentOrNull();
if (!win) {
@@ -409,6 +367,21 @@ AudioChannelService::GetState(nsPIDOMWindow* aWindow, uint32_t aAudioChannel,
// If there is no parent, or we are the toplevel we don't continue.
} while (window && window != aWindow);
return config;
}
void
AudioChannelService::AudioAudibleChanged(AudioChannelAgent* aAgent,
AudibleState aAudible)
{
MOZ_ASSERT(aAgent);
uint64_t windowID = aAgent->WindowID();
AudioChannelWindow* winData = GetWindowData(windowID);
if (winData) {
winData->AudioAudibleChanged(aAgent, aAudible);
}
}
bool
@@ -613,7 +586,8 @@ AudioChannelService::RefreshAgentsVolumeAndPropagate(AudioChannel aAudioChannel,
}
void
AudioChannelService::RefreshAgentsVolume(nsPIDOMWindow* aWindow)
AudioChannelService::RefreshAgents(nsPIDOMWindow* aWindow,
mozilla::function<void(AudioChannelAgent*)> aFunc)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
@@ -631,10 +605,27 @@ AudioChannelService::RefreshAgentsVolume(nsPIDOMWindow* aWindow)
nsTObserverArray<AudioChannelAgent*>::ForwardIterator
iter(winData->mAgents);
while (iter.HasMore()) {
iter.GetNext()->WindowVolumeChanged();
aFunc(iter.GetNext());
}
}
void
AudioChannelService::RefreshAgentsVolume(nsPIDOMWindow* aWindow)
{
RefreshAgents(aWindow, [] (AudioChannelAgent* agent) {
agent->WindowVolumeChanged();
});
}
void
AudioChannelService::RefreshAgentsSuspend(nsPIDOMWindow* aWindow,
nsSuspendedTypes aSuspend)
{
RefreshAgents(aWindow, [aSuspend] (AudioChannelAgent* agent) {
agent->WindowSuspendChanged(aSuspend);
});
}
void
AudioChannelService::SetWindowAudioCaptured(nsPIDOMWindow* aWindow,
uint64_t aInnerWindowID,
@@ -1032,3 +1023,146 @@ AudioChannelService::IsAudioChannelMutedByDefault()
CreateServiceIfNeeded();
return sAudioChannelMutedByDefault;
}
void
AudioChannelService::AudioChannelWindow::AppendAgent(AudioChannelAgent* aAgent,
AudibleState aAudible)
{
MOZ_ASSERT(aAgent);
AppendAgentAndIncreaseAgentsNum(aAgent);
AudioCapturedChanged(aAgent, AudioCaptureState::eCapturing);
AudioAudibleChanged(aAgent, aAudible);
}
void
AudioChannelService::AudioChannelWindow::RemoveAgent(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
RemoveAgentAndReduceAgentsNum(aAgent);
AudioCapturedChanged(aAgent, AudioCaptureState::eNotCapturing);
AudioAudibleChanged(aAgent, AudibleState::eNotAudible);
}
void
AudioChannelService::AudioChannelWindow::AppendAgentAndIncreaseAgentsNum(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
MOZ_ASSERT(!mAgents.Contains(aAgent));
int32_t channel = aAgent->AudioChannelType();
mAgents.AppendElement(aAgent);
++mChannels[channel].mNumberOfAgents;
// The first one, we must inform the BrowserElementAudioChannel.
if (mChannels[channel].mNumberOfAgents == 1) {
NotifyChannelActive(aAgent->WindowID(),
static_cast<AudioChannel>(channel),
true);
}
}
void
AudioChannelService::AudioChannelWindow::RemoveAgentAndReduceAgentsNum(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
MOZ_ASSERT(mAgents.Contains(aAgent));
int32_t channel = aAgent->AudioChannelType();
mAgents.RemoveElement(aAgent);
MOZ_ASSERT(mChannels[channel].mNumberOfAgents > 0);
--mChannels[channel].mNumberOfAgents;
if (mChannels[channel].mNumberOfAgents == 0) {
NotifyChannelActive(aAgent->WindowID(),
static_cast<AudioChannel>(channel),
false);
}
}
void
AudioChannelService::AudioChannelWindow::AudioCapturedChanged(AudioChannelAgent* aAgent,
AudioCaptureState aCapture)
{
MOZ_ASSERT(aAgent);
if (mIsAudioCaptured) {
aAgent->WindowAudioCaptureChanged(aAgent->InnerWindowID(), aCapture);
}
}
void
AudioChannelService::AudioChannelWindow::AudioAudibleChanged(AudioChannelAgent* aAgent,
AudibleState aAudible)
{
MOZ_ASSERT(aAgent);
if (aAudible) {
AppendAudibleAgentIfNotContained(aAgent);
} else {
RemoveAudibleAgentIfContained(aAgent);
}
}
void
AudioChannelService::AudioChannelWindow::AppendAudibleAgentIfNotContained(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
MOZ_ASSERT(mAgents.Contains(aAgent));
if (!mAudibleAgents.Contains(aAgent)) {
mAudibleAgents.AppendElement(aAgent);
if (IsFirstAudibleAgent()) {
NotifyAudioAudibleChanged(aAgent->Window(), AudibleState::eAudible);
}
}
}
void
AudioChannelService::AudioChannelWindow::RemoveAudibleAgentIfContained(AudioChannelAgent* aAgent)
{
MOZ_ASSERT(aAgent);
if (mAudibleAgents.Contains(aAgent)) {
mAudibleAgents.RemoveElement(aAgent);
if (IsLastAudibleAgent()) {
NotifyAudioAudibleChanged(aAgent->Window(), AudibleState::eNotAudible);
}
}
}
bool
AudioChannelService::AudioChannelWindow::IsFirstAudibleAgent() const
{
return (mAudibleAgents.Length() == 1);
}
bool
AudioChannelService::AudioChannelWindow::IsLastAudibleAgent() const
{
return mAudibleAgents.IsEmpty();
}
void
AudioChannelService::AudioChannelWindow::NotifyAudioAudibleChanged(nsPIDOMWindow* aWindow,
AudibleState aAudible)
{
RefPtr<AudioPlaybackRunnable> runnable =
new AudioPlaybackRunnable(aWindow, aAudible);
nsresult rv = NS_DispatchToCurrentThread(runnable);
NS_WARN_IF(NS_FAILED(rv));
}
void
AudioChannelService::AudioChannelWindow::NotifyChannelActive(uint64_t aWindowID,
AudioChannel aChannel,
bool aActive)
{
RefPtr<NotifyChannelActiveRunnable> runnable =
new NotifyChannelActiveRunnable(aWindowID, aChannel, aActive);
nsresult rv = NS_DispatchToCurrentThread(runnable);
NS_WARN_IF(NS_FAILED(rv));
}
+84 -11
View File
@@ -16,6 +16,7 @@
#include "AudioChannelAgent.h"
#include "nsAttrValue.h"
#include "mozilla/dom/AudioChannelBinding.h"
#include "mozilla/Function.h"
class nsIRunnable;
class nsPIDOMWindow;
@@ -32,6 +33,33 @@ class TabParent;
#define NUMBER_OF_AUDIO_CHANNELS (uint32_t)AudioChannel::EndGuard_
class AudioPlaybackConfig
{
public:
AudioPlaybackConfig()
: mVolume(1.0)
, mMuted(false)
, mSuspend(nsISuspendedTypes::NONE_SUSPENDED)
{}
AudioPlaybackConfig(float aVolume, bool aMuted, uint32_t aSuspended)
: mVolume(aVolume)
, mMuted(aMuted)
, mSuspend(aSuspended)
{}
void SetConfig(float aVolume, bool aMuted, uint32_t aSuspended)
{
mVolume = aVolume;
mMuted = aMuted;
mSuspend = aSuspended;
}
float mVolume;
bool mMuted;
uint32_t mSuspend;
};
class AudioChannelService final : public nsIAudioChannelService
, public nsIObserver
{
@@ -40,6 +68,16 @@ public:
NS_DECL_NSIOBSERVER
NS_DECL_NSIAUDIOCHANNELSERVICE
enum AudibleState : bool {
eAudible = true,
eNotAudible = false
};
enum AudioCaptureState : bool {
eCapturing = true,
eNotCapturing = false
};
/**
* Returns the AudioChannelServce singleton.
* If AudioChannelServce is not exist, create and return new one.
@@ -56,7 +94,7 @@ public:
* this service, sharing the AudioChannel.
*/
void RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
AudioChannel aChannel);
AudibleState aAudible);
/**
* Any audio channel agent that stops playing should unregister itself to
@@ -72,10 +110,17 @@ public:
/**
* Return the state to indicate this audioChannel for his window should keep
* playing/muted.
* playing/muted/suspended.
*/
void GetState(nsPIDOMWindow* aWindow, uint32_t aChannel,
float* aVolume, bool* aMuted);
AudioPlaybackConfig GetMediaConfig(nsPIDOMWindow* aWindow,
uint32_t aAudioChannel) const;
/**
* Called this method when the audible state of the audio playback changed,
* it would dispatch the playback event to observers which want to know the
* actual audible state of the window.
*/
void AudioAudibleChanged(AudioChannelAgent* aAgent, AudibleState aAudible);
/* Methods for the BrowserElementAudioChannel */
float GetAudioChannelVolume(nsPIDOMWindow* aWindow, AudioChannel aChannel);
@@ -114,6 +159,8 @@ public:
bool AnyAudioChannelIsActive();
void RefreshAgentsVolume(nsPIDOMWindow* aWindow);
void RefreshAgentsSuspend(nsPIDOMWindow* aWindow,
nsSuspendedTypes aSuspend);
void RefreshAgentsVolumeAndPropagate(AudioChannel aAudioChannel,
nsPIDOMWindow* aWindow);
@@ -156,6 +203,9 @@ private:
AudioChannelService();
~AudioChannelService();
void RefreshAgents(nsPIDOMWindow* aWindow,
mozilla::function<void(AudioChannelAgent*)> aFunc);
static void CreateServiceIfNeeded();
/**
@@ -171,22 +221,21 @@ private:
void SetDefaultVolumeControlChannelInternal(int32_t aChannel,
bool aVisible, uint64_t aChildID);
struct AudioChannelConfig final
class AudioChannelConfig final : public AudioPlaybackConfig
{
public:
AudioChannelConfig()
: mVolume(1.0)
, mMuted(IsAudioChannelMutedByDefault())
: AudioPlaybackConfig(1.0, IsAudioChannelMutedByDefault(),
nsISuspendedTypes::NONE_SUSPENDED)
, mNumberOfAgents(0)
{}
float mVolume;
bool mMuted;
uint32_t mNumberOfAgents;
};
struct AudioChannelWindow final
class AudioChannelWindow final
{
public:
explicit AudioChannelWindow(uint64_t aWindowID)
: mWindowID(aWindowID),
mIsAudioCaptured(false)
@@ -195,12 +244,36 @@ private:
mChannels[(int16_t)AudioChannel::System].mMuted = false;
}
void AudioAudibleChanged(AudioChannelAgent* aAgent, AudibleState aAudible);
void AppendAgent(AudioChannelAgent* aAgent, AudibleState aAudible);
void RemoveAgent(AudioChannelAgent* aAgent);
uint64_t mWindowID;
bool mIsAudioCaptured;
AudioChannelConfig mChannels[NUMBER_OF_AUDIO_CHANNELS];
// Raw pointer because the AudioChannelAgent must unregister itself.
nsTObserverArray<AudioChannelAgent*> mAgents;
nsTObserverArray<AudioChannelAgent*> mAudibleAgents;
private:
void AudioCapturedChanged(AudioChannelAgent* aAgent,
AudioCaptureState aCapture);
void AppendAudibleAgentIfNotContained(AudioChannelAgent* aAgent);
void RemoveAudibleAgentIfContained(AudioChannelAgent* aAgent);
void AppendAgentAndIncreaseAgentsNum(AudioChannelAgent* aAgent);
void RemoveAgentAndReduceAgentsNum(AudioChannelAgent* aAgent);
bool IsFirstAudibleAgent() const;
bool IsLastAudibleAgent() const;
void NotifyAudioAudibleChanged(nsPIDOMWindow* aWindow,
AudibleState aAudible);
void NotifyChannelActive(uint64_t aWindowID, AudioChannel aChannel,
bool aActive);
};
AudioChannelWindow*
+79 -12
View File
@@ -6,6 +6,65 @@
interface nsIDOMWindow;
typedef uint32_t nsSuspendedTypes;
[scriptable, builtinclass, uuid(2822a840-f009-11e5-a837-0800200c9a66)]
interface nsISuspendedTypes : nsISupports
{
/**
* The suspended enum is used in three different situations,
* - platform audio focus (Fennec/B2G)
* - remote media control (Fennec)
* - block auto-play video in non-active page
*
* Note: the "remote side" must control the AudioChannelAgent using
* nsIAudioChannelAgentCallback.windowSuspendChanged() callback instead using
* play/pause methods or any button in the webpage.
*
* - SUSPENDED_PAUSE :
* It's used when transiently losing audio focus, the media can't be resumed
* until we gain the audio focus again. It would change the internal state of
* MediaElement when it's being suspended/resumed, and it would trigger the
* related JS event. eg. "play" and "pause" event.
*
* - SUSPENDED_BLOCK
* It's used to prevent auto-playing media in inactive page in order to
* reduce the power consumption, and the media can't be resumed until the
* page becomes active again. It would change the internal state of
* MediaElement when it's being blocked/resumed, so it won't trigger the
* related JS event. eg. "play" and "pause" event.
*
* - SUSPENDED_PAUSE_DISPOSABLE
* It's used for remote media-control to pause the playing media and when we
* lose audio focus permanently. It's disposable suspended, so the media can
* be resumed arbitrary after that. Same as SUSPENDED_PAUSE, it would change
* the internal state of MediaElement when it's being suspended.
*
* - SUSPENDED_STOP_DISPOSABLE
* It's used for remote media-control to stop the playing media. The remote
* control would disappear after stopping the media, so we would disconnect
* the audio channel agent. It's disposable suspended, so the media can be
* resumed arbitrary after that. Same as SUSPENDED_PAUSE, it would change
* the internal state of MediaElement when it's being suspended.
*/
const uint32_t NONE_SUSPENDED = 0;
const uint32_t SUSPENDED_PAUSE = 1;
const uint32_t SUSPENDED_BLOCK = 2;
const uint32_t SUSPENDED_PAUSE_DISPOSABLE = 3;
const uint32_t SUSPENDED_STOP_DISPOSABLE = 4;
};
%{C++
namespace mozilla {
namespace dom {
// It's defined in dom/audiochannel/AudioChannelService.h.
class AudioPlaybackConfig;
}
}
%}
[ptr] native AudioPlaybackConfig(mozilla::dom::AudioPlaybackConfig);
[uuid(0a451ee0-972e-11e5-a837-0800200c9a66)]
interface nsIAudioChannelAgentCallback : nsISupports
{
@@ -14,6 +73,11 @@ interface nsIAudioChannelAgentCallback : nsISupports
*/
void windowVolumeChanged(in float aVolume, in bool aMuted);
/**
* Notified when the window needs to be suspended or resumed.
*/
void windowSuspendChanged(in uint32_t aSuspend);
/**
* Notified when the capture state is changed.
*/
@@ -25,10 +89,8 @@ interface nsIAudioChannelAgentCallback : nsISupports
* in the audio channel service. Gecko components are responsible for
* 1. Indicating what channel type they are using (via the init() member
* function).
* 2. Before playing, checking the playable status of the channel.
* 3. Notifying the agent when they start/stop using this channel.
* 4. Notifying the agent of changes to the visibility of the component using
* this channel.
* 2. Notifying the agent when they start/stop using this channel.
* 3. Notifying the agent when they are audible.
*
* The agent will invoke a callback to notify Gecko components of
* 1. Changes to the playable status of this channel.
@@ -98,15 +160,10 @@ interface nsIAudioChannelAgent : nsISupports
* Note: Gecko component SHOULD call this function first then start to
* play audio stream only when return value is true.
*
* @return
* normal state: the agent has registered with audio channel service and
* the component should start playback.
* muted state: the agent has registered with audio channel service but
* the component should not start playback.
* faded state: the agent has registered with audio channel service the
* component should start playback as well as reducing the volume.
* @param config
* It contains the playback related states (volume/mute/suspend)
*/
void notifyStartedPlaying(out float volume, out bool muted);
void notifyStartedPlaying(in AudioPlaybackConfig config, in bool audible);
/**
* Notify the agent we no longer want to play.
@@ -117,4 +174,14 @@ interface nsIAudioChannelAgent : nsISupports
* called to unregister the agent with the channel service.
*/
void notifyStoppedPlaying();
/**
* Notify agent that we already start producing audible data.
*
* Note : sometime audio might become silent during playing, this method is used to
* notify the actually audible state to other services which want to know
* about that, ex. tab sound indicator.
*/
void notifyStartedAudible(in bool audible);
};
+1 -1
View File
@@ -523,7 +523,7 @@ Element::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
}
else {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
}
}
}
+5 -16
View File
@@ -363,11 +363,7 @@ EventSource::OnStartRequest(nsIRequest *aRequest,
return NS_ERROR_ABORT;
}
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &EventSource::AnnounceConnection);
NS_ENSURE_STATE(event);
rv = NS_DispatchToMainThread(event);
rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::AnnounceConnection));
NS_ENSURE_SUCCESS(rv, rv);
mStatus = PARSE_STATE_BEGIN_OF_STREAM;
@@ -473,11 +469,7 @@ EventSource::OnStopRequest(nsIRequest *aRequest,
ClearFields();
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &EventSource::ReestablishConnection);
NS_ENSURE_STATE(event);
rv = NS_DispatchToMainThread(event);
rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::ReestablishConnection));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@@ -899,11 +891,8 @@ EventSource::ConsoleError()
nsresult
EventSource::DispatchFailConnection()
{
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &EventSource::FailConnection);
NS_ENSURE_STATE(event);
return NS_DispatchToMainThread(event);
return NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::FailConnection));
}
void
@@ -977,7 +966,7 @@ EventSource::Thaw()
nsresult rv;
if (!mGoingToDispatchAllMessages && mMessagesToDispatch.GetSize() > 0) {
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
NS_ENSURE_STATE(event);
mGoingToDispatchAllMessages = true;
@@ -1037,7 +1026,7 @@ EventSource::DispatchCurrentMessageEvent()
if (!mGoingToDispatchAllMessages) {
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents);
NS_ENSURE_STATE(event);
mGoingToDispatchAllMessages = true;
+2 -2
View File
@@ -540,7 +540,7 @@ ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration)
doc->SetOrientationPendingPromise(nullptr);
}
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(this,
nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(this,
&ScreenOrientation::DispatchChangeEvent);
rv = NS_DispatchToMainThread(runnable);
NS_WARN_IF(NS_FAILED(rv));
@@ -615,7 +615,7 @@ ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent)
doc->SetOrientationPendingPromise(nullptr);
}
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(orientation,
nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(orientation,
&ScreenOrientation::DispatchChangeEvent);
rv = NS_DispatchToMainThread(runnable);
if (NS_WARN_IF(rv.Failed())) {
+3 -1
View File
@@ -218,7 +218,9 @@ WindowNamedPropertiesHandler::ownPropNames(JSContext* aCx,
return true;
}
nsHTMLDocument* document = static_cast<nsHTMLDocument*>(htmlDoc.get());
document->GetSupportedNames(flags, names);
// Document names are enumerable, so we want to get them no matter what flags
// is.
document->GetSupportedNames(names);
JS::AutoIdVector docProps(aCx);
if (!AppendNamedPropertyIds(aCx, aProxy, names, false, docProps)) {
+3 -3
View File
@@ -37,9 +37,9 @@ public:
delete_(JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId,
JS::ObjectOpResult &aResult) const override;
// No need for getPrototypeIfOrdinary here: this object shouldn't have a
// lazy prototype, so this trap would never be called (and the inherited
// version, from BaseProxyHandler, just crashes).
// No need for getPrototypeIfOrdinary here: window named-properties objects
// have static prototypes, so the version inherited from BaseDOMProxyHandler
// will do the right thing.
virtual bool
preventExtensions(JSContext* aCx, JS::Handle<JSObject*> aProxy,
+1 -5
View File
@@ -538,12 +538,8 @@ nsContentList::NamedItem(const nsAString& aName, bool aDoFlush)
}
void
nsContentList::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
nsContentList::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
BringSelfUpToDate(true);
AutoTArray<nsIAtom*, 8> atoms;
+1 -2
View File
@@ -294,8 +294,7 @@ public:
aFound = !!item;
return item;
}
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
// nsContentList public methods
uint32_t Length(bool aDoFlush);
+1 -1
View File
@@ -271,7 +271,7 @@ nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel)
"Already dispatched an event?");
mProcessLinkHeaderEvent =
NS_NewNonOwningRunnableMethod(this,
NewNonOwningRunnableMethod(this,
&nsContentSink::DoProcessLinkHeader);
rv = NS_DispatchToCurrentThread(mProcessLinkHeaderEvent.get());
if (NS_FAILED(rv)) {
+12 -5
View File
@@ -5035,22 +5035,29 @@ nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument)
/* static */
bool
nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable)
nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable)
{
if (!aRunnable) {
nsCOMPtr<nsIRunnable> runnable = aRunnable;
if (!runnable) {
return false;
}
if (sScriptBlockerCount) {
return sBlockedScriptRunners->AppendElement(aRunnable) != nullptr;
return sBlockedScriptRunners->AppendElement(runnable.forget()) != nullptr;
}
nsCOMPtr<nsIRunnable> run = aRunnable;
run->Run();
runnable->Run();
return true;
}
/* static */
bool
nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) {
nsCOMPtr<nsIRunnable> runnable = aRunnable;
return AddScriptRunner(runnable.forget());
}
/* static */
void
nsContentUtils::RunInStableState(already_AddRefed<nsIRunnable> aRunnable)
+1
View File
@@ -1592,6 +1592,7 @@ public:
* has not yet been AddRefed.
* @return false on out of memory, true otherwise.
*/
static bool AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable);
static bool AddScriptRunner(nsIRunnable* aRunnable);
/**
+1 -12
View File
@@ -163,20 +163,9 @@ nsDOMAttributeMap::NamedGetter(const nsAString& aAttrName, bool& aFound)
return GetAttribute(ni);
}
bool
nsDOMAttributeMap::NameIsEnumerable(const nsAString& aName)
{
return false;
}
void
nsDOMAttributeMap::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
nsDOMAttributeMap::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
// For HTML elements in HTML documents, only include names that are still the
// same after ASCII-lowercasing, since our named getter will end up
// ASCII-lowercasing the given string.
+1 -2
View File
@@ -139,7 +139,6 @@ public:
// WebIDL
Attr* GetNamedItem(const nsAString& aAttrName);
Attr* NamedGetter(const nsAString& aAttrName, bool& aFound);
bool NameIsEnumerable(const nsAString& aName);
already_AddRefed<Attr>
RemoveNamedItem(mozilla::dom::NodeInfo* aNodeInfo, ErrorResult& aError);
already_AddRefed<Attr>
@@ -159,7 +158,7 @@ public:
ErrorResult& aError);
void
GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
GetSupportedNames(nsTArray<nsString>& aNames);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+11 -11
View File
@@ -1044,7 +1044,7 @@ nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
if (!widget)
return NS_ERROR_FAILURE;
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
NS_DispatchToMainThread(NewRunnableMethod
<int32_t, int32_t, uint32_t, nsString, nsString, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeKeyEvent, aNativeKeyboardLayout,
aNativeKeyCode, aModifiers, aCharacters, aUnmodifiedCharacters, aObserver));
@@ -1066,7 +1066,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
if (!widget)
return NS_ERROR_FAILURE;
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
NS_DispatchToMainThread(NewRunnableMethod
<LayoutDeviceIntPoint, int32_t, int32_t, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeMouseEvent,
LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags,
@@ -1085,7 +1085,7 @@ nsDOMWindowUtils::SendNativeMouseMove(int32_t aScreenX,
if (!widget)
return NS_ERROR_FAILURE;
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
NS_DispatchToMainThread(NewRunnableMethod
<LayoutDeviceIntPoint, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeMouseMove,
LayoutDeviceIntPoint(aScreenX, aScreenY), aObserver));
@@ -1112,7 +1112,7 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
return NS_ERROR_FAILURE;
}
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
NS_DispatchToMainThread(NewRunnableMethod
<mozilla::LayoutDeviceIntPoint, uint32_t, double, double, double, uint32_t, uint32_t, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeMouseScrollEvent,
LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aDeltaX, aDeltaY,
@@ -1140,7 +1140,7 @@ nsDOMWindowUtils::SendNativeTouchPoint(uint32_t aPointerId,
return NS_ERROR_INVALID_ARG;
}
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
NS_DispatchToMainThread(NewRunnableMethod
<uint32_t, nsIWidget::TouchPointerState, LayoutDeviceIntPoint, double, uint32_t, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId,
(nsIWidget::TouchPointerState)aTouchState,
@@ -1162,7 +1162,7 @@ nsDOMWindowUtils::SendNativeTouchTap(int32_t aScreenX,
return NS_ERROR_FAILURE;
}
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs
NS_DispatchToMainThread(NewRunnableMethod
<LayoutDeviceIntPoint, bool, nsIObserver*>
(widget, &nsIWidget::SynthesizeNativeTouchTap,
LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, aObserver));
@@ -1179,7 +1179,7 @@ nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver)
return NS_ERROR_FAILURE;
}
NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<nsIObserver*>
NS_DispatchToMainThread(NewRunnableMethod<nsIObserver*>
(widget, &nsIWidget::ClearNativeTouchSequence, aObserver));
return NS_OK;
}
@@ -3763,22 +3763,22 @@ nsDOMWindowUtils::PostRestyleSelfEvent(nsIDOMElement* aElement)
}
NS_IMETHODIMP
nsDOMWindowUtils::GetMediaSuspended(bool* aSuspended)
nsDOMWindowUtils::GetMediaSuspend(uint32_t* aSuspend)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
*aSuspended = window->GetMediaSuspended();
*aSuspend = window->GetMediaSuspend();
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetMediaSuspended(bool aSuspended)
nsDOMWindowUtils::SetMediaSuspend(uint32_t aSuspend)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
window->SetMediaSuspended(aSuspended);
window->SetMediaSuspend(aSuspend);
return NS_OK;
}
+10 -10
View File
@@ -4351,7 +4351,7 @@ nsDocument::SetStyleSheetApplicableState(StyleSheetHandle aSheet,
}
if (!mSSApplicableStateNotificationPending) {
nsCOMPtr<nsIRunnable> notification = NS_NewRunnableMethod(this,
nsCOMPtr<nsIRunnable> notification = NewRunnableMethod(this,
&nsDocument::NotifyStyleSheetApplicableStateChanged);
mSSApplicableStateNotificationPending =
NS_SUCCEEDED(NS_DispatchToCurrentThread(notification));
@@ -4944,7 +4944,7 @@ nsDocument::MaybeEndOutermostXBLUpdate()
BindingManager()->EndOutermostUpdate();
} else if (!mInDestructor) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate));
NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate));
}
}
}
@@ -5262,7 +5262,7 @@ nsDocument::UnblockDOMContentLoaded()
MOZ_ASSERT(mReadyState == READYSTATE_INTERACTIVE);
if (!mSynchronousDOMContentLoaded) {
nsCOMPtr<nsIRunnable> ev =
NS_NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents);
NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents);
NS_DispatchToCurrentThread(ev);
} else {
DispatchContentLoadedEvents();
@@ -7243,7 +7243,7 @@ nsDocument::NotifyPossibleTitleChange(bool aBoundTitleElement)
return;
RefPtr<nsRunnableMethod<nsDocument, void, false> > event =
NS_NewNonOwningRunnableMethod(this,
NewNonOwningRunnableMethod(this,
&nsDocument::DoNotifyPossibleTitleChange);
nsresult rv = NS_DispatchToCurrentThread(event);
if (NS_SUCCEEDED(rv)) {
@@ -7392,7 +7392,7 @@ nsDocument::InitializeFrameLoader(nsFrameLoader* aLoader)
mInitializableFrameLoaders.AppendElement(aLoader);
if (!mFrameLoaderRunner) {
mFrameLoaderRunner =
NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY);
nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
}
@@ -7410,7 +7410,7 @@ nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader, nsIRunnable* aFinalizer)
mFrameLoaderFinalizers.AppendElement(aFinalizer);
if (!mFrameLoaderRunner) {
mFrameLoaderRunner =
NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY);
nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
}
@@ -7434,7 +7434,7 @@ nsDocument::MaybeInitializeFinalizeFrameLoaders()
(mInitializableFrameLoaders.Length() ||
mFrameLoaderFinalizers.Length())) {
mFrameLoaderRunner =
NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
}
return;
@@ -9032,7 +9032,7 @@ nsDocument::BlockOnload()
++mAsyncOnloadBlockCount;
if (mAsyncOnloadBlockCount == 1) {
bool success = nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsDocument::AsyncBlockOnload));
NewRunnableMethod(this, &nsDocument::AsyncBlockOnload));
// The script runner shouldn't fail to add. But if somebody broke
// something and it does, we'll thrash at 100% cpu forever. The best
@@ -12724,7 +12724,7 @@ nsDocument::GetVisibilityState() const
nsDocument::PostVisibilityUpdateEvent()
{
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &nsDocument::UpdateVisibilityState);
NewRunnableMethod(this, &nsDocument::UpdateVisibilityState);
NS_DispatchToMainThread(event);
}
@@ -13445,7 +13445,7 @@ nsIDocument::RebuildUserFontSet()
// change reflow).
if (!mPostedFlushUserFontSet) {
nsCOMPtr<nsIRunnable> ev =
NS_NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet);
NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet);
if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
mPostedFlushUserFontSet = true;
}
+41 -24
View File
@@ -619,7 +619,8 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
mMayHavePointerEnterLeaveEventListener(false),
mInnerObjectsFreed(false),
mIsModalContentWindow(false),
mIsActive(false), mIsBackground(false), mMediaSuspended(false),
mIsActive(false), mIsBackground(false),
mMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED),
mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false),
mDesktopModeViewport(false), mInnerWindow(nullptr),
mOuterWindow(aOuterWindow),
@@ -911,13 +912,14 @@ nsOuterWindowProxy::getPrototypeIfOrdinary(JSContext* cx,
//
// https://html.spec.whatwg.org/multipage/browsers.html#windowproxy-getprototypeof
//
// We nonetheless can implement it here using a non-"lazy" [[Prototype]],
// because wrapper-class handlers (particularly, XOW in FilteringWrapper.cpp)
// supply all the non-ordinary behavior.
// We nonetheless can implement it with a static [[Prototype]], because
// wrapper-class handlers (particularly, XOW in FilteringWrapper.cpp) supply
// all non-ordinary behavior.
//
// But from a spec point of view, it's the exact same object in both cases --
// only the observer's changed. So both cases *must* report non-ordinary,
// even if non-"lazy" [[Prototype]] usually means ordinary.
// only the observer's changed. So this getPrototypeIfOrdinary trap on the
// non-wrapper object *must* report non-ordinary, even if static [[Prototype]]
// usually means ordinary.
*isOrdinary = false;
return true;
}
@@ -2637,7 +2639,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
under normal circumstances, but bug 49615 describes a case.) */
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsGlobalWindow::ClearStatus));
NewRunnableMethod(this, &nsGlobalWindow::ClearStatus));
// Sometimes, WouldReuseInnerWindow() returns true even if there's no inner
// window (see bug 776497). Be safe.
@@ -2954,8 +2956,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// up with the outer. See bug 969156.
if (createdInnerWindow) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(newInnerWindow,
&nsGlobalWindow::FireOnNewGlobalObject));
NewRunnableMethod(newInnerWindow,
&nsGlobalWindow::FireOnNewGlobalObject));
}
if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) {
@@ -2968,7 +2970,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
nsContentUtils::IsSystemPrincipal(mDoc->NodePrincipal())) {
newInnerWindow->mHasNotifiedGlobalCreated = true;
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated));
NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated));
}
}
@@ -3917,30 +3919,29 @@ nsPIDOMWindow::CreatePerformanceObjectIfNeeded()
}
}
bool
nsPIDOMWindow::GetMediaSuspended() const
SuspendTypes
nsPIDOMWindow::GetMediaSuspend() const
{
if (IsInnerWindow()) {
return mOuterWindow->GetMediaSuspended();
return mOuterWindow->GetMediaSuspend();
}
return mMediaSuspended;
return mMediaSuspend;
}
void
nsPIDOMWindow::SetMediaSuspended(bool aSuspended)
nsPIDOMWindow::SetMediaSuspend(SuspendTypes aSuspend)
{
if (IsInnerWindow()) {
mOuterWindow->SetMediaSuspended(aSuspended);
mOuterWindow->SetMediaSuspend(aSuspend);
return;
}
if (mMediaSuspended == aSuspended) {
return;
if (!IsDisposableSuspend(aSuspend)) {
mMediaSuspend = aSuspend;
}
mMediaSuspended = aSuspended;
RefreshMediaElements();
RefreshMediaElementsSuspend(aSuspend);
}
bool
@@ -3966,7 +3967,7 @@ nsPIDOMWindow::SetAudioMuted(bool aMuted)
}
mAudioMuted = aMuted;
RefreshMediaElements();
RefreshMediaElementsVolume();
}
float
@@ -3995,12 +3996,12 @@ nsPIDOMWindow::SetAudioVolume(float aVolume)
}
mAudioVolume = aVolume;
RefreshMediaElements();
RefreshMediaElementsVolume();
return NS_OK;
}
void
nsPIDOMWindow::RefreshMediaElements()
nsPIDOMWindow::RefreshMediaElementsVolume()
{
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (service) {
@@ -4008,6 +4009,22 @@ nsPIDOMWindow::RefreshMediaElements()
}
}
void
nsPIDOMWindow::RefreshMediaElementsSuspend(SuspendTypes aSuspend)
{
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
if (service) {
service->RefreshAgentsSuspend(GetOuterWindow(), aSuspend);
}
}
bool
nsPIDOMWindow::IsDisposableSuspend(SuspendTypes aSuspend) const
{
return (aSuspend == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
aSuspend == nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE);
}
void
nsPIDOMWindow::SetServiceWorkersTestingEnabled(bool aEnabled)
{
@@ -12256,7 +12273,7 @@ public:
~AutoUnblockScriptClosing()
{
void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing;
NS_DispatchToCurrentThread(NS_NewRunnableMethod(mWin, run));
NS_DispatchToCurrentThread(NewRunnableMethod(mWin, run));
}
};
+2 -8
View File
@@ -90,7 +90,7 @@ nsMimeTypeArray::IndexedGetter(uint32_t aIndex, bool &aFound)
}
static nsMimeType*
FindMimeType(const nsTArray<RefPtr<nsMimeType> >& aMimeTypes,
FindMimeType(const nsTArray<RefPtr<nsMimeType>>& aMimeTypes,
const nsAString& aType)
{
for (uint32_t i = 0; i < aMimeTypes.Length(); ++i) {
@@ -122,12 +122,6 @@ nsMimeTypeArray::NamedGetter(const nsAString& aName, bool &aFound)
return nullptr;
}
bool
nsMimeTypeArray::NameIsEnumerable(const nsAString& aName)
{
return true;
}
uint32_t
nsMimeTypeArray::Length()
{
@@ -137,7 +131,7 @@ nsMimeTypeArray::Length()
}
void
nsMimeTypeArray::GetSupportedNames(unsigned, nsTArray< nsString >& aRetval)
nsMimeTypeArray::GetSupportedNames(nsTArray<nsString>& aRetval)
{
EnsurePluginMimeTypes();
+1 -2
View File
@@ -35,9 +35,8 @@ public:
nsMimeType* NamedItem(const nsAString& name);
nsMimeType* IndexedGetter(uint32_t index, bool &found);
nsMimeType* NamedGetter(const nsAString& name, bool &found);
bool NameIsEnumerable(const nsAString& name);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray< nsString >& retval);
void GetSupportedNames(nsTArray<nsString>& retval);
protected:
virtual ~nsMimeTypeArray();
+20 -4
View File
@@ -35,6 +35,8 @@ class nsPIWindowRoot;
class nsXBLPrototypeHandler;
struct nsTimeout;
typedef uint32_t SuspendTypes;
namespace mozilla {
namespace dom {
class AudioContext;
@@ -208,8 +210,8 @@ public:
virtual bool IsRunningTimeout() = 0;
// Audio API
bool GetMediaSuspended() const;
void SetMediaSuspended(bool aSuspended);
SuspendTypes GetMediaSuspend() const;
void SetMediaSuspend(SuspendTypes aSuspend);
bool GetAudioMuted() const;
void SetAudioMuted(bool aMuted);
@@ -233,7 +235,9 @@ protected:
void MaybeCreateDoc();
float GetAudioGlobalVolumeInternal(float aVolume);
void RefreshMediaElements();
void RefreshMediaElementsVolume();
void RefreshMediaElementsSuspend(SuspendTypes aSuspend);
bool IsDisposableSuspend(SuspendTypes aSuspend) const;
public:
// Internal getter/setter for the frame element, this version of the
@@ -850,7 +854,19 @@ protected:
// "active". Only used on outer windows.
bool mIsBackground;
bool mMediaSuspended;
/**
* The suspended types can be "disposable" or "permanent". This varable only
* stores the value about permanent suspend.
* - disposable
* To pause all playing media in that window, but doesn't affect the media
* which starts after that.
*
* - permanent
* To pause all media in that window, and also affect the media which starts
* after that.
*/
SuspendTypes mMediaSuspend;
bool mAudioMuted;
float mAudioVolume;
+2 -14
View File
@@ -225,12 +225,6 @@ nsPluginArray::NamedGetter(const nsAString& aName, bool &aFound)
return plugin;
}
bool
nsPluginArray::NameIsEnumerable(const nsAString& aName)
{
return true;
}
uint32_t
nsPluginArray::Length()
{
@@ -244,7 +238,7 @@ nsPluginArray::Length()
}
void
nsPluginArray::GetSupportedNames(unsigned, nsTArray<nsString>& aRetval)
nsPluginArray::GetSupportedNames(nsTArray<nsString>& aRetval)
{
aRetval.Clear();
@@ -420,12 +414,6 @@ nsPluginElement::NamedGetter(const nsAString& aName, bool &aFound)
return nullptr;
}
bool
nsPluginElement::NameIsEnumerable(const nsAString& aName)
{
return true;
}
uint32_t
nsPluginElement::Length()
{
@@ -435,7 +423,7 @@ nsPluginElement::Length()
}
void
nsPluginElement::GetSupportedNames(unsigned, nsTArray<nsString>& retval)
nsPluginElement::GetSupportedNames(nsTArray<nsString>& retval)
{
EnsurePluginMimeTypes();
+2 -4
View File
@@ -49,9 +49,8 @@ public:
void Refresh(bool aReloadDocuments);
nsPluginElement* IndexedGetter(uint32_t aIndex, bool &aFound);
nsPluginElement* NamedGetter(const nsAString& aName, bool &aFound);
bool NameIsEnumerable(const nsAString& aName);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>& aRetval);
void GetSupportedNames(nsTArray<nsString>& aRetval);
private:
virtual ~nsPluginArray();
@@ -90,9 +89,8 @@ public:
nsMimeType* NamedItem(const nsAString& name);
nsMimeType* IndexedGetter(uint32_t index, bool &found);
nsMimeType* NamedGetter(const nsAString& name, bool &found);
bool NameIsEnumerable(const nsAString& aName);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>& retval);
void GetSupportedNames(nsTArray<nsString>& retval);
nsTArray<RefPtr<nsMimeType> >& MimeTypes();
+6 -8
View File
@@ -523,8 +523,8 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
if (!scriptURI) {
// Asynchronously report the failure to create a URI object
NS_DispatchToCurrentThread(
NS_NewRunnableMethod(aElement,
&nsIScriptElement::FireErrorEvent));
NewRunnableMethod(aElement,
&nsIScriptElement::FireErrorEvent));
return false;
}
@@ -590,8 +590,8 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
if (NS_FAILED(rv)) {
// Asynchronously report the load failure
NS_DispatchToCurrentThread(
NS_NewRunnableMethod(aElement,
&nsIScriptElement::FireErrorEvent));
NewRunnableMethod(aElement,
&nsIScriptElement::FireErrorEvent));
return false;
}
}
@@ -1170,10 +1170,8 @@ void
nsScriptLoader::ProcessPendingRequestsAsync()
{
if (mParserBlockingRequest || !mPendingChildLoaders.IsEmpty()) {
nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this,
&nsScriptLoader::ProcessPendingRequests);
NS_DispatchToCurrentThread(ev);
NS_DispatchToCurrentThread(NewRunnableMethod(this,
&nsScriptLoader::ProcessPendingRequests));
}
}
+1 -2
View File
@@ -273,8 +273,7 @@ nsAttributeTextNode::AttributeChanged(nsIDocument* aDocument,
// that if we get unbound while the event is up that's ok -- we'll just
// have no grandparent when it fires, and will do nothing.
void (nsAttributeTextNode::*update)() = &nsAttributeTextNode::UpdateText;
nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, update);
nsContentUtils::AddScriptRunner(ev);
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update));
}
}
Binary file not shown.
+31 -25
View File
@@ -10975,15 +10975,11 @@ class CGDOMJSProxyHandler_getOwnPropDescriptor(ClassMethod):
if self.descriptor.supportsNamedProperties():
operations = self.descriptor.operations
readonly = toStringBool(operations['NamedSetter'] is None)
enumerable = (
"self->NameIsEnumerable(Constify(%s))" %
# First [0] means first (and only) signature, [1] means
# "arguments" as opposed to return type, [0] means first (and
# only) argument.
operations['NamedGetter'].signatures()[0][1][0].identifier.name)
fillDescriptor = (
"FillPropertyDescriptor(desc, proxy, %s, %s);\n"
"return true;\n" % (readonly, enumerable))
"return true;\n" %
(readonly,
toStringBool(self.descriptor.namedPropertiesEnumerable)))
templateValues = {'jsvalRef': 'desc.value()', 'jsvalHandle': 'desc.value()',
'obj': 'proxy', 'successCode': fillDescriptor}
@@ -11299,14 +11295,17 @@ class CGDOMJSProxyHandler_ownPropNames(ClassMethod):
shadow = "false"
addNames = fill(
"""
nsTArray<nsString> names;
UnwrapProxy(proxy)->GetSupportedNames(flags, names);
UnwrapProxy(proxy)->GetSupportedNames(names);
if (!AppendNamedPropertyIds(cx, proxy, names, ${shadow}, props)) {
return false;
}
""",
shadow=shadow)
if not self.descriptor.namedPropertiesEnumerable:
addNames = CGIfWrapper(CGGeneric(addNames),
"flags & JSITER_HIDDEN").define()
addNames = "\n" + addNames
else:
addNames = ""
@@ -11666,6 +11665,23 @@ class CGDOMJSProxyHandler_getInstance(ClassMethod):
""")
class CGDOMJSProxyHandler_getPrototypeIfOrdinary(ClassMethod):
def __init__(self):
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'proxy'),
Argument('bool*', 'isOrdinary'),
Argument('JS::MutableHandle<JSObject*>', 'proto')]
ClassMethod.__init__(self, "getPrototypeIfOrdinary", "bool", args,
virtual=True, override=True, const=True)
def getBody(self):
return dedent("""
*isOrdinary = false;
return true;
""")
class CGDOMJSProxyHandler_call(ClassMethod):
def __init__(self):
args = [Argument('JSContext*', 'cx'),
@@ -11697,7 +11713,8 @@ class CGDOMJSProxyHandler_isCallable(ClassMethod):
class CGDOMJSProxyHandler(CGClass):
def __init__(self, descriptor):
assert (descriptor.supportsIndexedProperties() or
descriptor.supportsNamedProperties())
descriptor.supportsNamedProperties() or
descriptor.hasNonOrdinaryGetPrototypeOf())
methods = [CGDOMJSProxyHandler_getOwnPropDescriptor(descriptor),
CGDOMJSProxyHandler_defineProperty(descriptor),
ClassUsingDeclaration("mozilla::dom::DOMProxyHandler",
@@ -11724,6 +11741,8 @@ class CGDOMJSProxyHandler(CGClass):
(descriptor.operations['NamedSetter'] is not None and
descriptor.interface.getExtendedAttribute('OverrideBuiltins'))):
methods.append(CGDOMJSProxyHandler_setCustom(descriptor))
if descriptor.hasNonOrdinaryGetPrototypeOf():
methods.append(CGDOMJSProxyHandler_getPrototypeIfOrdinary())
if descriptor.operations['LegacyCaller']:
methods.append(CGDOMJSProxyHandler_call())
methods.append(CGDOMJSProxyHandler_isCallable())
@@ -14107,7 +14126,7 @@ class CGBindingImplClass(CGClass):
[]),
{"infallible": True}))
# And if we support named properties we need to be able to
# enumerate the supported names and test whether they're enumerable.
# enumerate the supported names.
if descriptor.supportsNamedProperties():
self.methodDecls.append(
CGNativeMember(
@@ -14115,20 +14134,7 @@ class CGBindingImplClass(CGClass):
"GetSupportedNames",
(IDLSequenceType(None,
BuiltinTypes[IDLBuiltinType.Types.domstring]),
# Let's use unsigned long for the type here, though really
# it's just a C++ "unsigned"...
[FakeArgument(BuiltinTypes[IDLBuiltinType.Types.unsigned_long],
FakeMember(),
name="aFlags")]),
{"infallible": True}))
self.methodDecls.append(
CGNativeMember(
descriptor, FakeMember(),
"NameIsEnumerable",
(BuiltinTypes[IDLBuiltinType.Types.boolean],
[FakeArgument(BuiltinTypes[IDLBuiltinType.Types.domstring],
FakeMember(),
name="aName")]),
[]),
{"infallible": True}))
wrapArgs = [Argument('JSContext*', 'aCx'),
+19 -1
View File
@@ -515,7 +515,8 @@ class Descriptor(DescriptorProvider):
self.proxy = (self.supportsIndexedProperties() or
(self.supportsNamedProperties() and
not self.hasNamedPropertiesObject))
not self.hasNamedPropertiesObject) or
self.hasNonOrdinaryGetPrototypeOf())
if self.proxy:
if (not self.operations['IndexedGetter'] and
@@ -747,6 +748,9 @@ class Descriptor(DescriptorProvider):
def supportsNamedProperties(self):
return self.operations['NamedGetter'] is not None
def hasNonOrdinaryGetPrototypeOf(self):
return self.interface.getExtendedAttribute("NonOrdinaryGetPrototypeOf")
def needsConstructHookHolder(self):
assert self.interface.hasInterfaceObject()
return False
@@ -806,6 +810,20 @@ class Descriptor(DescriptorProvider):
return (self.interface.getExtendedAttribute("Global") or
self.interface.getExtendedAttribute("PrimaryGlobal"))
@property
def namedPropertiesEnumerable(self):
"""
Returns whether this interface should have enumerable named properties
"""
assert self.proxy
assert self.supportsNamedProperties()
iface = self.interface
while iface:
if iface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
return False
iface = iface.parent
return True
# Some utility methods
def getTypesFromDescriptor(descriptor):
+10
View File
@@ -251,6 +251,16 @@ BaseDOMProxyHandler::ownPropertyKeys(JSContext* cx,
return ownPropNames(cx, proxy, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, props);
}
bool
BaseDOMProxyHandler::getPrototypeIfOrdinary(JSContext* cx, JS::Handle<JSObject*> proxy,
bool* isOrdinary,
JS::MutableHandle<JSObject*> proto) const
{
*isOrdinary = true;
proto.set(GetStaticPrototype(proxy));
return true;
}
bool
BaseDOMProxyHandler::getOwnEnumerablePropertyKeys(JSContext* cx,
JS::Handle<JSObject*> proxy,
+4
View File
@@ -59,6 +59,10 @@ public:
virtual bool ownPropertyKeys(JSContext* cx, JS::Handle<JSObject*> proxy,
JS::AutoIdVector &props) const override;
virtual bool getPrototypeIfOrdinary(JSContext* cx, JS::Handle<JSObject*> proxy,
bool* isOrdinary,
JS::MutableHandle<JSObject*> proto) const override;
// We override getOwnEnumerablePropertyKeys() and implement it directly
// instead of using the default implementation, which would call
// ownPropertyKeys and then filter out the non-enumerable ones. This avoids
+20 -1
View File
@@ -1078,6 +1078,23 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
specialMembersSeen[memberType] = member
if self.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
# Check that we have a named getter.
if "named getters" not in specialMembersSeen:
raise WebIDLError(
"Interface with [LegacyUnenumerableNamedProperties] does "
"not have a named getter",
[self.location])
ancestor = self.parent
while ancestor:
if ancestor.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
raise WebIDLError(
"Interface with [LegacyUnenumerableNamedProperties] "
"inherits from another interface with "
"[LegacyUnenumerableNamedProperties]",
[self.location, ancestor.location])
ancestor = ancestor.parent
if self._isOnGlobalProtoChain:
# Make sure we have no named setters, creators, or deleters
for memberType in ["setter", "creator", "deleter"]:
@@ -1464,7 +1481,9 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
identifier == "Unforgeable" or
identifier == "UnsafeInPrerendering" or
identifier == "LegacyEventInit" or
identifier == "ProbablyShortLivingObject"):
identifier == "ProbablyShortLivingObject" or
identifier == "LegacyUnenumerableNamedProperties" or
identifier == "NonOrdinaryGetPrototypeOf"):
# Known extended attributes that do not take values
if not attr.noArguments():
raise WebIDLError("[%s] must take no arguments" % identifier,
@@ -0,0 +1,64 @@
def WebIDLTest(parser, harness):
parser.parse(
"""
interface Foo {};
[LegacyUnenumerableNamedProperties]
interface Bar : Foo {
getter long(DOMString name);
};
interface Baz : Bar {
getter long(DOMString name);
};
""");
results = parser.finish();
harness.check(len(results), 3, "Should have three interfaces")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyUnenumerableNamedProperties]
interface NoNamedGetter {
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyUnenumerableNamedProperties=Foo]
interface ShouldNotHaveArg {
getter long(DOMString name);
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyUnenumerableNamedProperties]
interface Foo {
getter long(DOMString name);
};
interface Bar : Foo {};
[LegacyUnenumerableNamedProperties]
interface Baz : Bar {
getter long(DOMString name);
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should have thrown.")
+9 -18
View File
@@ -1137,8 +1137,7 @@ public:
virtual nsISupports* GetParentObject();
void NamedGetter(const nsAString&, bool&, nsAString&);
bool NameIsEnumerable(const nsAString&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedGetterAndSetterAndNamedGetterInterface : public nsISupports,
@@ -1151,8 +1150,7 @@ public:
virtual nsISupports* GetParentObject();
void NamedGetter(const nsAString&, bool&, nsAString&);
bool NameIsEnumerable(const nsAString&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
int32_t IndexedGetter(uint32_t, bool&);
void IndexedSetter(uint32_t, int32_t);
uint32_t Length();
@@ -1169,10 +1167,9 @@ public:
uint32_t IndexedGetter(uint32_t, bool&);
void NamedGetter(const nsAString&, bool&, nsAString&);
bool NameIsEnumerable(const nsAString&);
void NamedItem(const nsAString&, nsAString&);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedSetterInterface : public nsISupports,
@@ -1201,8 +1198,7 @@ public:
void NamedSetter(const nsAString&, TestIndexedSetterInterface&);
TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&);
bool NameIsEnumerable(const nsAString&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedAndNamedSetterInterface : public nsISupports,
@@ -1219,9 +1215,8 @@ public:
uint32_t Length();
void NamedSetter(const nsAString&, TestIndexedSetterInterface&);
TestIndexedSetterInterface* NamedGetter(const nsAString&, bool&);
bool NameIsEnumerable(const nsAString&);
void SetNamedItem(const nsAString&, TestIndexedSetterInterface&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedAndNamedGetterAndSetterInterface : public TestIndexedSetterInterface
@@ -1230,14 +1225,13 @@ public:
uint32_t IndexedGetter(uint32_t, bool&);
uint32_t Item(uint32_t);
void NamedGetter(const nsAString&, bool&, nsAString&);
bool NameIsEnumerable(const nsAString&);
void NamedItem(const nsAString&, nsAString&);
void IndexedSetter(uint32_t, int32_t&);
void IndexedSetter(uint32_t, const nsAString&) = delete;
void NamedSetter(const nsAString&, const nsAString&);
void Stringify(nsAString&);
uint32_t Length();
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestCppKeywordNamedMethodsInterface : public nsISupports,
@@ -1299,8 +1293,7 @@ public:
void NamedDeleter(const nsAString&, bool&);
long NamedGetter(const nsAString&, bool&);
bool NameIsEnumerable(const nsAString&);
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestNamedDeleterWithRetvalInterface : public nsISupports,
@@ -1315,10 +1308,9 @@ public:
bool NamedDeleter(const nsAString&, bool&);
bool NamedDeleter(const nsAString&) = delete;
long NamedGetter(const nsAString&, bool&);
bool NameIsEnumerable(const nsAString&);
bool DelNamedItem(const nsAString&);
bool DelNamedItem(const nsAString&, bool&) = delete;
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestIndexedAndNamedDeleterInterface : public nsISupports,
@@ -1337,10 +1329,9 @@ public:
void NamedDeleter(const nsAString&, bool&);
void NamedDeleter(const nsAString&) = delete;
long NamedGetter(const nsAString&, bool&);
bool NameIsEnumerable(const nsAString&);
void DelNamedItem(const nsAString&);
void DelNamedItem(const nsAString&, bool&) = delete;
void GetSupportedNames(unsigned, nsTArray<nsString>&);
void GetSupportedNames(nsTArray<nsString>&);
};
class TestParentInterface : public nsISupports,
Binary file not shown.
+3 -6
View File
@@ -687,7 +687,7 @@ Context::ThreadsafeHandle::AllowToClose()
// Dispatch is guaranteed to succeed here because we block shutdown until
// all Contexts have been destroyed.
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread);
NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread);
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}
@@ -703,7 +703,7 @@ Context::ThreadsafeHandle::InvalidateAndAllowToClose()
// Dispatch is guaranteed to succeed here because we block shutdown until
// all Contexts have been destroyed.
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread);
NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread);
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
}
@@ -727,10 +727,7 @@ Context::ThreadsafeHandle::~ThreadsafeHandle()
// Dispatch is guaranteed to succeed here because we block shutdown until
// all Contexts have been destroyed.
nsCOMPtr<nsIRunnable> runnable =
NS_NewNonOwningRunnableMethod(mStrongRef.forget().take(), &Context::Release);
MOZ_ALWAYS_SUCCEEDS(
mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
NS_ProxyRelease(mOwningThread, mStrongRef.forget());
}
void
+2 -4
View File
@@ -1028,7 +1028,7 @@ private:
// May be on any thread, including STS event target. Non-owning runnable
// here since we are guaranteed the Action will survive until
// CompleteOnInitiatingThread is called.
nsCOMPtr<nsIRunnable> runnable = NS_NewNonOwningRunnableMethodWithArgs<nsresult>(
nsCOMPtr<nsIRunnable> runnable = NewNonOwningRunnableMethod<nsresult>(
this, &CachePutAllAction::OnAsyncCopyComplete, aRv);
MOZ_ALWAYS_SUCCEEDS(
mTargetThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL));
@@ -1877,9 +1877,7 @@ Manager::~Manager()
// Don't spin the event loop in the destructor waiting for the thread to
// shutdown. Defer this to the main thread, instead.
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(ioThread, &nsIThread::Shutdown);
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioThread, &nsIThread::Shutdown)));
}
void
+2 -6
View File
@@ -171,9 +171,7 @@ CameraPreviewMediaStream::SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Im
++mInvalidatePending;
}
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate);
NS_DispatchToMainThread(event);
NS_DispatchToMainThread(NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate));
}
void
@@ -184,9 +182,7 @@ CameraPreviewMediaStream::ClearCurrentFrame()
for (nsTArray<RefPtr<VideoFrameContainer> >::size_type i = 0; i < mVideoOutputs.Length(); ++i) {
VideoFrameContainer* output = mVideoOutputs[i];
output->ClearCurrentFrame();
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(output, &VideoFrameContainer::Invalidate);
NS_DispatchToMainThread(event);
NS_DispatchToMainThread(NewRunnableMethod(output, &VideoFrameContainer::Invalidate));
}
}
+3 -12
View File
@@ -239,10 +239,10 @@ CameraRecorderProfiles::~CameraRecorderProfiles()
}
void
CameraRecorderProfiles::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
CameraRecorderProfiles::GetSupportedNames(nsTArray<nsString>& aNames)
{
DOM_CAMERA_LOGT("%s:%d : this=%p, flags=0x%x\n",
__func__, __LINE__, this, aFlags);
DOM_CAMERA_LOGT("%s:%d : this=%p\n",
__func__, __LINE__, this);
if (!mCameraControl) {
aNames.Clear();
return;
@@ -275,15 +275,6 @@ CameraRecorderProfiles::NamedGetter(const nsAString& aName, bool& aFound)
return profile;
}
bool
CameraRecorderProfiles::NameIsEnumerable(const nsAString& aName)
{
DOM_CAMERA_LOGT("%s:%d : this=%p, name='%s' (always returns true)\n",
__func__, __LINE__, this, NS_ConvertUTF16toUTF8(aName).get());
return true;
}
void
CameraRecorderProfiles::OnHardwareClosed()
{
+1 -2
View File
@@ -161,8 +161,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
CameraRecorderProfile* NamedGetter(const nsAString& aName, bool& aFound);
bool NameIsEnumerable(const nsAString& aName);
void GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
virtual void OnHardwareClosed();
+2 -4
View File
@@ -73,10 +73,8 @@ public:
TrackID aInputTrackID) override
{
if (aTrackEvents & TRACK_EVENT_CREATED) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<TrackID>(
this, &TrackCreatedListener::DoNotifyTrackCreated, aID);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
aGraph->DispatchToMainThreadAfterStreamStateUpdate(NewRunnableMethod<TrackID>(
this, &TrackCreatedListener::DoNotifyTrackCreated, aID));
}
}
+3 -3
View File
@@ -233,11 +233,11 @@ CameraPermissionRequest::DispatchCallback(uint32_t aPermission)
{
nsCOMPtr<nsIRunnable> callbackRunnable;
if (aPermission == nsIPermissionManager::ALLOW_ACTION) {
callbackRunnable = NS_NewRunnableMethod(this, &CameraPermissionRequest::CallAllow);
callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallAllow);
} else {
callbackRunnable = NS_NewRunnableMethod(this, &CameraPermissionRequest::CallCancel);
callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallCancel);
}
return NS_DispatchToMainThread(callbackRunnable);
return NS_DispatchToMainThread(callbackRunnable.forget());
}
void
+2 -2
View File
@@ -488,7 +488,7 @@ DeviceStorageStatics::AddListener(nsDOMDeviceStorage* aListener)
MOZ_ASSERT(sInstance->mInitialized);
if (sInstance->mListeners.IsEmpty()) {
NS_DispatchToMainThread(
NS_NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Register));
NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Register));
}
RefPtr<ListenerWrapper> wrapper =
@@ -519,7 +519,7 @@ DeviceStorageStatics::RemoveListener(nsDOMDeviceStorage* aListener)
if (removed && sInstance->mListeners.IsEmpty()) {
NS_DispatchToMainThread(
NS_NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Deregister));
NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Deregister));
}
}
+2 -3
View File
@@ -371,9 +371,8 @@ EventListenerService::NotifyAboutMainThreadListenerChangeInternal(dom::EventTarg
if (!mPendingListenerChanges) {
mPendingListenerChanges = nsArrayBase::Create();
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(this,
&EventListenerService::NotifyPendingChanges);
NS_DispatchToCurrentThread(runnable);
NS_DispatchToCurrentThread(NewRunnableMethod(this,
&EventListenerService::NotifyPendingChanges));
}
RefPtr<EventListenerChange> changes = mPendingListenerChangesSet.Get(aTarget);
+1 -3
View File
@@ -79,9 +79,7 @@ FetchDriver::Fetch(FetchDriverObserver* aObserver)
MOZ_RELEASE_ASSERT(!mRequest->IsSynchronous(),
"Synchronous fetch not supported");
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableMethod(this, &FetchDriver::ContinueFetch);
return NS_DispatchToCurrentThread(r);
return NS_DispatchToCurrentThread(NewRunnableMethod(this, &FetchDriver::ContinueFetch));
}
nsresult
+19 -5
View File
@@ -14,6 +14,7 @@
#include "mozilla/dom/PFMRadioChild.h"
#include "mozilla/dom/FMRadioService.h"
#include "mozilla/dom/TypedArray.h"
#include "AudioChannelService.h"
#include "DOMRequest.h"
#include "nsDOMClassInfo.h"
#include "nsIDocShell.h"
@@ -452,10 +453,15 @@ FMRadio::EnableAudioChannelAgent()
{
NS_ENSURE_TRUE_VOID(mAudioChannelAgent);
float volume = 0.0;
bool muted = true;
mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
WindowVolumeChanged(volume, muted);
AudioPlaybackConfig config;
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config,
AudioChannelService::AudibleState::eAudible);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
WindowVolumeChanged(config.mVolume, config.mMuted);
WindowSuspendChanged(config.mSuspend);
mAudioChannelAgentEnabled = true;
}
@@ -463,8 +469,16 @@ FMRadio::EnableAudioChannelAgent()
NS_IMETHODIMP
FMRadio::WindowVolumeChanged(float aVolume, bool aMuted)
{
// TODO : Not support to change volume now, so we just close it.
IFMRadioService::Singleton()->EnableAudio(!aMuted);
// TODO: what about the volume?
return NS_OK;
}
NS_IMETHODIMP
FMRadio::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
bool enable = (aSuspend == nsISuspendedTypes::NONE_SUSPENDED);
IFMRadioService::Singleton()->EnableAudio(enable);
return NS_OK;
}
+1 -5
View File
@@ -160,12 +160,8 @@ HTMLAllCollection::NamedGetter(const nsAString& aID,
}
void
HTMLAllCollection::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
HTMLAllCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
// XXXbz this is very similar to nsContentList::GetSupportedNames,
// but has to check IsAllNamedElement for the name case.
AutoTArray<nsIAtom*, 8> atoms;
+1 -5
View File
@@ -62,11 +62,7 @@ public:
void NamedGetter(const nsAString& aName,
bool& aFound,
Nullable<OwningNodeOrHTMLCollection>& aResult);
void GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
bool NameIsEnumerable(const nsAString& aName)
{
return false;
}
void GetSupportedNames(nsTArray<nsString>& aNames);
void LegacyCall(JS::Handle<JS::Value>, const nsAString& aName,
Nullable<OwningNodeOrHTMLCollection>& aResult)
{
+2 -2
View File
@@ -223,7 +223,7 @@ HTMLCanvasPrintState::Done()
mCanvas->InvalidateCanvas();
}
RefPtr<nsRunnableMethod<HTMLCanvasPrintState> > doneEvent =
NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone);
NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone);
if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) {
mPendingNotify = true;
}
@@ -503,7 +503,7 @@ HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback)
mPrintState = new HTMLCanvasPrintState(this, mCurrentContext, aCallback);
RefPtr<nsRunnableMethod<HTMLCanvasElement> > renderEvent =
NS_NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback);
NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback);
return NS_DispatchToCurrentThread(renderEvent);
}
+1 -6
View File
@@ -390,13 +390,8 @@ HTMLFormControlsCollection::NamedGetter(const nsAString& aName,
}
void
HTMLFormControlsCollection::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
HTMLFormControlsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
FlushPendingNotifications();
// Just enumerate mNameLookupTable. This won't guarantee order, but
// that's OK, because the HTML5 spec doesn't define an order for
+1 -2
View File
@@ -53,8 +53,7 @@ public:
bool dummy;
NamedGetter(aName, dummy, aResult);
}
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
nsresult AddElementToTable(nsGenericHTMLFormElement* aChild,
const nsAString& aName);
+1 -7
View File
@@ -1540,14 +1540,8 @@ HTMLFormElement::NamedGetter(const nsAString& aName, bool &aFound)
return nullptr;
}
bool
HTMLFormElement::NameIsEnumerable(const nsAString& aName)
{
return true;
}
void
HTMLFormElement::GetSupportedNames(unsigned, nsTArray<nsString >& aRetval)
HTMLFormElement::GetSupportedNames(nsTArray<nsString >& aRetval)
{
// TODO https://www.w3.org/Bugs/Public/show_bug.cgi?id=22320
}
+1 -3
View File
@@ -393,9 +393,7 @@ public:
already_AddRefed<nsISupports>
NamedGetter(const nsAString& aName, bool &aFound);
bool NameIsEnumerable(const nsAString& aName);
void GetSupportedNames(unsigned, nsTArray<nsString >& aRetval);
void GetSupportedNames(nsTArray<nsString>& aRetval);
static int32_t
CompareFormControlPosition(Element* aElement1, Element* aElement2,
+2 -2
View File
@@ -614,7 +614,7 @@ HTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// loading.
if (LoadingEnabled()) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage));
NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage));
}
}
@@ -821,7 +821,7 @@ HTMLImageElement::CopyInnerTo(Element* aDest)
if (!dest->InResponsiveMode() &&
dest->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage));
NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage));
}
}
+1 -1
View File
@@ -4353,7 +4353,7 @@ HTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
ClearBrokenState();
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage));
NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage));
}
}
+2 -2
View File
@@ -184,10 +184,10 @@ HTMLLinkElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
}
void (HTMLLinkElement::*update)() = &HTMLLinkElement::UpdateStyleSheetInternal;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update));
void (HTMLLinkElement::*updateImport)() = &HTMLLinkElement::UpdateImport;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, updateImport));
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, updateImport));
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded"));
+222 -92
View File
@@ -827,8 +827,8 @@ void HTMLMediaElement::QueueLoadFromSourceTask()
{
ChangeDelayLoadStatus(true);
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_LOADING);
RunInStableState(
NS_NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren));
RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren);
RunInStableState(r);
}
void HTMLMediaElement::QueueSelectResourceTask()
@@ -838,8 +838,8 @@ void HTMLMediaElement::QueueSelectResourceTask()
return;
mHaveQueuedSelectResource = true;
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE);
RunInStableState(
NS_NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper));
RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper);
RunInStableState(r);
}
NS_IMETHODIMP HTMLMediaElement::Load()
@@ -1147,16 +1147,6 @@ static bool IsAutoplayEnabled()
return Preferences::GetBool("media.autoplay.enabled");
}
static bool IsScriptedAutoplayEnabled()
{
return Preferences::GetBool("media.autoplay.allowscripted");
}
static bool UseAudioChannelAPI()
{
return Preferences::GetBool("media.useAudioChannelAPI");
}
void HTMLMediaElement::UpdatePreloadAction()
{
PreloadAction nextAction = PRELOAD_UNDEFINED;
@@ -2213,6 +2203,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mAutoplayEnabled(true),
mPaused(true),
mMuted(0),
mAudioChannelSuspended(nsISuspendedTypes::NONE_SUSPENDED),
mStatsShowing(false),
mAllowCasting(false),
mIsCasting(false),
@@ -2373,21 +2364,7 @@ HTMLMediaElement::Play(ErrorResult& aRv)
nsresult
HTMLMediaElement::PlayInternal(bool aCallerIsChrome)
{
// Prevent media element from being auto-started by a script when
// media.autoplay.enabled=false
if (!mHasUserInteraction
&& !IsAutoplayEnabled()
&& !IsScriptedAutoplayEnabled()
&& !EventStateManager::IsHandlingUserInput()
&& !aCallerIsChrome) {
LOG(LogLevel::Debug, ("%p Blocked attempt to autoplay media.", this));
#if defined(MOZ_WIDGET_ANDROID)
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<nsIContent*>(this),
NS_LITERAL_STRING("MozAutoplayMediaBlocked"),
false,
false);
#endif
if (!IsAllowedToPlay()) {
return NS_OK;
}
@@ -2452,6 +2429,8 @@ HTMLMediaElement::PlayInternal(bool aCallerIsChrome)
mPaused = false;
mAutoplaying = false;
SetAudioChannelSuspended(nsISuspendedTypes::NONE_SUSPENDED);
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
// and our preload status.
AddRemoveSelfReference();
@@ -2768,7 +2747,7 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen
if (mDecoder) {
// When the MediaElement is binding to tree, the dormant status is
// aligned to document's hidden status.
mDecoder->NotifyOwnerActivityChanged();
mDecoder->NotifyOwnerActivityChanged(!IsHidden());
}
return rv;
@@ -2857,7 +2836,7 @@ void HTMLMediaElement::UnbindFromTree(bool aDeep,
if (mDecoder) {
MOZ_ASSERT(IsHidden());
mDecoder->NotifyOwnerActivityChanged();
mDecoder->NotifyOwnerActivityChanged(false);
}
}
@@ -3145,9 +3124,9 @@ public:
{
nsCOMPtr<nsIRunnable> event;
if (aBlocked == BLOCKED) {
event = NS_NewRunnableMethod(this, &StreamListener::DoNotifyBlocked);
event = NewRunnableMethod(this, &StreamListener::DoNotifyBlocked);
} else {
event = NS_NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked);
event = NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked);
}
aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
}
@@ -3156,7 +3135,7 @@ public:
{
if (event == EVENT_FINISHED) {
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &StreamListener::DoNotifyFinished);
NewRunnableMethod(this, &StreamListener::DoNotifyFinished);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
}
}
@@ -3164,7 +3143,7 @@ public:
{
MutexAutoLock lock(mMutex);
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData);
NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
}
virtual void NotifyOutput(MediaStreamGraph* aGraph,
@@ -3175,7 +3154,7 @@ public:
return;
mPendingNotifyOutput = true;
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &StreamListener::DoNotifyOutput);
NewRunnableMethod(this, &StreamListener::DoNotifyOutput);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
}
@@ -3225,11 +3204,13 @@ public:
const VideoSegment& video = static_cast<const VideoSegment&>(aQueuedMedia);
for (VideoSegment::ConstChunkIterator c(video); !c.IsEnded(); c.Next()) {
if (c->mFrame.GetIntrinsicSize() != gfx::IntSize(0,0)) {
mInitialSizeFound = true;
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethodWithArgs<gfx::IntSize>(
NewRunnableMethod<gfx::IntSize>(
this, &StreamSizeListener::ReceivedSize,
c->mFrame.GetIntrinsicSize());
aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget());
return;
}
}
}
@@ -3346,6 +3327,10 @@ void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags)
mMediaStreamListener->Forget();
mMediaStreamListener = nullptr;
}
// If the input is a media stream, we don't check its data and always regard
// it as audible when it's playing.
NotifyAudibleStateChanged(shouldPlay);
}
void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream)
@@ -4453,12 +4438,7 @@ bool HTMLMediaElement::IsBeingDestroyed()
void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
{
bool pauseElement = NotifyOwnerDocumentActivityChangedInternal();
if (pauseElement && mAudioChannelAgent &&
// On B2G, NotifyOwnerDocumentActivityChangedInternal may return true for
// two reasons: the document no longer being active, or the element being
// paused by the audio channel. However we are only interested in the
// first case here, so we need to filter out the second case.
(!UseAudioChannelAPI() || !ComputedMuted())) {
if (pauseElement && mAudioChannelAgent) {
// If the element is being paused since we are navigating away from the
// document, notify the audio channel agent.
// Be careful to ignore this event during a docshell frame swap.
@@ -4475,21 +4455,11 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
bool
HTMLMediaElement::NotifyOwnerDocumentActivityChangedInternal()
{
nsIDocument* ownerDoc = OwnerDoc();
if (mDecoder && !IsBeingDestroyed()) {
mDecoder->SetElementVisibility(!ownerDoc->Hidden());
mDecoder->NotifyOwnerActivityChanged();
mDecoder->NotifyOwnerActivityChanged(!IsHidden());
}
bool pauseElement = !IsActive();
// Only pause the element when we start playing. If we pause without playing
// audio, the resource loading would be affected unexpectedly. For example,
// the media element is muted by default, but we don't want this behavior
// interrupting the loading process.
if (UseAudioChannelAPI() && mAudioChannelAgent) {
pauseElement |= ComputedMuted();
}
SuspendOrResumeElement(pauseElement, !IsActive());
if (!mPausedForInactiveDocumentOrChannel &&
@@ -4537,7 +4507,7 @@ void HTMLMediaElement::AddRemoveSelfReference()
// Dispatch Release asynchronously so that we don't destroy this object
// inside a call stack of method calls on this object
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference);
NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference);
NS_DispatchToMainThread(event);
}
}
@@ -4903,33 +4873,6 @@ ImageContainer* HTMLMediaElement::GetImageContainer()
return container ? container->GetImageContainer() : nullptr;
}
nsresult HTMLMediaElement::UpdateChannelMuteState(float aVolume, bool aMuted)
{
if (mAudioChannelVolume != aVolume) {
mAudioChannelVolume = aVolume;
SetVolumeInternal();
}
// We have to mute this channel.
if (aMuted && !ComputedMuted()) {
SetMutedInternal(mMuted | MUTED_BY_AUDIO_CHANNEL);
if (UseAudioChannelAPI()) {
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptbegin"));
}
} else if (!aMuted && ComputedMuted()) {
SetMutedInternal(mMuted & ~MUTED_BY_AUDIO_CHANNEL);
if (UseAudioChannelAPI()) {
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptend"));
}
}
if (UseAudioChannelAPI()) {
SuspendOrResumeElement(ComputedMuted(), false);
}
return NS_OK;
}
bool
HTMLMediaElement::MaybeCreateAudioChannelAgent()
{
@@ -4950,6 +4893,11 @@ HTMLMediaElement::MaybeCreateAudioChannelAgent()
bool
HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
{
// It might be resumed from remote, we should keep the audio channel agent.
if (IsSuspendedByAudioChannel()) {
return true;
}
// Are we paused or muted
if (mPaused || Muted()) {
return false;
@@ -5026,29 +4974,197 @@ HTMLMediaElement::NotifyAudioChannelAgent(bool aPlaying)
AutoNoJSAPI nojsapi;
if (aPlaying) {
float volume = 0.0;
bool muted = true;
mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
WindowVolumeChanged(volume, muted);
// The reason we don't call NotifyStartedPlaying after the media element
// really becomes audible is because there is another case needs to block
// element as early as we can, we would hear sound leaking if we block it
// too late. In that case (block autoplay in non-visited-tab), we need to
// create a connection before decoding, because we don't want user hearing
// any sound.
AudioPlaybackConfig config;
nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config,
mIsAudioTrackAudible);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
WindowVolumeChanged(config.mVolume, config.mMuted);
WindowSuspendChanged(config.mSuspend);
} else {
mAudioChannelAgent->NotifyStoppedPlaying();
mAudioChannelAgent = nullptr;
}
}
NS_IMETHODIMP HTMLMediaElement::WindowVolumeChanged(float aVolume, bool aMuted)
NS_IMETHODIMP
HTMLMediaElement::WindowVolumeChanged(float aVolume, bool aMuted)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement, WindowVolumeChanged, this = %p, "
"aVolume = %f, aMuted = %d\n", this, aVolume, aMuted));
UpdateChannelMuteState(aVolume, aMuted);
if (mAudioChannelVolume != aVolume) {
mAudioChannelVolume = aVolume;
SetVolumeInternal();
}
if (UseAudioChannelAPI()) {
mPaused.SetCanPlay(!aMuted);
if (aMuted && !ComputedMuted()) {
SetMutedInternal(mMuted | MUTED_BY_AUDIO_CHANNEL);
} else if (!aMuted && ComputedMuted()) {
SetMutedInternal(mMuted & ~MUTED_BY_AUDIO_CHANNEL);
}
return NS_OK;
}
NS_IMETHODIMP
HTMLMediaElement::WindowSuspendChanged(SuspendTypes aSuspend)
{
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement, WindowSuspendChanged, this = %p, "
"aSuspend = %d\n", this, aSuspend));
switch (aSuspend) {
case nsISuspendedTypes::NONE_SUSPENDED:
ResumeFromAudioChannel();
break;
case nsISuspendedTypes::SUSPENDED_PAUSE:
case nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE:
PauseByAudioChannel(aSuspend);
break;
case nsISuspendedTypes::SUSPENDED_BLOCK:
BlockByAudioChannel();
break;
case nsISuspendedTypes::SUSPENDED_STOP_DISPOSABLE:
Pause();
break;
default:
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement, WindowSuspendChanged, this = %p, "
"Error : unknown suspended type!\n", this));
}
return NS_OK;
}
void
HTMLMediaElement::ResumeFromAudioChannel()
{
if (!IsSuspendedByAudioChannel()) {
return;
}
switch (mAudioChannelSuspended) {
case nsISuspendedTypes::SUSPENDED_PAUSE:
case nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE:
ResumeFromAudioChannelPaused(mAudioChannelSuspended);
break;
case nsISuspendedTypes::SUSPENDED_BLOCK:
ResumeFromAudioChannelBlocked();
break;
default:
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement, ResumeFromAudioChannel, this = %p, "
"Error : resume without suspended!\n", this));
}
}
void
HTMLMediaElement::ResumeFromAudioChannelPaused(SuspendTypes aSuspend)
{
MOZ_ASSERT(mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_PAUSE ||
mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE);
SetAudioChannelSuspended(nsISuspendedTypes::NONE_SUSPENDED);
nsresult rv = PlayInternal(nsContentUtils::IsCallerChrome());
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptend"));
}
void
HTMLMediaElement::ResumeFromAudioChannelBlocked()
{
MOZ_ASSERT(mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_BLOCK);
SetAudioChannelSuspended(nsISuspendedTypes::NONE_SUSPENDED);
mPaused.SetCanPlay(true);
SuspendOrResumeElement(false /* resume */, false);
}
void
HTMLMediaElement::PauseByAudioChannel(SuspendTypes aSuspend)
{
if (IsSuspendedByAudioChannel()) {
return;
}
SetAudioChannelSuspended(aSuspend);
Pause();
DispatchAsyncEvent(NS_LITERAL_STRING("mozinterruptbegin"));
}
void
HTMLMediaElement::BlockByAudioChannel()
{
if (IsSuspendedByAudioChannel()) {
return;
}
SetAudioChannelSuspended(nsISuspendedTypes::SUSPENDED_BLOCK);
SuspendOrResumeElement(true /* suspend */, false);
mPaused.SetCanPlay(false);
}
void
HTMLMediaElement::SetAudioChannelSuspended(SuspendTypes aSuspend)
{
if (mAudioChannelSuspended == aSuspend) {
return;
}
mAudioChannelSuspended = aSuspend;
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
("HTMLMediaElement, SetAudioChannelSuspended, this = %p, "
"aSuspend = %d\n", this, aSuspend));
}
bool
HTMLMediaElement::IsSuspendedByAudioChannel() const
{
return (mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_PAUSE ||
mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_PAUSE_DISPOSABLE ||
mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_BLOCK);
}
bool
HTMLMediaElement::IsAllowedToPlay()
{
// Prevent media element from being auto-started by a script when
// media.autoplay.enabled=false
if (!mHasUserInteraction &&
!IsAutoplayEnabled() &&
!EventStateManager::IsHandlingUserInput() &&
!nsContentUtils::IsCallerChrome()) {
#if defined(MOZ_WIDGET_ANDROID)
nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
static_cast<nsIContent*>(this),
NS_LITERAL_STRING("MozAutoplayMediaBlocked"),
false,
false);
#endif
return false;
}
// The MediaElement can't start playback until it's resumed by audio channel.
if (mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_PAUSE ||
mAudioChannelSuspended == nsISuspendedTypes::SUSPENDED_BLOCK) {
return false;
}
return true;
}
#ifdef MOZ_EME
MediaKeys*
HTMLMediaElement::GetMediaKeys() const
@@ -5388,6 +5504,12 @@ HTMLMediaElement::ComputedMuted() const
return (mMuted & MUTED_BY_AUDIO_CHANNEL);
}
nsSuspendedTypes
HTMLMediaElement::ComputedSuspended() const
{
return mAudioChannelSuspended;
}
bool
HTMLMediaElement::IsCurrentlyPlaying() const
{
@@ -5414,7 +5536,15 @@ HTMLMediaElement::NotifyAudibleStateChanged(bool aAudible)
{
if (mIsAudioTrackAudible != aAudible) {
mIsAudioTrackAudible = aAudible;
// To do ...
NotifyAudioPlaybackChanged();
}
}
void
HTMLMediaElement::NotifyAudioPlaybackChanged()
{
if (mAudioChannelAgent) {
mAudioChannelAgent->NotifyStartedAudible(mIsAudioTrackAudible);
}
}
+41 -5
View File
@@ -35,6 +35,7 @@
typedef uint16_t nsMediaNetworkState;
typedef uint16_t nsMediaReadyState;
typedef uint32_t SuspendTypes;
namespace mozilla {
class DecoderDoctorDiagnostics;
@@ -448,9 +449,13 @@ public:
// when the connection between Rtsp server and client gets lost.
virtual void ResetConnectionState() final override;
// Called by media decoder when the audible state changed.
// Called by media decoder when the audible state changed or when input is
// a media stream.
virtual void NotifyAudibleStateChanged(bool aAudible) final override;
// Notify agent when the MediaElement changes its audible state.
void NotifyAudioPlaybackChanged();
// XPCOM GetPreload() is OK
void SetPreload(const nsAString& aValue, ErrorResult& aRv)
{
@@ -719,9 +724,10 @@ public:
IMPL_EVENT_HANDLER(mozinterruptbegin)
IMPL_EVENT_HANDLER(mozinterruptend)
// This is for testing only
// These are used for testing only
float ComputedVolume() const;
bool ComputedMuted() const;
nsSuspendedTypes ComputedSuspended() const;
protected:
virtual ~HTMLMediaElement();
@@ -1112,9 +1118,6 @@ protected:
// Check the permissions for audiochannel.
bool CheckAudioChannelPermissions(const nsAString& aType);
// This method does the check for muting/nmuting the audio channel.
nsresult UpdateChannelMuteState(float aVolume, bool aMuted);
// Seeks to aTime seconds. aSeekType can be Exact to seek to exactly the
// seek target, or PrevSyncPoint if a quicker but less precise seek is
// desired, and we'll seek to the sync point (keyframe and/or start of the
@@ -1149,6 +1152,38 @@ protected:
// channel agent is ready to be used.
bool MaybeCreateAudioChannelAgent();
/**
* We have different kinds of suspended cases,
* - SUSPENDED_PAUSE
* It's used when we temporary lost platform audio focus. MediaElement can
* only be resumed when we gain the audio focus again.
*
* - SUSPENDED_PAUSE_DISPOSABLE
* It's used when user press the pause botton on the remote media-control.
* MediaElement can be resumed by reomte media-control or via play().
*
* - SUSPENDED_BLOCK
* It's used to reduce the power comsuption, we won't play the auto-play
* audio/video in the page we have never visited before. MediaElement would
* be resumed when the page is active. See bug647429 for more details.
*
* - SUSPENDED_STOP_DISPOSABLE
* When we permanently lost platform audio focus, we shuold stop playing
* and stop the audio channel agent. MediaElement can only be restarted by
* play().
*/
void PauseByAudioChannel(SuspendTypes aSuspend);
void BlockByAudioChannel();
void ResumeFromAudioChannel();
void ResumeFromAudioChannelPaused(SuspendTypes aSuspend);
void ResumeFromAudioChannelBlocked();
bool IsSuspendedByAudioChannel() const;
void SetAudioChannelSuspended(SuspendTypes aSuspend);
bool IsAllowedToPlay();
class nsAsyncEventRunner;
using nsGenericHTMLElement::DispatchEvent;
// For nsAsyncEventRunner.
@@ -1363,6 +1398,7 @@ protected:
};
uint32_t mMuted;
SuspendTypes mAudioChannelSuspended;
// True if the media statistics are currently being shown by the builtin
// video controls
+1 -1
View File
@@ -280,7 +280,7 @@ HTMLObjectElement::BindToTree(nsIDocument *aDocument,
// If we already have all the children, start the load.
if (mIsDoneAddingChildren && !pluginDoc) {
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start));
}
return NS_OK;
+1 -6
View File
@@ -280,13 +280,8 @@ HTMLOptionsCollection::NamedItem(const nsAString& aName,
}
void
HTMLOptionsCollection::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
AutoTArray<nsIAtom*, 8> atoms;
for (uint32_t i = 0; i < mElements.Length(); ++i) {
HTMLOptionElement* content = mElements.ElementAt(i);
+1 -2
View File
@@ -154,8 +154,7 @@ public:
{
aError = SetOption(aIndex, aOption);
}
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
private:
/** The list of options (holds strong references). This is infallible, so
+1 -1
View File
@@ -288,7 +288,7 @@ HTMLPropertiesCollection::CrawlSubtree(Element* aElement)
}
void
HTMLPropertiesCollection::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
HTMLPropertiesCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
EnsureFresh();
mNames->CopyList(aNames);
+1 -6
View File
@@ -90,17 +90,12 @@ public:
aFound = IsSupportedNamedProperty(aName);
return aFound ? NamedItem(aName) : nullptr;
}
bool NameIsEnumerable(const nsAString& aName)
{
return true;
}
DOMStringList* Names()
{
EnsureFresh();
return mNames;
}
virtual void GetSupportedNames(unsigned,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
NS_DECL_NSIDOMHTMLCOLLECTION
+1 -1
View File
@@ -153,7 +153,7 @@ HTMLSharedObjectElement::BindToTree(nsIDocument *aDocument,
if (mIsDoneAddingChildren && !pluginDoc) {
void (HTMLSharedObjectElement::*start)() =
&HTMLSharedObjectElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start));
}
return NS_OK;
+1 -1
View File
@@ -147,7 +147,7 @@ HTMLStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
NS_ENSURE_SUCCESS(rv, rv);
void (HTMLStyleElement::*update)() = &HTMLStyleElement::UpdateStyleSheetInternal;
nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update));
return rv;
}
+3 -9
View File
@@ -41,8 +41,7 @@ public:
virtual Element*
GetFirstNamedElement(const nsAString& aName, bool& aFound) override;
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;
NS_IMETHOD ParentDestroyed();
@@ -236,18 +235,13 @@ TableRowsCollection::GetFirstNamedElement(const nsAString& aName, bool& aFound)
}
void
TableRowsCollection::GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames)
TableRowsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
if (!(aFlags & JSITER_HIDDEN)) {
return;
}
DO_FOR_EACH_ROWGROUP(
nsTArray<nsString> names;
nsCOMPtr<nsIHTMLCollection> coll = do_QueryInterface(rows);
if (coll) {
coll->GetSupportedNames(aFlags, names);
coll->GetSupportedNames(names);
for (uint32_t i = 0; i < names.Length(); ++i) {
if (!aNames.Contains(names[i])) {
aNames.AppendElement(names[i]);
+3 -3
View File
@@ -260,8 +260,8 @@ HTMLTrackElement::BindToTree(nsIDocument* aDocument,
media->NotifyAddedSource();
LOG(LogLevel::Debug, ("Track element sent notification to parent."));
mMediaParent->RunInStableState(
NS_NewRunnableMethod(this, &HTMLTrackElement::LoadResource));
RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLTrackElement::LoadResource);
mMediaParent->RunInStableState(r);
}
return NS_OK;
@@ -314,7 +314,7 @@ void
HTMLTrackElement::DispatchTrackRunnable(const nsString& aEventName)
{
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArg
NewRunnableMethod
<const nsString>(this,
&HTMLTrackElement::DispatchTrustedEvent,
aEventName);
+2 -2
View File
@@ -473,7 +473,7 @@ ImageDocument::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aDa
// come during painting and this will trigger invalidation.
if (aType == imgINotificationObserver::HAS_TRANSPARENCY) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &ImageDocument::OnHasTransparency);
NewRunnableMethod(this, &ImageDocument::OnHasTransparency);
nsContentUtils::AddScriptRunner(runnable);
}
@@ -534,7 +534,7 @@ ImageDocument::OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage)
aImage->GetHeight(&mImageHeight);
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing);
NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing);
nsContentUtils::AddScriptRunner(runnable);
UpdateTitleAndCharset();
+1 -7
View File
@@ -89,12 +89,6 @@ nsDOMStringMap::NamedGetter(const nsAString& aProp, bool& found,
found = mElement->GetAttr(attr, aResult);
}
bool
nsDOMStringMap::NameIsEnumerable(const nsAString& aName)
{
return true;
}
void
nsDOMStringMap::NamedSetter(const nsAString& aProp,
const nsAString& aValue,
@@ -149,7 +143,7 @@ nsDOMStringMap::NamedDeleter(const nsAString& aProp, bool& found)
}
void
nsDOMStringMap::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
nsDOMStringMap::GetSupportedNames(nsTArray<nsString>& aNames)
{
uint32_t attrCount = mElement->GetAttrCount();
+1 -2
View File
@@ -42,8 +42,7 @@ public:
void NamedSetter(const nsAString& aProp, const nsAString& aValue,
mozilla::ErrorResult& rv);
void NamedDeleter(const nsAString& aProp, bool &found);
bool NameIsEnumerable(const nsAString& aName);
void GetSupportedNames(unsigned, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
js::ExpandoAndGeneration mExpandoAndGeneration;
+2 -8
View File
@@ -2326,14 +2326,8 @@ nsHTMLDocument::NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
aRetval.set(&val.toObject());
}
bool
nsHTMLDocument::NameIsEnumerable(const nsAString& aName)
{
return true;
}
void
nsHTMLDocument::GetSupportedNames(unsigned, nsTArray<nsString>& aNames)
nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames)
{
for (auto iter = mIdentifierMap.Iter(); !iter.Done(); iter.Next()) {
nsIdentifierMapEntry* entry = iter.Get();
@@ -2506,7 +2500,7 @@ nsHTMLDocument::MaybeEditingStateChanged()
EditingStateChanged();
} else if (!mInDestructor) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged));
NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged));
}
}
}
+1 -2
View File
@@ -174,8 +174,7 @@ public:
void NamedGetter(JSContext* cx, const nsAString& aName, bool& aFound,
JS::MutableHandle<JSObject*> aRetval,
mozilla::ErrorResult& rv);
bool NameIsEnumerable(const nsAString& aName);
void GetSupportedNames(unsigned, nsTArray<nsString>& aNames);
void GetSupportedNames(nsTArray<nsString>& aNames);
nsGenericHTMLElement *GetBody();
void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv);
mozilla::dom::HTMLSharedElement *GetHead() {
+1 -6
View File
@@ -69,15 +69,10 @@ public:
{
return GetFirstNamedElement(aName, aFound);
}
bool NameIsEnumerable(const nsAString& aName)
{
return false;
}
virtual mozilla::dom::Element*
GetFirstNamedElement(const nsAString& aName, bool& aFound) = 0;
virtual void GetSupportedNames(unsigned aFlags,
nsTArray<nsString>& aNames) = 0;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) = 0;
JSObject* GetWrapperPreserveColor()
{
+7 -7
View File
@@ -11599,7 +11599,7 @@ ConnectionPool::ShutdownThread(ThreadInfo& aThreadInfo)
MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(runnable, NS_DISPATCH_NORMAL));
nsCOMPtr<nsIRunnable> shutdownRunnable =
NS_NewRunnableMethod(thread, &nsIThread::Shutdown);
NewRunnableMethod(thread, &nsIThread::Shutdown);
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(shutdownRunnable));
mTotalThreadCount--;
@@ -13451,7 +13451,7 @@ Database::MaybeCloseConnection()
IsClosed() &&
mDirectoryLock) {
nsCOMPtr<nsIRunnable> callback =
NS_NewRunnableMethod(this, &Database::ConnectionClosedCallback);
NewRunnableMethod(this, &Database::ConnectionClosedCallback);
RefPtr<WaitForTransactionsHelper> helper =
new WaitForTransactionsHelper(Id(), callback);
@@ -17153,7 +17153,7 @@ QuotaClient::StartIdleMaintenance()
}
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArg<uint32_t>(
NewRunnableMethod<uint32_t>(
this,
&QuotaClient::FindDatabasesForIdleMaintenance,
mMaintenanceRunId);
@@ -17379,7 +17379,7 @@ QuotaClient::FindDatabasesForIdleMaintenance(uint32_t aRunId)
if (!databasePaths.IsEmpty()) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<uint32_t, MultipleMaintenanceInfo&&>(
NewRunnableMethod<uint32_t, MultipleMaintenanceInfo&&>(
this,
&QuotaClient::GetDirectoryLockForIdleMaintenance,
aRunId,
@@ -17448,7 +17448,7 @@ QuotaClient::ScheduleIdleMaintenance(uint32_t aRunId,
for (const nsString& databasePath : aMaintenanceInfo.mDatabasePaths) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<uint32_t,
NewRunnableMethod<uint32_t,
nsCString,
SingleMaintenanceInfo&&>(
this,
@@ -17483,7 +17483,7 @@ QuotaClient::PerformIdleMaintenanceOnDatabase(
PerformIdleMaintenanceOnDatabaseInternal(aRunId, aMaintenanceInfo);
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<nsCString, nsString>(
NewRunnableMethod<nsCString, nsString>(
this,
&QuotaClient::MaybeReleaseDirectoryLockForIdleMaintenance,
aKey,
@@ -21084,7 +21084,7 @@ OpenDatabaseOp::SendResults()
mDatabase = nullptr;
} else if (mDirectoryLock) {
nsCOMPtr<nsIRunnable> callback =
NS_NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback);
NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback);
RefPtr<WaitForTransactionsHelper> helper =
new WaitForTransactionsHelper(mDatabaseId, callback);
+1 -1
View File
@@ -87,7 +87,7 @@ private:
}
nsCOMPtr<nsIRunnable> destroyRunnable =
NS_NewNonOwningRunnableMethod(this, &StreamWrapper::Destroy);
NewNonOwningRunnableMethod(this, &StreamWrapper::Destroy);
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(destroyRunnable,
NS_DISPATCH_NORMAL));
+3 -3
View File
@@ -1038,9 +1038,9 @@ IDBDatabase::DelayedMaybeExpireFileActors()
}
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArg<bool>(this,
&IDBDatabase::ExpireFileActors,
/* aExpireAll */ false);
NewRunnableMethod<bool>(this,
&IDBDatabase::ExpireFileActors,
/* aExpireAll */ false);
MOZ_ASSERT(runnable);
if (!NS_IsMainThread()) {
+3 -3
View File
@@ -1744,10 +1744,10 @@ interface nsIDOMWindowUtils : nsISupports {
void postRestyleSelfEvent(in nsIDOMElement aElement);
/**
* Used to pause or resume all MediaElements in this window. Use-cases are
* audio competing and remote media control.
* Used to pause or resume all media in this window. Use-cases are audio
* competing, remote media control and to prevent auto-playing media.
*/
attribute boolean mediaSuspended;
attribute uint32_t mediaSuspend;
/**
* With this it's possible to mute all the MediaElements in this window.
+6 -10
View File
@@ -293,7 +293,7 @@ ReleaseOnTarget(SmartPtr<T>& aDoomed, nsIEventTarget* aTarget)
auto* doomedSupports = static_cast<nsISupports*>(doomedRaw);
nsCOMPtr<nsIRunnable> releaseRunnable =
NS_NewNonOwningRunnableMethod(doomedSupports, &nsISupports::Release);
NewNonOwningRunnableMethod(doomedSupports, &nsISupports::Release);
MOZ_ASSERT(releaseRunnable);
if (aTarget) {
@@ -1600,11 +1600,7 @@ private:
NS_WARN_IF_FALSE(NS_SUCCEEDED(stream->Close()), "Failed to close stream!");
nsCOMPtr<nsIRunnable> shutdownRunnable =
NS_NewRunnableMethod(ioTarget, &nsIThread::Shutdown);
MOZ_ASSERT(shutdownRunnable);
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(shutdownRunnable));
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioTarget, &nsIThread::Shutdown)));
return NS_OK;
}
@@ -2138,7 +2134,7 @@ RemoteBlobImpl::Destroy()
}
nsCOMPtr<nsIRunnable> destroyRunnable =
NS_NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy);
NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy);
if (mActorTarget) {
destroyRunnable =
@@ -2566,7 +2562,7 @@ RemoteBlobImpl::Destroy()
}
nsCOMPtr<nsIRunnable> destroyRunnable =
NS_NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy);
NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy);
if (mActorTarget) {
destroyRunnable =
@@ -3422,7 +3418,7 @@ BlobChild::NoteDyingRemoteBlobImpl()
// on the owning thread, so we proxy here if necessary.
if (!IsOnOwningThread()) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewNonOwningRunnableMethod(this, &BlobChild::NoteDyingRemoteBlobImpl);
NewNonOwningRunnableMethod(this, &BlobChild::NoteDyingRemoteBlobImpl);
if (mEventTarget) {
runnable = new CancelableRunnableWrapper(runnable, mEventTarget);
@@ -4001,7 +3997,7 @@ BlobParent::NoteDyingRemoteBlobImpl()
// on the main thread, so we proxy here if necessary.
if (!IsOnOwningThread()) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewNonOwningRunnableMethod(this, &BlobParent::NoteDyingRemoteBlobImpl);
NewNonOwningRunnableMethod(this, &BlobParent::NoteDyingRemoteBlobImpl);
if (mEventTarget) {
runnable = new CancelableRunnableWrapper(runnable, mEventTarget);
+1 -2
View File
@@ -34,8 +34,7 @@ ContentBridgeChild::~ContentBridgeChild()
void
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
{
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
}
/*static*/ ContentBridgeChild*
+2 -4
View File
@@ -37,8 +37,7 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
if (os) {
os->RemoveObserver(this, "content-child-shutdown");
}
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy));
MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy));
}
/*static*/ ContentBridgeParent*
@@ -168,8 +167,7 @@ ContentBridgeParent::NotifyTabDestroyed()
{
int32_t numLiveTabs = ManagedPBrowserParent().Count();
if (numLiveTabs == 1) {
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentBridgeParent::Close));
MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::Close));
}
}
+6
View File
@@ -79,6 +79,12 @@ protected:
mIsForBrowser = aIsForBrowser;
}
void Close()
{
// Trick NewRunnableMethod
PContentBridgeParent::Close();
}
protected:
virtual bool
RecvSyncMessage(const nsString& aMsg,
+1 -1
View File
@@ -1573,7 +1573,7 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
hasRunOnce = true;
MOZ_ASSERT(!sFirstIdleTask);
RefPtr<CancelableRunnable> firstIdleTask = NewRunnableFunction(FirstIdle);
RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction(FirstIdle);
sFirstIdleTask = firstIdleTask;
MessageLoop::current()->PostIdleTask(firstIdleTask.forget());
+10 -7
View File
@@ -81,6 +81,7 @@
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/layers/PAPZParent.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/SharedBufferManagerParent.h"
#include "mozilla/layout/RenderFrameParent.h"
@@ -2166,9 +2167,10 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
// Destroy any processes created by this ContentParent
for(uint32_t i = 0; i < childIDArray.Length(); i++) {
ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
MessageLoop::current()->PostTask(
NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
MessageLoop::current()->PostTask(NewRunnableMethod
<ShutDownMethod>(cp,
&ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
}
cpm->RemoveContentProcess(this->ChildID());
@@ -2249,9 +2251,10 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
if (tabIds.Length() == 1) {
// In the case of normal shutdown, send a shutdown message to child to
// allow it to perform shutdown tasks.
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
MessageLoop::current()->PostTask(NewRunnableMethod
<ShutDownMethod>(this,
&ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
}
}
@@ -2540,7 +2543,7 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
// PBrowsers are created, because they rely on the Compositor
// already being around. (Creation is async, so can't happen
// on demand.)
bool useOffMainThreadCompositing = !!CompositorBridgeParent::CompositorLoop();
bool useOffMainThreadCompositing = !!CompositorThreadHolder::Loop();
if (useOffMainThreadCompositing) {
DebugOnly<bool> opened = PCompositorBridge::Open(this);
MOZ_ASSERT(opened);
+2 -3
View File
@@ -217,8 +217,7 @@ PreallocatedProcessManagerImpl::AllocateOnIdle()
return;
}
MessageLoop::current()->PostIdleTask(
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
MessageLoop::current()->PostIdleTask(NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
}
void
@@ -243,7 +242,7 @@ PreallocatedProcessManagerImpl::ScheduleDelayedNuwaFork()
return;
}
RefPtr<CancelableRunnable> task = NewRunnableMethod(
RefPtr<CancelableRunnable> task = NS_NewCancelableRunnableMethod(
this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
mPreallocateAppProcessTask = task;
MessageLoop::current()->PostDelayedTask(task.forget(),
+31 -41
View File
@@ -230,22 +230,6 @@ public:
} // namespace
template<>
struct RunnableMethodTraits<HangMonitorChild>
{
typedef HangMonitorChild Class;
static void RetainCallee(Class* obj) { }
static void ReleaseCallee(Class* obj) { }
};
template<>
struct RunnableMethodTraits<HangMonitorParent>
{
typedef HangMonitorParent Class;
static void RetainCallee(Class* obj) { }
static void ReleaseCallee(Class* obj) { }
};
/* HangMonitorChild implementation */
HangMonitorChild::HangMonitorChild(ProcessHangMonitor* aMonitor)
@@ -303,8 +287,7 @@ HangMonitorChild::ActorDestroy(ActorDestroyReason aWhy)
// We use a task here to ensure that IPDL is finished with this
// HangMonitorChild before it gets deleted on the main thread.
MonitorLoop()->PostTask(
NewRunnableMethod(this, &HangMonitorChild::ShutdownOnThread));
MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, &HangMonitorChild::ShutdownOnThread));
}
bool
@@ -390,9 +373,10 @@ HangMonitorChild::NotifySlowScript(nsITabChild* aTabChild,
}
nsAutoCString filename(aFileName);
MonitorLoop()->PostTask(
NewRunnableMethod(this, &HangMonitorChild::NotifySlowScriptAsync,
id, filename, aLineNo));
MonitorLoop()->PostTask(NewNonOwningRunnableMethod
<TabId, nsCString, unsigned>(this,
&HangMonitorChild::NotifySlowScriptAsync,
id, filename, aLineNo));
return SlowScriptAction::Continue;
}
@@ -420,10 +404,9 @@ HangMonitorChild::NotifyPluginHang(uint32_t aPluginId)
mSentReport = true;
// bounce to background thread
MonitorLoop()->PostTask(
NewRunnableMethod(this,
&HangMonitorChild::NotifyPluginHangAsync,
aPluginId));
MonitorLoop()->PostTask(NewNonOwningRunnableMethod<uint32_t>(this,
&HangMonitorChild::NotifyPluginHangAsync,
aPluginId));
}
void
@@ -445,8 +428,7 @@ HangMonitorChild::ClearHang()
if (mSentReport) {
// bounce to background thread
MonitorLoop()->PostTask(
NewRunnableMethod(this, &HangMonitorChild::ClearHangAsync));
MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, &HangMonitorChild::ClearHangAsync));
MonitorAutoLock lock(mMonitor);
mSentReport = false;
@@ -511,8 +493,8 @@ HangMonitorParent::Shutdown()
mProcess = nullptr;
}
MonitorLoop()->PostTask(
NewRunnableMethod(this, &HangMonitorParent::ShutdownOnThread));
MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this,
&HangMonitorParent::ShutdownOnThread));
while (!mShutdownDone) {
mMonitor.Wait();
@@ -832,8 +814,8 @@ HangMonitoredProcess::TerminateScript()
return NS_ERROR_UNEXPECTED;
}
ProcessHangMonitor::Get()->MonitorLoop()->PostTask(
NewRunnableMethod(mActor, &HangMonitorParent::TerminateScript));
ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor,
&HangMonitorParent::TerminateScript));
return NS_OK;
}
@@ -849,8 +831,8 @@ HangMonitoredProcess::BeginStartingDebugger()
return NS_ERROR_UNEXPECTED;
}
ProcessHangMonitor::Get()->MonitorLoop()->PostTask(
NewRunnableMethod(mActor, &HangMonitorParent::BeginStartingDebugger));
ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor,
&HangMonitorParent::BeginStartingDebugger));
return NS_OK;
}
@@ -866,8 +848,8 @@ HangMonitoredProcess::EndStartingDebugger()
return NS_ERROR_UNEXPECTED;
}
ProcessHangMonitor::Get()->MonitorLoop()->PostTask(
NewRunnableMethod(mActor, &HangMonitorParent::EndStartingDebugger));
ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor,
&HangMonitorParent::EndStartingDebugger));
return NS_OK;
}
@@ -1045,9 +1027,13 @@ mozilla::CreateHangMonitorParent(ContentParent* aContentParent,
HangMonitoredProcess* process = new HangMonitoredProcess(parent, aContentParent);
parent->SetProcess(process);
monitor->MonitorLoop()->PostTask(
NewRunnableMethod(parent, &HangMonitorParent::Open,
aTransport, aOtherPid, XRE_GetIOMessageLoop()));
monitor->MonitorLoop()->PostTask(NewNonOwningRunnableMethod
<mozilla::ipc::Transport*,
base::ProcessId,
MessageLoop*>(parent,
&HangMonitorParent::Open,
aTransport, aOtherPid,
XRE_GetIOMessageLoop()));
return parent;
}
@@ -1061,9 +1047,13 @@ mozilla::CreateHangMonitorChild(mozilla::ipc::Transport* aTransport,
ProcessHangMonitor* monitor = ProcessHangMonitor::GetOrCreate();
HangMonitorChild* child = new HangMonitorChild(monitor);
monitor->MonitorLoop()->PostTask(
NewRunnableMethod(child, &HangMonitorChild::Open,
aTransport, aOtherPid, XRE_GetIOMessageLoop()));
monitor->MonitorLoop()->PostTask(NewNonOwningRunnableMethod
<mozilla::ipc::Transport*,
base::ProcessId,
MessageLoop*>(child,
&HangMonitorChild::Open,
aTransport, aOtherPid,
XRE_GetIOMessageLoop()));
return child;
}
+1 -2
View File
@@ -660,8 +660,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
method = &nsJSChannel::NotifyListener;
}
nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, method);
nsresult rv = NS_DispatchToCurrentThread(ev);
nsresult rv = NS_DispatchToCurrentThread(mozilla::NewRunnableMethod(this, method));
if (NS_FAILED(rv)) {
loadGroup->RemoveRequest(this, nullptr, rv);
@@ -221,3 +221,4 @@ RewriteYoutubeEmbed=Rewriting old-style Youtube Flash embed (%S) to iframe embed
RewriteYoutubeEmbedInvalidQuery=Rewriting old-style Youtube Flash embed (%S) to iframe embed (%S). Query was invalid and removed from URL. Please update page to use iframe instead of embed/object, if possible.
# LOCALIZATION NOTE: Do not translate "ServiceWorker". %1$S is the ServiceWorker scope URL. %2$S is an error string.
PushMessageDecryptionFailure=The ServiceWorker for scope '%1$S' encountered an error decrypting a push message: '%2$S'. For help with encryption, please see https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Using_the_Push_API#Encryption
IIRFilterChannelCountChangeWarning=IIRFilterNode channel count changes may produce audio glitches.
+4 -5
View File
@@ -62,7 +62,7 @@ public:
// Return an event that will be notified when data arrives in MediaResource.
// MediaDecoderReader will register with this event to receive notifications
// in order to udpate buffer ranges.
// in order to update buffer ranges.
// Return null if this decoder doesn't support the event.
virtual MediaEventSource<void>* DataArrivedEvent()
{
@@ -74,10 +74,9 @@ protected:
public:
void DispatchUpdateEstimatedMediaDuration(int64_t aDuration)
{
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableMethodWithArg<int64_t>(this, &AbstractMediaDecoder::UpdateEstimatedMediaDuration,
aDuration);
NS_DispatchToMainThread(r);
NS_DispatchToMainThread(NewRunnableMethod<int64_t>(this,
&AbstractMediaDecoder::UpdateEstimatedMediaDuration,
aDuration));
}
virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
+4 -4
View File
@@ -192,13 +192,13 @@ public:
{
if (aTrackEvents & TRACK_EVENT_CREATED) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<TrackID, MediaSegment::Type, MediaStream*, TrackID>(
NewRunnableMethod<TrackID, MediaSegment::Type, MediaStream*, TrackID>(
this, &OwnedStreamListener::DoNotifyTrackCreated,
aID, aQueuedMedia.GetType(), aInputStream, aInputTrackID);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
} else if (aTrackEvents & TRACK_EVENT_ENDED) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<MediaStream*, TrackID>(
NewRunnableMethod<MediaStream*, TrackID>(
this, &OwnedStreamListener::DoNotifyTrackEnded,
aInputStream, aInputTrackID);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
@@ -282,7 +282,7 @@ public:
{
if (aTrackEvents & TRACK_EVENT_ENDED) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethodWithArgs<StorensRefPtrPassByPtr<MediaStream>, TrackID>(
NewRunnableMethod<StorensRefPtrPassByPtr<MediaStream>, TrackID>(
this, &PlaybackStreamListener::DoNotifyTrackEnded, aInputStream, aInputTrackID);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
}
@@ -291,7 +291,7 @@ public:
void NotifyFinishedTrackCreation(MediaStreamGraph* aGraph) override
{
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation);
NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation);
aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget());
}
+16 -5
View File
@@ -287,7 +287,7 @@ MediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes,
}
void
MediaDecoder::NotifyOwnerActivityChanged()
MediaDecoder::NotifyOwnerActivityChanged(bool aIsVisible)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -295,6 +295,8 @@ MediaDecoder::NotifyOwnerActivityChanged()
return;
}
SetElementVisibility(aIsVisible);
UpdateDormantState(false /* aDormantTimeout */, false /* aActivity */);
// Start dormant timer if necessary
StartDormantTimer();
@@ -330,10 +332,10 @@ MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
}
DECODER_LOG("UpdateDormantState aTimeout=%d aActivity=%d mIsDormant=%d "
"ownerActive=%d ownerHidden=%d mIsHeuristicDormant=%d "
"ownerActive=%d mIsVisible=%d mIsHeuristicDormant=%d "
"mPlayState=%s encrypted=%s",
aDormantTimeout, aActivity, mIsDormant, mOwner->IsActive(),
mOwner->IsHidden(), mIsHeuristicDormant, PlayStateStr(),
mIsVisible.Ref(), mIsHeuristicDormant, PlayStateStr(),
(!mInfo ? "Unknown" : (mInfo->IsEncrypted() ? "1" : "0")));
bool prevDormant = mIsDormant;
@@ -350,7 +352,7 @@ MediaDecoder::UpdateDormantState(bool aDormantTimeout, bool aActivity)
// Try to enable dormant by idle heuristic, when the owner is hidden.
bool prevHeuristicDormant = mIsHeuristicDormant;
mIsHeuristicDormant = false;
if (IsHeuristicDormantSupported() && mOwner->IsHidden()) {
if (IsHeuristicDormantSupported() && !mIsVisible) {
if (aDormantTimeout && !aActivity &&
(mPlayState == PLAY_STATE_PAUSED || IsEnded())) {
// Enable heuristic dormant
@@ -406,7 +408,7 @@ MediaDecoder::StartDormantTimer()
if (mIsHeuristicDormant ||
mShuttingDown ||
!mOwner->IsHidden() ||
mIsVisible ||
(mPlayState != PLAY_STATE_PAUSED &&
!IsEnded()))
{
@@ -572,6 +574,8 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
"MediaDecoder::mMediaSeekable (Canonical)")
, mMediaSeekableOnlyInBufferedRanges(AbstractThread::MainThread(), false,
"MediaDecoder::mMediaSeekableOnlyInBufferedRanges (Canonical)")
, mIsVisible(AbstractThread::MainThread(), !mOwner->IsHidden(),
"MediaDecoder::mIsVisible (Canonical)")
, mTelemetryReported(false)
{
MOZ_COUNT_CTOR(MediaDecoder);
@@ -1361,6 +1365,13 @@ MediaDecoder::DurationChanged()
}
}
void
MediaDecoder::SetElementVisibility(bool aIsVisible)
{
MOZ_ASSERT(NS_IsMainThread());
mIsVisible = aIsVisible;
}
void
MediaDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
{
+11 -5
View File
@@ -180,7 +180,7 @@ public:
// Dormant state is a state to free all scarce media resources
// (like hw video codec), did not decoding and stay dormant.
// It is used to share scarece media resources in system.
virtual void NotifyOwnerActivityChanged();
virtual void NotifyOwnerActivityChanged(bool aIsVisible);
void UpdateDormantState(bool aDormantTimeout, bool aActivity);
@@ -250,9 +250,6 @@ protected:
void UpdateEstimatedMediaDuration(int64_t aDuration) override;
public:
// Called from HTMLMediaElement when owner document activity changes
virtual void SetElementVisibility(bool aIsVisible) {}
// Set a flag indicating whether random seeking is supported
void SetMediaSeekable(bool aMediaSeekable);
// Set a flag indicating whether seeking is supported only in buffered ranges
@@ -368,6 +365,9 @@ private:
void SetAudioChannel(dom::AudioChannel aChannel) { mAudioChannel = aChannel; }
dom::AudioChannel GetAudioChannel() { return mAudioChannel; }
// Called from HTMLMediaElement when owner document activity changes
virtual void SetElementVisibility(bool aIsVisible);
/******
* The following methods must only be called on the main
* thread.
@@ -744,7 +744,7 @@ protected:
// start playing back again.
Mirror<int64_t> mPlaybackPosition;
// Used to distiguish whether the audio is producing sound.
// Used to distinguish whether the audio is producing sound.
Mirror<bool> mIsAudioDataAudible;
// Volume of playback. 0.0 = muted. 1.0 = full volume.
@@ -806,6 +806,9 @@ protected:
// True if the media is only seekable within its buffered ranges.
Canonical<bool> mMediaSeekableOnlyInBufferedRanges;
// True if the decoder is visible.
Canonical<bool> mIsVisible;
public:
AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() override;
AbstractCanonical<double>* CanonicalVolume() {
@@ -853,6 +856,9 @@ public:
AbstractCanonical<bool>* CanonicalMediaSeekableOnlyInBufferedRanges() {
return &mMediaSeekableOnlyInBufferedRanges;
}
AbstractCanonical<bool>* CanonicalIsVisible() {
return &mIsVisible;
}
private:
// Notify owner when the audible state changed
+12 -8
View File
@@ -85,8 +85,7 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder)
}
// Dispatch initialization that needs to happen on that task queue.
nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(this, &MediaDecoderReader::InitializationTask);
mTaskQueue->Dispatch(r.forget());
mTaskQueue->Dispatch(NewRunnableMethod(this, &MediaDecoderReader::InitializationTask));
}
void
@@ -133,17 +132,18 @@ size_t MediaDecoderReader::SizeOfAudioQueueInFrames()
return mAudioQueue.GetSize();
}
nsresult MediaDecoderReader::ResetDecode()
nsresult MediaDecoderReader::ResetDecode(TargetQueues aQueues /*= AUDIO_VIDEO*/)
{
VideoQueue().Reset();
AudioQueue().Reset();
mAudioDiscontinuity = true;
mVideoDiscontinuity = true;
mBaseAudioPromise.RejectIfExists(CANCELED, __func__);
mBaseVideoPromise.RejectIfExists(CANCELED, __func__);
if (aQueues == AUDIO_VIDEO) {
AudioQueue().Reset();
mAudioDiscontinuity = true;
mBaseAudioPromise.RejectIfExists(CANCELED, __func__);
}
return NS_OK;
}
@@ -184,6 +184,10 @@ MediaDecoderReader::UpdateBuffered()
mBuffered = GetBuffered();
}
void
MediaDecoderReader::VisibilityChanged()
{}
media::TimeIntervals
MediaDecoderReader::GetBuffered()
{
+8 -1
View File
@@ -73,6 +73,11 @@ public:
CANCELED
};
enum TargetQueues {
VIDEO_ONLY,
AUDIO_VIDEO
};
using MetadataPromise =
MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, IsExclusive>;
using MediaDataPromise =
@@ -125,7 +130,7 @@ public:
// The first samples of every stream produced after a ResetDecode() call
// *must* be marked as "discontinuities". If it's not, seeking work won't
// properly!
virtual nsresult ResetDecode();
virtual nsresult ResetDecode(TargetQueues aQueues = AUDIO_VIDEO);
// Requests one audio sample from the reader.
//
@@ -395,6 +400,8 @@ private:
// Recomputes mBuffered.
virtual void UpdateBuffered();
virtual void VisibilityChanged();
virtual void NotifyDataArrivedInternal() {}
// Overrides of this function should decodes an unspecified amount of
+6 -4
View File
@@ -316,7 +316,7 @@ MediaDecoderReaderWrapper::ReleaseMediaResources()
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources);
NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources);
mReader->OwnerThread()->Dispatch(r.forget());
}
@@ -325,12 +325,12 @@ MediaDecoderReaderWrapper::SetIdle()
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableMethod(mReader, &MediaDecoderReader::SetIdle);
NewRunnableMethod(mReader, &MediaDecoderReader::SetIdle);
mReader->OwnerThread()->Dispatch(r.forget());
}
void
MediaDecoderReaderWrapper::ResetDecode()
MediaDecoderReaderWrapper::ResetDecode(TargetQueues aQueues)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
@@ -338,7 +338,9 @@ MediaDecoderReaderWrapper::ResetDecode()
mVideoDataRequest.DisconnectIfExists();
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode);
NewRunnableMethod<TargetQueues>(mReader,
&MediaDecoderReader::ResetDecode,
aQueues);
mReader->OwnerThread()->Dispatch(r.forget());
}
+2 -1
View File
@@ -32,6 +32,7 @@ class MediaDecoderReaderWrapper {
typedef MediaDecoderReader::SeekPromise SeekPromise;
typedef MediaDecoderReader::WaitForDataPromise WaitForDataPromise;
typedef MediaDecoderReader::BufferedUpdatePromise BufferedUpdatePromise;
typedef MediaDecoderReader::TargetQueues TargetQueues;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReaderWrapper);
/*
@@ -255,7 +256,7 @@ public:
void ReleaseMediaResources();
void SetIdle();
void ResetDecode();
void ResetDecode(TargetQueues aQueues);
nsresult Init() { return mReader->Init(); }
bool IsWaitForDataSupported() const { return mReader->IsWaitForDataSupported(); }

Some files were not shown because too many files have changed in this diff Show More