diff --git a/browser/actors/ScreenshotsComponentChild.jsm b/browser/actors/ScreenshotsComponentChild.jsm
index 7436c043c8e6..bc2488a4b0b1 100644
--- a/browser/actors/ScreenshotsComponentChild.jsm
+++ b/browser/actors/ScreenshotsComponentChild.jsm
@@ -7,14 +7,6 @@
var EXPORTED_SYMBOLS = ["ScreenshotsComponentChild"];
-const { XPCOMUtils } = ChromeUtils.import(
- "resource://gre/modules/XPCOMUtils.jsm"
-);
-
-XPCOMUtils.defineLazyModuleGetters(this, {
- ScreenshotsOverlayChild: "resource:///modules/ScreenshotsOverlayChild.jsm",
-});
-
class ScreenshotsComponentChild extends JSWindowActorChild {
receiveMessage(message) {
switch (message.name) {
@@ -30,13 +22,6 @@ class ScreenshotsComponentChild extends JSWindowActorChild {
return null;
}
- /**
- * Send a request to cancel the screenshot to the parent process
- */
- requestCancelScreenshot() {
- this.sendAsyncMessage("Screenshots:CancelScreenshot", null);
- }
-
/**
* Resolves when the document is ready to have an overlay injected into it.
*
@@ -79,35 +64,16 @@ class ScreenshotsComponentChild extends JSWindowActorChild {
* @returns {Boolean} true when document is ready and the overlay is shown
* otherwise false
*/
- async startScreenshotsOverlay() {
+ async startScreenshotsOverlay(details = {}) {
try {
await this.documentIsReady();
} catch (ex) {
console.warn(`ScreenshotsComponentChild: ${ex.message}`);
return false;
}
- await this.documentIsReady();
- let overlay =
- this._overlay ||
- (this._overlay = new ScreenshotsOverlayChild.AnonymousContentOverlay(
- this.document,
- this
- ));
- this.document.addEventListener("keydown", this.handler);
- overlay.initialize();
return true;
}
- /**
- * Function to handle the escape key press to cancel screenshots overlay
- * @param event The keydown event
- */
- handler = event => {
- if (event.key === "Escape") {
- this.requestCancelScreenshot();
- }
- };
-
/**
* Remove the screenshots overlay.
*
@@ -115,8 +81,7 @@ class ScreenshotsComponentChild extends JSWindowActorChild {
* true when the overlay has been removed otherwise false
*/
endScreenshotsOverlay() {
- this.document.removeEventListener("keydown", this.handler);
- this._overlay?.tearDown();
+ // this function will be implemented soon
return true;
}
diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml
index 100c2f0eff02..2b171086afb3 100644
--- a/browser/base/content/main-popupset.inc.xhtml
+++ b/browser/base/content/main-popupset.inc.xhtml
@@ -172,7 +172,6 @@
norolluponanchor="true"
consumeoutsideclicks="never"
level="parent"
- noautohide="true"
tabspecific="true">
diff --git a/browser/base/content/test/static/browser_all_files_referenced.js b/browser/base/content/test/static/browser_all_files_referenced.js
index 9498e3d743d3..5fe231df020a 100644
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -273,6 +273,10 @@ var whitelist = [
// (The references to these files are dynamically generated, so the test can't
// find the references)
{ file: "chrome://browser/content/screenshots/copied-notification.svg" },
+ {
+ file:
+ "chrome://browser/content/screenshots/icon-welcome-face-without-eyes.svg",
+ },
{ file: "resource://app/modules/SnapshotSelector.jsm" },
diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm
index bbe2be8a6463..c322ec8d408b 100644
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -666,9 +666,6 @@ let JSWINDOWACTORS = {
},
ScreenshotsComponent: {
- parent: {
- moduleURI: "resource:///modules/ScreenshotsUtils.jsm",
- },
child: {
moduleURI: "resource:///actors/ScreenshotsComponentChild.jsm",
},
diff --git a/browser/components/screenshots/ScreenshotsOverlayChild.jsm b/browser/components/screenshots/ScreenshotsOverlayChild.jsm
deleted file mode 100644
index af6eba617754..000000000000
--- a/browser/components/screenshots/ScreenshotsOverlayChild.jsm
+++ /dev/null
@@ -1,291 +0,0 @@
-/* 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/. */
-
-/**
- * The Screenshots overlay is inserted into the document's
- * canvasFrame anonymous content container (see dom/webidl/Document.webidl).
- *
- * This container gets cleared automatically when the document navigates.
- *
- * Since the overlay markup is inserted in the canvasFrame using
- * insertAnonymousContent, this means that it can be modified using the API
- * described in AnonymousContent.webidl.
- *
- * Any mutation of this content must be via the AnonymousContent API.
- * This is similar in design to [devtools' highlighters](https://firefox-source-docs.mozilla.org/devtools/tools/highlighters.html#inserting-content-in-the-page),
- * though as Screenshots doesnt need to work on XUL documents, or allow multiple kinds of
- * highlight/overlay our case is a little simpler.
- *
- * To retrieve the AnonymousContent instance, use the `content` getter.
- */
-
-var EXPORTED_SYMBOLS = ["ScreenshotsOverlayChild"];
-
-const { XPCOMUtils } = ChromeUtils.import(
- "resource://gre/modules/XPCOMUtils.jsm"
-);
-
-XPCOMUtils.defineLazyGetter(this, "overlayLocalization", () => {
- return new Localization(["browser/screenshotsOverlay.ftl"], true);
-});
-
-const STYLESHEET_URL =
- "chrome://browser/content/screenshots/overlay/overlay.css";
-const HTML_NS = "http://www.w3.org/1999/xhtml";
-
-class AnonymousContentOverlay {
- constructor(contentDocument, screenshotsChild) {
- this.listeners = new Map();
- this.elements = new Map();
-
- this.screenshotsChild = screenshotsChild;
-
- this.contentDocument = contentDocument;
- // aliased for easier diffs/maintenance of the event management code borrowed from devtools highlighters
- this.pageListenerTarget = contentDocument.ownerGlobal;
-
- this.overlayFragment = null;
-
- this.overlayId = "screenshots-overlay-container";
- this._initialized = false;
- }
- get content() {
- if (!this._content || Cu.isDeadWrapper(this._content)) {
- return null;
- }
- return this._content;
- }
- async initialize() {
- if (this._initialized) {
- return;
- }
-
- let document = this.contentDocument;
- let window = document.ownerGlobal;
-
- // Inject stylesheet
- if (!this.overlayFragment) {
- try {
- window.windowUtils.loadSheetUsingURIString(
- STYLESHEET_URL,
- window.windowUtils.AGENT_SHEET
- );
- } catch {
- // The method fails if the url is already loaded.
- }
- }
-
- // Inject markup for the overlay UI
- this.overlayFragment = this.overlayFragment
- ? this.overlayFragment
- : this.buildOverlay();
-
- this._content = document.insertAnonymousContent(
- this.overlayFragment.children[0]
- );
-
- this.addEventListenerForElement(
- "screenshots-cancel-button",
- "click",
- (event, targetId) => {
- this.screenshotsChild.requestCancelScreenshot();
- }
- );
-
- // TODO:
- // * Define & hook up drag handles for custom region selection
-
- this._initialized = true;
- }
-
- tearDown() {
- if (this._content) {
- this._removeAllListeners();
- try {
- this.contentDocument.removeAnonymousContent(this._content);
- } catch (e) {
- // If the current window isn't the one the content was inserted into, this
- // will fail, but that's fine.
- }
- }
- this._initialized = false;
- }
-
- createElem(elemName, props = {}, className = "") {
- let elem = this.contentDocument.createElementNS(HTML_NS, elemName);
- if (props) {
- for (let [name, value] of Object.entries(props)) {
- elem[name] = value;
- }
- }
- if (className) {
- elem.className = className;
- }
- // register this element so we can target events at it
- if (elem.id) {
- this.elements.set(elem.id, elem);
- }
- return elem;
- }
-
- buildOverlay() {
- let [cancel, instrustions] = overlayLocalization.formatMessagesSync([
- { id: "screenshots-overlay-cancel-button" },
- { id: "screenshots-overlay-instructions" },
- ]);
-
- const htmlString = `
-
-
-
-
${instrustions.value}
-
${cancel.value}
-
-
{
- if (name === "originalTarget") {
- return null;
- } else if (name === "stopPropagation") {
- return () => {
- isPropagationStopped = true;
- };
- }
- return obj[name];
- },
- });
-
- // Start at originalTarget, bubble through ancestors and call handlers when
- // needed.
- let node = event.originalTarget;
- while (node) {
- let nodeId = node.id;
- if (nodeId) {
- const handler = listeners.get(node.id);
- if (handler) {
- handler(eventProxy, nodeId);
- if (isPropagationStopped) {
- break;
- }
- }
- if (nodeId == this.overlayId) {
- break;
- }
- }
- node = node.parentNode;
- }
- }
-
- _removeAllListeners() {
- if (this.pageListenerTarget) {
- const target = this.pageListenerTarget;
- for (const [type] of this.listeners) {
- target.removeEventListener(type, this, true);
- }
- }
- this.listeners.clear();
- }
-}
-
-var ScreenshotsOverlayChild = {
- AnonymousContentOverlay,
-};
diff --git a/browser/components/screenshots/ScreenshotsUtils.jsm b/browser/components/screenshots/ScreenshotsUtils.jsm
index 6d2bb5efea1d..fd4bdfdc409c 100644
--- a/browser/components/screenshots/ScreenshotsUtils.jsm
+++ b/browser/components/screenshots/ScreenshotsUtils.jsm
@@ -4,7 +4,7 @@
"use strict";
-var EXPORTED_SYMBOLS = ["ScreenshotsUtils", "ScreenshotsComponentParent"];
+var EXPORTED_SYMBOLS = ["ScreenshotsUtils"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
@@ -12,16 +12,6 @@ const PanelPosition = "bottomright topright";
const PanelOffsetX = -33;
const PanelOffsetY = -8;
-class ScreenshotsComponentParent extends JSWindowActorParent {
- receiveMessage(message) {
- switch (message.name) {
- case "Screenshots:CancelScreenshot":
- let browser = message.target.browsingContext.topFrameElement;
- ScreenshotsUtils.closePanel(browser);
- }
- }
-}
-
var ScreenshotsUtils = {
initialized: false,
initialize() {
@@ -67,8 +57,9 @@ var ScreenshotsUtils = {
}
break;
case "screenshots-take-screenshot":
- // need to close the preview because screenshot was taken
- this.closePanel(browser);
+ // need to toggle because panel button was clicked
+ // and we need to hide the buttons
+ this.togglePreview(browser);
// init UI as a tab dialog box
let dialogBox = gBrowser.getTabDialogBox(browser);
@@ -112,31 +103,8 @@ var ScreenshotsUtils = {
return actor;
},
/**
- * Open the panel buttons and call child actor to open the overlay
- * @param browser The current browser
- */
- openPanel(browser) {
- let actor = this.getActor(browser);
- actor.sendQuery("Screenshots:ShowOverlay");
- this.createOrDisplayButtons(browser);
- },
- /**
- * Close the panel and call child actor to close the overlay
- * @param browser The current browser
- */
- closePanel(browser) {
- let buttonsPanel = browser.ownerDocument.querySelector(
- "#screenshotsPagePanel"
- );
- if (buttonsPanel && buttonsPanel.state !== "closed") {
- buttonsPanel.hidePopup();
- }
- let actor = this.getActor(browser);
- actor.sendQuery("Screenshots:HideOverlay");
- },
- /**
- * If the buttons panel exists and is open we will hide both the panel
- * popup and the overlay.
+ * If the buttons panel exists and the panel is open we will hipe the panel
+ * popup and hide the screenshot overlay.
* Otherwise create or display the buttons.
* @param browser The current browser.
*/
@@ -149,8 +117,6 @@ var ScreenshotsUtils = {
let actor = this.getActor(browser);
return actor.sendQuery("Screenshots:HideOverlay");
}
- let actor = this.getActor(browser);
- actor.sendQuery("Screenshots:ShowOverlay");
return this.createOrDisplayButtons(browser);
},
/**
@@ -207,9 +173,10 @@ var ScreenshotsUtils = {
template.replaceWith(clone);
buttonsPanel = doc.querySelector("#screenshotsPagePanel");
}
-
let anchor = doc.querySelector("#navigator-toolbox");
buttonsPanel.openPopup(anchor, PanelPosition, PanelOffsetX, PanelOffsetY);
+ let actor = this.getActor(browser);
+ return actor.sendQuery("Screenshots:ShowOverlay");
},
/**
* Gets the full page bounds from the screenshots child actor.
diff --git a/browser/components/screenshots/jar.mn b/browser/components/screenshots/jar.mn
index 94df5bd72ebe..3dd2ac22e702 100644
--- a/browser/components/screenshots/jar.mn
+++ b/browser/components/screenshots/jar.mn
@@ -16,7 +16,3 @@ browser.jar:
content/browser/screenshots/screenshots-buttons.css (screenshots-buttons.css)
content/browser/screenshots/screenshots.css (content/screenshots.css)
content/browser/screenshots/screenshots.html (content/screenshots.html)
- content/browser/screenshots/overlay/ (overlay/**)
-
-
-% content screenshots-overlay %overlay/
diff --git a/browser/components/screenshots/moz.build b/browser/components/screenshots/moz.build
index 9e9a96d2078a..855937861ef7 100644
--- a/browser/components/screenshots/moz.build
+++ b/browser/components/screenshots/moz.build
@@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [
- "ScreenshotsOverlayChild.jsm",
"ScreenshotsUtils.jsm",
]
diff --git a/browser/components/screenshots/overlay/overlay.css b/browser/components/screenshots/overlay/overlay.css
deleted file mode 100644
index d93aa04804e8..000000000000
--- a/browser/components/screenshots/overlay/overlay.css
+++ /dev/null
@@ -1,126 +0,0 @@
-/* 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/. */
-
-:-moz-native-anonymous #screenshots-overlay-container {
- /*
- Content CSS applying to the html element can impact the overlay.
- To avoid that, possible cases have been set to initial.
- */
- text-transform: initial;
- text-indent: initial;
- letter-spacing: initial;
- word-spacing: initial;
- color: initial;
- direction: initial;
- writing-mode: initial;
-}
-
-/**
- * Overlay content is position: fixed as we need to allow for the possiblily
- * of the document scrolling or changing size while the overlay is visible
- */
-:-moz-native-anonymous #screenshots-overlay-container {
- position: fixed;
- top: 0; left: 0;
- width: 100vw;
- height: 100vh;
- background-color: rgba(0, 0, 0, 0.7);
- pointer-events: auto;
- cursor: crosshair;
-}
-
-:-moz-native-anonymous #screenshots-overlay-container[hidden] {
- display: none;
-}
-
-:-moz-native-anonymous #screenshots-overlay-container[dragging] {
- cursor: grabbing;
-}
-
-:-moz-native-anonymous #screenshots-cancel-button {
- background-color: transparent;
- width: fit-content;
- cursor: pointer;
- outline: none;
- border-radius: 3px;
- border: 1px #9b9b9b solid;
- color: #fff;
- cursor: pointer;
- font-family: -apple-system, BlinkMacSystemFont, "segoe ui", "helvetica neue", helvetica, ubuntu, roboto, noto, arial, sans-serif;
- font-size: 16px;
- margin-top: 40px;
- padding: 10px 25px;
-}
-
-:-moz-native-anonymous .fixed-container {
- align-items: center;
- display: flex;
- flex-direction: column;
- height: 100vh;
- justify-content: center;
- inset-inline-start: 0;
- margin: 0;
- padding: 0;
- position: fixed;
- top: 0;
- width: 100%;
-}
-
-:-moz-native-anonymous .face-container {
- position: relative;
- width: 64px;
- height: 64px;
-}
-
-:-moz-native-anonymous .face {
- width: 62px;
- height: 62px;
- display: block;
- background-image: url("chrome://browser/content/screenshots/icon-welcome-face-without-eyes.svg");
-}
-
-:-moz-native-anonymous .eye {
- background-color: #fff;
- width: 10px;
- height: 14px;
- position: absolute;
- border-radius: 100%;
- overflow: hidden;
- inset-inline-start: 16px;
- top: 19px;
-}
-
-:-moz-native-anonymous .eyeball {
- position: absolute;
- width: 6px;
- height: 6px;
- background-color: #000;
- border-radius: 50%;
- inset-inline-start: 2px;
- top: 4px;
- z-index: 10;
-}
-
-:-moz-native-anonymous .left {
- margin-inline-start: 0;
-}
-
-:-moz-native-anonymous .right {
- margin-inline-start: 20px;
-}
-
-:-moz-native-anonymous .preview-instructions {
- display: flex;
- align-items: center;
- justify-content: center;
- animation: pulse 125mm cubic-bezier(0.07, 0.95, 0, 1);
- color: #fff;
- font-family: -apple-system, BlinkMacSystemFont, "segoe ui", "helvetica neue", helvetica, ubuntu, roboto, noto, arial, sans-serif;
- font-size: 24px;
- line-height: 32px;
- text-align: center;
- padding-top: 20px;
- width: 400px;
- user-select: none;
-}
diff --git a/browser/components/screenshots/tests/browser/browser.ini b/browser/components/screenshots/tests/browser/browser.ini
index a1dd74afa484..f173eaa51d9e 100644
--- a/browser/components/screenshots/tests/browser/browser.ini
+++ b/browser/components/screenshots/tests/browser/browser.ini
@@ -7,7 +7,6 @@ prefs =
extensions.screenshots.disabled=false
screenshots.browser.component.enabled=true
-[browser_screenshots_test_escape.js]
[browser_screenshots_test_full_page.js]
skip-if = (!debug && os == 'win' && os_version == '6.1') # Bug 1746281
[browser_screenshots_test_toggle_pref.js]
diff --git a/browser/components/screenshots/tests/browser/browser_screenshots_test_escape.js b/browser/components/screenshots/tests/browser/browser_screenshots_test_escape.js
deleted file mode 100644
index dc005b458237..000000000000
--- a/browser/components/screenshots/tests/browser/browser_screenshots_test_escape.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-add_task(async function test_fullpageScreenshot() {
- CustomizableUI.addWidgetToArea(
- "screenshot-button",
- CustomizableUI.AREA_NAVBAR
- );
- let screenshotBtn = document.getElementById("screenshot-button");
- Assert.ok(screenshotBtn, "The screenshots button was added to the nav bar");
-
- await BrowserTestUtils.withNewTab(
- {
- gBrowser,
- url: TEST_PAGE,
- },
- async browser => {
- let helper = new ScreenshotsHelper(browser);
- let contentInfo = await helper.getContentDimensions();
- ok(contentInfo, "Got dimensions back from the content");
-
- // click toolbar button so panel shows
- helper.triggerUIFromToolbar();
-
- let panel = gBrowser.selectedBrowser.ownerDocument.querySelector(
- "#screenshotsPagePanel"
- );
- await BrowserTestUtils.waitForMutationCondition(
- panel,
- { attributes: true },
- () => {
- return BrowserTestUtils.is_visible(panel);
- }
- );
- ok(BrowserTestUtils.is_visible(panel), "Panel buttons are visible");
-
- EventUtils.synthesizeKey("KEY_Escape");
-
- await BrowserTestUtils.waitForMutationCondition(
- panel,
- { attributes: true },
- () => {
- return BrowserTestUtils.is_hidden(panel);
- }
- );
-
- ok(BrowserTestUtils.is_hidden(panel), "Panel buttons are hidden");
- }
- );
-});
diff --git a/browser/locales/en-US/browser/screenshotsOverlay.ftl b/browser/locales/en-US/browser/screenshotsOverlay.ftl
deleted file mode 100644
index fa468a7ba2bd..000000000000
--- a/browser/locales/en-US/browser/screenshotsOverlay.ftl
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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/.
-
-screenshots-overlay-cancel-button = Cancel
-screenshots-overlay-instructions = Drag or click on the page to select a region. Press ESC to cancel.