Bug 630946 - Repaint does not occur when dismissing a combo box [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 09 Feb 2011 00:22:27 +0100
changeset 67359 76deb4e68c16500a6e483d84a40627c30cf47f89
parent 67358 b46d6b9d5fda70fbb8f78f5aff2e55873c919fa0
child 67360 978f2e630f6df5ac3d15be0ad4e10c6d76b3ce1b
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
bugs630946
Bug 630946 - Repaint does not occur when dismissing a combo box [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/chrome/content/common-ui.js
mobile/chrome/content/content.js
mobile/chrome/tests/browser_click_content.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -485,17 +485,17 @@ var BrowserUI = {
 
       // 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);
+      Elements.tabs.addEventListener("TabRemove", BrowserUI, true);
 
       // Init the views
       ExtensionsView.init();
       DownloadsView.init();
       PreferencesView.init();
       ConsoleView.init();
 
 #ifdef MOZ_IPC
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -286,17 +286,16 @@ var Browser = {
       let [scrollbox, scrollInterface] = ScrollUtils.getScrollboxFromElement(currentElement);
       if (scrollbox && scrollInterface && currentElement && currentElement != scrollbox) {
         // retrieve the direct child of the scrollbox
         while (currentElement.parentNode != scrollbox)
           currentElement = currentElement.parentNode;
 
         setTimeout(function() { scrollInterface.ensureElementIsVisible(currentElement) }, 0);
       }
-      getBrowser().finishFuzzyZoom();
     }
     window.addEventListener("resize", resizeHandler, false);
 
     function fullscreenHandler() {
       if (!window.fullScreen)
         document.getElementById("toolbar-main").setAttribute("fullscreen", "true");
       else
         document.getElementById("toolbar-main").removeAttribute("fullscreen");
@@ -2498,23 +2497,27 @@ Tab.prototype = {
     }
 
     if (browser.contentWindowWidth != viewportW || browser.contentWindowHeight != viewportH)
       browser.setWindowSize(viewportW, viewportH);
   },
 
   restoreViewportPosition: function restoreViewportPosition(aOldWidth, aNewWidth) {
     let browser = this._browser;
-    let view = browser.getRootView();
-    let pos = view.getPosition();
 
     // zoom to keep the same portion of the document visible
     let oldScale = browser.scale;
     let newScale = this.clampZoomLevel(oldScale * aNewWidth / aOldWidth);
     let scaleRatio = newScale / oldScale;
+  
+    // Recalculate whether the visible area is actually in bounds
+    let view = browser.getRootView();
+    view.scrollBy(0,0);
+
+    let pos = view.getPosition();
     browser.fuzzyZoom(newScale, pos.x * scaleRatio, pos.y * scaleRatio);
   },
 
   startLoading: function startLoading() {
     if (this._loading) throw "Already Loading!";
     this._loading = true;
   },
 
@@ -2834,18 +2837,20 @@ var ViewableAreaObserver = {
       tab.updateViewportSize();
       
       // Don't bother updating the zoom level on startup
       if (!startup)
         tab.updateDefaultZoomLevel();
 
       // If the viewport width is still the same, the page layout has not
       // changed, so we can keep keep the same content on-screen.
-      if (tab.browser.contentWindowWidth == oldWidth)
+      if (tab.browser.contentWindowWidth == oldWidth) {
         tab.restoreViewportPosition(oldWidth, newWidth);
+        tab.browser.finishFuzzyZoom();
+      }
     }
 
     // setTimeout(callback, 0) to ensure the resize event handler dispatch is finished
     setTimeout(function() {
       let event = document.createEvent("Events");
       event.initEvent("SizeChanged", true, false);
       Elements.browsers.dispatchEvent(event);
     }, 0);
--- a/mobile/chrome/content/common-ui.js
+++ b/mobile/chrome/content/common-ui.js
@@ -784,18 +784,16 @@ var FormHelperUI = {
     return (this._container.getAttribute("type") == this.type);
   },
 
   set _open(aVal) {
     if (aVal == this._open)
       return;
 
     this._container.hidden = !aVal;
-    this._container.contentHasChanged();
-
     if (aVal) {
       this._zoomStart();
       this._container.show(this);
     } else {
       this._zoomFinish();
       this._currentElement = null;
       this._container.hide(this);
     }
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -171,16 +171,18 @@ 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 = ContentScroll.getScrollOffset(content);
+  offset = new Point(offset.x, offset.y);
+
   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;
@@ -202,16 +204,18 @@ function getOverflowContentBoundingRect(
   for (let i = 0; i < aElement.childElementCount; i++)
     r = r.union(getBoundingContentRect(aElement.children[i]));
 
   return r;
 }
 
 function getContentClientRects(aElement) {
   let offset = ContentScroll.getScrollOffset(content);
+  offset = new Point(offset.x, offset.y);
+
   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));
--- a/mobile/chrome/tests/browser_click_content.js
+++ b/mobile/chrome/tests/browser_click_content.js
@@ -95,17 +95,20 @@ 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 content = document.defaultView;
-  let offset = Util.getScrollOffset(content);
+  let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+  let scrollX = {}, scrollY = {};
+  cwu.getScrollXY(false, scrollX, scrollY);
+  let offset = new Point(scrollX.value, scrollY.value);
   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;