Bug 605630 - Scroll scrollboxes in local tabs [r=stechz, a=blocking-fennec]
authorWes Johnston <wjohnston@mozilla.com>
Mon, 31 Jan 2011 14:11:27 -0800
changeset 2725 47fcd80acad09b287f6384a13764afdad5a8e3e3
parent 2724 62f187e05e7eeb5093147350988c1f10fe8fbd8f
child 2726 b9bc51d30b324ec1b2a17a2d0df235b3b9f97e11
push id2288
push userwjohnston@mozilla.com
push dateMon, 31 Jan 2011 22:12:21 +0000
reviewersstechz, blocking-fennec
bugs605630
Bug 605630 - Scroll scrollboxes in local tabs [r=stechz, a=blocking-fennec]
chrome/content/bindings/browser.xml
--- a/chrome/content/bindings/browser.xml
+++ b/chrome/content/bindings/browser.xml
@@ -64,17 +64,17 @@
 
       <field name="_searchEngines">[]</field>
       <property name="searchEngines"
                 onget="return this._searchEngines"
                 readonly="true"/>
 
       <field name="_documentURI">null</field>
       <property name="documentURI"
-                onget="return this._documentURI ? Services.io.newURI(this._documentURI, null, null) : null"
+                onget="return this._documentURI ? this._ios.newURI(this._documentURI, null, null) : null"
                 readonly="true"/>
 
       <field name="contentWindowId">null</field>
 
       <property name="messageManager"
                 onget="return this._frameLoader.messageManager;"
                 readonly="true"/>
 
@@ -153,17 +153,17 @@
         })
       ]]></field>
 
       <method name="loadFavicon">
         <parameter name="aURL"/>
         <parameter name="aCharset"/>
         <body><![CDATA[
             try { // newURI call is throwing for chrome URI
-              let iconURI = Services.io.newURI(aURL, aCharset, null);
+              let iconURI = this._ios.newURI(aURL, aCharset, null);
               if (gFaviconService.isFailedFavicon(iconURI))
                 return;
 
               gFaviconService.setAndLoadFaviconForPage(this.currentURI, iconURI, true);
               this.mIconURL = iconURI.spec;
             } catch (e) {
               this.mIconURL = null;
             }
@@ -223,26 +223,27 @@
 
                 if (this._browser.updateWindowId(json.contentWindowId)) {
                   this._browser._documentURI = json.documentURI;
                   this._browser._searchEngines = [];
                 }
                 break;
 
               case "Content:SecurityChange":
-                let serhelper = Cc["@mozilla.org/network/serialization-helper;1"].getService(Ci.nsISerializationHelper);
+                let serhelper = Components.classes["@mozilla.org/network/serialization-helper;1"]
+                                .getService(Components.interfaces.nsISerializationHelper);
                 let SSLStatus = json.SSLStatusAsString ? serhelper.deserializeObject(json.SSLStatusAsString) : null;
                 if (SSLStatus) {
-                  SSLStatus.QueryInterface(Ci.nsISSLStatus);
+                  SSLStatus.QueryInterface(Components.interfaces.nsISSLStatus);
                   if (SSLStatus) {
                     // We must check the Extended Validation (EV) state here, on the chrome
                     // process, because NSS is needed for that determination.
-                    let ii = SSLStatus.serverCert.QueryInterface(Ci.nsIIdentityInfo);
+                    let ii = SSLStatus.serverCert.QueryInterface(Components.interfaces.nsIIdentityInfo);
                     if (ii && ii.isExtendedValidation)
-                      json.state |= Ci.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL;
+                      json.state |= Components.interfaces.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL;
                   }
                 }
 
                 let data = this._getIdentityData(SSLStatus);
                 this._browser._securityUI = {
                   SSLStatus: SSLStatus ? {serverCert: data} : null,
                   state: json.state
                 }
@@ -278,17 +279,18 @@
                 result.state = result.subjectNameFields.ST;
                 result.country = result.subjectNameFields.C;
               }
 
               // Human readable name of Certificate Authority
               result.caOrg =  cert.issuerOrganization || cert.issuerCommonName;
 
               if (!this._overrideService)
-                this._overrideService = Cc["@mozilla.org/security/certoverride;1"].getService(Ci.nsICertOverrideService);
+                this._overrideService = Components.classes["@mozilla.org/security/certoverride;1"]
+                                        .getService(Components.interfaces.nsICertOverrideService);
 
               // Check whether this site is a security exception.
               let currentURI = this._browser._webNavigation._currentURI;
               result.isException = !!this._overrideService.hasMatchingOverride(currentURI.asciiHost, currentURI.port, cert, {}, {});
             }
 
             return result;
           }
@@ -349,17 +351,17 @@
               this.pageReport = [];
             }
 
             let json = aMessage.json;
             // XXX Replacing requestingWindow && requestingDocument affects
             // http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#500
             var obj = {
               requestingWindowId: json.windowId,
-              popupWindowURI: Services.io.newURI(json.popupWindowURI.spec, json.popupWindowURI.charset, null),
+              popupWindowURI: this._ios.newURI(json.popupWindowURI.spec, json.popupWindowURI.charset, null),
               popupWindowFeatures: json.popupWindowFeatures,
               popupWindowName: json.popupWindowName
             };
 
             this.pageReport.push(obj);
             this.pageReport.reported = false;
             this.updatePageReport();
           ]]>
@@ -432,20 +434,63 @@
       <method name="getRootView">
         <body>
           <![CDATA[
             return this._contentView;
           ]]>
         </body>
       </method>
 
+      <field name="_contentViewPrototype"><![CDATA[
+        ({
+          _scrollbox: null,
+
+          init: function(aElement) {
+            this._scrollbox = aElement.scrollBoxObject;
+          },
+
+          isRoot: function() {
+            return false;
+          },
+
+          scrollBy: function(x, y) {
+            this._scrollbox.scrollBy(x,y);
+          },
+
+          scrollTo: function(x, y) {
+            this._scrollbox.scrollTo(x,y);
+          },
+
+          getPosition: function() {
+            let x = {}, y = {};
+            this._scrollbox.getPosition(x, y);
+            return { x: x.value, y: y.value };
+          }
+        })
+        ]]>
+      </field>
+
       <method name="getViewAt">
+        <parameter name="x"/>
+        <parameter name="y"/>
         <body>
           <![CDATA[
-            return this._contentView;
+            let cwu = this.contentDocument.defaultView.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+                                                      .getInterface(Components.interfaces.nsIDOMWindowUtils);
+            let elt = cwu.elementFromPoint(x, y, false, false);
+
+            while (elt && !elt.scrollBoxObject)
+              elt = elt.parentNode;
+ 
+            if (!elt)
+              return this._contentView;
+
+            let cv = Object.create(this._contentViewPrototype);
+            cv.init(elt);
+            return cv;
           ]]>
         </body>
       </method>
 
       <field name="_contentView"><![CDATA[
         ({
           self: this,