Bug 961377 - Extend webapp runtime to support tooltips in webapps like in the normal browser; r=felipe
authorJeroen van der Gun <jeroen@blijbol.nl>
Thu, 23 Jan 2014 10:31:00 +0000
changeset 164993 7d6daa084033cf2afb3fa8c37e4cd75db37cd6ac
parent 164992 822ce3170f0f8f457888c0ca8e9e47bce9ce4c9b
child 164994 65bfef117974dcc3fd6c145642b1e3664c13e0a6
push id38871
push usercbook@mozilla.com
push dateFri, 24 Jan 2014 08:28:29 +0000
treeherdermozilla-inbound@8be30d3b0b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs961377
milestone29.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
Bug 961377 - Extend webapp runtime to support tooltips in webapps like in the normal browser; r=felipe
webapprt/content/webapp.js
webapprt/content/webapp.xul
--- a/webapprt/content/webapp.js
+++ b/webapprt/content/webapp.js
@@ -19,16 +19,37 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    "nsICrashReporter");
 #endif
 
 let progressListener = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
                                          Ci.nsISupportsWeakReference]),
   onLocationChange: function onLocationChange(progress, request, location,
                                               flags) {
+
+    // Close tooltip (code adapted from /browser/base/content/browser.js)
+    let pageTooltip = document.getElementById("contentAreaTooltip");
+    let tooltipNode = pageTooltip.triggerNode;
+    if (tooltipNode) {
+      // Optimise for the common case
+      if (progress.isTopLevel) {
+        pageTooltip.hidePopup();
+      }
+      else {
+        for (let tooltipWindow = tooltipNode.ownerDocument.defaultView;
+             tooltipWindow != tooltipWindow.parent;
+             tooltipWindow = tooltipWindow.parent) {
+          if (tooltipWindow == progress.DOMWindow) {
+            pageTooltip.hidePopup();
+            break;
+          }
+        }
+      }
+    }
+
     // Set the title of the window to the name of the webapp, adding the origin
     // of the page being loaded if it's from a different origin than the app
     // (per security bug 741955, which specifies that other-origin pages loaded
     // in runtime windows must be identified in chrome).
     let title = WebappRT.config.app.manifest.name;
     let origin = location.prePath;
     if (origin != WebappRT.config.app.origin) {
       title = origin + " - " + title;
--- a/webapprt/content/webapp.xul
+++ b/webapprt/content/webapp.xul
@@ -150,18 +150,19 @@
                   label="&selectAllCmd.label;"
                   key="key_selectAll"
                   accesskey="&selectAllCmd.accesskey;"
                   command="cmd_selectAll"/>
       </menupopup>
     </menu>
   </menubar>
 
-  <browser type="content-primary" id="content" flex="1" context="contentAreaContextMenu" />
+  <browser type="content-primary" id="content" flex="1" context="contentAreaContextMenu" tooltip="contentAreaTooltip" />
 
   <popupset>
     <menupopup id="contentAreaContextMenu" pagemenu="start"
                onpopupshowing="return showContextMenu(event, this)"
                onpopuphiding="hideContextMenu(event, this)">
     </menupopup>
+    <tooltip id="contentAreaTooltip" page="true" />
   </popupset>
 
 </window>