Bug 1392352 - Part 2 - Translate the tabbrowser implementation into a JS class;r=mconley,r=dao CLOSED TREE

We keep the XBL binding around for <content>, <constructor>, and <destructor>. This can
eventually be migrated to a Custom Element once we have platform support, but in the meantime
this is a way to get the many thousands of LOC into a JS class.

MozReview-Commit-ID: 1dCQp527yF9

--HG--
extra : rebase_source : 26b833413bab71168aa15e03f0f3803884be3f6b
extra : amend_source : 150cef6748ca8a9e819de0c674fac5966dd574cf
This commit is contained in:
Brian Grinstead 2018-02-27 10:04:14 -08:00
parent 378c6e27f2
commit 18bb37dcc8
14 changed files with 5660 additions and 12494 deletions

View File

@ -376,7 +376,7 @@ var FullScreen = {
// request was initiated from an in-process browser, we need
// to get its corresponding browser here.
let browser;
if (event.target == gBrowser) {
if (event.target == gBrowser.container) {
browser = event.originalTarget;
} else {
let topWin = event.target.ownerGlobal.top;

View File

@ -221,6 +221,7 @@ XPCOMUtils.defineLazyGetter(this, "Win7Features", function() {
const nsIWebNavigation = Ci.nsIWebNavigation;
var gBrowser = null; // Will be instantiated by the <tabbbrowser> constructor.
var gLastValidURLStr = "";
var gInPrintPreviewMode = false;
var gContextMenu = null; // nsContextMenu instance
@ -234,9 +235,8 @@ if (AppConstants.platform != "macosx") {
var gEditUIVisible = true;
}
/* globals gBrowser, gNavToolbox, gURLBar:true */
/* globals gNavToolbox, gURLBar:true */
[
["gBrowser", "content"],
["gNavToolbox", "navigator-toolbox"],
["gURLBar", "urlbar"],
].forEach(function(elementGlobal) {
@ -1196,8 +1196,7 @@ var gBrowserInit = {
window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow =
new nsBrowserAccess();
let initBrowser =
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
let initBrowser = gBrowser.initialBrowser;
// remoteType and sameProcessAsFrameLoader are passed through to
// updateBrowserRemoteness as part of an options object, which itself defaults
@ -1301,7 +1300,7 @@ var gBrowserInit = {
if (!gMultiProcessBrowser) {
// There is a Content:Click message manually sent from content.
Services.els.addSystemEventListener(gBrowser, "click", contentAreaClick, true);
Services.els.addSystemEventListener(gBrowser.container, "click", contentAreaClick, true);
}
// hook up UI through progress listener
@ -4342,15 +4341,11 @@ var XULBrowserWindow = {
},
forceInitialBrowserRemote(aRemoteType) {
let initBrowser =
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
gBrowser.updateBrowserRemoteness(initBrowser, true, { remoteType: aRemoteType });
gBrowser.updateBrowserRemoteness(gBrowser.initialBrowser, true, { remoteType: aRemoteType });
},
forceInitialBrowserNonRemote(aOpener) {
let initBrowser =
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
gBrowser.updateBrowserRemoteness(initBrowser, false, { opener: aOpener });
gBrowser.updateBrowserRemoteness(gBrowser.initialBrowser, false, { opener: aOpener });
},
setDefaultStatus(status) {

View File

@ -14,6 +14,7 @@
<?xml-stylesheet href="chrome://browser/skin/customizableui/panelUI.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/downloads/downloads.css"?>
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/tabbrowser.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
<?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
@ -1209,8 +1210,7 @@
<splitter id="sidebar-splitter" class="chromeclass-extrachrome sidebar-splitter" hidden="true"/>
<vbox id="appcontent" flex="1">
<notificationbox id="high-priority-global-notificationbox" notificationside="top"/>
<tabbrowser id="content"
flex="1" contenttooltip="aHTMLTooltip"
<tabbrowser flex="1" contenttooltip="aHTMLTooltip"
tabcontainer="tabbrowser-tabs"
contentcontextmenu="contentAreaContextMenu"
autocompletepopup="PopupAutoComplete"

1
browser/base/content/global-scripts.inc Executable file → Normal file
View File

@ -11,6 +11,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
for (let script of [
"chrome://browser/content/tabbrowser.js",
"chrome://browser/content/browser.js",
"chrome://browser/content/browser-captivePortal.js",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ const EXPECTED_REFLOWS = [
stack: [
"select@chrome://global/content/bindings/textbox.xml",
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.js",
],
}
];

View File

@ -14,7 +14,7 @@ const EXPECTED_OVERFLOW_REFLOWS = [
stack: [
"select@chrome://global/content/bindings/textbox.xml",
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.js",
]
},
];

View File

@ -117,6 +117,7 @@ browser.jar:
content/browser/contentSearchUI.js (content/contentSearchUI.js)
content/browser/contentSearchUI.css (content/contentSearchUI.css)
content/browser/tabbrowser.css (content/tabbrowser.css)
content/browser/tabbrowser.js (content/tabbrowser.js)
content/browser/tabbrowser.xml (content/tabbrowser.xml)
* content/browser/urlbarBindings.xml (content/urlbarBindings.xml)
content/browser/utilityOverlay.js (content/utilityOverlay.js)

View File

@ -91,7 +91,7 @@ function runTests() {
"setText() worked with no end for the replace range");
},
then: function* ([, , result]) {
is(result.class, "XULElement",
is(result.class, "Object",
"chrome context has access to chrome objects");
}
}, {

View File

@ -144,7 +144,7 @@ var BrowserTestUtils = {
*/
openNewForegroundTab(tabbrowser, ...args) {
let options;
if (tabbrowser instanceof Ci.nsIDOMXULElement) {
if (tabbrowser.ownerGlobal && tabbrowser === tabbrowser.ownerGlobal.gBrowser) {
// tabbrowser is a tabbrowser, read the rest of the arguments from args.
let [
opening = "about:blank",

View File

@ -439,13 +439,17 @@ var EventTargetParent = {
// Some non-browser windows define gBrowser globals which are not elements
// and can't be passed to target.contains().
if (window &&
window.gBrowser instanceof Ci.nsIDOMXULElement &&
target.contains(window.gBrowser)) {
if (window && window.gBrowser &&
window.gBrowser.container instanceof Ci.nsIDOMXULElement &&
target.contains(window.gBrowser.container)) {
return window;
}
}
if (target.ownerGlobal && target === target.ownerGlobal.gBrowser) {
return target.ownerGlobal;
}
return null;
},

View File

@ -113,10 +113,10 @@ AddonInterpositionService.prototype = {
if (target.localName == "browser" && target.isRemoteBrowser) {
return "RemoteBrowserElement";
}
}
if (target.localName == "tabbrowser") {
return "TabBrowserElement";
}
if (target.ownerGlobal && target === target.ownerGlobal.gBrowser) {
return "TabBrowserElement";
}
if (target instanceof Ci.nsIDOMChromeWindow && target.gMultiProcessBrowser) {

View File

@ -188,7 +188,7 @@ Notification.prototype = {
* The PopupNotifications object manages popup notifications for a given browser
* window.
* @param tabbrowser
* window's <xul:tabbrowser/>. Used to observe tab switching events and
* window's TabBrowser. Used to observe tab switching events and
* for determining the active browser element.
* @param panel
* The <xul:panel/> element to use for notifications. The panel is
@ -211,7 +211,7 @@ Notification.prototype = {
*/
function PopupNotifications(tabbrowser, panel,
iconBox, options = {}) {
if (!(tabbrowser instanceof Ci.nsIDOMXULElement))
if (!tabbrowser)
throw "Invalid tabbrowser";
if (iconBox && !(iconBox instanceof Ci.nsIDOMXULElement))
throw "Invalid iconBox";