Bug 1742889 - Rewrite consumers of whereToOpenLink to use BrowserUtils.whereToOpenLink. r=Gijs,search-reviewers,places-reviewers,firefox-desktop-core-reviewers ,home-newtab-reviewers,reusable-components-reviewers,hjones,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D208680
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
|
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
|
||||||
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
|
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
|
||||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||||
@@ -99,7 +100,7 @@ export class ClickHandlerParent extends JSWindowActorParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This part is based on handleLinkClick.
|
// This part is based on handleLinkClick.
|
||||||
var where = window.whereToOpenLink(data);
|
var where = lazy.BrowserUtils.whereToOpenLink(data);
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const lazy = {};
|
|||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
|
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
FormHistory: "resource://gre/modules/FormHistory.sys.mjs",
|
FormHistory: "resource://gre/modules/FormHistory.sys.mjs",
|
||||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||||
SearchSuggestionController:
|
SearchSuggestionController:
|
||||||
@@ -216,7 +217,7 @@ export let ContentSearch = {
|
|||||||
// message and the time we handle it.
|
// message and the time we handle it.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let where = win.whereToOpenLink(data.originalEvent);
|
let where = lazy.BrowserUtils.whereToOpenLink(data.originalEvent);
|
||||||
|
|
||||||
// There is a chance that by the time we receive the search message, the user
|
// There is a chance that by the time we receive the search message, the user
|
||||||
// has switched away from the tab that triggered the search. If, based on the
|
// has switched away from the tab that triggered the search. If, based on the
|
||||||
@@ -510,10 +511,11 @@ export let ContentSearch = {
|
|||||||
lazy.UrlbarPrefs.get("shouldHandOffToSearchMode")
|
lazy.UrlbarPrefs.get("shouldHandOffToSearchMode")
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
let state = await this.currentStateObj();
|
let state = await this.currentStateObj();
|
||||||
this._broadcast("CurrentState", state);
|
this._broadcast("CurrentState", state);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ var BrowserCommands = {
|
|||||||
let where = "tab";
|
let where = "tab";
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
where = whereToOpenLink(event, false, true);
|
where = BrowserUtils.whereToOpenLink(event, false, true);
|
||||||
|
|
||||||
switch (where) {
|
switch (where) {
|
||||||
case "tab":
|
case "tab":
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
|
|||||||
{}
|
{}
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
if (document.defaultView.whereToOpenLink(e) != "current") {
|
if (BrowserUtils.whereToOpenLink(e) != "current") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2523,7 +2523,7 @@ const BrowserSearch = {
|
|||||||
event
|
event
|
||||||
) {
|
) {
|
||||||
event = getRootEvent(event);
|
event = getRootEvent(event);
|
||||||
let where = whereToOpenLink(event);
|
let where = BrowserUtils.whereToOpenLink(event);
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
// override: historically search opens in new tab
|
// override: historically search opens in new tab
|
||||||
where = "tab";
|
where = "tab";
|
||||||
@@ -4537,7 +4537,7 @@ nsBrowserAccess.prototype = {
|
|||||||
: PrivateBrowsingUtils.isWindowPrivate(window);
|
: PrivateBrowsingUtils.isWindowPrivate(window);
|
||||||
|
|
||||||
switch (aWhere) {
|
switch (aWhere) {
|
||||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW:
|
case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW: {
|
||||||
// FIXME: Bug 408379. So how come this doesn't send the
|
// FIXME: Bug 408379. So how come this doesn't send the
|
||||||
// referrer like the other loads do?
|
// referrer like the other loads do?
|
||||||
var url = aURI && aURI.spec;
|
var url = aURI && aURI.spec;
|
||||||
@@ -4581,6 +4581,7 @@ nsBrowserAccess.prototype = {
|
|||||||
console.error(ex);
|
console.error(ex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB:
|
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB:
|
||||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND: {
|
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB_BACKGROUND: {
|
||||||
// If we have an opener, that means that the caller is expecting access
|
// If we have an opener, that means that the caller is expecting access
|
||||||
@@ -4991,7 +4992,7 @@ function setToolbarVisibility(
|
|||||||
document.documentElement.toggleAttribute(overlapAttr, false);
|
document.documentElement.toggleAttribute(overlapAttr, false);
|
||||||
break;
|
break;
|
||||||
case "newtab":
|
case "newtab":
|
||||||
default:
|
default: {
|
||||||
let currentURI = gBrowser?.currentURI;
|
let currentURI = gBrowser?.currentURI;
|
||||||
if (!gBrowserInit.domContentLoaded) {
|
if (!gBrowserInit.domContentLoaded) {
|
||||||
let uriToLoad = gBrowserInit.uriToLoadPromise;
|
let uriToLoad = gBrowserInit.uriToLoadPromise;
|
||||||
@@ -5008,6 +5009,7 @@ function setToolbarVisibility(
|
|||||||
isVisible = BookmarkingUI.isOnNewTabPage(currentURI);
|
isVisible = BookmarkingUI.isOnNewTabPage(currentURI);
|
||||||
document.documentElement.toggleAttribute(overlapAttr, isVisible);
|
document.documentElement.toggleAttribute(overlapAttr, isVisible);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5420,7 +5422,7 @@ function handleLinkClick(event, href, linkNode) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var where = whereToOpenLink(event);
|
var where = BrowserUtils.whereToOpenLink(event);
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -5493,7 +5495,7 @@ function middleMousePaste(event) {
|
|||||||
|
|
||||||
// if it's not the current tab, we don't need to do anything because the
|
// if it's not the current tab, we don't need to do anything because the
|
||||||
// browser doesn't exist.
|
// browser doesn't exist.
|
||||||
let where = whereToOpenLink(event, true, false);
|
let where = BrowserUtils.whereToOpenLink(event, true, false);
|
||||||
let lastLocationChange;
|
let lastLocationChange;
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
|
lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
|
||||||
@@ -7051,7 +7053,7 @@ function safeModeRestart() {
|
|||||||
*/
|
*/
|
||||||
function duplicateTabIn(aTab, where, delta) {
|
function duplicateTabIn(aTab, where, delta) {
|
||||||
switch (where) {
|
switch (where) {
|
||||||
case "window":
|
case "window": {
|
||||||
let otherWin = OpenBrowserWindow({
|
let otherWin = OpenBrowserWindow({
|
||||||
private: PrivateBrowsingUtils.isBrowserPrivate(aTab.linkedBrowser),
|
private: PrivateBrowsingUtils.isBrowserPrivate(aTab.linkedBrowser),
|
||||||
});
|
});
|
||||||
@@ -7073,6 +7075,7 @@ function duplicateTabIn(aTab, where, delta) {
|
|||||||
"browser-delayed-startup-finished"
|
"browser-delayed-startup-finished"
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "tabshifted":
|
case "tabshifted":
|
||||||
SessionStore.duplicateTab(window, aTab, delta);
|
SessionStore.duplicateTab(window, aTab, delta);
|
||||||
// A background tab has been opened, nothing else to do here.
|
// A background tab has been opened, nothing else to do here.
|
||||||
@@ -8085,7 +8088,7 @@ var FirefoxViewHandler = {
|
|||||||
},
|
},
|
||||||
handleEvent(e) {
|
handleEvent(e) {
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case "TabSelect":
|
case "TabSelect": {
|
||||||
const selected = e.target == this.tab;
|
const selected = e.target == this.tab;
|
||||||
this.button?.toggleAttribute("open", selected);
|
this.button?.toggleAttribute("open", selected);
|
||||||
this.button?.setAttribute("aria-pressed", selected);
|
this.button?.setAttribute("aria-pressed", selected);
|
||||||
@@ -8096,6 +8099,7 @@ var FirefoxViewHandler = {
|
|||||||
gBrowser.visibleTabs[0].style.MozUserFocus =
|
gBrowser.visibleTabs[0].style.MozUserFocus =
|
||||||
e.target == this.tab ? "normal" : "";
|
e.target == this.tab ? "normal" : "";
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "TabClose":
|
case "TabClose":
|
||||||
this.tab = null;
|
this.tab = null;
|
||||||
gBrowser.tabContainer.removeEventListener("TabSelect", this);
|
gBrowser.tabContainer.removeEventListener("TabSelect", this);
|
||||||
|
|||||||
@@ -1685,7 +1685,7 @@ class nsContextMenu {
|
|||||||
|
|
||||||
// Change current window to the URL of the image, video, or audio.
|
// Change current window to the URL of the image, video, or audio.
|
||||||
viewMedia(e) {
|
viewMedia(e) {
|
||||||
let where = whereToOpenLink(e, false, false);
|
let where = BrowserUtils.whereToOpenLink(e, false, false);
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
}
|
}
|
||||||
@@ -2499,7 +2499,7 @@ class nsContextMenu {
|
|||||||
let drmInfoURL =
|
let drmInfoURL =
|
||||||
Services.urlFormatter.formatURLPref("app.support.baseURL") +
|
Services.urlFormatter.formatURLPref("app.support.baseURL") +
|
||||||
"drm-content";
|
"drm-content";
|
||||||
let dest = whereToOpenLink(aEvent);
|
let dest = BrowserUtils.whereToOpenLink(aEvent);
|
||||||
// Don't ever want this to open in the same tab as it'll unload the
|
// Don't ever want this to open in the same tab as it'll unload the
|
||||||
// DRM'd video, which is going to be a bad idea in most cases.
|
// DRM'd video, which is going to be a bad idea in most cases.
|
||||||
if (dest == "current") {
|
if (dest == "current") {
|
||||||
|
|||||||
@@ -113,11 +113,6 @@ function getRootEvent(aEvent) {
|
|||||||
return BrowserUtils.getRootEvent(aEvent);
|
return BrowserUtils.getRootEvent(aEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is here for historical reasons. bug 1742889 covers cleaning this up.
|
|
||||||
function whereToOpenLink(e, ignoreButton, ignoreAlt) {
|
|
||||||
return BrowserUtils.whereToOpenLink(e, ignoreButton, ignoreAlt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openTrustedLinkIn(url, where, params) {
|
function openTrustedLinkIn(url, where, params) {
|
||||||
URILoadingHelper.openTrustedLinkIn(window, url, where, params);
|
URILoadingHelper.openTrustedLinkIn(window, url, where, params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||||||
BookmarkJSONUtils: "resource://gre/modules/BookmarkJSONUtils.sys.mjs",
|
BookmarkJSONUtils: "resource://gre/modules/BookmarkJSONUtils.sys.mjs",
|
||||||
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
|
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
|
||||||
BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs",
|
BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs",
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.sys.mjs",
|
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.sys.mjs",
|
||||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
||||||
BuiltInThemes: "resource:///modules/BuiltInThemes.sys.mjs",
|
BuiltInThemes: "resource:///modules/BuiltInThemes.sys.mjs",
|
||||||
@@ -1197,13 +1198,13 @@ BrowserGlue.prototype = {
|
|||||||
case "initial-migration-did-import-default-bookmarks":
|
case "initial-migration-did-import-default-bookmarks":
|
||||||
this._initPlaces(true);
|
this._initPlaces(true);
|
||||||
break;
|
break;
|
||||||
case "handle-xul-text-link":
|
case "handle-xul-text-link": {
|
||||||
let linkHandled = subject.QueryInterface(Ci.nsISupportsPRBool);
|
let linkHandled = subject.QueryInterface(Ci.nsISupportsPRBool);
|
||||||
if (!linkHandled.data) {
|
if (!linkHandled.data) {
|
||||||
let win = lazy.BrowserWindowTracker.getTopWindow();
|
let win = lazy.BrowserWindowTracker.getTopWindow();
|
||||||
if (win) {
|
if (win) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
let where = win.whereToOpenLink(data);
|
let where = lazy.BrowserUtils.whereToOpenLink(data);
|
||||||
// Preserve legacy behavior of non-modifier left-clicks
|
// Preserve legacy behavior of non-modifier left-clicks
|
||||||
// opening in a new selected tab.
|
// opening in a new selected tab.
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
@@ -1214,13 +1215,14 @@ BrowserGlue.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "profile-before-change":
|
case "profile-before-change":
|
||||||
// Any component depending on Places should be finalized in
|
// Any component depending on Places should be finalized in
|
||||||
// _onPlacesShutdown. Any component that doesn't need to act after
|
// _onPlacesShutdown. Any component that doesn't need to act after
|
||||||
// the UI has gone should be finalized in _onQuitApplicationGranted.
|
// the UI has gone should be finalized in _onQuitApplicationGranted.
|
||||||
this._dispose();
|
this._dispose();
|
||||||
break;
|
break;
|
||||||
case "keyword-search":
|
case "keyword-search": {
|
||||||
// This notification is broadcast by the docshell when it "fixes up" a
|
// This notification is broadcast by the docshell when it "fixes up" a
|
||||||
// URI that it's been asked to load into a keyword search.
|
// URI that it's been asked to load into a keyword search.
|
||||||
let engine = null;
|
let engine = null;
|
||||||
@@ -1238,13 +1240,15 @@ BrowserGlue.prototype = {
|
|||||||
"urlbar"
|
"urlbar"
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "xpi-signature-changed":
|
}
|
||||||
|
case "xpi-signature-changed": {
|
||||||
let disabledAddons = JSON.parse(data).disabled;
|
let disabledAddons = JSON.parse(data).disabled;
|
||||||
let addons = await lazy.AddonManager.getAddonsByIDs(disabledAddons);
|
let addons = await lazy.AddonManager.getAddonsByIDs(disabledAddons);
|
||||||
if (addons.some(addon => addon)) {
|
if (addons.some(addon => addon)) {
|
||||||
this._notifyUnsignedAddonsDisabled();
|
this._notifyUnsignedAddonsDisabled();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "sync-ui-state:update":
|
case "sync-ui-state:update":
|
||||||
this._updateFxaBadges(lazy.BrowserWindowTracker.getTopWindow());
|
this._updateFxaBadges(lazy.BrowserWindowTracker.getTopWindow());
|
||||||
break;
|
break;
|
||||||
@@ -1262,7 +1266,7 @@ BrowserGlue.prototype = {
|
|||||||
lazy.DownloadsViewableInternally.register();
|
lazy.DownloadsViewableInternally.register();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "app-startup":
|
case "app-startup": {
|
||||||
this._earlyBlankFirstPaint(subject);
|
this._earlyBlankFirstPaint(subject);
|
||||||
gThisInstanceIsTaskbarTab = subject.handleFlag("taskbar-tab", false);
|
gThisInstanceIsTaskbarTab = subject.handleFlag("taskbar-tab", false);
|
||||||
gThisInstanceIsLaunchOnLogin = subject.handleFlag(
|
gThisInstanceIsLaunchOnLogin = subject.handleFlag(
|
||||||
@@ -1296,6 +1300,7 @@ BrowserGlue.prototype = {
|
|||||||
await lazy.WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey();
|
await lazy.WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ HistoryDownloadElementShell.prototype = {
|
|||||||
// be opened.
|
// be opened.
|
||||||
let browserWin = BrowserWindowTracker.getTopWindow();
|
let browserWin = BrowserWindowTracker.getTopWindow();
|
||||||
let openWhere = browserWin
|
let openWhere = browserWin
|
||||||
? browserWin.whereToOpenLink(event, false, true)
|
? BrowserUtils.whereToOpenLink(event, false, true)
|
||||||
: "window";
|
: "window";
|
||||||
if (["window", "tabshifted", "tab"].includes(openWhere)) {
|
if (["window", "tabshifted", "tab"].includes(openWhere)) {
|
||||||
command += ":" + openWhere;
|
command += ":" + openWhere;
|
||||||
|
|||||||
@@ -866,7 +866,7 @@ var DownloadsView = {
|
|||||||
} else if (aEvent.shiftKey || aEvent.ctrlKey || aEvent.metaKey) {
|
} else if (aEvent.shiftKey || aEvent.ctrlKey || aEvent.metaKey) {
|
||||||
// We adjust the command for supported modifiers to suggest where the download
|
// We adjust the command for supported modifiers to suggest where the download
|
||||||
// may be opened
|
// may be opened
|
||||||
let openWhere = target.ownerGlobal.whereToOpenLink(aEvent, false, true);
|
let openWhere = BrowserUtils.whereToOpenLink(aEvent, false, true);
|
||||||
if (["tab", "window", "tabshifted"].includes(openWhere)) {
|
if (["tab", "window", "tabshifted"].includes(openWhere)) {
|
||||||
command += ":" + openWhere;
|
command += ":" + openWhere;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { actionTypes as at } from "resource://activity-stream/common/Actions.mjs
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
DownloadsCommon: "resource:///modules/DownloadsCommon.sys.mjs",
|
DownloadsCommon: "resource:///modules/DownloadsCommon.sys.mjs",
|
||||||
DownloadsViewUI: "resource:///modules/DownloadsViewUI.sys.mjs",
|
DownloadsViewUI: "resource:///modules/DownloadsViewUI.sys.mjs",
|
||||||
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
|
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
|
||||||
@@ -166,10 +167,8 @@ export class DownloadsManager {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case at.OPEN_DOWNLOAD_FILE:
|
case at.OPEN_DOWNLOAD_FILE: {
|
||||||
const win = action._target.browser.ownerGlobal;
|
const openWhere = lazy.BrowserUtils.whereToOpenLink(action.data.event);
|
||||||
const openWhere =
|
|
||||||
action.data.event && win.whereToOpenLink(action.data.event);
|
|
||||||
doDownloadAction(download => {
|
doDownloadAction(download => {
|
||||||
lazy.DownloadsCommon.openDownload(download, {
|
lazy.DownloadsCommon.openDownload(download, {
|
||||||
// Replace "current" or unknown value with "tab" as the default behavior
|
// Replace "current" or unknown value with "tab" as the default behavior
|
||||||
@@ -180,6 +179,7 @@ export class DownloadsManager {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case at.UNINIT:
|
case at.UNINIT:
|
||||||
this.uninit();
|
this.uninit();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const { AboutNewTab } = ChromeUtils.importESModule(
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs",
|
ExperimentAPI: "resource://nimbus/ExperimentAPI.sys.mjs",
|
||||||
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
|
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
|
||||||
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
|
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
|
||||||
@@ -274,7 +275,7 @@ export class PlacesFeed {
|
|||||||
const win = action._target.browser.ownerGlobal;
|
const win = action._target.browser.ownerGlobal;
|
||||||
win.openTrustedLinkIn(
|
win.openTrustedLinkIn(
|
||||||
urlToOpen,
|
urlToOpen,
|
||||||
where || win.whereToOpenLink(event),
|
where || lazy.BrowserUtils.whereToOpenLink(event),
|
||||||
params
|
params
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ add_task(async function test_onAction_OPEN_LINK() {
|
|||||||
data: { url: "https://foo.com" },
|
data: { url: "https://foo.com" },
|
||||||
_target: {
|
_target: {
|
||||||
browser: {
|
browser: {
|
||||||
ownerGlobal: { openTrustedLinkIn, whereToOpenLink: () => "current" },
|
ownerGlobal: { openTrustedLinkIn },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -524,7 +524,7 @@ add_task(async function test_onAction_OPEN_LINK_pocket() {
|
|||||||
},
|
},
|
||||||
_target: {
|
_target: {
|
||||||
browser: {
|
browser: {
|
||||||
ownerGlobal: { openTrustedLinkIn, whereToOpenLink: () => "current" },
|
ownerGlobal: { openTrustedLinkIn },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -551,7 +551,7 @@ add_task(async function test_onAction_OPEN_LINK_not_http() {
|
|||||||
data: { url: "file:///foo.com" },
|
data: { url: "file:///foo.com" },
|
||||||
_target: {
|
_target: {
|
||||||
browser: {
|
browser: {
|
||||||
ownerGlobal: { openTrustedLinkIn, whereToOpenLink: () => "current" },
|
ownerGlobal: { openTrustedLinkIn },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const lazy = {};
|
|||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
CLIENT_NOT_CONFIGURED: "resource://services-sync/constants.sys.mjs",
|
CLIENT_NOT_CONFIGURED: "resource://services-sync/constants.sys.mjs",
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
||||||
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
|
CustomizableUI: "resource:///modules/CustomizableUI.sys.mjs",
|
||||||
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
|
MigrationUtils: "resource:///modules/MigrationUtils.sys.mjs",
|
||||||
@@ -467,7 +468,7 @@ class BookmarkState {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "tags":
|
case "tags": {
|
||||||
const newTags = value.filter(
|
const newTags = value.filter(
|
||||||
tag => !this._originalState.tags.includes(tag)
|
tag => !this._originalState.tags.includes(tag)
|
||||||
);
|
);
|
||||||
@@ -491,6 +492,7 @@ class BookmarkState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "keyword":
|
case "keyword":
|
||||||
transactions.push(
|
transactions.push(
|
||||||
lazy.PlacesTransactions.EditKeyword({
|
lazy.PlacesTransactions.EditKeyword({
|
||||||
@@ -985,7 +987,7 @@ export var PlacesUIUtils = {
|
|||||||
// whereToOpenLink doesn't return "window" when there's no browser window
|
// whereToOpenLink doesn't return "window" when there's no browser window
|
||||||
// open (Bug 630255).
|
// open (Bug 630255).
|
||||||
var where = browserWindow
|
var where = browserWindow
|
||||||
? browserWindow.whereToOpenLink(aEvent, false, true)
|
? lazy.BrowserUtils.whereToOpenLink(aEvent, false, true)
|
||||||
: "window";
|
: "window";
|
||||||
if (where == "window") {
|
if (where == "window") {
|
||||||
// There is no browser window open, thus open a new one.
|
// There is no browser window open, thus open a new one.
|
||||||
@@ -1076,7 +1078,7 @@ export var PlacesUIUtils = {
|
|||||||
openNodeWithEvent: function PUIU_openNodeWithEvent(aNode, aEvent) {
|
openNodeWithEvent: function PUIU_openNodeWithEvent(aNode, aEvent) {
|
||||||
let window = aEvent.target.ownerGlobal;
|
let window = aEvent.target.ownerGlobal;
|
||||||
|
|
||||||
let where = window.whereToOpenLink(aEvent, false, true);
|
let where = lazy.BrowserUtils.whereToOpenLink(aEvent, false, true);
|
||||||
if (this.loadBookmarksInTabs && lazy.PlacesUtils.nodeIsBookmark(aNode)) {
|
if (this.loadBookmarksInTabs && lazy.PlacesUtils.nodeIsBookmark(aNode)) {
|
||||||
if (where == "current" && !aNode.uri.startsWith("javascript:")) {
|
if (where == "current" && !aNode.uri.startsWith("javascript:")) {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
@@ -1690,7 +1692,7 @@ export var PlacesUIUtils = {
|
|||||||
doCommand(command) {
|
doCommand(command) {
|
||||||
let window = this.triggerNode.ownerGlobal;
|
let window = this.triggerNode.ownerGlobal;
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "placesCmd_copy":
|
case "placesCmd_copy": {
|
||||||
// This is a little hacky, but there is a lot of code in Places that handles
|
// This is a little hacky, but there is a lot of code in Places that handles
|
||||||
// clipboard stuff, so it's easier to reuse.
|
// clipboard stuff, so it's easier to reuse.
|
||||||
let node = {};
|
let node = {};
|
||||||
@@ -1735,6 +1737,7 @@ export var PlacesUIUtils = {
|
|||||||
Ci.nsIClipboard.kGlobalClipboard
|
Ci.nsIClipboard.kGlobalClipboard
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "placesCmd_open:privatewindow":
|
case "placesCmd_open:privatewindow":
|
||||||
window.openTrustedLinkIn(this.triggerNode.link, "window", {
|
window.openTrustedLinkIn(this.triggerNode.link, "window", {
|
||||||
private: true,
|
private: true,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// Wrap in a block to prevent leaking to window scope.
|
// Wrap in a block to prevent leaking to window scope.
|
||||||
{
|
{
|
||||||
ChromeUtils.defineESModuleGetters(this, {
|
ChromeUtils.defineESModuleGetters(this, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
SearchOneOffs: "resource:///modules/SearchOneOffs.sys.mjs",
|
SearchOneOffs: "resource:///modules/SearchOneOffs.sys.mjs",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@
|
|||||||
let search = this.input.controller.getValueAt(this.selectedIndex);
|
let search = this.input.controller.getValueAt(this.selectedIndex);
|
||||||
|
|
||||||
// open the search results according to the clicking subtlety
|
// open the search results according to the clicking subtlety
|
||||||
let where = whereToOpenLink(aEvent, false, true);
|
let where = this.BrowserUtils.whereToOpenLink(aEvent, false, true);
|
||||||
let params = {};
|
let params = {};
|
||||||
|
|
||||||
// But open ctrl/cmd clicks on autocomplete items in a new background tab.
|
// But open ctrl/cmd clicks on autocomplete items in a new background tab.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
FormHistory: "resource://gre/modules/FormHistory.sys.mjs",
|
FormHistory: "resource://gre/modules/FormHistory.sys.mjs",
|
||||||
SearchSuggestionController:
|
SearchSuggestionController:
|
||||||
"resource://gre/modules/SearchSuggestionController.sys.mjs",
|
"resource://gre/modules/SearchSuggestionController.sys.mjs",
|
||||||
@@ -317,7 +318,7 @@
|
|||||||
if (aEvent.button == 2) {
|
if (aEvent.button == 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
where = whereToOpenLink(aEvent, false, true);
|
where = lazy.BrowserUtils.whereToOpenLink(aEvent, false, true);
|
||||||
if (
|
if (
|
||||||
newTabPref &&
|
newTabPref &&
|
||||||
!aEvent.altKey &&
|
!aEvent.altKey &&
|
||||||
@@ -885,12 +886,13 @@
|
|||||||
goDoCommand("cmd_paste");
|
goDoCommand("cmd_paste");
|
||||||
this.handleSearchCommand(event);
|
this.handleSearchCommand(event);
|
||||||
break;
|
break;
|
||||||
case clearHistoryItem:
|
case clearHistoryItem: {
|
||||||
let param = this.textbox.getAttribute("autocompletesearchparam");
|
let param = this.textbox.getAttribute("autocompletesearchparam");
|
||||||
lazy.FormHistory.update({ op: "remove", fieldname: param });
|
lazy.FormHistory.update({ op: "remove", fieldname: param });
|
||||||
this.textbox.value = "";
|
this.textbox.value = "";
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
let cmd = event.originalTarget.getAttribute("cmd");
|
let cmd = event.originalTarget.getAttribute("cmd");
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
let controller =
|
let controller =
|
||||||
@@ -898,6 +900,7 @@
|
|||||||
controller.doCommand(cmd);
|
controller.doCommand(cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -290,7 +291,7 @@ TabListView.prototype = {
|
|||||||
|
|
||||||
// Middle click on a client
|
// Middle click on a client
|
||||||
if (itemNode.classList.contains("client")) {
|
if (itemNode.classList.contains("client")) {
|
||||||
let where = getChromeWindow(this._window).whereToOpenLink(event);
|
let where = lazy.BrowserUtils.whereToOpenLink(event);
|
||||||
if (where != "current") {
|
if (where != "current") {
|
||||||
this._openAllClientTabs(itemNode, where);
|
this._openAllClientTabs(itemNode, where);
|
||||||
}
|
}
|
||||||
@@ -346,7 +347,7 @@ TabListView.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onOpenSelected(url, event) {
|
onOpenSelected(url, event) {
|
||||||
let where = getChromeWindow(this._window).whereToOpenLink(event);
|
let where = lazy.BrowserUtils.whereToOpenLink(event);
|
||||||
this.props.onOpenTab(url, where, {});
|
this.props.onOpenTab(url, where, {});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const lazy = {};
|
|||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
|
BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
|
||||||
BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs",
|
BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs",
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
ExtensionSearchHandler:
|
ExtensionSearchHandler:
|
||||||
"resource://gre/modules/ExtensionSearchHandler.sys.mjs",
|
"resource://gre/modules/ExtensionSearchHandler.sys.mjs",
|
||||||
ObjectUtils: "resource://gre/modules/ObjectUtils.sys.mjs",
|
ObjectUtils: "resource://gre/modules/ObjectUtils.sys.mjs",
|
||||||
@@ -3048,7 +3049,7 @@ export class UrlbarInput {
|
|||||||
// pressed, open in current tab to allow ctrl-enter to canonize URL.
|
// pressed, open in current tab to allow ctrl-enter to canonize URL.
|
||||||
where = "current";
|
where = "current";
|
||||||
} else {
|
} else {
|
||||||
where = this.window.whereToOpenLink(event, false, false);
|
where = lazy.BrowserUtils.whereToOpenLink(event, false, false);
|
||||||
}
|
}
|
||||||
if (lazy.UrlbarPrefs.get("openintab")) {
|
if (lazy.UrlbarPrefs.get("openintab")) {
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
|||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
||||||
ClickHandlerParent: "resource:///actors/ClickHandlerParent.sys.mjs",
|
ClickHandlerParent: "resource:///actors/ClickHandlerParent.sys.mjs",
|
||||||
UrlbarUtils: "resource:///modules/UrlbarUtils.sys.mjs",
|
UrlbarUtils: "resource:///modules/UrlbarUtils.sys.mjs",
|
||||||
@@ -249,8 +250,7 @@ export var WebNavigationManager = {
|
|||||||
onContentClick(target, data) {
|
onContentClick(target, data) {
|
||||||
// We are interested only on clicks to links which are not "add to bookmark" commands
|
// We are interested only on clicks to links which are not "add to bookmark" commands
|
||||||
if (data.href && !data.bookmark) {
|
if (data.href && !data.bookmark) {
|
||||||
let ownerWin = target.ownerGlobal;
|
let where = lazy.BrowserUtils.whereToOpenLink(data);
|
||||||
let where = ownerWin.whereToOpenLink(data);
|
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
this.setRecentTabTransitionData({ link: true });
|
this.setRecentTabTransitionData({ link: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ export default class MozSupportLink extends HTMLAnchorElement {
|
|||||||
*/
|
*/
|
||||||
#register() {
|
#register() {
|
||||||
if (window.document.nodePrincipal?.isSystemPrincipal) {
|
if (window.document.nodePrincipal?.isSystemPrincipal) {
|
||||||
|
ChromeUtils.defineESModuleGetters(MozSupportLink, {
|
||||||
|
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line no-shadow
|
// eslint-disable-next-line no-shadow
|
||||||
let { XPCOMUtils } = window.XPCOMUtils
|
let { XPCOMUtils } = window.XPCOMUtils
|
||||||
? window
|
? window
|
||||||
@@ -72,7 +76,7 @@ export default class MozSupportLink extends HTMLAnchorElement {
|
|||||||
handleEvent(e) {
|
handleEvent(e) {
|
||||||
if (e.type == "click") {
|
if (e.type == "click") {
|
||||||
if (window.openTrustedLinkIn) {
|
if (window.openTrustedLinkIn) {
|
||||||
let where = whereToOpenLink(e, false, true);
|
let where = MozSupportLink.BrowserUtils.whereToOpenLink(e, false, true);
|
||||||
if (where == "current") {
|
if (where == "current") {
|
||||||
where = "tab";
|
where = "tab";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user