Bug 851130 - Part 9 - Deal with tab switching from StartUI tabs that have active context actions. r=sfoster

This commit is contained in:
Jim Mathies 2013-08-09 04:50:59 -05:00
parent fd8d10a4c0
commit 70732017b0
4 changed files with 29 additions and 0 deletions

View File

@ -31,6 +31,14 @@ var Appbar = {
switch (aEvent.type) {
case 'URLChanged':
case 'TabSelect':
this.update();
// Switching away from or loading a site into a startui tab that has actions
// pending, we consider this confirmation that the user wants to flush changes.
if (this.activeTileset && aEvent.lastTab && aEvent.lastTab.browser.currentURI.spec == kStartURI) {
ContextUI.dismiss();
}
break;
case 'MozAppbarShowing':
this.update();
break;

View File

@ -563,9 +563,16 @@ var Browser = {
item.owner = null;
});
// tray tab
let event = document.createEvent("Events");
event.initEvent("TabClose", true, false);
aTab.chromeTab.dispatchEvent(event);
// tab window
event = document.createEvent("Events");
event.initEvent("TabClose", true, false);
aTab.browser.contentWindow.dispatchEvent(event);
aTab.browser.messageManager.sendAsyncMessage("Browser:TabClose");
let container = aTab.chromeTab.parentNode;

View File

@ -28,6 +28,7 @@ function BookmarksView(aSet, aLimit, aRoot, aFilterUnpinned) {
Services.obs.addObserver(this, "metro_viewstate_changed", false);
StartUI.chromeWin.addEventListener('MozAppbarDismissing', this, false);
StartUI.chromeWin.addEventListener('BookmarksNeedsRefresh', this, false);
window.addEventListener("TabClose", this, true);
this.root = aRoot;
}
@ -297,6 +298,12 @@ BookmarksView.prototype = Util.extend(Object.create(View.prototype), {
case "BookmarksNeedsRefresh":
this.getBookmarks(true);
break;
case "TabClose":
// Flush any pending actions - appbar will call us back
// before this returns with 'MozAppbarDismissing' above.
StartUI.chromeWin.ContextUI.dismiss();
break;
}
}
});

View File

@ -19,6 +19,7 @@ function HistoryView(aSet, aLimit, aFilterUnpinned) {
Services.obs.addObserver(this, "metro_viewstate_changed", false);
StartUI.chromeWin.addEventListener('MozAppbarDismissing', this, false);
StartUI.chromeWin.addEventListener('HistoryNeedsRefresh', this, false);
window.addEventListener("TabClose", this, true);
}
HistoryView.prototype = Util.extend(Object.create(View.prototype), {
@ -210,6 +211,12 @@ HistoryView.prototype = Util.extend(Object.create(View.prototype), {
case "HistoryNeedsRefresh":
this.populateGrid(true);
break;
case "TabClose":
// Flush any pending actions - appbar will call us back
// before this returns with 'MozAppbarDismissing' above.
StartUI.chromeWin.ContextUI.dismiss();
break;
}
},