Bug 842782 - p2: introduce attributes for orientation lock to video element. r?jwwang,smaug
MozReview-Commit-ID: odq1y9qH1
--- a/dom/html/HTMLVideoElement.cpp
+++ b/dom/html/HTMLVideoElement.cpp
@@ -42,16 +42,17 @@ namespace dom {
static bool sVideoStatsEnabled;
NS_IMPL_ELEMENT_CLONE(HTMLVideoElement)
HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo)
: HTMLMediaElement(aNodeInfo)
, mUseScreenWakeLock(true)
+ , mIsOrientationLocked(false)
{
}
HTMLVideoElement::~HTMLVideoElement()
{
}
nsresult HTMLVideoElement::GetVideoSize(nsIntSize* size)
--- a/dom/html/HTMLVideoElement.h
+++ b/dom/html/HTMLVideoElement.h
@@ -4,16 +4,17 @@
* 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/. */
#ifndef mozilla_dom_HTMLVideoElement_h
#define mozilla_dom_HTMLVideoElement_h
#include "mozilla/Attributes.h"
#include "mozilla/dom/HTMLMediaElement.h"
+#include "MediaPrefs.h"
namespace mozilla {
class FrameStatistics;
namespace dom {
class WakeLock;
@@ -134,28 +135,46 @@ public:
void NotifyOwnerDocumentActivityChanged() override;
// Gives access to the decoder's frame statistics, if present.
FrameStatistics* GetFrameStatistics();
already_AddRefed<VideoPlaybackQuality> GetVideoPlaybackQuality();
+
+ bool MozOrientationLockEnabled() const
+ {
+ return MediaPrefs::VideoOrientationLockEnabled();
+ }
+
+ bool MozIsOrientationLocked() const
+ {
+ return mIsOrientationLocked;
+ }
+
+ void SetMozIsOrientationLocked(bool aLock)
+ {
+ mIsOrientationLocked = aLock;
+ }
+
protected:
virtual ~HTMLVideoElement();
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
virtual void WakeLockCreate() override;
virtual void WakeLockRelease() override;
void UpdateScreenWakeLock();
bool mUseScreenWakeLock;
RefPtr<WakeLock> mScreenWakeLock;
+ bool mIsOrientationLocked;
+
private:
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData);
static bool IsVideoStatsEnabled();
double TotalPlayTime() const;
};
--- a/dom/webidl/HTMLVideoElement.webidl
+++ b/dom/webidl/HTMLVideoElement.webidl
@@ -44,15 +44,23 @@ partial interface HTMLVideoElement {
readonly attribute double mozFrameDelay;
// True if the video has an audio track available.
readonly attribute boolean mozHasAudio;
// True if the video should use a screen wake lock.
[Pref="dom.wakelock.enabled", Func="Navigator::HasWakeLockSupport"]
attribute boolean mozUseScreenWakeLock;
+
+ // Attributes for builtin video controls to lock screen orientation.
+ // True if video controls should lock orientation when fullscreen.
+ [Pref="media.videocontrols.lock-video-orientation", Func="IsChromeOrXBL"]
+ readonly attribute boolean mozOrientationLockEnabled;
+ // True if screen orientation is locked by video controls.
+ [Pref="media.videocontrols.lock-video-orientation", Func="IsChromeOrXBL"]
+ attribute boolean mozIsOrientationLocked;
};
// https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#idl-def-HTMLVideoElement
partial interface HTMLVideoElement {
[Func="mozilla::dom::MediaSource::Enabled", NewObject]
VideoPlaybackQuality getVideoPlaybackQuality();
};