Bug 1265424 - Record if the target was confirmed via a timeout or not. r?botond
MozReview-Commit-ID: Azm6Z0DZMNF
--- a/gfx/layers/apz/src/InputBlockState.cpp
+++ b/gfx/layers/apz/src/InputBlockState.cpp
@@ -20,32 +20,35 @@
namespace mozilla {
namespace layers {
static uint64_t sBlockCounter = InputBlockState::NO_BLOCK_ID + 1;
InputBlockState::InputBlockState(const RefPtr<AsyncPanZoomController>& aTargetApzc,
bool aTargetConfirmed)
: mTargetApzc(aTargetApzc)
- , mTargetConfirmed(aTargetConfirmed)
+ , mTargetConfirmed(aTargetConfirmed ? TargetConfirmationState::eConfirmed
+ : TargetConfirmationState::eUnconfirmed)
, mBlockId(sBlockCounter++)
, mTransformToApzc(aTargetApzc->GetTransformToThis())
{
// We should never be constructed with a nullptr target.
MOZ_ASSERT(mTargetApzc);
mOverscrollHandoffChain = mTargetApzc->BuildOverscrollHandoffChain();
}
bool
-InputBlockState::SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc)
+InputBlockState::SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc,
+ bool aFromTimeout)
{
- if (mTargetConfirmed) {
+ if (mTargetConfirmed != TargetConfirmationState::eUnconfirmed) {
return false;
}
- mTargetConfirmed = true;
+ mTargetConfirmed = aFromTimeout ? TargetConfirmationState::eTimedOut
+ : TargetConfirmationState::eConfirmed;
TBS_LOG("%p got confirmed target APZC %p\n", this, mTargetApzc.get());
if (mTargetApzc == aTargetApzc) {
// The confirmed target is the same as the tentative one, so we're done.
return true;
}
TBS_LOG("%p replacing unconfirmed target %p with real target %p\n",
@@ -80,17 +83,17 @@ uint64_t
InputBlockState::GetBlockId() const
{
return mBlockId;
}
bool
InputBlockState::IsTargetConfirmed() const
{
- return mTargetConfirmed;
+ return mTargetConfirmed != TargetConfirmationState::eUnconfirmed;
}
bool
InputBlockState::IsDownchainOf(AsyncPanZoomController* aA, AsyncPanZoomController* aB) const
{
if (aA == aB) {
return true;
}
@@ -354,28 +357,29 @@ WheelBlockState::SetContentResponse(bool
{
if (aPreventDefault) {
EndTransaction();
}
return CancelableBlockState::SetContentResponse(aPreventDefault);
}
bool
-WheelBlockState::SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc)
+WheelBlockState::SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc,
+ bool aFromTimeout)
{
// The APZC that we find via APZCCallbackHelpers may not be the same APZC
// ESM or OverscrollHandoff would have computed. Make sure we get the right
// one by looking for the first apzc the next pending event can scroll.
RefPtr<AsyncPanZoomController> apzc = aTargetApzc;
if (apzc && mEvents.Length() > 0) {
const ScrollWheelInput& event = mEvents.ElementAt(0);
apzc = apzc->BuildOverscrollHandoffChain()->FindFirstScrollable(event);
}
- InputBlockState::SetConfirmedTargetApzc(apzc);
+ InputBlockState::SetConfirmedTargetApzc(apzc, aFromTimeout);
return true;
}
void
WheelBlockState::Update(ScrollWheelInput& aEvent)
{
// We might not be in a transaction if the block never started in a
// transaction - for example, if nothing was scrollable.
@@ -598,32 +602,33 @@ PanGestureBlockState::PanGestureBlockSta
if (apzc && apzc != GetTargetApzc()) {
UpdateTargetApzc(apzc);
}
}
}
bool
-PanGestureBlockState::SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc)
+PanGestureBlockState::SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc,
+ bool aFromTimeout)
{
// The APZC that we find via APZCCallbackHelpers may not be the same APZC
// ESM or OverscrollHandoff would have computed. Make sure we get the right
// one by looking for the first apzc the next pending event can scroll.
RefPtr<AsyncPanZoomController> apzc = aTargetApzc;
if (apzc && mEvents.Length() > 0) {
const PanGestureInput& event = mEvents.ElementAt(0);
RefPtr<AsyncPanZoomController> scrollableApzc =
apzc->BuildOverscrollHandoffChain()->FindFirstScrollable(event);
if (scrollableApzc) {
apzc = scrollableApzc;
}
}
- InputBlockState::SetConfirmedTargetApzc(apzc);
+ InputBlockState::SetConfirmedTargetApzc(apzc, aFromTimeout);
return true;
}
void
PanGestureBlockState::AddEvent(const PanGestureInput& aEvent)
{
mEvents.AppendElement(aEvent);
}
--- a/gfx/layers/apz/src/InputBlockState.h
+++ b/gfx/layers/apz/src/InputBlockState.h
@@ -39,17 +39,17 @@ class InputBlockState
public:
static const uint64_t NO_BLOCK_ID = 0;
explicit InputBlockState(const RefPtr<AsyncPanZoomController>& aTargetApzc,
bool aTargetConfirmed);
virtual ~InputBlockState()
{}
- virtual bool SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc);
+ virtual bool SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc, bool aFromTimeout);
const RefPtr<AsyncPanZoomController>& GetTargetApzc() const;
const RefPtr<const OverscrollHandoffChain>& GetOverscrollHandoffChain() const;
uint64_t GetBlockId() const;
bool IsTargetConfirmed() const;
void SetScrolledApzc(AsyncPanZoomController* aApzc);
AsyncPanZoomController* GetScrolledApzc() const;
@@ -59,18 +59,24 @@ protected:
virtual void UpdateTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc);
private:
// Checks whether |aA| is an ancestor of |aB| (or the same as |aB|) in
// |mOverscrollHandoffChain|.
bool IsDownchainOf(AsyncPanZoomController* aA, AsyncPanZoomController* aB) const;
private:
+ enum class TargetConfirmationState {
+ eUnconfirmed,
+ eTimedOut,
+ eConfirmed
+ };
+
RefPtr<AsyncPanZoomController> mTargetApzc;
- bool mTargetConfirmed;
+ TargetConfirmationState mTargetConfirmed;
const uint64_t mBlockId;
// The APZC that was actually scrolled by events in this input block.
// This is used in configurations where a single input block is only
// allowed to scroll a single APZC (configurations where gfxPrefs::
// APZAllowImmediateHandoff() is false).
// Set the first time an input event in this block scrolls an APZC.
RefPtr<AsyncPanZoomController> mScrolledApzc;
@@ -222,17 +228,17 @@ public:
const ScrollWheelInput& aEvent);
bool SetContentResponse(bool aPreventDefault) override;
bool HasEvents() const override;
void DropEvents() override;
void HandleEvents() override;
bool MustStayActive() override;
const char* Type() override;
- bool SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc) override;
+ bool SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc, bool aFromTimeout) override;
void AddEvent(const ScrollWheelInput& aEvent);
WheelBlockState *AsWheelBlock() override {
return this;
}
/**
@@ -343,17 +349,17 @@ public:
bool SetContentResponse(bool aPreventDefault) override;
bool HasReceivedAllContentNotifications() const override;
bool IsReadyForHandling() const override;
bool HasEvents() const override;
void DropEvents() override;
void HandleEvents() override;
bool MustStayActive() override;
const char* Type() override;
- bool SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc) override;
+ bool SetConfirmedTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc, bool aFromTimeout) override;
void AddEvent(const PanGestureInput& aEvent);
PanGestureBlockState *AsPanGestureBlock() override {
return this;
}
/**
--- a/gfx/layers/apz/src/InputQueue.cpp
+++ b/gfx/layers/apz/src/InputQueue.cpp
@@ -113,17 +113,17 @@ InputQueue::ReceiveTouchInput(const RefP
block->GetOverscrollHandoffChain()->HasFastFlungApzc() &&
haveBehaviors) {
// If we're already in a fast fling, and a single finger goes down, then
// we want special handling for the touch event, because it shouldn't get
// delivered to content. Note that we don't set this flag when going
// from a fast fling to a pinch state (i.e. second finger goes down while
// the first finger is moving).
block->SetDuringFastFling();
- block->SetConfirmedTargetApzc(aTarget);
+ block->SetConfirmedTargetApzc(aTarget, false);
if (gfxPrefs::TouchActionEnabled()) {
block->SetAllowedTouchBehaviors(currentBehaviors);
}
INPQ_LOG("block %p tagged as fast-motion\n", block);
}
CancelAnimationsForNewBlock(block);
@@ -581,17 +581,17 @@ InputQueue::MainThreadTimeout(const uint
INPQ_LOG("got a main thread timeout; block=%" PRIu64 "\n", aInputBlockId);
bool success = false;
for (size_t i = 0; i < mInputBlockQueue.Length(); i++) {
if (mInputBlockQueue[i]->GetBlockId() == aInputBlockId) {
// time out the touch-listener response and also confirm the existing
// target apzc in the case where the main thread doesn't get back to us
// fast enough.
success = mInputBlockQueue[i]->TimeoutContentResponse();
- success |= mInputBlockQueue[i]->SetConfirmedTargetApzc(mInputBlockQueue[i]->GetTargetApzc());
+ success |= mInputBlockQueue[i]->SetConfirmedTargetApzc(mInputBlockQueue[i]->GetTargetApzc(), true);
break;
}
}
if (success) {
ProcessInputBlocks();
}
}
@@ -619,17 +619,17 @@ InputQueue::SetConfirmedTargetApzc(uint6
APZThreadUtils::AssertOnControllerThread();
INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n",
aInputBlockId, aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : "");
bool success = false;
for (size_t i = 0; i < mInputBlockQueue.Length(); i++) {
CancelableBlockState* block = mInputBlockQueue[i].get();
if (block->GetBlockId() == aInputBlockId) {
- success = block->SetConfirmedTargetApzc(aTargetApzc);
+ success = block->SetConfirmedTargetApzc(aTargetApzc, false);
block->RecordContentResponseTime();
break;
}
}
if (success) {
ProcessInputBlocks();
}
}
@@ -642,17 +642,17 @@ InputQueue::ConfirmDragBlock(uint64_t aI
INPQ_LOG("got a target apzc; block=%" PRIu64 " guid=%s\n",
aInputBlockId, aTargetApzc ? Stringify(aTargetApzc->GetGuid()).c_str() : "");
bool success = false;
for (size_t i = 0; i < mInputBlockQueue.Length(); i++) {
DragBlockState* block = mInputBlockQueue[i]->AsDragBlock();
if (block && block->GetBlockId() == aInputBlockId) {
block->SetDragMetrics(aDragMetrics);
- success = block->SetConfirmedTargetApzc(aTargetApzc);
+ success = block->SetConfirmedTargetApzc(aTargetApzc, false);
block->RecordContentResponseTime();
break;
}
}
if (success) {
ProcessInputBlocks();
}
}