Bug 1180295 - Ensure we don't scroll past the end of the page. r=rbarker

--HG--
extra : commitid : 1y6f6Li4Zl4
This commit is contained in:
Kartikaya Gupta 2015-08-18 14:27:20 -04:00
Родитель 9e624195ef
Коммит 5ba8c32366
5 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -206,6 +206,7 @@ abstract class Axis {
protected abstract float getViewportLength();
protected abstract float getPageStart();
protected abstract float getPageLength();
protected abstract float getVisibleEndOfLayerView();
Axis(SubdocumentScrollHelper subscroller) {
mSubscroller = subscroller;
@ -499,8 +500,8 @@ abstract class Axis {
if (mDisplacement + getOrigin() < getPageStart()) {
mDisplacement = getPageStart() - getOrigin();
} else if (mDisplacement + getViewportEnd() > getPageEnd()) {
mDisplacement = getPageEnd() - getViewportEnd();
} else if (mDisplacement + getOrigin() + getVisibleEndOfLayerView() > getPageEnd()) {
mDisplacement = getPageEnd() - getOrigin() - getVisibleEndOfLayerView();
}
// Return the amount of overscroll so that the overscroll controller can draw it for us

Просмотреть файл

@ -331,6 +331,11 @@ public class DynamicToolbarAnimator {
return true;
}
public PointF getVisibleEndOfLayerView() {
return new PointF(mTarget.getView().getWidth(),
mTarget.getView().getHeight() - mMaxTranslation + mLayerViewTranslation);
}
private float bottomOfCssViewport(ImmutableViewportMetrics aMetrics) {
return aMetrics.getHeight() + mMaxTranslation - mLayerViewTranslation;
}

Просмотреть файл

@ -746,6 +746,12 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mView.getFullScreenState();
}
/** Implementation of PanZoomTarget */
@Override
public PointF getVisibleEndOfLayerView() {
return mToolbarAnimator.getVisibleEndOfLayerView();
}
/** Implementation of PanZoomTarget */
@Override
public void setAnimationTarget(ImmutableViewportMetrics metrics) {

Просмотреть файл

@ -1103,6 +1103,10 @@ class JavaPanZoomController
@Override
protected float getPageLength() { return getMetrics().getPageWidthWithMargins(); }
@Override
protected float getVisibleEndOfLayerView() {
return mTarget.getVisibleEndOfLayerView().x;
}
@Override
protected void overscrollFling(final float velocity) {
if (mOverscroll != null) {
mOverscroll.setVelocity(velocity, Overscroll.Axis.X);
@ -1127,6 +1131,10 @@ class JavaPanZoomController
@Override
protected float getPageLength() { return getMetrics().getPageHeightWithMargins(); }
@Override
protected float getVisibleEndOfLayerView() {
return mTarget.getVisibleEndOfLayerView().y;
}
@Override
protected void overscrollFling(final float velocity) {
if (mOverscroll != null) {
mOverscroll.setVelocity(velocity, Overscroll.Axis.Y);

Просмотреть файл

@ -14,6 +14,7 @@ public interface PanZoomTarget {
public ImmutableViewportMetrics getViewportMetrics();
public ZoomConstraints getZoomConstraints();
public FullScreenState getFullScreenState();
public PointF getVisibleEndOfLayerView();
public void setAnimationTarget(ImmutableViewportMetrics viewport);
public void setViewportMetrics(ImmutableViewportMetrics viewport);