Bug 842782 - p3: lock fullscreen video orientation. r=ralin

- if enabled, lock orienation when fullscreen state change
- use video aspect ratio to choose which orientation to lock

MozReview-Commit-ID: 3HP60YNbWcc
This commit is contained in:
John Lin 2017-08-17 11:07:13 +08:00
Родитель bad6535260
Коммит 38273ed7b3
1 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -1234,12 +1234,38 @@
},
onFullscreenChange() {
this.updateOrientationState(this.isVideoInFullScreen());
if (this.isVideoInFullScreen()) {
Utils._hideControlsTimeout = setTimeout(this._hideControlsFn, this.HIDE_CONTROLS_TIMEOUT_MS);
}
this.setFullscreenButtonState();
},
updateOrientationState(lock) {
if (!this.video.mozOrientationLockEnabled) {
return;
}
if (lock) {
if (this.video.mozIsOrientationLocked) {
return;
}
let dimenDiff = this.video.videoWidth - this.video.videoHeight;
if (dimenDiff > 0) {
this.video.mozIsOrientationLocked = window.screen.mozLockOrientation("landscape");
} else if (dimenDiff < 0) {
this.video.mozIsOrientationLocked = window.screen.mozLockOrientation("portrait");
} else {
this.video.mozIsOrientationLocked = window.screen.mozLockOrientation(window.screen.orientation);
}
} else {
if (!this.video.mozIsOrientationLocked) {
return;
}
window.screen.mozUnlockOrientation();
this.video.mozIsOrientationLocked = false;
}
},
clickToPlayClickHandler(e) {
if (e.button != 0) {
return;
@ -1836,6 +1862,7 @@
<destructor>
<![CDATA[
this.Utils.terminateEventListeners();
this.Utils.updateOrientationState(false);
// randomID used to be a <field>, which meant that the XBL machinery
// undefined the property when the element was unbound. The code in
// this file actually depends on this, so now that randomID is an