mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1299576 - Part 2 - Cancel edit mode when restoring a recently closed tab. r=sebastian
When restoring a recently closed tab from the corresponding home panel, we normally directly switch to the freshly recreated tab. However if we've entered the home panels through editing mode (as opposed to opening a new tab with about:home), editing mode takes priority and the restored tab is opened in background instead, because we return to the originally selected tab when exiting editing mode. To fix this inconsistency, we introduce a new parameter for opening tabs from Gecko that cancels editing mode if necessary to allow for directly switching to the new tab. MozReview-Commit-ID: 4iqPISmtNIx --HG-- extra : rebase_source : fab9dc911171deef1a984bd96993287d146b370a
This commit is contained in:
parent
eefcf19c49
commit
6afa573825
@ -693,6 +693,7 @@ public class BrowserApp extends GeckoApp
|
||||
"LightweightTheme:Update",
|
||||
"Search:Keyword",
|
||||
"Prompt:ShowTop",
|
||||
"Tab:Added",
|
||||
"Video:Play");
|
||||
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener)this,
|
||||
@ -1427,6 +1428,7 @@ public class BrowserApp extends GeckoApp
|
||||
"LightweightTheme:Update",
|
||||
"Search:Keyword",
|
||||
"Prompt:ShowTop",
|
||||
"Tab:Added",
|
||||
"Video:Play");
|
||||
|
||||
EventDispatcher.getInstance().unregisterGeckoThreadListener((NativeEventListener) this,
|
||||
@ -2044,6 +2046,20 @@ public class BrowserApp extends GeckoApp
|
||||
startActivity(bringToFrontIntent);
|
||||
break;
|
||||
|
||||
case "Tab:Added":
|
||||
if (message.getBoolean("cancelEditMode")) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Set the target tab to null so it does not get selected (on editing
|
||||
// mode exit) in lieu of the tab that we're going to open and select.
|
||||
mTargetTabForEditingMode = null;
|
||||
mBrowserToolbar.cancelEdit();
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
super.handleMessage(event, message);
|
||||
break;
|
||||
|
@ -472,6 +472,13 @@ public class Tabs implements GeckoEventListener {
|
||||
if (event.equals("Tab:Added")) {
|
||||
String url = message.isNull("uri") ? null : message.getString("uri");
|
||||
|
||||
if (message.getBoolean("cancelEditMode")) {
|
||||
final Tab oldTab = getSelectedTab();
|
||||
if (oldTab != null) {
|
||||
oldTab.setIsEditing(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (message.getBoolean("stub")) {
|
||||
if (tab == null) {
|
||||
// Tab was already closed; abort
|
||||
|
@ -3525,7 +3525,8 @@ Tab.prototype = {
|
||||
parentId: ("parentId" in aParams) ? aParams.parentId : -1,
|
||||
tabIndex: ("tabIndex" in aParams) ? aParams.tabIndex : -1,
|
||||
external: ("external" in aParams) ? aParams.external : false,
|
||||
selected: ("selected" in aParams) ? aParams.selected : true,
|
||||
selected: ("selected" in aParams || aParams.cancelEditMode === true) ? aParams.selected : true,
|
||||
cancelEditMode: aParams.cancelEditMode === true,
|
||||
title: truncate(title, MAX_TITLE_LENGTH),
|
||||
delayLoad: aParams.delayLoad || false,
|
||||
desktopMode: this.desktopMode,
|
||||
|
@ -1347,10 +1347,12 @@ SessionStore.prototype = {
|
||||
let window = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
for (let i = 0; i < aData.tabs.length; i++) {
|
||||
let tabData = JSON.parse(aData.tabs[i]);
|
||||
let isSelectedTab = (i == aData.tabs.length - 1);
|
||||
let params = {
|
||||
selected: (i == aData.tabs.length - 1),
|
||||
selected: isSelectedTab,
|
||||
isPrivate: tabData.isPrivate,
|
||||
desktopMode: tabData.desktopMode,
|
||||
cancelEditMode: isSelectedTab
|
||||
};
|
||||
|
||||
let tab = window.BrowserApp.addTab(tabData.entries[tabData.index - 1].url, params);
|
||||
|
Loading…
Reference in New Issue
Block a user