Bug 1543122 - Add a preference for controlling whether or not we display a toggle for Picture-in-Picture on <video> elements. r=jaws

Depends on D26775

Differential Revision: https://phabricator.services.mozilla.com/D26776

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Conley 2019-04-15 01:07:13 +00:00
Родитель 25829adc57
Коммит 827f8a0905
2 изменённых файлов: 17 добавлений и 6 удалений

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

@ -56,6 +56,9 @@ class UAWidgetsChild extends ActorChild {
case "audio": case "audio":
uri = "chrome://global/content/elements/videocontrols.js"; uri = "chrome://global/content/elements/videocontrols.js";
widgetName = "VideoControlsWidget"; widgetName = "VideoControlsWidget";
prefKeys = [
"media.videocontrols.picture-in-picture.video-toggle.enabled",
];
break; break;
case "input": case "input":
uri = "chrome://global/content/elements/datetimebox.js"; uri = "chrome://global/content/elements/datetimebox.js";

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

@ -12,8 +12,9 @@
* according to the value of the "controls" property. * according to the value of the "controls" property.
*/ */
this.VideoControlsWidget = class { this.VideoControlsWidget = class {
constructor(shadowRoot) { constructor(shadowRoot, prefs) {
this.shadowRoot = shadowRoot; this.shadowRoot = shadowRoot;
this.prefs = prefs;
this.element = shadowRoot.host; this.element = shadowRoot.host;
this.document = this.element.ownerDocument; this.document = this.element.ownerDocument;
this.window = this.document.defaultView; this.window = this.document.defaultView;
@ -67,7 +68,7 @@ this.VideoControlsWidget = class {
this.shadowRoot.firstChild.remove(); this.shadowRoot.firstChild.remove();
} }
if (newImpl) { if (newImpl) {
this.impl = new newImpl(this.shadowRoot); this.impl = new newImpl(this.shadowRoot, this.prefs);
this.impl.onsetup(); this.impl.onsetup();
} else { } else {
this.impl = undefined; this.impl = undefined;
@ -89,8 +90,9 @@ this.VideoControlsWidget = class {
}; };
this.VideoControlsImplWidget = class { this.VideoControlsImplWidget = class {
constructor(shadowRoot) { constructor(shadowRoot, prefs) {
this.shadowRoot = shadowRoot; this.shadowRoot = shadowRoot;
this.prefs = prefs;
this.element = shadowRoot.host; this.element = shadowRoot.host;
this.document = this.element.ownerDocument; this.document = this.element.ownerDocument;
this.window = this.document.defaultView; this.window = this.document.defaultView;
@ -1943,13 +1945,18 @@ this.VideoControlsImplWidget = class {
} }
}, },
init(shadowRoot) { get pipToggleEnabled() {
return this.prefs["media.videocontrols.picture-in-picture.video-toggle.enabled"];
},
init(shadowRoot, prefs) {
this.shadowRoot = shadowRoot; this.shadowRoot = shadowRoot;
this.video = this.installReflowCallValidator(shadowRoot.host); this.video = this.installReflowCallValidator(shadowRoot.host);
this.videocontrols = this.installReflowCallValidator(shadowRoot.firstChild); this.videocontrols = this.installReflowCallValidator(shadowRoot.firstChild);
this.document = this.videocontrols.ownerDocument; this.document = this.videocontrols.ownerDocument;
this.window = this.document.defaultView; this.window = this.document.defaultView;
this.shadowRoot = shadowRoot; this.shadowRoot = shadowRoot;
this.prefs = prefs;
this.controlsContainer = this.shadowRoot.getElementById("controlsContainer"); this.controlsContainer = this.shadowRoot.getElementById("controlsContainer");
this.statusIcon = this.shadowRoot.getElementById("statusIcon"); this.statusIcon = this.shadowRoot.getElementById("statusIcon");
@ -2210,7 +2217,7 @@ this.VideoControlsImplWidget = class {
}, },
}; };
this.Utils.init(this.shadowRoot); this.Utils.init(this.shadowRoot, this.prefs);
if (this.Utils.isTouchControls) { if (this.Utils.isTouchControls) {
this.TouchUtils.init(this.shadowRoot, this.Utils); this.TouchUtils.init(this.shadowRoot, this.Utils);
} }
@ -2468,8 +2475,9 @@ this.NoControlsMobileImplWidget = class {
}; };
this.NoControlsPictureInPictureImplWidget = class { this.NoControlsPictureInPictureImplWidget = class {
constructor(shadowRoot) { constructor(shadowRoot, prefs) {
this.shadowRoot = shadowRoot; this.shadowRoot = shadowRoot;
this.prefs = prefs;
this.element = shadowRoot.host; this.element = shadowRoot.host;
this.document = this.element.ownerDocument; this.document = this.element.ownerDocument;
this.window = this.document.defaultView; this.window = this.document.defaultView;