Bug 63742 Snap displayport updates to device pixels [r=mbrubeck]
authorBenjamin Stover <bstover@mozilla.com>
Wed, 02 Mar 2011 16:33:57 -0800
changeset 67466 cba6aba978cb021d67d08ad84afe47108fe331ed
parent 67465 8f4937a1fa8be52b231fc496789f4219ea5cf6f9
child 67467 5f90d630749b654ba5df9e7e3202bc03f99e2b29
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)
reviewersmbrubeck
bugs63742
Bug 63742 Snap displayport updates to device pixels [r=mbrubeck]
mobile/chrome/content/bindings/browser.js
mobile/chrome/content/bindings/browser.xml
--- a/mobile/chrome/content/bindings/browser.js
+++ b/mobile/chrome/content/bindings/browser.js
@@ -332,21 +332,27 @@ let ContentScroll =  {
           this.setScrollOffsetForElement(element, json.scrollX, json.scrollY)
           if (json.id == 1)
             this._scrollOffset = this.getScrollOffset(content);
         }
 
         // Set displayport. We want to set this after setting the scroll offset, because
         // it is calculated based on the scroll offset.
         let scrollOffset = this.getScrollOffsetForElement(element);
+        let x = displayport.x - scrollOffset.x;
+        let y = displayport.y - scrollOffset.y;
+
+        if (json.id == 1) {
+          x = Math.round(x * json.scale) / json.scale;
+          y = Math.round(y * json.scale) / json.scale;
+        }
+
         let win = element.ownerDocument.defaultView;
         let winCwu = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
-        winCwu.setDisplayPort(
-          displayport.x - scrollOffset.x, displayport.y - scrollOffset.y,
-          displayport.width, displayport.height);
+        winCwu.setDisplayPort(x, y, displayport.width, displayport.height);
 
         break;
       }
 
       case "Content:SetWindowSize": {
         let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
         cwu.setCSSViewport(json.width, json.height);
         break;
--- a/mobile/chrome/content/bindings/browser.xml
+++ b/mobile/chrome/content/bindings/browser.xml
@@ -919,22 +919,22 @@
             // Use our pixels efficiently and don't try to cache things outside of content
             // boundaries.
             let bounds = new Rect(0, 0, contentSize.width, contentSize.height);
             let displayport = new Rect(cacheX, cacheY, cacheSize.width, cacheSize.height);
             displayport.translateInside(bounds);
 
             let rootScale = self.scale;
             self.messageManager.sendAsyncMessage("Content:SetCacheViewport", {
-              scrollX: scrollX / rootScale,
-              scrollY: scrollY / rootScale,
-              x: displayport.x / rootScale,
-              y: displayport.y / rootScale,
-              w: displayport.width / rootScale,
-              h: displayport.height / rootScale,
+              scrollX: Math.round(scrollX) / rootScale,
+              scrollY: Math.round(scrollY) / rootScale,
+              x: Math.round(displayport.x) / rootScale,
+              y: Math.round(displayport.y) / rootScale,
+              w: Math.round(displayport.width) / rootScale,
+              h: Math.round(displayport.height) / rootScale,
               scale: rootScale,
               id: contentView.id
             });
 
             this._pixelsPannedSinceRefresh.x = 0;
             this._pixelsPannedSinceRefresh.y = 0;
           },