mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 716403 - Make the top of the page accessible with the toolbar visible. r=kats
This makes it possible to scroll to the top of the page with the toolbar visible in Firefox for Android. It also causes JavaScript scrolling to position 0 to expose the toolbar.
This commit is contained in:
parent
3bee7155b6
commit
e7a2989cdd
@ -183,9 +183,17 @@ abstract public class BrowserApp extends GeckoApp
|
|||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(View view, MotionEvent event) {
|
public boolean onInterceptTouchEvent(View view, MotionEvent event) {
|
||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
|
|
||||||
int pointerCount = event.getPointerCount();
|
int pointerCount = event.getPointerCount();
|
||||||
|
|
||||||
|
// Whenever there are no pointers left on the screen, tell the page
|
||||||
|
// to clamp the viewport on fixed layer margin changes. This lets the
|
||||||
|
// toolbar scrolling off the top of the page make the page scroll up
|
||||||
|
// if it'd cause the page to go into overscroll, but only when there
|
||||||
|
// are no pointers held down.
|
||||||
|
mLayerView.getLayerClient().setClampOnFixedLayerMarginsChange(
|
||||||
|
pointerCount == 0 || action == MotionEvent.ACTION_CANCEL ||
|
||||||
|
action == MotionEvent.ACTION_UP);
|
||||||
|
|
||||||
View toolbarView = mBrowserToolbar.getLayout();
|
View toolbarView = mBrowserToolbar.getLayout();
|
||||||
if (action == MotionEvent.ACTION_DOWN ||
|
if (action == MotionEvent.ACTION_DOWN ||
|
||||||
action == MotionEvent.ACTION_POINTER_DOWN) {
|
action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||||
|
@ -91,6 +91,8 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||||||
private final PanZoomController mPanZoomController;
|
private final PanZoomController mPanZoomController;
|
||||||
private LayerView mView;
|
private LayerView mView;
|
||||||
|
|
||||||
|
private boolean mClampOnMarginChange;
|
||||||
|
|
||||||
public GeckoLayerClient(Context context, LayerView view, EventDispatcher eventDispatcher) {
|
public GeckoLayerClient(Context context, LayerView view, EventDispatcher eventDispatcher) {
|
||||||
// we can fill these in with dummy values because they are always written
|
// we can fill these in with dummy values because they are always written
|
||||||
// to before being read
|
// to before being read
|
||||||
@ -105,6 +107,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||||||
mProgressiveUpdateDisplayPort = new DisplayPortMetrics();
|
mProgressiveUpdateDisplayPort = new DisplayPortMetrics();
|
||||||
mLastProgressiveUpdateWasLowPrecision = false;
|
mLastProgressiveUpdateWasLowPrecision = false;
|
||||||
mProgressiveUpdateWasInDanger = false;
|
mProgressiveUpdateWasInDanger = false;
|
||||||
|
mClampOnMarginChange = true;
|
||||||
|
|
||||||
mForceRedraw = true;
|
mForceRedraw = true;
|
||||||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
||||||
@ -354,11 +357,21 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||||||
*/
|
*/
|
||||||
public void setFixedLayerMargins(float left, float top, float right, float bottom) {
|
public void setFixedLayerMargins(float left, float top, float right, float bottom) {
|
||||||
ImmutableViewportMetrics oldMetrics = getViewportMetrics();
|
ImmutableViewportMetrics oldMetrics = getViewportMetrics();
|
||||||
setViewportMetrics(oldMetrics.setFixedLayerMargins(left, top, right, bottom), false);
|
ImmutableViewportMetrics newMetrics = oldMetrics.setFixedLayerMargins(left, top, right, bottom);
|
||||||
|
|
||||||
|
if (mClampOnMarginChange) {
|
||||||
|
newMetrics = newMetrics.clampWithMargins();
|
||||||
|
}
|
||||||
|
|
||||||
|
setViewportMetrics(newMetrics, false);
|
||||||
|
|
||||||
mView.requestRender();
|
mView.requestRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClampOnFixedLayerMarginsChange(boolean aClamp) {
|
||||||
|
mClampOnMarginChange = aClamp;
|
||||||
|
}
|
||||||
|
|
||||||
// This is called on the Gecko thread to determine if we're still interested
|
// This is called on the Gecko thread to determine if we're still interested
|
||||||
// in the update of this display-port to continue. We can return true here
|
// in the update of this display-port to continue. We can return true here
|
||||||
// to abort the current update and continue with any subsequent ones. This
|
// to abort the current update and continue with any subsequent ones. This
|
||||||
@ -470,7 +483,15 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||||||
float pageLeft, float pageTop, float pageRight, float pageBottom,
|
float pageLeft, float pageTop, float pageRight, float pageBottom,
|
||||||
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
|
float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
final ImmutableViewportMetrics newMetrics = getViewportMetrics()
|
ImmutableViewportMetrics currentMetrics = getViewportMetrics();
|
||||||
|
|
||||||
|
// If we're meant to be scrolled to the top, take into account any
|
||||||
|
// margin set on the pan zoom controller.
|
||||||
|
if (offsetY == 0) {
|
||||||
|
offsetY = -currentMetrics.fixedLayerMarginTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ImmutableViewportMetrics newMetrics = currentMetrics
|
||||||
.setViewportOrigin(offsetX, offsetY)
|
.setViewportOrigin(offsetX, offsetY)
|
||||||
.setZoomFactor(zoom)
|
.setZoomFactor(zoom)
|
||||||
.setPageRect(new RectF(pageLeft, pageTop, pageRight, pageBottom),
|
.setPageRect(new RectF(pageLeft, pageTop, pageRight, pageBottom),
|
||||||
@ -549,10 +570,20 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
|
|||||||
mCurrentViewTransform.x = mFrameMetrics.viewportRectLeft;
|
mCurrentViewTransform.x = mFrameMetrics.viewportRectLeft;
|
||||||
mCurrentViewTransform.y = mFrameMetrics.viewportRectTop;
|
mCurrentViewTransform.y = mFrameMetrics.viewportRectTop;
|
||||||
mCurrentViewTransform.scale = mFrameMetrics.zoomFactor;
|
mCurrentViewTransform.scale = mFrameMetrics.zoomFactor;
|
||||||
mCurrentViewTransform.fixedLayerMarginLeft = mFrameMetrics.fixedLayerMarginLeft;
|
|
||||||
mCurrentViewTransform.fixedLayerMarginTop = mFrameMetrics.fixedLayerMarginTop;
|
// Adjust the fixed layer margins so that overscroll subtracts from them.
|
||||||
mCurrentViewTransform.fixedLayerMarginRight = mFrameMetrics.fixedLayerMarginRight;
|
mCurrentViewTransform.fixedLayerMarginLeft =
|
||||||
mCurrentViewTransform.fixedLayerMarginBottom = mFrameMetrics.fixedLayerMarginBottom;
|
Math.max(0, mFrameMetrics.fixedLayerMarginLeft +
|
||||||
|
Math.min(0, mFrameMetrics.viewportRectLeft - mFrameMetrics.pageRectLeft));
|
||||||
|
mCurrentViewTransform.fixedLayerMarginTop =
|
||||||
|
Math.max(0, mFrameMetrics.fixedLayerMarginTop +
|
||||||
|
Math.min(0, mFrameMetrics.viewportRectTop - mFrameMetrics.pageRectTop));
|
||||||
|
mCurrentViewTransform.fixedLayerMarginRight =
|
||||||
|
Math.max(0, mFrameMetrics.fixedLayerMarginRight +
|
||||||
|
Math.min(0, (mFrameMetrics.pageRectRight - mFrameMetrics.viewportRectRight)));
|
||||||
|
mCurrentViewTransform.fixedLayerMarginBottom =
|
||||||
|
Math.max(0, mFrameMetrics.fixedLayerMarginBottom +
|
||||||
|
Math.min(0, (mFrameMetrics.pageRectBottom - mFrameMetrics.viewportRectBottom)));
|
||||||
|
|
||||||
mRootLayer.setPositionAndResolution(x, y, x + width, y + height, resolution);
|
mRootLayer.setPositionAndResolution(x, y, x + width, y + height, resolution);
|
||||||
|
|
||||||
|
@ -237,19 +237,20 @@ public class ImmutableViewportMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Clamps the viewport to remain within the page rect. */
|
/** Clamps the viewport to remain within the page rect. */
|
||||||
public ImmutableViewportMetrics clamp() {
|
private ImmutableViewportMetrics clamp(float marginLeft, float marginTop,
|
||||||
|
float marginRight, float marginBottom) {
|
||||||
RectF newViewport = getViewport();
|
RectF newViewport = getViewport();
|
||||||
|
|
||||||
// The viewport bounds ought to never exceed the page bounds.
|
// The viewport bounds ought to never exceed the page bounds.
|
||||||
if (newViewport.right > pageRectRight)
|
if (newViewport.right > pageRectRight + marginRight)
|
||||||
newViewport.offset(pageRectRight - newViewport.right, 0);
|
newViewport.offset((pageRectRight + marginRight) - newViewport.right, 0);
|
||||||
if (newViewport.left < pageRectLeft)
|
if (newViewport.left < pageRectLeft - marginLeft)
|
||||||
newViewport.offset(pageRectLeft - newViewport.left, 0);
|
newViewport.offset((pageRectLeft - marginLeft) - newViewport.left, 0);
|
||||||
|
|
||||||
if (newViewport.bottom > pageRectBottom)
|
if (newViewport.bottom > pageRectBottom + marginBottom)
|
||||||
newViewport.offset(0, pageRectBottom - newViewport.bottom);
|
newViewport.offset(0, (pageRectBottom + marginBottom) - newViewport.bottom);
|
||||||
if (newViewport.top < pageRectTop)
|
if (newViewport.top < pageRectTop - marginTop)
|
||||||
newViewport.offset(0, pageRectTop - newViewport.top);
|
newViewport.offset(0, (pageRectTop - marginTop) - newViewport.top);
|
||||||
|
|
||||||
return new ImmutableViewportMetrics(
|
return new ImmutableViewportMetrics(
|
||||||
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
|
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
|
||||||
@ -259,6 +260,15 @@ public class ImmutableViewportMetrics {
|
|||||||
zoomFactor);
|
zoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImmutableViewportMetrics clamp() {
|
||||||
|
return clamp(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImmutableViewportMetrics clampWithMargins() {
|
||||||
|
return clamp(fixedLayerMarginLeft, fixedLayerMarginTop,
|
||||||
|
fixedLayerMarginRight, fixedLayerMarginBottom);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean fuzzyEquals(ImmutableViewportMetrics other) {
|
public boolean fuzzyEquals(ImmutableViewportMetrics other) {
|
||||||
// Don't bother checking the pageRectXXX values because they are a product
|
// Don't bother checking the pageRectXXX values because they are a product
|
||||||
// of the cssPageRectXXX values and the zoomFactor, except with more rounding
|
// of the cssPageRectXXX values and the zoomFactor, except with more rounding
|
||||||
|
@ -937,7 +937,7 @@ class JavaPanZoomController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now we pan to the right origin. */
|
/* Now we pan to the right origin. */
|
||||||
viewportMetrics = viewportMetrics.clamp();
|
viewportMetrics = viewportMetrics.clampWithMargins();
|
||||||
|
|
||||||
return viewportMetrics;
|
return viewportMetrics;
|
||||||
}
|
}
|
||||||
@ -949,9 +949,15 @@ class JavaPanZoomController
|
|||||||
@Override
|
@Override
|
||||||
protected float getViewportLength() { return getMetrics().getWidth(); }
|
protected float getViewportLength() { return getMetrics().getWidth(); }
|
||||||
@Override
|
@Override
|
||||||
protected float getPageStart() { return getMetrics().pageRectLeft; }
|
protected float getPageStart() {
|
||||||
|
ImmutableViewportMetrics metrics = getMetrics();
|
||||||
|
return metrics.pageRectLeft - metrics.fixedLayerMarginLeft;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected float getPageLength() { return getMetrics().getPageWidth(); }
|
protected float getPageLength() {
|
||||||
|
ImmutableViewportMetrics metrics = getMetrics();
|
||||||
|
return metrics.getPageWidth() + metrics.fixedLayerMarginLeft + metrics.fixedLayerMarginRight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AxisY extends Axis {
|
private class AxisY extends Axis {
|
||||||
@ -961,9 +967,15 @@ class JavaPanZoomController
|
|||||||
@Override
|
@Override
|
||||||
protected float getViewportLength() { return getMetrics().getHeight(); }
|
protected float getViewportLength() { return getMetrics().getHeight(); }
|
||||||
@Override
|
@Override
|
||||||
protected float getPageStart() { return getMetrics().pageRectTop; }
|
protected float getPageStart() {
|
||||||
|
ImmutableViewportMetrics metrics = getMetrics();
|
||||||
|
return metrics.pageRectTop - metrics.fixedLayerMarginTop;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected float getPageLength() { return getMetrics().getPageHeight(); }
|
protected float getPageLength() {
|
||||||
|
ImmutableViewportMetrics metrics = getMetrics();
|
||||||
|
return metrics.getPageHeight() + metrics.fixedLayerMarginTop + metrics.fixedLayerMarginBottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user