From 4a19924c662c5b070edf477623c5b638a84b5fa6 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Mon, 15 Jul 2013 17:03:24 +0100 Subject: [PATCH] Bug 892246 - Allow subdocument scrolling to reveal margins. r=kats This adds a notification callback to PanZoomTarget that the PanZoomController can call to notify GeckoLayerClient that a subdocument is being scrolled. This allows GeckoLayerClient to call LayerMarginsAnimator and alter the margins accordingly, stopping a page from trapping the toolbar on/off the screen with a screen-covering subframe. --- mobile/android/base/gfx/GeckoLayerClient.java | 15 +++++++++++++++ .../android/base/gfx/JavaPanZoomController.java | 6 +++++- mobile/android/base/gfx/PanZoomTarget.java | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index 587ab55ee9cb..b6be90c79518 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -854,6 +854,21 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget viewportMetricsChanged(true); } + /** Implementation of PanZoomTarget + * Notification that a subdocument has been scrolled by a certain amount. + * This is used here to make sure that the margins are still accessible + * during subdocument scrolling. + * + * You must hold the monitor while calling this. + */ + @Override + public void onSubdocumentScrollBy(float dx, float dy) { + ImmutableViewportMetrics newMarginsMetrics = + mMarginsAnimator.scrollBy(mViewportMetrics, dx, dy); + mViewportMetrics = mViewportMetrics.setMarginsFrom(newMarginsMetrics); + viewportMetricsChanged(true); + } + /** Implementation of PanZoomTarget */ @Override public void panZoomStopped() { diff --git a/mobile/android/base/gfx/JavaPanZoomController.java b/mobile/android/base/gfx/JavaPanZoomController.java index c53a8ded92ce..3a3b00f3d861 100644 --- a/mobile/android/base/gfx/JavaPanZoomController.java +++ b/mobile/android/base/gfx/JavaPanZoomController.java @@ -806,7 +806,11 @@ class JavaPanZoomController if (FloatUtils.fuzzyEquals(displacement.x, 0.0f) && FloatUtils.fuzzyEquals(displacement.y, 0.0f)) { return; } - if (! mSubscroller.scrollBy(displacement)) { + if (mSubscroller.scrollBy(displacement)) { + synchronized (mTarget.getLock()) { + mTarget.onSubdocumentScrollBy(displacement.x, displacement.y); + } + } else { synchronized (mTarget.getLock()) { scrollBy(displacement.x, displacement.y); } diff --git a/mobile/android/base/gfx/PanZoomTarget.java b/mobile/android/base/gfx/PanZoomTarget.java index ef01a723099c..d0df1057a15b 100644 --- a/mobile/android/base/gfx/PanZoomTarget.java +++ b/mobile/android/base/gfx/PanZoomTarget.java @@ -17,6 +17,7 @@ public interface PanZoomTarget { public void setAnimationTarget(ImmutableViewportMetrics viewport); public void setViewportMetrics(ImmutableViewportMetrics viewport); public void scrollBy(float dx, float dy); + public void onSubdocumentScrollBy(float dx, float dy); public void panZoomStopped(); /** This triggers an (asynchronous) viewport update/redraw. */ public void forceRedraw(DisplayPortMetrics displayPort);