Bug 1248078 - Remove the dedicated scroll acknowledgement message. r?botond
MozReview-Commit-ID: 4xUujXnAU0x
--- a/gfx/layers/apz/public/GeckoContentController.h
+++ b/gfx/layers/apz/public/GeckoContentController.h
@@ -32,24 +32,16 @@ public:
/**
* Requests a paint of the given FrameMetrics |aFrameMetrics| from Gecko.
* Implementations per-platform are responsible for actually handling this.
* This method will always be called on the Gecko main thread.
*/
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
/**
- * Acknowledges the recipt of a scroll offset update for the scrollable
- * frame with the given scroll id. This is used to maintain consistency
- * between APZ and other sources of scroll changes.
- */
- virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration) = 0;
-
- /**
* Requests handling of a double tap. |aPoint| is in CSS pixels, relative to
* the current scroll offset. This should eventually round-trip back to
* AsyncPanZoomController::ZoomToRect with the dimensions that we want to zoom
* to.
*/
virtual void HandleDoubleTap(const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid) = 0;
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -3459,17 +3459,17 @@ void AsyncPanZoomController::NotifyLayer
if ((aIsFirstPaint && aThisLayerTreeUpdated) || isDefault) {
// Initialize our internal state to something sane when the content
// that was just painted is something we knew nothing about previously
CancelAnimation();
mScrollMetadata = aScrollMetadata;
if (scrollOffsetUpdated) {
- AcknowledgeScrollUpdate();
+ needContentRepaint = true;
}
mExpectedGeckoMetrics = aLayerMetrics;
ShareCompositorFrameMetrics();
if (mFrameMetrics.GetDisplayPortMargins() != ScreenMargin()) {
// A non-zero display port margin here indicates a displayport has
// been set by a previous APZC for the content at this guid. The
// scrollable rect may have changed since then, making the margins
@@ -3534,17 +3534,16 @@ void AsyncPanZoomController::NotifyLayer
// Send an acknowledgement with the new scroll generation so that any
// repaint requests later in this function go through.
// Because of the scroll generation update, any inflight paint requests are
// going to be ignored by layout, and so mExpectedGeckoMetrics
// becomes incorrect for the purposes of calculating the LD transform. To
// correct this we need to update mExpectedGeckoMetrics to be the
// last thing we know was painted by Gecko.
mFrameMetrics.CopyScrollInfoFrom(aLayerMetrics);
- AcknowledgeScrollUpdate();
mExpectedGeckoMetrics = aLayerMetrics;
// Cancel the animation (which might also trigger a repaint request)
// after we update the scroll offset above. Otherwise we can be left
// in a state where things are out of sync.
CancelAnimation();
// Since the scroll offset has changed, we need to recompute the
@@ -3566,17 +3565,17 @@ void AsyncPanZoomController::NotifyLayer
APZC_LOG("%p smooth scrolling from %s to %s in state %d\n", this,
Stringify(mFrameMetrics.GetScrollOffset()).c_str(),
Stringify(aLayerMetrics.GetSmoothScrollOffset()).c_str(),
mState);
// See comment on the similar code in the |if (scrollOffsetUpdated)| block
// above.
mFrameMetrics.CopySmoothScrollInfoFrom(aLayerMetrics);
- AcknowledgeScrollUpdate();
+ needContentRepaint = true;
mExpectedGeckoMetrics = aLayerMetrics;
SmoothScrollTo(mFrameMetrics.GetSmoothScrollOffset());
}
if (needContentRepaint) {
RequestContentRepaint();
}
@@ -3597,41 +3596,25 @@ AsyncPanZoomController::NotifyScrollUpda
if (!scrollOffsetUpdated) {
return;
}
APZC_LOG("%p updating scroll offset from %s to %s\n", this,
Stringify(mFrameMetrics.GetScrollOffset()).c_str(),
Stringify(aScrollOffset).c_str());
mFrameMetrics.UpdateScrollInfo(aScrollGeneration, aScrollOffset);
- AcknowledgeScrollUpdate();
mExpectedGeckoMetrics.UpdateScrollInfo(aScrollGeneration, aScrollOffset);
CancelAnimation();
RequestContentRepaint();
UpdateSharedCompositorFrameMetrics();
// We don't call ScheduleComposite() here because that happens higher up
// in the call stack, when LayerTransactionParent handles this message.
// If we did it here it would incur an extra message posting unnecessarily.
}
-void
-AsyncPanZoomController::AcknowledgeScrollUpdate() const
-{
- // Once layout issues a scroll offset update, it becomes impervious to
- // scroll offset updates from APZ until we acknowledge the update it sent.
- // This prevents APZ updates from clobbering scroll updates from other
- // more "legitimate" sources like content scripts.
- RefPtr<GeckoContentController> controller = GetGeckoContentController();
- if (controller) {
- APZC_LOG("%p sending scroll update acknowledgement with gen %u\n", this, mFrameMetrics.GetScrollGeneration());
- controller->AcknowledgeScrollUpdate(mFrameMetrics.GetScrollId(),
- mFrameMetrics.GetScrollGeneration());
- }
-}
-
const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() const {
mMonitor.AssertCurrentThreadIn();
return mFrameMetrics;
}
APZCTreeManager* AsyncPanZoomController::GetApzcTreeManager() const {
mMonitor.AssertNotCurrentThreadIn();
return mTreeManager;
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -897,18 +897,16 @@ private:
// Start an overscroll animation with the given initial velocity.
void StartOverscrollAnimation(const ParentLayerPoint& aVelocity);
void SmoothScrollTo(const CSSPoint& aDestination);
// Returns whether overscroll is allowed during an event.
bool AllowScrollHandoffInCurrentBlock() const;
- void AcknowledgeScrollUpdate() const;
-
/* ===================================================================
* The functions and members in this section are used to make ancestor chains
* out of APZC instances. These chains can only be walked or manipulated
* while holding the lock in the associated APZCTreeManager instance.
*/
public:
void SetParent(AsyncPanZoomController* aParent) {
mParent = aParent;
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -119,19 +119,19 @@ ScrollFrameTo(nsIScrollableFrame* aFrame
*/
static void
ScrollFrame(nsIContent* aContent,
FrameMetrics& aMetrics)
{
// Scroll the window to the desired spot
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.GetScrollId());
if (sf) {
+ sf->ResetScrollInfoIfGeneration(aMetrics.GetScrollGeneration());
sf->SetScrollableByAPZ(!aMetrics.IsScrollInfoLayer());
}
-
bool scrollUpdated = false;
CSSPoint apzScrollOffset = aMetrics.GetScrollOffset();
CSSPoint actualScrollOffset = ScrollFrameTo(sf, apzScrollOffset, scrollUpdated);
if (scrollUpdated) {
if (aMetrics.IsScrollInfoLayer()) {
// In cases where the APZ scroll offset is different from the content scroll
// offset, we want to interpret the margins as relative to the APZ scroll
@@ -326,64 +326,16 @@ APZCCallbackHelper::InitializeRootDispla
// nsRootBoxFrame::BuildDisplayList.
nsLayoutUtils::SetDisplayPortMargins(content, aPresShell, ScreenMargin(), 0,
nsLayoutUtils::RepaintMode::DoNotRepaint);
nsLayoutUtils::SetZeroMarginDisplayPortOnAsyncScrollableAncestors(
content->GetPrimaryFrame(), nsLayoutUtils::RepaintMode::DoNotRepaint);
}
}
-class AcknowledgeScrollUpdateEvent : public nsRunnable
-{
- typedef mozilla::layers::FrameMetrics::ViewID ViewID;
-
-public:
- AcknowledgeScrollUpdateEvent(const ViewID& aScrollId, const uint32_t& aScrollGeneration)
- : mScrollId(aScrollId)
- , mScrollGeneration(aScrollGeneration)
- {
- }
-
- NS_IMETHOD Run() {
- MOZ_ASSERT(NS_IsMainThread());
-
- nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(mScrollId);
- if (sf) {
- sf->ResetScrollInfoIfGeneration(mScrollGeneration);
- }
-
- // Since the APZ and content are in sync, we need to clear any callback transform
- // that might have been set on the last repaint request (which might have failed
- // due to the inflight scroll update that this message is acknowledging).
- nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mScrollId);
- if (content) {
- content->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(),
- nsINode::DeleteProperty<CSSPoint>);
- }
-
- return NS_OK;
- }
-
-protected:
- ViewID mScrollId;
- uint32_t mScrollGeneration;
-};
-
-void
-APZCCallbackHelper::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration)
-{
- nsCOMPtr<nsIRunnable> r1 = new AcknowledgeScrollUpdateEvent(aScrollId, aScrollGeneration);
- if (!NS_IsMainThread()) {
- NS_DispatchToMainThread(r1);
- } else {
- r1->Run();
- }
-}
-
nsIPresShell*
APZCCallbackHelper::GetRootContentDocumentPresShellForContent(nsIContent* aContent)
{
nsIDocument* doc = aContent->GetComposedDoc();
if (!doc) {
return nullptr;
}
nsIPresShell* shell = doc->GetShell();
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -61,21 +61,16 @@ public:
static bool GetOrCreateScrollIdentifiers(nsIContent* aContent,
uint32_t* aPresShellIdOut,
FrameMetrics::ViewID* aViewIdOut);
/* Initialize a zero-margin displayport on the root document element of the
given presShell. */
static void InitializeRootDisplayport(nsIPresShell* aPresShell);
- /* Tell layout that we received the scroll offset update for the given view ID, so
- that it accepts future scroll offset updates from APZ. */
- static void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration);
-
/* Get the pres shell associated with the root content document enclosing |aContent|. */
static nsIPresShell* GetRootContentDocumentPresShellForContent(nsIContent* aContent);
/* Apply an "input transform" to the given |aInput| and return the transformed value.
The input transform applied is the one for the content element corresponding to
|aGuid|; this is populated in a previous call to UpdateCallbackTransform. See that
method's documentations for details.
This method additionally adjusts |aInput| by inversely scaling by the provided
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -64,23 +64,16 @@ ChromeProcessController::RequestContentR
void
ChromeProcessController::PostDelayedTask(Task* aTask, int aDelayMs)
{
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
}
void
-ChromeProcessController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration)
-{
- APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
-}
-
-void
ChromeProcessController::Destroy()
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ChromeProcessController::Destroy));
return;
}
--- a/gfx/layers/apz/util/ChromeProcessController.h
+++ b/gfx/layers/apz/util/ChromeProcessController.h
@@ -35,19 +35,16 @@ protected:
public:
explicit ChromeProcessController(nsIWidget* aWidget, APZEventState* aAPZEventState, APZCTreeManager* aAPZCTreeManager);
~ChromeProcessController();
virtual void Destroy() override;
// GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) override;
virtual void PostDelayedTask(Task* aTask, int aDelayMs) override;
- virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration) override;
-
virtual void HandleDoubleTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers,
const ScrollableLayerGuid& aGuid) override;
virtual void HandleSingleTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers,
const ScrollableLayerGuid& aGuid) override;
virtual void HandleLongTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId) override;
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
--- a/gfx/layers/ipc/APZChild.cpp
+++ b/gfx/layers/ipc/APZChild.cpp
@@ -90,24 +90,16 @@ APZChild::~APZChild()
bool
APZChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
{
return mBrowser->UpdateFrame(aFrameMetrics);
}
bool
-APZChild::RecvAcknowledgeScrollUpdate(const ViewID& aScrollId,
- const uint32_t& aScrollGeneration)
-{
- APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
- return true;
-}
-
-bool
APZChild::RecvHandleDoubleTap(const CSSPoint& aPoint,
const Modifiers& aModifiers,
const ScrollableLayerGuid& aGuid)
{
mBrowser->HandleDoubleTap(aPoint, aModifiers, aGuid);
return true;
}
--- a/gfx/layers/ipc/APZChild.h
+++ b/gfx/layers/ipc/APZChild.h
@@ -23,19 +23,16 @@ class APZChild final : public PAPZChild
{
public:
static APZChild* Create(const dom::TabId& aTabId);
~APZChild();
virtual bool RecvUpdateFrame(const FrameMetrics& frame) override;
- virtual bool RecvAcknowledgeScrollUpdate(const ViewID& aScrollId,
- const uint32_t& aScrollGeneration) override;
-
virtual bool RecvHandleDoubleTap(const CSSPoint& aPoint,
const Modifiers& aModifiers,
const ScrollableLayerGuid& aGuid) override;
virtual bool RecvHandleSingleTap(const CSSPoint& aPoint,
const Modifiers& aModifiers,
const ScrollableLayerGuid& aGuid,
const bool& aCallTakeFocusForClickFromTap) override;
--- a/gfx/layers/ipc/PAPZ.ipdl
+++ b/gfx/layers/ipc/PAPZ.ipdl
@@ -84,17 +84,16 @@ parent:
MaybeZoomConstraints aConstraints);
child:
async UpdateFrame(FrameMetrics frame);
// The following methods correspond to functions on the GeckoContentController
// interface in gfx/layers/apz/public/GeckoContentController.h. Refer to documentation
// in that file for these functions.
- async AcknowledgeScrollUpdate(ViewID aScrollId, uint32_t aScrollGeneration);
async HandleDoubleTap(CSSPoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid);
async HandleSingleTap(CSSPoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid, bool aCallTakeFocusForClickFromTap);
async HandleLongTap(CSSPoint point, Modifiers aModifiers, ScrollableLayerGuid aGuid, uint64_t aInputBlockId);
async NotifyAPZStateChange(ViewID aViewId, APZStateChange aChange, int aArg);
async NotifyFlushComplete();
async __delete__();
};
--- a/gfx/layers/ipc/RemoteContentController.cpp
+++ b/gfx/layers/ipc/RemoteContentController.cpp
@@ -47,34 +47,16 @@ RemoteContentController::RequestContentR
{
MOZ_ASSERT(NS_IsMainThread());
if (CanSend()) {
Unused << SendUpdateFrame(aFrameMetrics);
}
}
void
-RemoteContentController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration)
-{
- if (MessageLoop::current() != mUILoop) {
- // We have to send this message from the "UI thread" (main
- // thread).
- mUILoop->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &RemoteContentController::AcknowledgeScrollUpdate,
- aScrollId, aScrollGeneration));
- return;
- }
- if (CanSend()) {
- Unused << SendAcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
- }
-}
-
-void
RemoteContentController::HandleDoubleTap(const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid)
{
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
--- a/gfx/layers/ipc/RemoteContentController.h
+++ b/gfx/layers/ipc/RemoteContentController.h
@@ -37,19 +37,16 @@ public:
explicit RemoteContentController(uint64_t aLayersId,
dom::TabParent* aBrowserParent);
virtual ~RemoteContentController();
// Needs to be called on the main thread.
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) override;
- virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
- const uint32_t& aScrollGeneration) override;
-
virtual void HandleDoubleTap(const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid) override;
virtual void HandleSingleTap(const CSSPoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid) override;