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
This commit is contained in:
@@ -376,7 +376,7 @@ var FullScreen = {
|
|||||||
// request was initiated from an in-process browser, we need
|
// request was initiated from an in-process browser, we need
|
||||||
// to get its corresponding browser here.
|
// to get its corresponding browser here.
|
||||||
let browser;
|
let browser;
|
||||||
if (event.target == gBrowser) {
|
if (event.target == gBrowser.container) {
|
||||||
browser = event.originalTarget;
|
browser = event.originalTarget;
|
||||||
} else {
|
} else {
|
||||||
let topWin = event.target.ownerGlobal.top;
|
let topWin = event.target.ownerGlobal.top;
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ XPCOMUtils.defineLazyGetter(this, "Win7Features", function() {
|
|||||||
|
|
||||||
const nsIWebNavigation = Ci.nsIWebNavigation;
|
const nsIWebNavigation = Ci.nsIWebNavigation;
|
||||||
|
|
||||||
|
var gBrowser = null; // Will be instantiated by the <tabbbrowser> constructor.
|
||||||
var gLastValidURLStr = "";
|
var gLastValidURLStr = "";
|
||||||
var gInPrintPreviewMode = false;
|
var gInPrintPreviewMode = false;
|
||||||
var gContextMenu = null; // nsContextMenu instance
|
var gContextMenu = null; // nsContextMenu instance
|
||||||
@@ -234,9 +235,8 @@ if (AppConstants.platform != "macosx") {
|
|||||||
var gEditUIVisible = true;
|
var gEditUIVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* globals gBrowser, gNavToolbox, gURLBar:true */
|
/* globals gNavToolbox, gURLBar:true */
|
||||||
[
|
[
|
||||||
["gBrowser", "content"],
|
|
||||||
["gNavToolbox", "navigator-toolbox"],
|
["gNavToolbox", "navigator-toolbox"],
|
||||||
["gURLBar", "urlbar"],
|
["gURLBar", "urlbar"],
|
||||||
].forEach(function(elementGlobal) {
|
].forEach(function(elementGlobal) {
|
||||||
@@ -1196,8 +1196,7 @@ var gBrowserInit = {
|
|||||||
window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow =
|
window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow =
|
||||||
new nsBrowserAccess();
|
new nsBrowserAccess();
|
||||||
|
|
||||||
let initBrowser =
|
let initBrowser = gBrowser.initialBrowser;
|
||||||
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
|
|
||||||
|
|
||||||
// remoteType and sameProcessAsFrameLoader are passed through to
|
// remoteType and sameProcessAsFrameLoader are passed through to
|
||||||
// updateBrowserRemoteness as part of an options object, which itself defaults
|
// updateBrowserRemoteness as part of an options object, which itself defaults
|
||||||
@@ -1301,7 +1300,7 @@ var gBrowserInit = {
|
|||||||
|
|
||||||
if (!gMultiProcessBrowser) {
|
if (!gMultiProcessBrowser) {
|
||||||
// There is a Content:Click message manually sent from content.
|
// 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
|
// hook up UI through progress listener
|
||||||
@@ -4342,15 +4341,11 @@ var XULBrowserWindow = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
forceInitialBrowserRemote(aRemoteType) {
|
forceInitialBrowserRemote(aRemoteType) {
|
||||||
let initBrowser =
|
gBrowser.updateBrowserRemoteness(gBrowser.initialBrowser, true, { remoteType: aRemoteType });
|
||||||
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
|
|
||||||
gBrowser.updateBrowserRemoteness(initBrowser, true, { remoteType: aRemoteType });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
forceInitialBrowserNonRemote(aOpener) {
|
forceInitialBrowserNonRemote(aOpener) {
|
||||||
let initBrowser =
|
gBrowser.updateBrowserRemoteness(gBrowser.initialBrowser, false, { opener: aOpener });
|
||||||
document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
|
|
||||||
gBrowser.updateBrowserRemoteness(initBrowser, false, { opener: aOpener });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setDefaultStatus(status) {
|
setDefaultStatus(status) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<?xml-stylesheet href="chrome://browser/skin/customizableui/panelUI.css" type="text/css"?>
|
<?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/downloads/downloads.css"?>
|
||||||
<?xml-stylesheet href="chrome://browser/skin/" type="text/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://global/content/editMenuOverlay.xul"?>
|
||||||
<?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
|
<?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
|
||||||
@@ -1209,8 +1210,7 @@
|
|||||||
<splitter id="sidebar-splitter" class="chromeclass-extrachrome sidebar-splitter" hidden="true"/>
|
<splitter id="sidebar-splitter" class="chromeclass-extrachrome sidebar-splitter" hidden="true"/>
|
||||||
<vbox id="appcontent" flex="1">
|
<vbox id="appcontent" flex="1">
|
||||||
<notificationbox id="high-priority-global-notificationbox" notificationside="top"/>
|
<notificationbox id="high-priority-global-notificationbox" notificationside="top"/>
|
||||||
<tabbrowser id="content"
|
<tabbrowser flex="1" contenttooltip="aHTMLTooltip"
|
||||||
flex="1" contenttooltip="aHTMLTooltip"
|
|
||||||
tabcontainer="tabbrowser-tabs"
|
tabcontainer="tabbrowser-tabs"
|
||||||
contentcontextmenu="contentAreaContextMenu"
|
contentcontextmenu="contentAreaContextMenu"
|
||||||
autocompletepopup="PopupAutoComplete"
|
autocompletepopup="PopupAutoComplete"
|
||||||
|
|||||||
1
browser/base/content/global-scripts.inc
Executable file → Normal file
1
browser/base/content/global-scripts.inc
Executable file → Normal file
@@ -11,6 +11,7 @@
|
|||||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
for (let script of [
|
for (let script of [
|
||||||
|
"chrome://browser/content/tabbrowser.js",
|
||||||
"chrome://browser/content/browser.js",
|
"chrome://browser/content/browser.js",
|
||||||
|
|
||||||
"chrome://browser/content/browser-captivePortal.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
@@ -14,7 +14,7 @@ const EXPECTED_REFLOWS = [
|
|||||||
stack: [
|
stack: [
|
||||||
"select@chrome://global/content/bindings/textbox.xml",
|
"select@chrome://global/content/bindings/textbox.xml",
|
||||||
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
|
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
|
||||||
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
|
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.js",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const EXPECTED_OVERFLOW_REFLOWS = [
|
|||||||
stack: [
|
stack: [
|
||||||
"select@chrome://global/content/bindings/textbox.xml",
|
"select@chrome://global/content/bindings/textbox.xml",
|
||||||
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
|
"focusAndSelectUrlBar@chrome://browser/content/browser.js",
|
||||||
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
|
"_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.js",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ browser.jar:
|
|||||||
content/browser/contentSearchUI.js (content/contentSearchUI.js)
|
content/browser/contentSearchUI.js (content/contentSearchUI.js)
|
||||||
content/browser/contentSearchUI.css (content/contentSearchUI.css)
|
content/browser/contentSearchUI.css (content/contentSearchUI.css)
|
||||||
content/browser/tabbrowser.css (content/tabbrowser.css)
|
content/browser/tabbrowser.css (content/tabbrowser.css)
|
||||||
|
content/browser/tabbrowser.js (content/tabbrowser.js)
|
||||||
content/browser/tabbrowser.xml (content/tabbrowser.xml)
|
content/browser/tabbrowser.xml (content/tabbrowser.xml)
|
||||||
* content/browser/urlbarBindings.xml (content/urlbarBindings.xml)
|
* content/browser/urlbarBindings.xml (content/urlbarBindings.xml)
|
||||||
content/browser/utilityOverlay.js (content/utilityOverlay.js)
|
content/browser/utilityOverlay.js (content/utilityOverlay.js)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ function runTests() {
|
|||||||
"setText() worked with no end for the replace range");
|
"setText() worked with no end for the replace range");
|
||||||
},
|
},
|
||||||
then: function* ([, , result]) {
|
then: function* ([, , result]) {
|
||||||
is(result.class, "XULElement",
|
is(result.class, "Object",
|
||||||
"chrome context has access to chrome objects");
|
"chrome context has access to chrome objects");
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ var BrowserTestUtils = {
|
|||||||
*/
|
*/
|
||||||
openNewForegroundTab(tabbrowser, ...args) {
|
openNewForegroundTab(tabbrowser, ...args) {
|
||||||
let options;
|
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.
|
// tabbrowser is a tabbrowser, read the rest of the arguments from args.
|
||||||
let [
|
let [
|
||||||
opening = "about:blank",
|
opening = "about:blank",
|
||||||
|
|||||||
@@ -439,13 +439,17 @@ var EventTargetParent = {
|
|||||||
|
|
||||||
// Some non-browser windows define gBrowser globals which are not elements
|
// Some non-browser windows define gBrowser globals which are not elements
|
||||||
// and can't be passed to target.contains().
|
// and can't be passed to target.contains().
|
||||||
if (window &&
|
if (window && window.gBrowser &&
|
||||||
window.gBrowser instanceof Ci.nsIDOMXULElement &&
|
window.gBrowser.container instanceof Ci.nsIDOMXULElement &&
|
||||||
target.contains(window.gBrowser)) {
|
target.contains(window.gBrowser.container)) {
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target.ownerGlobal && target === target.ownerGlobal.gBrowser) {
|
||||||
|
return target.ownerGlobal;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -113,10 +113,10 @@ AddonInterpositionService.prototype = {
|
|||||||
if (target.localName == "browser" && target.isRemoteBrowser) {
|
if (target.localName == "browser" && target.isRemoteBrowser) {
|
||||||
return "RemoteBrowserElement";
|
return "RemoteBrowserElement";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (target.localName == "tabbrowser") {
|
if (target.ownerGlobal && target === target.ownerGlobal.gBrowser) {
|
||||||
return "TabBrowserElement";
|
return "TabBrowserElement";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Ci.nsIDOMChromeWindow && target.gMultiProcessBrowser) {
|
if (target instanceof Ci.nsIDOMChromeWindow && target.gMultiProcessBrowser) {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ Notification.prototype = {
|
|||||||
* The PopupNotifications object manages popup notifications for a given browser
|
* The PopupNotifications object manages popup notifications for a given browser
|
||||||
* window.
|
* window.
|
||||||
* @param tabbrowser
|
* @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.
|
* for determining the active browser element.
|
||||||
* @param panel
|
* @param panel
|
||||||
* The <xul:panel/> element to use for notifications. The panel is
|
* The <xul:panel/> element to use for notifications. The panel is
|
||||||
@@ -211,7 +211,7 @@ Notification.prototype = {
|
|||||||
*/
|
*/
|
||||||
function PopupNotifications(tabbrowser, panel,
|
function PopupNotifications(tabbrowser, panel,
|
||||||
iconBox, options = {}) {
|
iconBox, options = {}) {
|
||||||
if (!(tabbrowser instanceof Ci.nsIDOMXULElement))
|
if (!tabbrowser)
|
||||||
throw "Invalid tabbrowser";
|
throw "Invalid tabbrowser";
|
||||||
if (iconBox && !(iconBox instanceof Ci.nsIDOMXULElement))
|
if (iconBox && !(iconBox instanceof Ci.nsIDOMXULElement))
|
||||||
throw "Invalid iconBox";
|
throw "Invalid iconBox";
|
||||||
|
|||||||
Reference in New Issue
Block a user