Bug 626457 - Move some code out of Browser.startup(); [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 08 Feb 2011 23:46:24 +0100
changeset 67358 b46d6b9d5fda70fbb8f78f5aff2e55873c919fa0
parent 67357 b36d32dbc61145553dd6c5ea3839dba217c24830
child 67359 76deb4e68c16500a6e483d84a40627c30cf47f89
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)
reviewersmfinkle
bugs626457
Bug 626457 - Move some code out of Browser.startup(); [r=mfinkle]
mobile/chrome/content/Util.js
mobile/chrome/content/bindings/browser.js
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/chrome/content/content.js
mobile/chrome/content/forms.js
--- a/mobile/chrome/content/Util.js
+++ b/mobile/chrome/content/Util.js
@@ -64,24 +64,16 @@ let Util = {
       dump(arguments[i] + " ");
     dump("\n");
   },
 
   getWindowUtils: function getWindowUtils(aWindow) {
     return aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
   },
 
-  getScrollOffset: function getScrollOffset(aWindow) {
-    let cwu = Util.getWindowUtils(aWindow);
-    let scrollX = {};
-    let scrollY = {};
-    cwu.getScrollXY(false, scrollX, scrollY);
-    return new Point(scrollX.value, scrollY.value);
-  },
-
   /** Executes aFunc after other events have been processed. */
   executeSoon: function executeSoon(aFunc) {
     Services.tm.mainThread.dispatch({
       run: function() {
         aFunc();
       }
     }, Ci.nsIThread.DISPATCH_NORMAL);
   },
--- a/mobile/chrome/content/bindings/browser.js
+++ b/mobile/chrome/content/bindings/browser.js
@@ -279,21 +279,28 @@ let ContentScroll =  {
     addMessageListener("Content:ScrollBy", this);
     addMessageListener("Content:SetCacheViewport", this);
     addMessageListener("Content:SetWindowSize", this);
 
     addEventListener("scroll", this, false);
     addEventListener("MozScrolledAreaChanged", this, false);
   },
 
+  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 };
+  },
+
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     switch (aMessage.name) {
       case "Content:ScrollTo": {
-        let scrollOffset = Util.getScrollOffset(content);
+        let scrollOffset = this.getScrollOffset(content);
         if (scrollOffset.x == json.x && scrollOffset.y == json.y)
           return;
 
         this.ignoreScroll = true;
         content.scrollTo(json.x, json.y);
         break;
       }
 
@@ -301,17 +308,17 @@ let ContentScroll =  {
         if (!json.dx && !json.dy)
           return;
 
         this.ignoreScroll = true;
         content.scrollBy(json.dx, json.dy);
         break;
 
       case "Content:SetCacheViewport": {
-        let rootCwu = Util.getWindowUtils(content);
+        let rootCwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
         if (json.id == 1)
           rootCwu.setResolution(json.scale, json.scale);
 
         let displayport = new Rect(json.x, json.y, json.w, json.h);
         if (displayport.isEmpty())
           break;
 
         let cwu20 = rootCwu.QueryInterface(Ci.nsIDOMWindowUtils_MOZILLA_2_0_BRANCH);
@@ -328,30 +335,30 @@ let ContentScroll =  {
           element.scrollLeft = json.scrollX;
           element.scrollTop = json.scrollY;
           displayportElement = element;
           scrollOffset = { x: element.scrollLeft, y: element.scrollTop };
         } else {
           if (json.id != 1)
             win.scrollTo(json.scrollX, json.scrollY);
           displayportElement = null;
-          scrollOffset = Util.getScrollOffset(win);
+          scrollOffset = this.getScrollOffset(win);
         }
 
-        let winCwu = Util.getWindowUtils(win);
+        let winCwu = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
         winCwu.setDisplayPort(
           displayport.x - scrollOffset.x, displayport.y - scrollOffset.y,
           displayport.width, displayport.height,
           element);
 
         break;
       }
 
       case "Content:SetWindowSize": {
-        let cwu = Util.getWindowUtils(content);
+        let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
         cwu.setCSSViewport(json.width, json.height);
         break;
       }
     }
   },
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
@@ -360,32 +367,30 @@ let ContentScroll =  {
           this.ignoreScroll = false;
           return;
         }
 
         let doc = aEvent.target;
         if (doc != content.document)
           return;
 
