From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- toolkit/actors/PictureInPictureChild.sys.mjs | 3152 ++++++++++++++++++++++++++ 1 file changed, 3152 insertions(+) create mode 100644 toolkit/actors/PictureInPictureChild.sys.mjs (limited to 'toolkit/actors/PictureInPictureChild.sys.mjs') diff --git a/toolkit/actors/PictureInPictureChild.sys.mjs b/toolkit/actors/PictureInPictureChild.sys.mjs new file mode 100644 index 0000000000..ffaabbd5da --- /dev/null +++ b/toolkit/actors/PictureInPictureChild.sys.mjs @@ -0,0 +1,3152 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* 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/. */ + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + ContentDOMReference: "resource://gre/modules/ContentDOMReference.sys.mjs", + DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs", + KEYBOARD_CONTROLS: "resource://gre/modules/PictureInPictureControls.sys.mjs", + NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs", + Rect: "resource://gre/modules/Geometry.sys.mjs", + TOGGLE_POLICIES: "resource://gre/modules/PictureInPictureControls.sys.mjs", + TOGGLE_POLICY_STRINGS: + "resource://gre/modules/PictureInPictureControls.sys.mjs", +}); + +import { WebVTT } from "resource://gre/modules/vtt.sys.mjs"; +import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs"; +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; + +XPCOMUtils.defineLazyPreferenceGetter( + lazy, + "DISPLAY_TEXT_TRACKS_PREF", + "media.videocontrols.picture-in-picture.display-text-tracks.enabled", + false +); +XPCOMUtils.defineLazyPreferenceGetter( + lazy, + "IMPROVED_CONTROLS_ENABLED_PREF", + "media.videocontrols.picture-in-picture.improved-video-controls.enabled", + false +); +XPCOMUtils.defineLazyPreferenceGetter( + lazy, + "MIN_VIDEO_LENGTH", + "media.videocontrols.picture-in-picture.video-toggle.min-video-secs", + 45 +); +XPCOMUtils.defineLazyPreferenceGetter( + lazy, + "PIP_TOGGLE_ALWAYS_SHOW", + "media.videocontrols.picture-in-picture.video-toggle.always-show", + false +); +XPCOMUtils.defineLazyPreferenceGetter( + lazy, + "PIP_URLBAR_BUTTON", + "media.videocontrols.picture-in-picture.urlbar-button.enabled", + false +); + +const PIP_ENABLED_PREF = "media.videocontrols.picture-in-picture.enabled"; +const TOGGLE_ENABLED_PREF = + "media.videocontrols.picture-in-picture.video-toggle.enabled"; +const TOGGLE_FIRST_SEEN_PREF = + "media.videocontrols.picture-in-picture.video-toggle.first-seen-secs"; +const TOGGLE_FIRST_TIME_DURATION_DAYS = 28; +const TOGGLE_HAS_USED_PREF = + "media.videocontrols.picture-in-picture.video-toggle.has-used"; +const TOGGLE_TESTING_PREF = + "media.videocontrols.picture-in-picture.video-toggle.testing"; +const TOGGLE_VISIBILITY_THRESHOLD_PREF = + "media.videocontrols.picture-in-picture.video-toggle.visibility-threshold"; +const TEXT_TRACK_FONT_SIZE = + "media.videocontrols.picture-in-picture.display-text-tracks.size"; + +const MOUSEMOVE_PROCESSING_DELAY_MS = 50; +const TOGGLE_HIDING_TIMEOUT_MS = 3000; +// If you change this, also change VideoControlsWidget.SEEK_TIME_SECS: +const SEEK_TIME_SECS = 5; +const EMPTIED_TIMEOUT_MS = 1000; + +// The ToggleChild does not want to capture events from the PiP +// windows themselves. This set contains all currently open PiP +// players' content windows +var gPlayerContents = new WeakSet(); + +// To make it easier to write tests, we have a process-global +// WeakSet of all