Bug 1023407 - Revert switch-to-new-tab ButtonToast (Bug 997288) in Fennec <= 32. r=margaret,a=lsblakk
authorNick Alexander <nalexander@mozilla.com>
Fri, 13 Jun 2014 16:33:18 -0700
changeset 206996 d07928996bf14c0620b7d523f522153fa1f8f517
parent 206995 e161f3e3b3325bcb29dfc9eb8d9faf27765f1d5b
child 206997 a3add4076de2c5ba6096f8c48ab0887ee9927c91
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lsblakk
bugs1023407, 997288, 1019735
milestone32.0a2
Bug 1023407 - Revert switch-to-new-tab ButtonToast (Bug 997288) in Fennec <= 32. r=margaret,a=lsblakk ButtonToasts interact badly with touch events, blocking interaction with the rest of the system until the ButtonToast expires or is otherwise dismissed (Bug 1019735). Until this is fixed, we'll just show system Toasts. This patch is *not* a straight back-out; it is a selective disabling of the new functionality.
mobile/android/base/home/HomeFragment.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/home/HomeFragment.java
+++ b/mobile/android/base/home/HomeFragment.java
@@ -186,36 +186,23 @@ abstract class HomeFragment extends Frag
 
             Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.CONTEXT_MENU);
 
             final String url = (info.isInReadingList() ? ReaderModeUtils.getAboutReaderForUrl(info.url) : info.url);
 
             // Some pinned site items have "user-entered" urls. URLs entered in the PinSiteDialog are wrapped in
             // a special URI until we can get a valid URL. If the url is a user-entered url, decode the URL before loading it.
             final Tab newTab = Tabs.getInstance().loadUrl(decodeUserEnteredUrl(url), flags);
-            final int newTabId = newTab.getId(); // We don't want to hold a reference to the Tab.
-
             final String message = isPrivate ?
                     getResources().getString(R.string.new_private_tab_opened) :
                     getResources().getString(R.string.new_tab_opened);
-            final String buttonMessage = getResources().getString(R.string.switch_button_message);
-            final GeckoApp geckoApp = (GeckoApp) context;
-            geckoApp.getButtonToast().show(false,
-                    message,
-                    buttonMessage,
-                    R.drawable.switch_button_icon,
-                    new ButtonToast.ToastListener() {
-                        @Override
-                        public void onButtonClicked() {
-                            Tabs.getInstance().selectTab(newTabId);
-                        }
-
-                        @Override
-                        public void onToastHidden(ButtonToast.ReasonHidden reason) { }
-                    });
+            // Bug 1023407: ButtonToasts interact badly with touch events, blocking interaction with
+            // the rest of the system until the ButtonToast expires or is otherwise dismissed (Bug
+            // 1019735). Until this is fixed, we'll just use regular system Toasts.
+            Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
             return true;
         }
 
         if (itemId == R.id.home_edit_bookmark) {
             // UI Dialog associates to the activity context, not the applications'.
             new EditBookmarkDialog(context).show(info.url);
             return true;
         }
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -485,43 +485,37 @@ var BrowserApp = {
       NativeWindow.contextmenus.linkOpenableNonPrivateContext,
       function(aTarget) {
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         ContentAreaUtils.urlSecurityCheck(url, aTarget.ownerDocument.nodePrincipal);
         let tab = BrowserApp.addTab(url, { selected: false, parentId: BrowserApp.selectedTab.id });
 
         let newtabStrings = Strings.browser.GetStringFromName("newtabpopup.opened");
         let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
-        let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
-        NativeWindow.toast.show(label, "long", {
-          button: {
-            icon: "drawable://switch_button_icon",
-            label: buttonLabel,
-            callback: () => { BrowserApp.selectTab(tab); },
-          }
-        });
+        // Bug 1023407: ButtonToasts interact badly with touch events, blocking
+        // interaction with the rest of the system until the ButtonToast expires
+        // or is otherwise dismissed (Bug 1019735). Until this is fixed, we'll
+        // just use regular system Toasts.
+        NativeWindow.toast.show(label, "short");
       });
 
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.openInPrivateTab"),
       NativeWindow.contextmenus.linkOpenableContext,
       function(aTarget) {
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         ContentAreaUtils.urlSecurityCheck(url, aTarget.ownerDocument.nodePrincipal);
         let tab = BrowserApp.addTab(url, { selected: false, parentId: BrowserApp.selectedTab.id, isPrivate: true });
 
         let newtabStrings = Strings.browser.GetStringFromName("newprivatetabpopup.opened");
         let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
-        let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
-        NativeWindow.toast.show(label, "long", {
-          button: {
-            icon: "drawable://switch_button_icon",
-            label: buttonLabel,
-            callback: () => { BrowserApp.selectTab(tab); },
-          }
-        });
+        // Bug 1023407: ButtonToasts interact badly with touch events, blocking
+        // interaction with the rest of the system until the ButtonToast expires
+        // or is otherwise dismissed (Bug 1019735). Until this is fixed, we'll
+        // just use regular system Toasts.
+        NativeWindow.toast.show(label, "short");
       });
 
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.copyLink"),
       NativeWindow.contextmenus.linkCopyableContext,
       function(aTarget) {
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         NativeWindow.contextmenus._copyStringToDefaultClipboard(url);
       });