From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../components/screenshots/screenshots-buttons.js | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 browser/components/screenshots/screenshots-buttons.js (limited to 'browser/components/screenshots/screenshots-buttons.js') diff --git a/browser/components/screenshots/screenshots-buttons.js b/browser/components/screenshots/screenshots-buttons.js new file mode 100644 index 0000000000..864505ae2f --- /dev/null +++ b/browser/components/screenshots/screenshots-buttons.js @@ -0,0 +1,68 @@ +/* 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/. */ +/* eslint-env mozilla/browser-window */ + +"use strict"; + +// This is loaded into chrome windows with the subscript loader. Wrap in +// a block to prevent accidentally leaking globals onto `window`. +{ + ChromeUtils.defineESModuleGetters(this, { + ScreenshotsUtils: "resource:///modules/ScreenshotsUtils.sys.mjs", + }); + + class ScreenshotsButtons extends MozXULElement { + static get markup() { + return ` + + + + + `; + } + + connectedCallback() { + const shadowRoot = this.attachShadow({ mode: "open" }); + document.l10n.connectRoot(shadowRoot); + + let fragment = MozXULElement.parseXULToFragment(this.constructor.markup); + this.shadowRoot.append(fragment); + + let visibleButton = shadowRoot.querySelector(".visible-page"); + visibleButton.onclick = function () { + ScreenshotsUtils.doScreenshot(gBrowser.selectedBrowser, "visible"); + }; + + let fullpageButton = shadowRoot.querySelector(".full-page"); + fullpageButton.onclick = function () { + ScreenshotsUtils.doScreenshot(gBrowser.selectedBrowser, "full_page"); + }; + } + + disconnectedCallback() { + document.l10n.disconnectRoot(this.shadowRoot); + } + + /** + * Focus the last used button. + * This will default to the visible page button. + * @param {String} buttonToFocus + */ + focusButton(buttonToFocus) { + if (buttonToFocus === "fullpage") { + this.shadowRoot + .querySelector(".full-page") + .focus({ focusVisible: true }); + } else { + this.shadowRoot + .querySelector(".visible-page") + .focus({ focusVisible: true }); + } + } + } + + customElements.define("screenshots-buttons", ScreenshotsButtons, { + extends: "toolbar", + }); +} -- cgit v1.2.3