Bug 709492 - Part 3: Tie viewport updates to drawing to avoid page transition flicker. r=kats

This commit is contained in:
Patrick Walton 2012-01-03 22:55:04 -08:00
parent 5d1122e7e9
commit 37040a8f9f
4 changed files with 18 additions and 19 deletions

View File

@ -615,7 +615,10 @@ abstract public class GeckoApp
if (lastHistoryEntry.mUri.equals(mLastUri))
return;
mLastViewport = mSoftwareLayerClient.getGeckoViewportMetrics().toJSON();
ViewportMetrics viewportMetrics = mSoftwareLayerClient.getGeckoViewportMetrics();
if (viewportMetrics != null)
mLastViewport = viewportMetrics.toJSON();
mLastUri = lastHistoryEntry.mUri;
mLastTitle = lastHistoryEntry.mTitle;
Bitmap bitmap = mSoftwareLayerClient.getBitmap();

View File

@ -140,7 +140,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
layerController.setViewportMetrics(mGeckoViewport);
}
GeckoAppShell.registerGeckoEventListener("Viewport:Update", this);
GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this);
GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this);
}
@ -340,19 +340,13 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
}
public void handleMessage(String event, JSONObject message) {
if ("Viewport:Update".equals(event)) {
beginTransaction(mTileLayer);
try {
updateViewport(message.getString("viewport"), false);
} catch (JSONException e) {
Log.e(LOGTAG, "Unable to update viewport", e);
} finally {
endTransaction(mTileLayer);
}
if ("Viewport:UpdateAndDraw".equals(event)) {
mUpdateViewportOnEndDraw = true;
// Redraw everything.
Rect rect = new Rect(0, 0, mBufferSize.width, mBufferSize.height);
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.DRAW, rect));
} else if ("Viewport:UpdateLater".equals(event)) {
if (!mTileLayer.inTransaction()) {
Log.e(LOGTAG, "Viewport:UpdateLater called while not in transaction. You should be using Viewport:Update instead!");
}
mUpdateViewportOnEndDraw = true;
}
}

View File

@ -255,7 +255,10 @@ public class PanZoomController
// the screen orientation changed) so abort it and start a new one to
// ensure the viewport doesn't contain out-of-bounds areas
case NOTHING:
bounce();
// Don't do animations here; they're distracting and can cause flashes on page
// transitions.
mController.setViewportMetrics(getValidViewportMetrics());
mController.notifyLayerClientOfGeometryChange();
break;
}
}

View File

@ -1491,8 +1491,7 @@ Tab.prototype = {
return;
sendMessageToJava({
gecko: {
type: "Viewport:Update",
viewport: JSON.stringify(this.viewport)
type: "Viewport:UpdateAndDraw"
}
});
},