-        let scrollOffset = Util.getScrollOffset(content);
+        let scrollOffset = this.getScrollOffset(content);
         sendAsyncMessage("scroll", scrollOffset);
         break;
       }
 
       case "MozScrolledAreaChanged": {
         let doc = aEvent.originalTarget;
         if (content != doc.defaultView) // We are only interested in root scroll pane changes
           return;
 
-        // XXX need to make some things in Util as its own module!
-        let scrollOffset = Util.getScrollOffset(content);
-
         // Adjust width and height from the incoming event properties so that we
         // ignore changes to width and height contributed by growth in page
         // quadrants other than x > 0 && y > 0.
+        let scrollOffset = this.getScrollOffset(content);
         let x = aEvent.x + scrollOffset.x;
         let y = aEvent.y + scrollOffset.y;
         let width = aEvent.width + (x < 0 ? x : 0);
         let height = aEvent.height + (y < 0 ? y : 0);
 
         sendAsyncMessage("MozScrolledAreaChanged", {
           width: width,
           height: height
@@ -405,18 +410,18 @@ let ContentActive =  {
     addMessageListener("Content:Deactivate", this);
   },
 
   receiveMessage: function(aMessage) {
     let json = aMessage.json;
     switch (aMessage.name) {
       case "Content:Deactivate":
         docShell.isActive = false;
-        let utils = Util.getWindowUtils(content);
-        utils.setDisplayPort(0,0,0,0);
+        let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+        cwu.setDisplayPort(0,0,0,0);
         break;
 
       case "Content:Activate":
         docShell.isActive = true;
         break;
     }
   }
 };
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -433,20 +433,16 @@ var BrowserUI = {
     this._favicon.addEventListener("error", this, false);
 
     this._edit.addEventListener("click", this, false);
     this._edit.addEventListener("mousedown", this, false);
 
     window.addEventListener("NavigationPanelShown", this, false);
     window.addEventListener("NavigationPanelHidden", this, false);
 
-    Elements.tabs.addEventListener("TabSelect", this, true);
-    Elements.tabs.addEventListener("TabOpen", this, true);
-    Elements.tabs.addEventListener("TabRemove", this, true);
-
     Elements.browsers.addEventListener("PanFinished", this, true);
 #if MOZ_PLATFORM_MAEMO == 6
     Elements.browsers.addEventListener("SizeChanged", this, true);
 #endif
 
     // listen content messages
     messageManager.addMessageListener("DOMLinkAdded", this);
     messageManager.addMessageListener("DOMTitleChanged", this);
@@ -482,16 +478,25 @@ var BrowserUI = {
 
     // Delay the panel UI and Sync initialization.
     window.addEventListener("UIReadyDelayed", function(aEvent) {
       window.removeEventListener(aEvent.type, arguments.callee, false);
 
       // We unhide the panelUI so the XBL and settings can initialize
       Elements.panelUI.hidden = false;
 
+      // Login Manager and Form History initialization
+      Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
+      Cc["@mozilla.org/satchel/form-history;1"].getService(Ci.nsIFormHistory2);
+
+      // Listen tabs event
+      Elements.tabs.addEventListener("TabSelect", BrowserUI, true);
+      Elements.tabs.addEventListener("TabOpen", BrowserUI, true);
+      Elements.tabs.addEventListener("TabRemove", this, true);
+
       // Init the views
       ExtensionsView.init();
       DownloadsView.init();
       PreferencesView.init();
       ConsoleView.init();
 
 #ifdef MOZ_IPC
       // Pre-start the content process
@@ -499,16 +504,18 @@ var BrowserUI = {
           .ensureContentProcess();
 #endif
 
 #ifdef MOZ_SERVICES_SYNC
       // Init the sync system
       WeaveGlue.init();
 #endif
 
+      Services.obs.addObserver(BrowserSearch, "browser-search-engine-modified", false);
+
       // Init helpers
       BadgeHandlers.register(BrowserUI._edit.popup);
       FormHelperUI.init();
       FindHelperUI.init();
       PageActions.init();
       FullScreenVideo.init();
       NewTabPopup.init();
 
@@ -526,16 +533,17 @@ var BrowserUI = {
           if (name != "process")
             Services.console.logStringMessage("[timing] " + name + ": " + (startup[name] - startup.process) + "ms");
         }
       }, 3000);
 #endif
   },
 
   uninit: function() {
+    Services.obs.removeObserver(BrowserSearch, "browser-search-engine-modified");
     ExtensionsView.uninit();
     ConsoleView.uninit();
   },
 
   update: function(aState) {
     let browser = Browser.selectedBrowser;
 
     switch (aState) {
@@ -1175,23 +1183,21 @@ var BrowserUI = {
           button.disabled = true;
           setTimeout(function() { button.disabled = false; }, 5000);
 
           Sanitizer.sanitize();
         }
         break;
       }
       case "cmd_panel":
-      {
-        if (BrowserUI.isPanelVisible())
+        if (this.isPanelVisible())
           this.hidePanel();
         else
           this.showPanel();
         break;
-      }
       case "cmd_zoomin":
         Browser.zoom(-1);
         break;
       case "cmd_zoomout":
         Browser.zoom(1);
         break;
       case "cmd_volumeLeft":
         // Zoom in (portrait) or out (landscape)
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -70,105 +70,78 @@ window.sizeToContent = function() {
   Cu.reportError("window.sizeToContent is not allowed in this window");
 }
 
 #ifdef MOZ_CRASH_REPORTER
 XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
   "@mozilla.org/xre/app-info;1", "nsICrashReporter");
 #endif
 
-function onDebugKeyPress(ev) {
-  if (!ev.ctrlKey)
+function onDebugKeyPress(aEvent) {
+  if (!aEvent.ctrlKey)
     return;
 
-  // use capitals so we require SHIFT here too
-
-  const a = 65; // swipe left
-  const b = 66;
-  const c = 67;
-  const d = 68; // swipe right
-  const e = 69;
-  const f = 70;  // force GC
-  const g = 71;
-  const h = 72;
-  const i = 73;
-  const j = 74;
-  const k = 75;
-  const l = 76;
-  const m = 77; // Android menu
-  const n = 78;
-  const o = 79;
-  const p = 80;  // fake pinch zoom
-  const q = 81;  // toggle orientation
-  const r = 82;
-  const s = 83; // swipe down
-  const t = 84;
-  const u = 85;
-  const v = 86;
-  const w = 87; // swipe up
-  const x = 88;
-  const y = 89;
-  const z = 90;
-
   function doSwipe(aDirection) {
-    let e = document.createEvent("SimpleGestureEvent");
-    e.initSimpleGestureEvent("MozSwipeGesture", true, true, window, null,
+    let evt = document.createEvent("SimpleGestureEvent");
+    evt.initSimpleGestureEvent("MozSwipeGesture", true, true, window, null,
                                0, 0, 0, 0, false, false, false, false, 0, null,
                                aDirection, 0);
-    Browser.selectedTab.inputHandler.dispatchEvent(e);
+    Browser.selectedTab.inputHandler.dispatchEvent(evt);
   }
-  switch (ev.charCode) {
-  case w:
-    doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_UP);
-    break;
-  case s:
-    doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_DOWN);
-    break;
-  case d:
-    doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_RIGHT);
-    break;
-  case a:
-    doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_LEFT);
-    break;
-  case f:
-    MemoryObserver.observe();
-    dump("Forced a GC\n");
-    break;
-  case m:
-    CommandUpdater.doCommand("cmd_menu");
-    break;
+
+  let nsIDOMKeyEvent  = Ci.nsIDOMKeyEvent;
+  switch (aEvent.charCode) {
+    case nsIDOMKeyEvent.DOM_VK_A: // Swipe Left
+      doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_LEFT);
+      break;
+    case nsIDOMKeyEvent.DOM_VK_D: // Swipe Right
+      doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_RIGHT);
+      break;
+    case nsIDOMKeyEvent.DOM_VK_F: // Forge GC
+      MemoryObserver.observe();
+      dump("Forced a GC\n");
+      break;
+    case nsIDOMKeyEvent.DOM_VK_M: // Android Menu
+      CommandUpdater.doCommand("cmd_menu");
+      break;
 #ifndef MOZ_PLATFORM_MAEMO
-  case p:
-    function dispatchMagnifyEvent(aName, aDelta) {
-      let e = document.createEvent("SimpleGestureEvent");
-      e.initSimpleGestureEvent("MozMagnifyGesture"+aName, true, true, window, null,
-                               0, 0, 0, 0, false, false, false, false, 0, null, 0, aDelta);
-      Browser.selectedTab.inputHandler.dispatchEvent(e);
-    }
-    dispatchMagnifyEvent("Start", 0);
-
-    let frame = 0;
-    let timer = new Util.Timeout();
-    timer.interval(100, function() {
-      dispatchMagnifyEvent("Update", 20);
-      if (++frame > 10) {
-        timer.clear();
-        dispatchMagnifyEvent("", frame*20);
+    case nsIDOMKeyEvent.DOM_VK_P: // Fake pinch zoom
+      function dispatchMagnifyEvent(aName, aDelta) {
+        let evt = document.createEvent("SimpleGestureEvent");
+        evt.initSimpleGestureEvent("MozMagnifyGesture" + aName, true, true, window, null,
+                                   0, 0, 0, 0, false, false, false, false, 0, null, 0, aDelta);
+        Browser.selectedTab.inputHandler.dispatchEvent(evt);
       }
-    });
-    break;
-  case q:
-    if (Util.isPortrait())
-      window.top.resizeTo(800,480);
-    else
-      window.top.resizeTo(480,800);
-    break;
+      dispatchMagnifyEvent("Start", 0);
+
+      let frame = 0;
+      let timer = new Util.Timeout();
+      timer.interval(100, function() {
+        dispatchMagnifyEvent("Update", 20);
+        if (++frame > 10) {
+          timer.clear();
+          dispatchMagnifyEvent("", frame*20);
+        }
+      });
+      break;
+    case nsIDOMKeyEvent.DOM_VK_Q: // Toggle Orientation
+      if (Util.isPortrait())
+        window.top.resizeTo(800,480);
+      else
+        window.top.resizeTo(480,800);
+      break;
 #endif
-  default:
-    break;
+    case nsIDOMKeyEvent.DOM_VK_S: // Swipe down
+      doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_DOWN);
+      break;
+    case nsIDOMKeyEvent.DOM_VK_W: // Swipe up
+      doSwipe(Ci.nsIDOMSimpleGestureEvent.DIRECTION_UP);
+      break;
+    default:
+      break;
   }
 }
 
 var Browser = {
   _tabs: [],
   _selectedTab: null,
   windowUtils: window.QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIDOMWindowUtils),
@@ -336,34 +309,29 @@ var Browser = {
     window.controllers.appendController(BrowserUI);
 
     var os = Services.obs;
     os.addObserver(XPInstallObserver, "addon-install-blocked", false);
     os.addObserver(XPInstallObserver, "addon-install-started", false);
     os.addObserver(SessionHistoryObserver, "browser:purge-session-history", false);
     os.addObserver(ContentCrashObserver, "ipc:content-shutdown", false);
     os.addObserver(MemoryObserver, "memory-pressure", false);
-    os.addObserver(BrowserSearch, "browser-search-engine-modified", false);
 
     // Listens for change in the viewable area
 #if MOZ_PLATFORM_MAEMO == 6
     os.addObserver(ViewableAreaObserver, "softkb-change", false);
 #endif
     Elements.contentNavigator.addEventListener("SizeChanged", function() {
       ViewableAreaObserver.update();
     }, true);
 
     window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess();
 
     Elements.browsers.addEventListener("DOMUpdatePageReport", PopupBlockerObserver.onUpdatePageReport, false);
 
-    // Login Manager and Form History initialization
-    Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
-    Cc["@mozilla.org/satchel/form-history;1"].getService(Ci.nsIFormHistory2);
-
     // Make sure we're online before attempting to load
     Util.forceOnline();
 
     // If this is an intial window launch the commandline handler passes us the default
     // page as an argument. commandURL _should_ never be empty, but we protect against it
     // below. However, we delay trying to get the fallback homepage until we really need it.
     let commandURL = null;
     if (window.arguments && window.arguments[0])
@@ -482,17 +450,16 @@ var Browser = {
     messageManager.removeMessageListener("Browser:CertException", this);
 
     var os = Services.obs;
     os.removeObserver(XPInstallObserver, "addon-install-blocked");
     os.removeObserver(XPInstallObserver, "addon-install-started");
     os.removeObserver(SessionHistoryObserver, "browser:purge-session-history");
     os.removeObserver(ContentCrashObserver, "ipc:content-shutdown");
     os.removeObserver(MemoryObserver, "memory-pressure");
-    os.removeObserver(BrowserSearch, "browser-search-engine-modified");
 
     window.controllers.removeController(this);
     window.controllers.removeController(BrowserUI);
   },
 
   getHomePage: function getHomePage(aOptions) {
     aOptions = aOptions || { useDefault: false };
 
@@ -2810,16 +2777,21 @@ function rendererFactory(aBrowser, aCanv
     wrapper.drawContent = function(callback) {
       callback(ctx, draw);
     };
   }
 
   return wrapper;
 };
 
+/* ViewableAreaObserver is an helper object where width/height represents the
+ * size of the currently viewable area in pixels. This is use instead of
+ * window.innerHeight/innerWidth because some keyboards does not resize the
+ * window but floats over it.
+ */
 var ViewableAreaObserver = {
   get width() {
     return this._width || window.innerWidth;
   },
 
   get height() {
     return (this._height || window.innerHeight) - Elements.contentNavigator.getBoundingClientRect().height;
   },
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -144,17 +144,17 @@ const ElementTouchHelper = {
 /**
  * @param x,y Browser coordinates
  * @return Element at position, null if no active browser or no element found
  */
 function elementFromPoint(x, y) {
   // browser's elementFromPoint expect browser-relative client coordinates.
   // subtract browser's scroll values to adjust
   let cwu = Util.getWindowUtils(content);
-  let scroll = Util.getScrollOffset(content);
+  let scroll = ContentScroll.getScrollOffset(content);
   x = x - scroll.x;
   y = y - scroll.y;
   let elem = ElementTouchHelper.getClosest(cwu, x, y);
 
   // step through layers of IFRAMEs and FRAMES to find innermost element
   while (elem && (elem instanceof HTMLIFrameElement || elem instanceof HTMLFrameElement)) {
     // adjust client coordinates' origin to be top left of iframe viewport
     let rect = elem.getBoundingClientRect();
@@ -170,17 +170,17 @@ function elementFromPoint(x, y) {
 function getBoundingContentRect(aElement) {
   if (!aElement)
     return new Rect(0, 0, 0, 0);
 
   let document = aElement.ownerDocument;
   while(document.defaultView.frameElement)
     document = document.defaultView.frameElement.ownerDocument;
 
-  let offset = Util.getScrollOffset(content);
+  let offset = ContentScroll.getScrollOffset(content);
   let r = aElement.getBoundingClientRect();
 
   // step out of iframes and frames, offsetting scroll values
   for (let frame = aElement.ownerDocument.defaultView; frame != content; frame = frame.parent) {
     // adjust client coordinates' origin to be top left of iframe viewport
     let rect = frame.frameElement.getBoundingClientRect();
     let left = frame.getComputedStyle(frame.frameElement, "").borderLeftWidth;
     let top = frame.getComputedStyle(frame.frameElement, "").borderTopWidth;
@@ -201,17 +201,17 @@ function getOverflowContentBoundingRect(
 
   for (let i = 0; i < aElement.childElementCount; i++)
     r = r.union(getBoundingContentRect(aElement.children[i]));
 
   return r;
 }
 
 function getContentClientRects(aElement) {
-  let offset = Util.getScrollOffset(content);
+  let offset = ContentScroll.getScrollOffset(content);
   let nativeRects = aElement.getClientRects();
   // step out of iframes and frames, offsetting scroll values
   for (let frame = aElement.ownerDocument.defaultView; frame != content; frame = frame.parent) {
     // adjust client coordinates' origin to be top left of iframe viewport
     let rect = frame.frameElement.getBoundingClientRect();
     let left = frame.getComputedStyle(frame.frameElement, "").borderLeftWidth;
     let top = frame.getComputedStyle(frame.frameElement, "").borderTopWidth;
     offset.add(rect.left + parseInt(left), rect.top + parseInt(top));
@@ -226,16 +226,21 @@ function getContentClientRects(aElement)
                   height: r.height
                 });
   }
   return result;
 };
 
 
 let Content = {
+  get _formAssistant() {
+    delete this._formAssistant;
+    return this._formAssistant = new FormAssistant();
+  },
+
   init: function init() {
     this._isZoomedToElement = false;
 
     addMessageListener("Browser:Blur", this);
     addMessageListener("Browser:MouseOver", this);
     addMessageListener("Browser:MouseLong", this);
     addMessageListener("Browser:MouseDown", this);
     addMessageListener("Browser:MouseUp", this);
@@ -247,18 +252,16 @@ let Content = {
     if (Util.isParentProcess())
       addEventListener("DOMActivate", this, true);
 
     addEventListener("MozApplicationManifest", this, false);
     addEventListener("command", this, false);
     addEventListener("pagehide", this, false);
     addEventListener("keypress", this, false, false);
 
-    this._formAssistant = new FormAssistant();
-
     try{
       docShell.QueryInterface(Ci.nsIDocShellHistory).useGlobalHistory = true;
     } catch(e) { }
   },
 
   handleEvent: function handleEvent(aEvent) {
     switch (aEvent.type) {
       // If the keypress is a trusted event and has not been consume by content
@@ -533,17 +536,17 @@ let Content = {
       if (isTouchClick) {
         let rect = rects[0];
         let point = (new Rect(rect.left, rect.top, rect.width, rect.height)).center();
         aX = point.x;
         aY = point.y;
       }
     }
 
-    let scrollOffset = Util.getScrollOffset(content);
+    let scrollOffset = ContentScroll.getScrollOffset(content);
     let windowUtils = Util.getWindowUtils(content);
     aButton = aButton || 0;
     windowUtils.sendMouseEventToWindow(aName, aX - scrollOffset.x, aY - scrollOffset.y, aButton, 1, 0, true);
   },
 
   _setTextZoom: function _setTextZoom(aZoom) {
     let viewer = docShell.contentViewer.QueryInterface(Ci.nsIMarkupDocumentViewer);
     viewer.textZoom = aZoom;
@@ -942,17 +945,17 @@ var FindHandler = {
         if (node instanceof Ci.nsIDOMNSEditableElement && node.editor) {
           selection = node.editor.selectionController.getSelection(Ci.nsISelectionController.SELECTION_NORMAL);
           if (selection.rangeCount && !selection.isCollapsed)
             break;
         }
       }
     }
 
-    let scroll = Util.getScrollOffset(content);
+    let scroll = ContentScroll.getScrollOffset(content);
     for (let frame = this._fastFind.currentWindow; frame != content; frame = frame.parent) {
       let rect = frame.frameElement.getBoundingClientRect();
       let left = frame.getComputedStyle(frame.frameElement, "").borderLeftWidth;
       let top = frame.getComputedStyle(frame.frameElement, "").borderTopWidth;
       scroll.add(rect.left + parseInt(left), rect.top + parseInt(top));
     }
 
     let rangeRect = selection.getRangeAt(0).getBoundingClientRect();
--- a/mobile/chrome/content/forms.js
+++ b/mobile/chrome/content/forms.js
@@ -495,17 +495,17 @@ FormAssistant.prototype = {
     let element = this.currentElement;
     let focusedElement = gFocusManager.getFocusedElementForWindow(content, true, {});
     if ((element instanceof HTMLTextAreaElement ||
         (element instanceof HTMLInputElement && element.type == "text")) &&
         focusedElement == element) {
       let utils = Util.getWindowUtils(element.ownerDocument.defaultView);
       let rect = utils.sendQueryContentEvent(utils.QUERY_CARET_RECT, element.selectionEnd, 0, 0, 0);
       if (rect) {
-        let scroll = Util.getScrollOffset(element.ownerDocument.defaultView);
+        let scroll = ContentScroll.getScrollOffset(element.ownerDocument.defaultView);
         return new Rect(scroll.x + rect.left, scroll.y + rect.top, rect.width, rect.height);
       }
     }
 
     return new Rect(0, 0, 0, 0);
   },
 
   /** Gets a rect bounding important parts of the element that must be seen when assisting. */