bug 868341 - pinch to zoom jumps all over page randomly r=mfinkle,kats

This commit is contained in:
Brad Lassey 2013-12-12 01:43:44 -05:00
parent 85e0ab5708
commit 058bac8da4
2 changed files with 49 additions and 22 deletions

View File

@ -245,12 +245,16 @@ class JavaPanZoomController
final RectF zoomRect = new RectF(x, y,
x + (float)message.getDouble("w"),
y + (float)message.getDouble("h"));
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(zoomRect);
}
});
if (message.optBoolean("animate", true)) {
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(zoomRect);
}
});
} else {
mTarget.setViewportMetrics(getMetricsToZoomTo(zoomRect));
}
} else if (MESSAGE_ZOOM_PAGE.equals(event)) {
ImmutableViewportMetrics metrics = getMetrics();
RectF cssPageRect = metrics.getCssPageRect();
@ -264,12 +268,16 @@ class JavaPanZoomController
y + dh/2,
cssPageRect.width(),
y + dh/2 + newHeight);
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(r);
}
});
if (message.optBoolean("animate", true)) {
mTarget.post(new Runnable() {
@Override
public void run() {
animatedZoomTo(r);
}
});
} else {
mTarget.setViewportMetrics(getMetricsToZoomTo(r));
}
} else if (MESSAGE_TOUCH_LISTENER.equals(event)) {
int tabId = message.getInt("tabID");
final Tab tab = Tabs.getInstance().getTab(tabId);
@ -1399,7 +1407,7 @@ class JavaPanZoomController
* While we usually use device pixels, @zoomToRect must be specified in CSS
* pixels.
*/
private boolean animatedZoomTo(RectF zoomToRect) {
private ImmutableViewportMetrics getMetricsToZoomTo(RectF zoomToRect) {
final float startZoom = getMetrics().zoomFactor;
RectF viewport = getMetrics().getViewport();
@ -1434,8 +1442,11 @@ class JavaPanZoomController
// 2. now run getValidViewportMetrics on it, so that the target viewport is
// clamped down to prevent overscroll, over-zoom, and other bad conditions.
finalMetrics = getValidViewportMetrics(finalMetrics);
return finalMetrics;
}
bounce(finalMetrics, PanZoomState.ANIMATED_ZOOM);
private boolean animatedZoomTo(RectF zoomToRect) {
bounce(getMetricsToZoomTo(zoomToRect), PanZoomState.ANIMATED_ZOOM);
return true;
}

View File

@ -178,15 +178,20 @@ function doChangeMaxLineBoxWidth(aWidth) {
range = BrowserApp.selectedTab._mReflozPoint.range;
}
docViewer.changeMaxLineBoxWidth(aWidth);
try {
docViewer.pausePainting();
docViewer.changeMaxLineBoxWidth(aWidth);
if (range) {
BrowserEventHandler._zoomInAndSnapToRange(range);
} else {
// In this case, we actually didn't zoom into a specific range. It probably
// happened from a page load reflow-on-zoom event, so we need to make sure
// painting is re-enabled.
BrowserApp.selectedTab.clearReflowOnZoomPendingActions();
if (range) {
BrowserEventHandler._zoomInAndSnapToRange(range);
} else {
// In this case, we actually didn't zoom into a specific range. It
// probably happened from a page load reflow-on-zoom event, so we
// need to make sure painting is re-enabled.
BrowserApp.selectedTab.clearReflowOnZoomPendingActions();
}
} finally {
docViewer.resumePainting();
}
}
@ -3223,10 +3228,17 @@ Tab.prototype = {
BrowserApp.selectedTab._mReflozPoint = null;
}
let docViewer = null;
if (isZooming &&
BrowserEventHandler.mReflozPref &&
BrowserApp.selectedTab._mReflozPoint &&
BrowserApp.selectedTab.probablyNeedRefloz) {
let webNav = BrowserApp.selectedTab.window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
let docShell = webNav.QueryInterface(Ci.nsIDocShell);
docViewer = docShell.contentViewer.QueryInterface(Ci.nsIMarkupDocumentViewer);
docViewer.pausePainting();
BrowserApp.selectedTab.performReflowOnZoom(aViewport);
BrowserApp.selectedTab.probablyNeedRefloz = false;
}
@ -3255,6 +3267,9 @@ Tab.prototype = {
aViewport.fixedMarginLeft / aViewport.zoom);
Services.obs.notifyObservers(null, "after-viewport-change", "");
if (docViewer) {
docViewer.resumePainting();
}
},
setResolution: function(aZoom, aForce) {
@ -4680,6 +4695,7 @@ var BrowserEventHandler = {
rect.y = Math.max(topPos, viewport.cssPageTop);
rect.w = viewport.cssWidth;
rect.h = viewport.cssHeight;
rect.animate = false;
sendMessageToJava(rect);
BrowserApp.selectedTab._mReflozPoint = null;