fix tap highlighting
authorBenjamin Stover <bstover@mozilla.com>
Thu, 02 Sep 2010 13:57:02 -0700
changeset 66626 170b86ea6a36eaed1d7f1f0ba850ec3f2231fbcf
parent 66625 5484e321e6618720ddafbe2d2a6514b20c9d976b
child 66627 91874b795d6e89a4fc96856c64b2547d1726e9e4
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
fix tap highlighting
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/chrome/content/browser.xul
mobile/chrome/content/content.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1032,42 +1032,44 @@ var BrowserUI = {
 
 var TapHighlightHelper = {
   get _overlay() {
     delete this._overlay;
     return this._overlay = document.getElementById("content-overlay");
   },
 
   show: function show(aRects) {
-    return;
+    let scrollX = {}, scrollY = {};
+    getBrowser().getPosition(scrollX, scrollY);
 
     let union = aRects.reduce(function(a, b) {
       return a.expandToContain(b);
-    }, new Rect(0, 0, 0, 0)).map(bv.browserToViewport);
-
-    let vis = Browser.getVisibleRect();
+    }, new Rect(0, 0, 0, 0)).map(function(val) { return val * getBrowser().scale; })
+                            .translate(-scrollX.value, -scrollY.value);
+
+    let vis = Rect.fromRect(getBrowser().getBoundingClientRect());
     let canvasArea = vis.intersect(union);
 
     let overlay = this._overlay;
     overlay.width = canvasArea.width;
     overlay.style.width = canvasArea.width + "px";
     overlay.height = canvasArea.height;
     overlay.style.height = canvasArea.height + "px";
 
     let ctx = overlay.getContext("2d");
     ctx.save();
     ctx.translate(-canvasArea.left, -canvasArea.top);
-    bv.browserToViewportCanvasContext(ctx);
+    ctx.scale(getBrowser().scale, getBrowser().scale);
 
     overlay.style.left = canvasArea.left + "px";
     overlay.style.top = canvasArea.top + "px";
     ctx.fillStyle = "rgba(0, 145, 255, .5)";
     for (let i = aRects.length - 1; i >= 0; i--) {
       let rect = aRects[i];
-      ctx.fillRect(rect.left, rect.top, rect.width, rect.height);
+      ctx.fillRect(rect.left - scrollX.value / getBrowser().scale, rect.top - scrollY.value / getBrowser().scale, rect.width, rect.height);
     }
     ctx.restore();
     overlay.style.display = "block";
   },
 
   hide: function hide() {
     this._overlay.style.display = "none";
   }
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -762,18 +762,18 @@ var Browser = {
     if (!dy) dy = 0;
 
     let leftbarCBR = document.getElementById('tabs-container').getBoundingClientRect();
     let ritebarCBR = document.getElementById('browser-controls').getBoundingClientRect();
 
     if (leftbarCBR.left > ritebarCBR.left)
       [ritebarCBR, leftbarCBR] = [leftbarCBR, ritebarCBR]; // switch in RTL case
 
-    let leftbar = new Rect(Math.round(leftbarCBR.left) - dx, 0, Math.round(leftbarCBR.width), 1);
-    let ritebar = new Rect(Math.round(ritebarCBR.left) - dx, 0, Math.round(ritebarCBR.width), 1);
+    let leftbar = new Rect(Math.round(leftbarCBR.left) - Math.round(dx), 0, Math.round(leftbarCBR.width), 1);
+    let ritebar = new Rect(Math.round(ritebarCBR.left) - Math.round(dx), 0, Math.round(ritebarCBR.width), 1);
     let leftw = leftbar.width;
     let ritew = ritebar.width;
 
     let visrect = new Rect(0, 0, window.innerWidth, 1);
 
     let leftvis = visibility(leftbar, visrect);
     let ritevis = visibility(ritebar, visrect);
 
@@ -1051,28 +1051,23 @@ Browser.MainDragger.prototype = {
   isDraggable: function isDraggable(target, scroller) {
     return { x: true, y: true };
   },
 
   dragStart: function dragStart(clientX, clientY, target, scroller) {
   },
 
   dragStop: function dragStop(dx, dy, scroller) {
-    this.draggedFrame = null;
     this.dragMove(Browser.snapSidebars(), 0, scroller);
     Browser.tryUnfloatToolbar();
   },
 
   dragMove: function dragMove(dx, dy, scroller) {
     let doffset = new Point(dx, dy);
 
-    if (!this._dragMoved) {
-      this._dragMoved = true;
-    }
-
     // First calculate any panning to take sidebars out of view
     let panOffset = this._panControlsAwayOffset(doffset);
 
     // Do content panning
     this._panScroller(Browser.contentScrollboxScroller, doffset);
 
     // Any leftover panning in doffset would bring controls into view. Add to sidebar
     // away panning for the total scroll offset.
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -267,20 +267,21 @@
             </box>
 
             <notificationbox id="notifications" class="window-width"/>
 
             <!-- Content viewport -->
             <vbox class="window-width window-height">
               <stack id="tile-stack" class="window-width" flex="1">
               <!-- Content viewport -->
-                <html:div id="browsers"/>
-                <html:canvas id="content-overlay" style="display: none; position: absolute; z-index: 1000; left: 0; top: 0;">
-                </html:canvas>
-                <html:div id="inputhandler-overlay" style="z-index: 1000; left: 0; top: 0" tabindex="-1"/>
+                <html:div>
+                  <html:div id="browsers"/>
+                  <html:canvas id="content-overlay" style="display: none; position: absolute; z-index: 1000; left: 0; top: 0;"/>
+                </html:div>
+                <html:div id="inputhandler-overlay" style="z-index: 1001" tabindex="-1"/>
               </stack>
               <box id="content-navigator-spacer" hidden="true"/>
             </vbox>
           </vbox>
         </scrollbox>
 
         <!-- popup for content navigator helper -->
         <vbox id="content-navigator" class="window-width" top="0" spacer="content-navigator-spacer">
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -409,23 +409,22 @@ Content.prototype = {
       case "Browser:MouseDown":
         this._overlayTimeout.clear();
         this._contextTimeout.clear();
 
         let element = elementFromPoint(x, y);
         if (!element)
           return;
 
-// XXX somehow this always take up the entire screen
-/*        if (element.mozMatchesSelector("*:link,*:visited,*:link *,*:visited *,*[role=button],button,input,option,select,textarea,label")) {
+        if (element.mozMatchesSelector("*:link,*:visited,*:link *,*:visited *,*[role=button],button,input,option,select,textarea,label")) {
           this._overlayTimeout.once(kTapOverlayTimeout, function() {
             let rects = getContentClientRects(element);
             sendAsyncMessage("Browser:Highlight", { rects: rects });
           });
-        } */
+        }
 
         // We add a few milliseconds because of how the InputHandler wait before
         // dispatching a single click (default: 500)
         this._contextTimeout.once(500 + 200, function() {
           let event = content.document.createEvent("PopupEvents");
           event.initEvent("contextmenu", true, true);
           element.dispatchEvent(event);
         });