From 3c2f1084ec2d3f0f849e6eee22092aec2009abbd Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Wed, 9 Feb 2011 00:22:27 +0100 Subject: [PATCH] Bug 630946 - Repaint does not occur when dismissing a combo box [r=mfinkle] --- mobile/chrome/content/browser-ui.js | 2 +- mobile/chrome/content/browser.js | 13 +++++++++---- mobile/chrome/content/common-ui.js | 2 -- mobile/chrome/content/content.js | 4 ++++ mobile/chrome/tests/browser_click_content.js | 5 ++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/mobile/chrome/content/browser-ui.js b/mobile/chrome/content/browser-ui.js index 5558792e3aec..91528e2d5764 100644 --- a/mobile/chrome/content/browser-ui.js +++ b/mobile/chrome/content/browser-ui.js @@ -490,7 +490,7 @@ var BrowserUI = { // 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(); diff --git a/mobile/chrome/content/browser.js b/mobile/chrome/content/browser.js index fd490532189d..f205c68a4699 100644 --- a/mobile/chrome/content/browser.js +++ b/mobile/chrome/content/browser.js @@ -291,7 +291,6 @@ var Browser = { setTimeout(function() { scrollInterface.ensureElementIsVisible(currentElement) }, 0); } - getBrowser().finishFuzzyZoom(); } window.addEventListener("resize", resizeHandler, false); @@ -2503,13 +2502,17 @@ Tab.prototype = { 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); }, @@ -2839,8 +2842,10 @@ var ViewableAreaObserver = { // 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 diff --git a/mobile/chrome/content/common-ui.js b/mobile/chrome/content/common-ui.js index f455c06271fb..f4d9ea200acc 100644 --- a/mobile/chrome/content/common-ui.js +++ b/mobile/chrome/content/common-ui.js @@ -789,8 +789,6 @@ var FormHelperUI = { return; this._container.hidden = !aVal; - this._container.contentHasChanged(); - if (aVal) { this._zoomStart(); this._container.show(this); diff --git a/mobile/chrome/content/content.js b/mobile/chrome/content/content.js index dedadee1f983..daa3ef694e81 100644 --- a/mobile/chrome/content/content.js +++ b/mobile/chrome/content/content.js @@ -176,6 +176,8 @@ function getBoundingContentRect(aElement) { 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 @@ -207,6 +209,8 @@ function getOverflowContentBoundingRect(aElement) { 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) { diff --git a/mobile/chrome/tests/browser_click_content.js b/mobile/chrome/tests/browser_click_content.js index 4b32257c9de9..b77856ed9525 100644 --- a/mobile/chrome/tests/browser_click_content.js +++ b/mobile/chrome/tests/browser_click_content.js @@ -100,7 +100,10 @@ function getBoundingContentRect(aElement) { 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