Bug 1180295 - Remove the unneeded margin code from JavaPanZoomController and Axis. r=rbarker

--HG--
extra : commitid : Bfkmg6iXCsr
This commit is contained in:
Kartikaya Gupta 2015-08-18 14:27:19 -04:00
Родитель 9881f8e7c2
Коммит 6cf72f3a6f
2 изменённых файлов: 6 добавлений и 41 удалений

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

@ -206,9 +206,6 @@ abstract class Axis {
protected abstract float getViewportLength();
protected abstract float getPageStart();
protected abstract float getPageLength();
protected abstract float getMarginStart();
protected abstract float getMarginEnd();
protected abstract boolean marginsHidden();
Axis(SubdocumentScrollHelper subscroller) {
mSubscroller = subscroller;
@ -370,13 +367,6 @@ abstract class Axis {
return false;
}
// if there are margins on this axis but they are currently hidden,
// we must be able to scroll in order to make them visible, so allow
// scrolling in that case
if (marginsHidden()) {
return true;
}
// there is scrollable space, and we're not disabled, or the document fits the viewport
// but we always allow overscroll anyway
return getViewportLength() <= getPageLength() - MIN_SCROLLABLE_DISTANCE ||
@ -507,10 +497,10 @@ abstract class Axis {
if (getOverScrollMode() == View.OVER_SCROLL_NEVER && !mSubscroller.scrolling()) {
float originalDisplacement = mDisplacement;
if (mDisplacement + getOrigin() < getPageStart() - getMarginStart()) {
mDisplacement = getPageStart() - getMarginStart() - getOrigin();
} else if (mDisplacement + getViewportEnd() > getPageEnd() + getMarginEnd()) {
mDisplacement = getPageEnd() - getMarginEnd() - getViewportEnd();
if (mDisplacement + getOrigin() < getPageStart()) {
mDisplacement = getPageStart() - getOrigin();
} else if (mDisplacement + getViewportEnd() > getPageEnd()) {
mDisplacement = getPageEnd() - getViewportEnd();
}
// Return the amount of overscroll so that the overscroll controller can draw it for us

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

@ -1036,11 +1036,6 @@ class JavaPanZoomController
float zoomFactor = viewportMetrics.zoomFactor;
RectF pageRect = viewportMetrics.getPageRect();
RectF viewport = viewportMetrics.getViewport();
RectF maxMargins = mTarget.getMaxMargins();
RectF margins = new RectF(Math.max(maxMargins.left, viewportMetrics.marginLeft),
Math.max(maxMargins.top, viewportMetrics.marginTop),
Math.max(maxMargins.right, viewportMetrics.marginRight),
Math.max(maxMargins.bottom, viewportMetrics.marginBottom));
float focusX = viewport.width() / 2.0f;
float focusY = viewport.height() / 2.0f;
@ -1062,14 +1057,14 @@ class JavaPanZoomController
// Ensure minZoomFactor keeps the page at least as big as the viewport.
if (pageRect.width() > 0) {
float pageWidth = pageRect.width() + margins.left + margins.right;
float pageWidth = pageRect.width();
float scaleFactor = viewport.width() / pageWidth;
minZoomFactor = Math.max(minZoomFactor, zoomFactor * scaleFactor);
if (viewport.width() > pageWidth)
focusX = 0.0f;
}
if (pageRect.height() > 0) {
float pageHeight = pageRect.height() + margins.top + margins.bottom;
float pageHeight = pageRect.height();
float scaleFactor = viewport.height() / pageHeight;
minZoomFactor = Math.max(minZoomFactor, zoomFactor * scaleFactor);
if (viewport.height() > pageHeight)
@ -1106,18 +1101,8 @@ class JavaPanZoomController
@Override
protected float getPageStart() { return getMetrics().pageRectLeft; }
@Override
protected float getMarginStart() { return mTarget.getMaxMargins().left - getMetrics().marginLeft; }
@Override
protected float getMarginEnd() { return mTarget.getMaxMargins().right - getMetrics().marginRight; }
@Override
protected float getPageLength() { return getMetrics().getPageWidthWithMargins(); }
@Override
protected boolean marginsHidden() {
ImmutableViewportMetrics metrics = getMetrics();
RectF maxMargins = mTarget.getMaxMargins();
return (metrics.marginLeft < maxMargins.left || metrics.marginRight < maxMargins.right);
}
@Override
protected void overscrollFling(final float velocity) {
if (mOverscroll != null) {
mOverscroll.setVelocity(velocity, Overscroll.Axis.X);
@ -1142,16 +1127,6 @@ class JavaPanZoomController
@Override
protected float getPageLength() { return getMetrics().getPageHeightWithMargins(); }
@Override
protected float getMarginStart() { return mTarget.getMaxMargins().top - getMetrics().marginTop; }
@Override
protected float getMarginEnd() { return mTarget.getMaxMargins().bottom - getMetrics().marginBottom; }
@Override
protected boolean marginsHidden() {
ImmutableViewportMetrics metrics = getMetrics();
RectF maxMargins = mTarget.getMaxMargins();
return (metrics.marginTop < maxMargins.top || metrics.marginBottom < maxMargins.bottom);
}
@Override
protected void overscrollFling(final float velocity) {
if (mOverscroll != null) {
mOverscroll.setVelocity(velocity, Overscroll.Axis.Y);