mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 23:30:46 +00:00
Bug 777075 - Add a getMutableMetrics helper. r=mbrubeck
This commit is contained in:
parent
270c2238aa
commit
891c5b57d0
@ -158,6 +158,10 @@ public class PanZoomController
|
||||
return mTarget.getViewportMetrics();
|
||||
}
|
||||
|
||||
private ViewportMetrics getMutableMetrics() {
|
||||
return new ViewportMetrics(getMetrics());
|
||||
}
|
||||
|
||||
// for debugging bug 713011; it can be taken out once that is resolved.
|
||||
private void checkMainThread() {
|
||||
if (mMainThread != Thread.currentThread()) {
|
||||
@ -313,7 +317,7 @@ public class PanZoomController
|
||||
if (mState == PanZoomState.NOTHING) {
|
||||
synchronized (mTarget.getLock()) {
|
||||
ViewportMetrics validated = getValidViewportMetrics();
|
||||
if (! (new ViewportMetrics(getMetrics())).fuzzyEquals(validated)) {
|
||||
if (! getMutableMetrics().fuzzyEquals(validated)) {
|
||||
// page size changed such that we are now in overscroll. snap to the
|
||||
// the nearest valid viewport
|
||||
mTarget.setViewportMetrics(validated);
|
||||
@ -538,7 +542,7 @@ public class PanZoomController
|
||||
}
|
||||
|
||||
private void scrollBy(PointF point) {
|
||||
ViewportMetrics viewportMetrics = new ViewportMetrics(getMetrics());
|
||||
ViewportMetrics viewportMetrics = getMutableMetrics();
|
||||
PointF origin = viewportMetrics.getOrigin();
|
||||
origin.offset(point.x, point.y);
|
||||
viewportMetrics.setOrigin(origin);
|
||||
@ -563,7 +567,7 @@ public class PanZoomController
|
||||
private void bounce(ViewportMetrics metrics) {
|
||||
stopAnimationTimer();
|
||||
|
||||
ViewportMetrics bounceStartMetrics = new ViewportMetrics(getMetrics());
|
||||
ViewportMetrics bounceStartMetrics = getMutableMetrics();
|
||||
if (bounceStartMetrics.fuzzyEquals(metrics)) {
|
||||
setState(PanZoomState.NOTHING);
|
||||
return;
|
||||
@ -788,7 +792,7 @@ public class PanZoomController
|
||||
|
||||
/* Returns the nearest viewport metrics with no overscroll visible. */
|
||||
private ViewportMetrics getValidViewportMetrics() {
|
||||
return getValidViewportMetrics(new ViewportMetrics(getMetrics()));
|
||||
return getValidViewportMetrics(getMutableMetrics());
|
||||
}
|
||||
|
||||
private ViewportMetrics getValidViewportMetrics(ViewportMetrics viewportMetrics) {
|
||||
@ -978,7 +982,7 @@ public class PanZoomController
|
||||
* scale operation. You must hold the monitor while calling this.
|
||||
*/
|
||||
private void scaleWithFocus(float zoomFactor, PointF focus) {
|
||||
ViewportMetrics viewportMetrics = new ViewportMetrics(getMetrics());
|
||||
ViewportMetrics viewportMetrics = getMutableMetrics();
|
||||
viewportMetrics.scaleTo(zoomFactor, focus);
|
||||
mTarget.setViewportMetrics(viewportMetrics);
|
||||
mTarget.notifyLayerClientOfGeometryChange();
|
||||
@ -1086,7 +1090,7 @@ public class PanZoomController
|
||||
|
||||
float finalZoom = viewport.width() / zoomToRect.width();
|
||||
|
||||
ViewportMetrics finalMetrics = new ViewportMetrics(getMetrics());
|
||||
ViewportMetrics finalMetrics = getMutableMetrics();
|
||||
finalMetrics.setOrigin(new PointF(zoomToRect.left * finalMetrics.getZoomFactor(),
|
||||
zoomToRect.top * finalMetrics.getZoomFactor()));
|
||||
finalMetrics.scaleTo(finalZoom, new PointF(0.0f, 0.0f));
|
||||
|
Loading…
x
Reference in New Issue
Block a user