Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HTMLVideoElement.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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
#ifndef mozilla_dom_HTMLVideoElement_h
8
#define mozilla_dom_HTMLVideoElement_h
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/dom/HTMLMediaElement.h"
12
#include "mozilla/StaticPrefs.h"
13
14
namespace mozilla {
15
16
class FrameStatistics;
17
18
namespace dom {
19
20
class WakeLock;
21
class VideoPlaybackQuality;
22
23
class HTMLVideoElement final : public HTMLMediaElement
24
{
25
public:
26
  typedef mozilla::dom::NodeInfo NodeInfo;
27
28
  explicit HTMLVideoElement(already_AddRefed<NodeInfo>&& aNodeInfo);
29
30
  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLVideoElement, video)
31
32
  using HTMLMediaElement::GetPaused;
33
34
0
  virtual bool IsVideo() const override {
35
0
    return true;
36
0
  }
37
38
  virtual bool ParseAttribute(int32_t aNamespaceID,
39
                              nsAtom* aAttribute,
40
                              const nsAString& aValue,
41
                              nsIPrincipal* aMaybeScriptedPrincipal,
42
                              nsAttrValue& aResult) override;
43
  NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
44
45
  static void Init();
46
47
  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
48
49
  virtual nsresult Clone(NodeInfo*, nsINode** aResult) const override;
50
51
  // Set size with the current video frame's height and width.
52
  // If there is no video frame, returns NS_ERROR_FAILURE.
53
  nsresult GetVideoSize(nsIntSize* size);
54
55
  virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel) override;
56
57
  // Element
58
  virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
59
60
  // WebIDL
61
62
  uint32_t Width() const
63
0
  {
64
0
    return GetIntAttr(nsGkAtoms::width, 0);
65
0
  }
66
67
  void SetWidth(uint32_t aValue, ErrorResult& aRv)
68
0
  {
69
0
    SetUnsignedIntAttr(nsGkAtoms::width, aValue, 0, aRv);
70
0
  }
71
72
  uint32_t Height() const
73
0
  {
74
0
    return GetIntAttr(nsGkAtoms::height, 0);
75
0
  }
76
77
  void SetHeight(uint32_t aValue, ErrorResult& aRv)
78
0
  {
79
0
    SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
80
0
  }
81
82
  uint32_t VideoWidth() const
83
0
  {
84
0
    if (mMediaInfo.HasVideo()) {
85
0
      if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
86
0
          mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
87
0
        return mMediaInfo.mVideo.mDisplay.height;
88
0
      }
89
0
      return mMediaInfo.mVideo.mDisplay.width;
90
0
    }
91
0
    return 0;
92
0
  }
93
94
  uint32_t VideoHeight() const
95
0
  {
96
0
    if (mMediaInfo.HasVideo()) {
97
0
      if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
98
0
          mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
99
0
        return mMediaInfo.mVideo.mDisplay.width;
100
0
      }
101
0
      return mMediaInfo.mVideo.mDisplay.height;
102
0
    }
103
0
    return 0;
104
0
  }
105
106
  VideoInfo::Rotation RotationDegrees() const
107
0
  {
108
0
    return mMediaInfo.mVideo.mRotation;
109
0
  }
110
111
  void GetPoster(nsAString& aValue)
112
0
  {
113
0
    GetURIAttr(nsGkAtoms::poster, nullptr, aValue);
114
0
  }
115
  void SetPoster(const nsAString& aValue, ErrorResult& aRv)
116
0
  {
117
0
    SetHTMLAttr(nsGkAtoms::poster, aValue, aRv);
118
0
  }
119
120
  uint32_t MozParsedFrames() const;
121
122
  uint32_t MozDecodedFrames() const;
123
124
  uint32_t MozPresentedFrames() const;
125
126
  uint32_t MozPaintedFrames();
127
128
  double MozFrameDelay();
129
130
  bool MozHasAudio() const;
131
132
  // Gives access to the decoder's frame statistics, if present.
133
  FrameStatistics* GetFrameStatistics();
134
135
  already_AddRefed<VideoPlaybackQuality> GetVideoPlaybackQuality();
136
137
138
  bool MozOrientationLockEnabled() const
139
0
  {
140
0
    return StaticPrefs::MediaVideocontrolsLockVideoOrientation();
141
0
  }
142
143
  bool MozIsOrientationLocked() const
144
0
  {
145
0
    return mIsOrientationLocked;
146
0
  }
147
148
  void SetMozIsOrientationLocked(bool aLock)
149
0
  {
150
0
    mIsOrientationLocked = aLock;
151
0
  }
152
153
protected:
154
  virtual ~HTMLVideoElement();
155
156
  virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
157
158
  virtual void WakeLockCreate() override;
159
  virtual void WakeLockRelease() override;
160
  void UpdateScreenWakeLock();
161
162
  RefPtr<WakeLock> mScreenWakeLock;
163
164
  bool mIsOrientationLocked;
165
166
private:
167
  static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
168
                                    MappedDeclarations&);
169
170
  static bool IsVideoStatsEnabled();
171
  double TotalPlayTime() const;
172
};
173
174
} // namespace dom
175
} // namespace mozilla
176
177
#endif // mozilla_dom_HTMLVideoElement_h