зеркало из https://github.com/mozilla/gecko-dev.git
Bug 598331 - Stop using a single notificationbox for all browsers (part 1) [r=mfinkle r=stechz]
This commit is contained in:
Родитель
ec33d9f865
Коммит
32b1d31069
|
@ -745,16 +745,11 @@ var Browser = {
|
||||||
if (this._selectedTab.isLoading())
|
if (this._selectedTab.isLoading())
|
||||||
BrowserUI.lockToolbar();
|
BrowserUI.lockToolbar();
|
||||||
|
|
||||||
if (oldBrowser) {
|
if (lastTab)
|
||||||
oldBrowser.setAttribute("type", "content");
|
lastTab.updateBrowser(false);
|
||||||
oldBrowser.messageManager.sendAsyncMessage("Browser:Blur", {});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser) {
|
if (tab)
|
||||||
browser.setAttribute("type", "content-primary");
|
tab.updateBrowser(true);
|
||||||
Elements.browsers.selectedPanel = browser;
|
|
||||||
browser.messageManager.sendAsyncMessage("Browser:Focus", {});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("tabs").selectedTab = tab.chromeTab;
|
document.getElementById("tabs").selectedTab = tab.chromeTab;
|
||||||
|
|
||||||
|
@ -803,22 +798,8 @@ var Browser = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getNotificationBox: function getNotificationBox(aBrowser) {
|
getNotificationBox: function getNotificationBox(aBrowser) {
|
||||||
return document.getElementById("notifications");
|
let browser = aBrowser || this.selectedBrowser;
|
||||||
},
|
return browser.parentNode;
|
||||||
|
|
||||||
removeTransientNotificationsForTab: function removeTransientNotificationsForTab(aTab) {
|
|
||||||
let notificationBox = this.getNotificationBox();
|
|
||||||
let notifications = notificationBox.allNotifications;
|
|
||||||
for (let n = notifications.length - 1; n >= 0; n--) {
|
|
||||||
let notification = notifications[n];
|
|
||||||
if (notification._chromeTab != aTab.chromeTab)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (notification.persistence)
|
|
||||||
notification.persistence--;
|
|
||||||
else if (Date.now() > notification.timeout)
|
|
||||||
notificationBox.removeNotification(notification);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2329,7 +2310,7 @@ ProgressController.prototype = {
|
||||||
TapHighlightHelper.hide();
|
TapHighlightHelper.hide();
|
||||||
|
|
||||||
this.browser.lastLocation = location;
|
this.browser.lastLocation = location;
|
||||||
Browser.removeTransientNotificationsForTab(this._tab);
|
Browser.getNotificationBox(this.browser).removeTransientNotifications();
|
||||||
this._tab.resetZoomLevel();
|
this._tab.resetZoomLevel();
|
||||||
|
|
||||||
if (this._tab == Browser.selectedTab) {
|
if (this._tab == Browser.selectedTab) {
|
||||||
|
@ -2633,6 +2614,9 @@ Tab.prototype = {
|
||||||
_createBrowser: function _createBrowser(aURI, aInsertBefore) {
|
_createBrowser: function _createBrowser(aURI, aInsertBefore) {
|
||||||
if (this._browser)
|
if (this._browser)
|
||||||
throw "Browser already exists";
|
throw "Browser already exists";
|
||||||
|
|
||||||
|
// Create a notification box around the browser
|
||||||
|
let notification = this._notification = document.createElement("notificationbox");
|
||||||
|
|
||||||
// Create the browser using the current width the dynamically size the height
|
// Create the browser using the current width the dynamically size the height
|
||||||
let browser = this._browser = document.createElement("browser");
|
let browser = this._browser = document.createElement("browser");
|
||||||
|
@ -2646,7 +2630,8 @@ Tab.prototype = {
|
||||||
browser.setAttribute("remote", (!useLocal && useRemote) ? "true" : "false");
|
browser.setAttribute("remote", (!useLocal && useRemote) ? "true" : "false");
|
||||||
|
|
||||||
// Append the browser to the document, which should start the page load
|
// Append the browser to the document, which should start the page load
|
||||||
Elements.browsers.insertBefore(browser, aInsertBefore);
|
notification.appendChild(browser);
|
||||||
|
Elements.browsers.insertBefore(notification, aInsertBefore);
|
||||||
|
|
||||||
// stop about:blank from loading
|
// stop about:blank from loading
|
||||||
browser.stop();
|
browser.stop();
|
||||||
|
@ -2766,6 +2751,21 @@ Tab.prototype = {
|
||||||
this._chromeTab.updateThumbnail(browser, browser.contentWindowWidth, browser.contentWindowHeight);
|
this._chromeTab.updateThumbnail(browser, browser.contentWindowWidth, browser.contentWindowHeight);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateBrowser: function updateBrowser(aDisplay) {
|
||||||
|
let notification = this._notification;
|
||||||
|
let browser = this._browser;
|
||||||
|
if (aDisplay) {
|
||||||
|
browser.setAttribute("type", "content-primary");
|
||||||
|
notification.style.display = "";
|
||||||
|
browser.messageManager.sendAsyncMessage("Browser:Focus", {});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
browser.setAttribute("type", "content");
|
||||||
|
notification.style.display = "none";
|
||||||
|
browser.messageManager.sendAsyncMessage("Browser:Blur", {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "[Tab " + (this._browser ? this._browser.currentURI.spec : "(no browser)") + "]";
|
return "[Tab " + (this._browser ? this._browser.currentURI.spec : "(no browser)") + "]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,27 +34,14 @@
|
||||||
</content>
|
</content>
|
||||||
|
|
||||||
<implementation implements="nsIDOMEventListener">
|
<implementation implements="nsIDOMEventListener">
|
||||||
<constructor>
|
|
||||||
<![CDATA[
|
|
||||||
this._chromeTab = Browser.selectedTab.chromeTab;
|
|
||||||
document.addEventListener("TabSelect", this, true);
|
|
||||||
document.addEventListener("TabClose", this, true);
|
|
||||||
]]>
|
|
||||||
</constructor>
|
|
||||||
|
|
||||||
// We need to override the close method here, otherwise the destructor
|
// We need to override the close method here, otherwise the destructor
|
||||||
// is not called on removeChild (see bug 230086)
|
// is not called on removeChild (see bug 230086)
|
||||||
<method name="close">
|
<method name="close">
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
var control = this.control;
|
var control = this.control;
|
||||||
if (control) {
|
if (control)
|
||||||
document.removeEventListener("TabClose", this, true);
|
|
||||||
document.removeEventListener("TabSelect", this, true);
|
|
||||||
control.removeNotification(this);
|
control.removeNotification(this);
|
||||||
} else {
|
|
||||||
this.hidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire an event when closing a notification
|
// Fire an event when closing a notification
|
||||||
let event = document.createEvent("Events");
|
let event = document.createEvent("Events");
|
||||||
|
@ -63,32 +50,10 @@
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<method name="handleEvent">
|
|
||||||
<parameter name="aEvent"/>
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
switch(aEvent.type) {
|
|
||||||
case "TabSelect":
|
|
||||||
if (this._chromeTab == aEvent.target)
|
|
||||||
this.hidden = false;
|
|
||||||
else
|
|
||||||
this.hidden = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "TabClose":
|
|
||||||
if (this._chromeTab == aEvent.target)
|
|
||||||
this.close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
</implementation>
|
</implementation>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
||||||
<binding id="geo-notification" extends="chrome://browser/content/notification.xml#notification">
|
<binding id="geo-notification" extends="chrome://browser/content/notification.xml#notification">
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<stylesheet src="chrome://browser/skin/notification.css"/>
|
<stylesheet src="chrome://browser/skin/notification.css"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче