☠☠ backed out by 85ed494c5b02 ☠ ☠ | |
author | Michael Comella <michael.l.comella@gmail.com> |
Mon, 28 Oct 2013 12:20:26 -0700 | |
changeset 152612 | 906461e491d9e1a7840af646252b7ea5d117658c |
parent 152611 | 29fb758db4021e05879846601687e4bc1851e777 |
child 152613 | d93a9e884f136db3d50462c2f87eb38d5c4ab85b |
push id | 25553 |
push user | cbook@mozilla.com |
push date | Tue, 29 Oct 2013 12:22:52 +0000 |
treeherder | mozilla-central@bc3916e4f4c5 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | lucasr |
bugs | 915918 |
milestone | 27.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -162,16 +162,19 @@ abstract public class BrowserApp extends private Integer mPrefObserverId; private SharedPreferencesHelper mSharedPreferencesHelper; private OrderedBroadcastHelper mOrderedBroadcastHelper; 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 // race by determining if the web content should be hidden at the animation's end. private boolean mHideWebContentOnAnimationEnd = false; private SiteIdentityPopup mSiteIdentityPopup; @@ -482,17 +485,19 @@ abstract public class BrowserApp extends public void onStartEditing() { // Temporarily disable doorhanger notifications. mDoorHangerPopup.disable(); } }); 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(); } }); // Intercept key events for gamepad shortcuts mBrowserToolbar.setOnKeyListener(this); if (mTabsPanel != null) { @@ -1306,17 +1311,20 @@ abstract public class BrowserApp extends if (tabId < 0) { return false; } // If this tab is already selected, just hide the home pager. 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(); mBrowserToolbar.cancelEdit(); return true; } @@ -1420,16 +1428,19 @@ abstract public class BrowserApp extends * Enters editing mode with the specified URL. This method will * always open the HISTORY page on about:home. */ private void enterEditingMode(String url) { if (url == null) { 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); mBrowserToolbar.startEditing(url, animator); showHomePagerWithAnimator(HomePager.Page.TOP_SITES, animator); animator.start(); } @@ -1533,16 +1544,32 @@ abstract public class BrowserApp extends } else { showBrowserSearch(); mHomePager.setVisibility(View.INVISIBLE); mBrowserSearch.filter(searchTerm, handler); } } /** + * 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. */ private void updateHomePagerForTab(Tab tab) { // Don't change the visibility of the home pager if we're in editing mode. if (mBrowserToolbar.isEditing()) { return; }