support for caching outside of visible region (currently buggy in platform)
authorBenjamin Stover <bstover@mozilla.com>
Fri, 27 Aug 2010 12:12:48 -0700
changeset 1963 188df9e247934bca62ff36621aee5c73b664a27c
parent 1962 59aead7224007bb4cec554a75b1c08eb81454ed8
child 1964 20424865e08b3da1cfd7f4e85f58e79d05b14d8f
push id1714
push userdougt@mozilla.com
push dateThu, 16 Sep 2010 02:04:21 +0000
support for caching outside of visible region (currently buggy in platform)
chrome/content/bindings/browser.js
chrome/content/bindings/browser.xml
--- a/chrome/content/bindings/browser.js
+++ b/chrome/content/bindings/browser.js
@@ -361,27 +361,43 @@ let DOMEvents =  {
 };
 
 DOMEvents.init();
 
 let ContentScroll =  {
   init: function() {
     addMessageListener("Content:ScrollTo", this);
     addMessageListener("Content:ScrollBy", this);
+    addMessageListener("Content:ZoomLevel", this);
+    addMessageListener("Content:FastScrollTo", this);
   },
 
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     switch (aMessage.name) {
       case "Content:ScrollTo":
         content.scrollTo(json.x, json.y);
         break;
       case "Content:ScrollBy":
         content.scrollBy(json.dx, json.dy);
         break;
+      case "Content:ZoomLevel":
+        // XXX not working yet
+        break;
+      case "Content:FastScrollTo":
+        // XXX not working yet
+        try {
+          let cwu = Util.getWindowUtils(content);
+          cwu.setDisplayport(json.x - 200, json.y - 400,
+                             content.innerWidth + 400, content.innerHeight + 800);
+        } catch(e) {
+          Util.dumpLn(e);
+        }
+        sendAsyncMessage("Content:FastScrollTo:Return");
+        break;
     }
   }
 };
 
 ContentScroll.init();
 
 
 function PromptRemoter() {
--- a/chrome/content/bindings/browser.xml
+++ b/chrome/content/bindings/browser.xml
@@ -144,16 +144,20 @@
 
             case "Prompt:Prompt":
               return prompt(aMessage.json.text, aMessage.json.value);
 
             case "MozScrolledAreaChanged":
               this._widthInDevicePx = aMessage.json.width;
               this._heightInDevicePx = aMessage.json.height;
               break;
+
+            case "Content:FastScrollTo:Return":
+              this._flushingFastScroll = false;
+              break;
          }
         ]]></body>
       </method>
 
       <method name="_getLinkType">
         <parameter name="aLink" />
         <body><![CDATA[
           let type = "";
@@ -376,25 +380,44 @@
           ]]>
         </body>
       </method>
 
       <property name="_frameLoader"
                 onget="return this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;"
                 readonly="true"/>
 
+      <field name="_flushingFastScroll">false</field>
       <field name="_widthInDevicePx">0</field>
       <field name="_heightInDevicePx">0</field>
+      <field name="_zoomLevel">1</field>
+
       <property name="widthInDevicePx"
                 onget="return this._widthInDevicePx;"
                 readonly="true"/>
       <property name="heightInDevicePx"
                 onget="return this._heightInDevicePx;"
                 readonly="true"/>
 
+      <property name="zoomLevel"
+                onget="return this._zoomLevel;"
+                onset="return this._setZoomLevel(val);"/>
+
+      <method name="_setZoomLevel">
+        <parameter name="zl"/>
+        <body>
+          <![CDATA[
+            throw "Not supported yet!";
+            if (zl <= 0) throw "Bad zoom level given.";
+            this._zoomLevel = zl;
+            this.messageManager.sendAsyncMessage("Content:ZoomLevel", { zoomLevel: zl });
+          ]]>
+        </body>
+      </method>
+
       <method name="flushScroll">
         <body>
           <![CDATA[
             let frameLoader = this._frameLoader;
             this.messageManager.sendAsyncMessage("Content:ScrollTo", {
               x: frameLoader.viewportScrollX,
               y: frameLoader.viewportScrollY
             });
@@ -410,17 +433,32 @@
             let frameLoader = this._frameLoader;
 
             // XXX don't assume window size is viewport size
             let viewportWidth = window.innerWidth;
             let viewportHeight = window.innerHeight;
 
             x = Math.max(0, Math.min(this.widthInDevicePx - viewportWidth, frameLoader.viewportScrollX + x)) - frameLoader.viewportScrollX;
             y = Math.max(0, Math.min(this.heightInDevicePx - viewportHeight, frameLoader.viewportScrollY + y)) - frameLoader.viewportScrollY;
+
+            if (x == 0 && y == 0)
+              return;
+
             frameLoader.scrollViewportBy(x, y);
+
+            /*
+            XXX broken right now
+            if (this._flushingFastScroll == false) {
+              this._flushingFastScroll = true;
+              this.messageManager.sendAsyncMessage("Content:FastScrollTo", {
+                x: frameLoader.viewportScrollX + x,
+                y: frameLoader.viewportScrollY + y
+              });
+            }
+            */
           ]]>
         </body>
       </method>
 
       <method name="scrollTo">
         <parameter name="x"/>
         <parameter name="y"/>
         <body>
@@ -464,16 +502,17 @@
           this.messageManager.addMessageListener("DOMPopupBlocked", this);
 
           // Prompt remoting
           ["Alert", "Confirm", "Prompt"].forEach(function(name) {
             this.messageManager.addMessageListener("Prompt:" + name, this);
           }, this);
 
           this.messageManager.addMessageListener("MozScrolledAreaChanged", this);
+          this.messageManager.addMessageListener("Content:FastScrollTo:Return", this);
 
           this._webProgress._init();
         ]]>
       </constructor>
 
     </implementation>
 
   </binding>