Merge fx-team to m-c
authorWes Kocher <wkocher@mozilla.com>
Wed, 26 Feb 2014 18:13:35 -0800
changeset 171217 ef13453839909de4e5d4f9db0b3996110558173e
parent 171209 5d479eb9dc3e9539e8d50ee294d820d1035401ec (current diff)
parent 171216 37a363478881ab6063fcd3b9d980a2b1f1a5ba3d (diff)
child 171218 de2ce8226ca8b1852486da1b7d861ab46caed020
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
milestone30.0a1
Merge fx-team to m-c
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4796,33 +4796,31 @@ const nodeToShortcutMap = {
 #ifdef XP_MACOSX
   "print-button": "printKb",
 #endif
   "new-window-button": "key_newNavigator",
   "fullscreen-button": "key_fullScreen",
   "tabview-button": "key_tabview",
 };
 const gDynamicTooltipCache = new Map();
-function UpdateDynamicShortcutTooltipText(popupTriggerNode) {
-  let label = document.getElementById("dynamic-shortcut-tooltip-label");
-  let nodeId = popupTriggerNode.id;
+function UpdateDynamicShortcutTooltipText(aTooltip) {
+  let nodeId = aTooltip.triggerNode.id;
   if (!gDynamicTooltipCache.has(nodeId) && nodeId in nodeToTooltipMap) {
     let strId = nodeToTooltipMap[nodeId];
     let args = [];
     if (nodeId in nodeToShortcutMap) {
       let shortcutId = nodeToShortcutMap[nodeId];
       let shortcut = document.getElementById(shortcutId);
       if (shortcut) {
         args.push(ShortcutUtils.prettifyShortcut(shortcut));
       }
     }
     gDynamicTooltipCache.set(nodeId, gNavigatorBundle.getFormattedString(strId, args));
   }
-  let desiredLabel = gDynamicTooltipCache.get(nodeId);
-  label.setAttribute("value", desiredLabel);
+  aTooltip.setAttribute("label", gDynamicTooltipCache.get(nodeId));
 }
 
 /**
  * Gets the selected text in the active browser. Leading and trailing
  * whitespace is removed, and consecutive whitespace is replaced by a single
  * space. A maximum of 150 characters will be returned, regardless of the value
  * of aCharLen.
  *
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -471,19 +471,17 @@
 
     <hbox id="bookmarked-notification-container" mousethrough="always">
       <vbox id="bookmarked-notification-anchor">
         <vbox id="bookmarked-notification"/>
       </vbox>
     </hbox>
 
     <tooltip id="dynamic-shortcut-tooltip"
-             onpopupshowing="UpdateDynamicShortcutTooltipText(this.triggerNode)">
-      <label id="dynamic-shortcut-tooltip-label"/>
-    </tooltip>
+             onpopupshowing="UpdateDynamicShortcutTooltipText(this);"/>
   </popupset>
 
 #ifdef CAN_DRAW_IN_TITLEBAR
 <vbox id="titlebar">
   <hbox id="titlebar-content">
     <spacer id="titlebar-spacer" flex="1"/>
     <hbox id="titlebar-buttonbox-container">
       <hbox id="titlebar-buttonbox">
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -69,16 +69,22 @@ public class Tab {
     private static final int MAX_HISTORY_LIST_SIZE = 50;
     private int mLoadProgress;
 
     public static final int STATE_DELAYED = 0;
     public static final int STATE_LOADING = 1;
     public static final int STATE_SUCCESS = 2;
     public static final int STATE_ERROR = 3;
 
+    public static final int LOAD_PROGRESS_INIT = 10;
+    public static final int LOAD_PROGRESS_START = 20;
+    public static final int LOAD_PROGRESS_LOCATION_CHANGE = 60;
+    public static final int LOAD_PROGRESS_LOADED = 80;
+    public static final int LOAD_PROGRESS_STOP = 100;
+
     private static final int DEFAULT_BACKGROUND_COLOR = Color.WHITE;
 
     public enum ErrorType {
         CERT_ERROR,  // Pages with certificate problems
         BLOCKED,     // Pages blocked for phishing or malware warnings
         NET_ERROR,   // All other types of error
         NONE         // Non error pages
     }
@@ -107,16 +113,17 @@ public class Tab {
         mBookmark = false;
         mReadingListItem = false;
         mFaviconLoadId = 0;
         mContentType = "";
         mZoomConstraints = new ZoomConstraints(false);
         mPluginViews = new ArrayList<View>();
         mPluginLayers = new HashMap<Object, Layer>();
         mState = shouldShowProgress(url) ? STATE_SUCCESS : STATE_LOADING;
+        mLoadProgress = LOAD_PROGRESS_INIT;
 
         // At startup, the background is set to a color specified by LayerView
         // when the LayerView is created. Shortly after, this background color
         // will be used before the tab's content is shown.
         mBackgroundColor = DEFAULT_BACKGROUND_COLOR;
 
         updateBookmark();
     }
@@ -623,48 +630,55 @@ public class Tab {
         setHasFeeds(false);
         setHasOpenSearch(false);
         updateIdentityData(null);
         setReaderEnabled(false);
         setZoomConstraints(new ZoomConstraints(true));
         setHasTouchListeners(false);
         setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
         setErrorType(ErrorType.NONE);
+        setLoadProgress(LOAD_PROGRESS_LOCATION_CHANGE);
 
         Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.LOCATION_CHANGE, oldUrl);
     }
 
     private static boolean shouldShowProgress(final String url) {
         return AboutPages.isAboutHome(url) ||
                AboutPages.isAboutReader(url) ||
                AboutPages.isAboutPrivateBrowsing(url);
     }
 
     void handleDocumentStart(boolean showProgress, String url) {
+        setLoadProgress(LOAD_PROGRESS_START);
         setState(showProgress ? STATE_LOADING : STATE_SUCCESS);
         updateIdentityData(null);
         setReaderEnabled(false);
     }
 
     void handleDocumentStop(boolean success) {
         setState(success ? STATE_SUCCESS : STATE_ERROR);
 
         final String oldURL = getURL();
         final Tab tab = this;
+        tab.setLoadProgress(LOAD_PROGRESS_STOP);
         ThreadUtils.getBackgroundHandler().postDelayed(new Runnable() {
             @Override
             public void run() {
                 // tab.getURL() may return null
                 if (!TextUtils.equals(oldURL, getURL()))
                     return;
 
                 ThumbnailHelper.getInstance().getAndProcessThumbnailFor(tab);
             }
         }, 500);
-     }
+    }
+
+    void handleContentLoaded() {
+        setLoadProgress(LOAD_PROGRESS_LOADED);
+    }
 
     protected void saveThumbnailToDB() {
         try {
             String url = getURL();
             if (url == null)
                 return;
 
             BrowserDB.updateThumbnailForUrl(getContentResolver(), url, mThumbnail);
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -46,21 +46,16 @@ public class Tabs implements GeckoEventL
     private volatile Tab mSelectedTab;
 
     // All accesses to mTabs must be synchronized on the Tabs instance.
     private final HashMap<Integer, Tab> mTabs = new HashMap<Integer, Tab>();
 
     private AccountManager mAccountManager;
     private OnAccountsUpdateListener mAccountListener = null;
 
-    private static final int LOAD_PROGRESS_START = 20;
-    private static final int LOAD_PROGRESS_LOCATION_CHANGE = 60;
-    private static final int LOAD_PROGRESS_LOADED = 80;
-    private static final int LOAD_PROGRESS_STOP = 100;
-
     public static final int LOADURL_NONE         = 0;
     public static final int LOADURL_NEW_TAB      = 1 << 0;
     public static final int LOADURL_USER_ENTERED = 1 << 1;
     public static final int LOADURL_PRIVATE      = 1 << 2;
     public static final int LOADURL_PINNED       = 1 << 3;
     public static final int LOADURL_DELAY_LOAD   = 1 << 4;
     public static final int LOADURL_DESKTOP      = 1 << 5;
     public static final int LOADURL_BACKGROUND   = 1 << 6;
@@ -435,53 +430,50 @@ public class Tabs implements GeckoEventL
             if (event.startsWith("SessionHistory:")) {
                 event = event.substring("SessionHistory:".length());
                 tab.handleSessionHistoryMessage(event, message);
             } else if (event.equals("Tab:Close")) {
                 closeTab(tab);
             } else if (event.equals("Tab:Select")) {
                 selectTab(tab.getId());
             } else if (event.equals("Content:LocationChange")) {
-                tab.setLoadProgress(LOAD_PROGRESS_LOCATION_CHANGE);
                 tab.handleLocationChange(message);
             } else if (event.equals("Content:SecurityChange")) {
                 tab.updateIdentityData(message.getJSONObject("identity"));
                 notifyListeners(tab, TabEvents.SECURITY_CHANGE);
             } else if (event.equals("Content:ReaderEnabled")) {
                 tab.setReaderEnabled(true);
                 notifyListeners(tab, TabEvents.READER_ENABLED);
             } else if (event.equals("Content:StateChange")) {
                 int state = message.getInt("state");
                 if ((state & GeckoAppShell.WPL_STATE_IS_NETWORK) != 0) {
                     if ((state & GeckoAppShell.WPL_STATE_START) != 0) {
                         boolean showProgress = message.getBoolean("showProgress");
                         tab.handleDocumentStart(showProgress, message.getString("uri"));
-                        tab.setLoadProgress(LOAD_PROGRESS_START);
                         notifyListeners(tab, Tabs.TabEvents.START);
                     } else if ((state & GeckoAppShell.WPL_STATE_STOP) != 0) {
                         tab.handleDocumentStop(message.getBoolean("success"));
-                        tab.setLoadProgress(LOAD_PROGRESS_STOP);
                         notifyListeners(tab, Tabs.TabEvents.STOP);
                     }
                 }
             } else if (event.equals("Content:LoadError")) {
-                tab.setLoadProgress(LOAD_PROGRESS_LOADED);
+                tab.handleContentLoaded();
                 notifyListeners(tab, Tabs.TabEvents.LOAD_ERROR);
             } else if (event.equals("Content:PageShow")) {
                 notifyListeners(tab, TabEvents.PAGE_SHOW);
             } else if (event.equals("DOMContentLoaded")) {
+                tab.handleContentLoaded();
                 String backgroundColor = message.getString("bgColor");
                 if (backgroundColor != null) {
                     tab.setBackgroundColor(backgroundColor);
                 } else {
                     // Default to white if no color is given
                     tab.setBackgroundColor(Color.WHITE);
                 }
                 tab.setErrorType(message.optString("errorType"));
-                tab.setLoadProgress(LOAD_PROGRESS_LOADED);
                 notifyListeners(tab, Tabs.TabEvents.LOADED);
             } else if (event.equals("DOMTitleChanged")) {
                 tab.updateTitle(message.getString("title"));
             } else if (event.equals("Link:Favicon")) {
                 tab.updateFaviconURL(message.getString("href"), message.getInt("size"));
                 notifyListeners(tab, TabEvents.LINK_FAVICON);
             } else if (event.equals("Link:Feed")) {
                 tab.setHasFeeds(true);
--- a/mobile/android/base/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/toolbar/BrowserToolbar.java
@@ -465,18 +465,19 @@ public class BrowserToolbar extends Geck
         }
 
         if (tabs.isSelectedTab(tab)) {
             final EnumSet<UpdateFlags> flags = EnumSet.noneOf(UpdateFlags.class);
 
             // Progress-related handling
             switch (msg) {
                 case START:
-                    updateProgressVisibility(tab, 0);
+                    updateProgressVisibility(tab, Tab.LOAD_PROGRESS_INIT);
                     // Fall through.
+                case ADDED:
                 case LOCATION_CHANGE:
                 case LOAD_ERROR:
                 case LOADED:
                 case STOP:
                     flags.add(UpdateFlags.PROGRESS);
                     if (mProgressBar.getVisibility() == View.VISIBLE) {
                         mProgressBar.animateProgress(tab.getLoadProgress());
                     }