Bug 618975 Mobile patch r=mfinkle a=blocking-fennec
authorBenjamin Stover <bstover@mozilla.com>
Tue, 15 Mar 2011 16:22:10 -0700
changeset 2915 a847680012a7be59cde44f6a5a953b8607ee1c8b
parent 2914 1f1e7d6465644f79c4a5977fc05474746119cc68
child 2916 90d505ee8f9b801afff34386683b0f1727f7fce4
push id2459
push userbstover@mozilla.com
push dateTue, 15 Mar 2011 23:22:58 +0000
reviewersmfinkle, blocking-fennec
bugs618975
Bug 618975 Mobile patch r=mfinkle a=blocking-fennec
chrome/content/bindings/browser.js
chrome/content/bindings/browser.xml
chrome/content/browser.js
--- a/chrome/content/bindings/browser.js
+++ b/chrome/content/bindings/browser.js
@@ -298,21 +298,28 @@ let ContentScroll =  {
   getScrollOffset: function(aWindow) {
     let cwu = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
     let scrollX = {}, scrollY = {};
     cwu.getScrollXY(false, scrollX, scrollY);
     return { x: scrollX.value, y: scrollY.value };
   },
 
   getScrollOffsetForElement: function(aElement) {
-    return this.getScrollOffset(aElement.ownerDocument.defaultView);
+    if (aElement.parentNode == aElement.ownerDocument)
+      return this.getScrollOffset(aElement.ownerDocument.defaultView);
+    return { x: aElement.scrollLeft, y: aElement.scrollTop };
   },
 
   setScrollOffsetForElement: function(aElement, aLeft, aTop) {
-    aElement.ownerDocument.defaultView.scrollTo(aLeft, aTop);
+    if (aElement.parentNode == aElement.ownerDocument) {
+      aElement.ownerDocument.defaultView.scrollTo(aLeft, aTop);
+    } else {
+      aElement.scrollLeft = aLeft;
+      aElement.scrollTop = aTop;
+    }
   },
 
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     switch (aMessage.name) {
       case "Content:SetCacheViewport": {
         // Set resolution for root view
         let rootCwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
@@ -344,17 +351,18 @@ let ContentScroll =  {
 
         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(x, y, displayport.width, displayport.height);
+        let winCwu20 = winCwu.QueryInterface(Ci.nsIDOMWindowUtils_MOZILLA_2_0_BRANCH);
+        winCwu20.setDisplayPortForElement(x, y, displayport.width, displayport.height, element);
 
         // XXX If we scrolled during this displayport update, then it is the
         //     end of a pan. Due to bug 637852, there may be seaming issues
         //     with the visible content, so we need to redraw.
         if (json.id == 1 && json.scrollX >= 0 && json.scrollY >= 0)
           winCwu.redraw();
 
         break;
@@ -422,17 +430,18 @@ let ContentActive =  {
   },
 
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     switch (aMessage.name) {
       case "Content:Deactivate":
         docShell.isActive = false;
         let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
-        cwu.setDisplayPort(0,0,0,0);
+        let cwu20 = cwu.QueryInterface(Ci.nsIDOMWindowUtils_MOZILLA_2_0_BRANCH);
+        cwu20.setDisplayPortForElement(0,0,0,0,content.document.documentElement);
         break;
 
       case "Content:Activate":
         docShell.isActive = true;
         break;
     }
   }
 };
--- a/chrome/content/bindings/browser.xml
+++ b/chrome/content/bindings/browser.xml
@@ -948,17 +948,23 @@
           },
 
           /**
            * The cache viewport is what parts of content is cached in the parent process for
            * fast scrolling. This syncs that up with the current projection viewport.
            */
           _updateCacheViewport: function() {
             // Do not update scroll values for content.
-            this._sendDisplayportUpdate(-1, -1);
+            if (this.isRoot())
+              this._sendDisplayportUpdate(-1, -1);
+            else {
+              let contentView = this._contentView;
+              this._sendDisplayportUpdate(contentView.scrollX,
+                                          contentView.scrollY);
+            }
           },
 
           _getContentSize: function() {
             let self = this.self;
             if (this.isRoot()) {
               // XXX Bug 626792 means contentWidth and contentHeight aren't always
               // updated immediately. This makes the displayport go haywire so
               // use contentDocument properties.
--- a/chrome/content/browser.js
+++ b/chrome/content/browser.js
@@ -1161,16 +1161,18 @@ Browser.MainDragger.prototype = {
     this._hitSidebar = false;
     if (this._sidebarTimeout) {
       clearTimeout(this._sidebarTimeout);
       this._sidebarTimeout = null;
     }
   },
 
   dragStop: function dragStop(dx, dy, scroller) {
+    if (this._contentView && this._contentView._updateCacheViewport)
+      this._contentView._updateCacheViewport();
     this._contentView = null;
     this.dragMove(Browser.snapSidebars(), 0, scroller);
     Browser.tryUnfloatToolbar();
   },
 
   dragMove: function dragMove(dx, dy, scroller, aIsKinetic) {
     let doffset = new Point(dx, dy);