2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2013-03-19 16:27:35 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_HTMLVideoElement_h
|
|
|
|
#define mozilla_dom_HTMLVideoElement_h
|
2010-04-02 07:03:07 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-03-19 16:23:54 +04:00
|
|
|
#include "mozilla/dom/HTMLMediaElement.h"
|
2018-03-20 01:48:56 +03:00
|
|
|
#include "mozilla/StaticPrefs.h"
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
namespace mozilla {
|
2017-08-15 08:09:06 +03:00
|
|
|
|
|
|
|
class FrameStatistics;
|
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2014-01-07 16:16:07 +04:00
|
|
|
class WakeLock;
|
2013-10-22 01:23:33 +04:00
|
|
|
class VideoPlaybackQuality;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLVideoElement final : public HTMLMediaElement
|
2008-07-09 12:22:20 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-07-13 06:20:42 +04:00
|
|
|
typedef mozilla::dom::NodeInfo NodeInfo;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo);
|
2011-12-04 01:50:16 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLVideoElement, video)
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
using HTMLMediaElement::GetPaused;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2018-02-15 08:22:38 +03:00
|
|
|
virtual bool IsVideo() const override {
|
2014-07-13 06:20:42 +04:00
|
|
|
return true;
|
|
|
|
}
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2014-07-13 06:20:42 +04:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
2013-06-11 19:23:13 +04:00
|
|
|
|
|
|
|
static void Init();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
|
2009-02-26 10:04:42 +03:00
|
|
|
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2008-07-09 12:22:20 +04:00
|
|
|
|
2012-05-11 12:32:15 +04:00
|
|
|
// Set size with the current video frame's height and width.
|
|
|
|
// If there is no video frame, returns NS_ERROR_FAILURE.
|
|
|
|
nsresult GetVideoSize(nsIntSize* size);
|
2010-07-23 13:49:57 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult SetAcceptHeader(nsIHttpChannel* aChannel) override;
|
2010-07-29 08:58:07 +04:00
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
// Element
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
|
2015-01-20 23:39:28 +03:00
|
|
|
|
2013-03-19 16:28:34 +04:00
|
|
|
// WebIDL
|
|
|
|
|
|
|
|
uint32_t Width() const
|
|
|
|
{
|
|
|
|
return GetIntAttr(nsGkAtoms::width, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWidth(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
{
|
2016-05-05 21:29:54 +03:00
|
|
|
SetUnsignedIntAttr(nsGkAtoms::width, aValue, 0, aRv);
|
2013-03-19 16:28:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t Height() const
|
|
|
|
{
|
|
|
|
return GetIntAttr(nsGkAtoms::height, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHeight(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
{
|
2016-05-05 21:29:54 +03:00
|
|
|
SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
|
2013-03-19 16:28:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t VideoWidth() const
|
|
|
|
{
|
2016-05-11 20:54:52 +03:00
|
|
|
if (mMediaInfo.HasVideo()) {
|
|
|
|
if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
|
|
|
|
mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
|
|
|
|
return mMediaInfo.mVideo.mDisplay.height;
|
|
|
|
}
|
|
|
|
return mMediaInfo.mVideo.mDisplay.width;
|
|
|
|
}
|
|
|
|
return 0;
|
2013-03-19 16:28:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t VideoHeight() const
|
|
|
|
{
|
2016-05-11 20:54:52 +03:00
|
|
|
if (mMediaInfo.HasVideo()) {
|
|
|
|
if (mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_90 ||
|
|
|
|
mMediaInfo.mVideo.mRotation == VideoInfo::Rotation::kDegree_270) {
|
|
|
|
return mMediaInfo.mVideo.mDisplay.width;
|
|
|
|
}
|
|
|
|
return mMediaInfo.mVideo.mDisplay.height;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoInfo::Rotation RotationDegrees() const
|
|
|
|
{
|
|
|
|
return mMediaInfo.mVideo.mRotation;
|
2013-03-19 16:28:34 +04:00
|
|
|
}
|
|
|
|
|
2014-07-13 06:20:42 +04:00
|
|
|
void GetPoster(nsAString& aValue)
|
|
|
|
{
|
|
|
|
GetURIAttr(nsGkAtoms::poster, nullptr, aValue);
|
|
|
|
}
|
2013-03-19 16:28:34 +04:00
|
|
|
void SetPoster(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::poster, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t MozParsedFrames() const;
|
|
|
|
|
|
|
|
uint32_t MozDecodedFrames() const;
|
|
|
|
|
|
|
|
uint32_t MozPresentedFrames() const;
|
|
|
|
|
|
|
|
uint32_t MozPaintedFrames();
|
|
|
|
|
|
|
|
double MozFrameDelay();
|
|
|
|
|
|
|
|
bool MozHasAudio() const;
|
|
|
|
|
2016-07-26 04:32:58 +03:00
|
|
|
// Gives access to the decoder's frame statistics, if present.
|
|
|
|
FrameStatistics* GetFrameStatistics();
|
|
|
|
|
2013-07-05 04:24:35 +04:00
|
|
|
already_AddRefed<VideoPlaybackQuality> GetVideoPlaybackQuality();
|
2013-06-21 07:14:18 +04:00
|
|
|
|
2017-08-25 09:23:03 +03:00
|
|
|
|
|
|
|
bool MozOrientationLockEnabled() const
|
|
|
|
{
|
2018-03-20 01:48:56 +03:00
|
|
|
return StaticPrefs::MediaVideocontrolsLockVideoOrientation();
|
2017-08-25 09:23:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MozIsOrientationLocked() const
|
|
|
|
{
|
|
|
|
return mIsOrientationLocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMozIsOrientationLocked(bool aLock)
|
|
|
|
{
|
|
|
|
mIsOrientationLocked = aLock;
|
|
|
|
}
|
|
|
|
|
2013-03-19 16:28:34 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLVideoElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-05-10 16:42:39 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void WakeLockCreate() override;
|
|
|
|
virtual void WakeLockRelease() override;
|
2014-03-18 12:44:41 +04:00
|
|
|
void UpdateScreenWakeLock();
|
2013-05-10 16:42:39 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<WakeLock> mScreenWakeLock;
|
2013-11-19 23:21:29 +04:00
|
|
|
|
2017-08-25 09:23:03 +03:00
|
|
|
bool mIsOrientationLocked;
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
private:
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2017-01-27 00:39:13 +03:00
|
|
|
GenericSpecifiedValues* aGenericData);
|
2017-06-19 09:43:26 +03:00
|
|
|
|
|
|
|
static bool IsVideoStatsEnabled();
|
2017-07-17 10:13:55 +03:00
|
|
|
double TotalPlayTime() const;
|
2008-07-09 12:22:20 +04:00
|
|
|
};
|
2010-04-02 07:03:07 +04:00
|
|
|
|
2013-03-19 16:27:35 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLVideoElement_h
|