Bug 915918 - Part 1: Select previously selected tab upon editing mode exit. r=lucasr

This commit is contained in:
Michael Comella 2013-10-21 12:11:08 -07:00
Родитель 701a3f885d
Коммит f716edc0ab
1 изменённых файлов: 29 добавлений и 2 удалений

Просмотреть файл

@ -167,6 +167,9 @@ abstract public class BrowserApp extends GeckoApp
private BrowserHealthReporter mBrowserHealthReporter;
// The tab to be selected on editing mode exit.
private Integer mTargetTabForEditingMode = null;
// The animator used to toggle HomePager visibility has a race where if the HomePager is shown
// (starting the animation), the HomePager is hidden, and the HomePager animation completes,
// both the web content and the HomePager will be hidden. This flag is used to prevent the
@ -487,7 +490,9 @@ abstract public class BrowserApp extends GeckoApp
mBrowserToolbar.setOnStopEditingListener(new BrowserToolbar.OnStopEditingListener() {
public void onStopEditing() {
// Re-enable doorhanger notifications.
selectTargetTabForEditingMode();
// Re-enable doorhanger notifications. They may trigger on the selected tab above.
mDoorHangerPopup.enable();
}
});
@ -1311,7 +1316,10 @@ abstract public class BrowserApp extends GeckoApp
if (tabs.isSelectedTabId(tabId)) {
hideHomePager();
} else {
tabs.selectTab(tabId);
// Set the target tab to null so it does not get selected (on editing
// mode exit) in lieu of the tab we are about to select.
mTargetTabForEditingMode = null;
Tabs.getInstance().selectTab(tabId);
}
hideBrowserSearch();
@ -1425,6 +1433,9 @@ abstract public class BrowserApp extends GeckoApp
throw new IllegalArgumentException("Cannot handle null URLs in enterEditingMode");
}
final Tab selectedTab = Tabs.getInstance().getSelectedTab();
mTargetTabForEditingMode = (selectedTab != null ? selectedTab.getId() : null);
final PropertyAnimator animator = new PropertyAnimator(250);
animator.setUseHardwareLayer(false);
@ -1537,6 +1548,22 @@ abstract public class BrowserApp extends GeckoApp
}
}
/**
* Selects the target tab for editing mode. This is expected to be the tab selected on editing
* mode entry, unless it is subsequently overridden.
*
* A background tab may be selected while editing mode is active (e.g. popups), causing the
* new url to load in the newly selected tab. Call this method on editing mode exit to
* mitigate this.
*/
private void selectTargetTabForEditingMode() {
if (mTargetTabForEditingMode != null) {
Tabs.getInstance().selectTab(mTargetTabForEditingMode);
}
mTargetTabForEditingMode = null;
}
/**
* Shows or hides the home pager for the given tab.
*/