Bug 842782 - p2: introduce attributes for orientation lock to video element. r?jwwang,smaug draft
authorJohn Lin <jolin@mozilla.com>
Fri, 25 Aug 2017 14:23:03 +0800
changeset 653827 f5d676c45639139e78ae573aabb95e1f5336c82e
parent 653826 2721c272e86c5608b9a66e42b49a3607c635e27d
child 653828 95bd6e38cb402c4641a753db3fd4ba79f0acf101
push id76424
push userbmo:jolin@mozilla.com
push dateMon, 28 Aug 2017 04:04:03 +0000
reviewersjwwang, smaug
bugs842782
milestone57.0a1
Bug 842782 - p2: introduce attributes for orientation lock to video element. r?jwwang,smaug MozReview-Commit-ID: odq1y9qH1
dom/html/HTMLVideoElement.cpp
dom/html/HTMLVideoElement.h
dom/webidl/HTMLVideoElement.webidl
--- 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();
 };