Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/AudioTrack.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 et tw=78: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/dom/AudioTrack.h"
8
#include "mozilla/dom/AudioTrackBinding.h"
9
#include "mozilla/dom/AudioTrackList.h"
10
#include "mozilla/dom/HTMLMediaElement.h"
11
12
namespace mozilla {
13
namespace dom {
14
15
AudioTrack::AudioTrack(nsIGlobalObject* aOwnerGlobal,
16
                       const nsAString& aId,
17
                       const nsAString& aKind,
18
                       const nsAString& aLabel,
19
                       const nsAString& aLanguage,
20
                       bool aEnabled)
21
  : MediaTrack(aOwnerGlobal, aId, aKind, aLabel, aLanguage)
22
  , mEnabled(aEnabled)
23
0
{
24
0
}
25
26
JSObject*
27
AudioTrack::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
28
0
{
29
0
  return AudioTrack_Binding::Wrap(aCx, this, aGivenProto);
30
0
}
31
32
void
33
AudioTrack::SetEnabled(bool aEnabled)
34
0
{
35
0
  SetEnabledInternal(aEnabled, MediaTrack::DEFAULT);
36
0
}
37
38
void
39
AudioTrack::SetEnabledInternal(bool aEnabled, int aFlags)
40
0
{
41
0
  if (aEnabled == mEnabled) {
42
0
    return;
43
0
  }
44
0
  mEnabled = aEnabled;
45
0
46
0
  // If this AudioTrack is no longer in its original AudioTrackList, then
47
0
  // whether it is enabled or not has no effect on its original list.
48
0
  if (!mList) {
49
0
    return;
50
0
  }
51
0
52
0
  if (mEnabled) {
53
0
    HTMLMediaElement* element = mList->GetMediaElement();
54
0
    if (element) {
55
0
      element->NotifyMediaTrackEnabled(this);
56
0
    }
57
0
  } else {
58
0
    HTMLMediaElement* element = mList->GetMediaElement();
59
0
    if (element) {
60
0
      element->NotifyMediaTrackDisabled(this);
61
0
    }
62
0
  }
63
0
64
0
  if (!(aFlags & MediaTrack::FIRE_NO_EVENTS)) {
65
0
    mList->CreateAndDispatchChangeEvent();
66
0
  }
67
0
}
68
69
} // namespace dom
70
} //namespace mozilla