mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Add wheel events to the APZ input queue. (bug 1013432 part 4, r=kats)
--HG-- extra : rebase_source : beaf39e7ef1eb192e5edd14aa8e55d741f7ffad2
This commit is contained in:
parent
636a716c5b
commit
498066a4b1
@ -132,6 +132,63 @@ CancelableBlockState::IsReadyForHandling() const
|
||||
return mContentResponded || mContentResponseTimerExpired;
|
||||
}
|
||||
|
||||
WheelBlockState::WheelBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed)
|
||||
: CancelableBlockState(aTargetApzc, aTargetConfirmed)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
WheelBlockState::AddEvent(const ScrollWheelInput& aEvent)
|
||||
{
|
||||
mEvents.AppendElement(aEvent);
|
||||
}
|
||||
|
||||
bool
|
||||
WheelBlockState::IsReadyForHandling() const
|
||||
{
|
||||
if (!CancelableBlockState::IsReadyForHandling()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WheelBlockState::HasEvents() const
|
||||
{
|
||||
return !mEvents.IsEmpty();
|
||||
}
|
||||
|
||||
void
|
||||
WheelBlockState::DropEvents()
|
||||
{
|
||||
TBS_LOG("%p dropping %lu events\n", this, mEvents.Length());
|
||||
mEvents.Clear();
|
||||
}
|
||||
|
||||
void
|
||||
WheelBlockState::HandleEvents(const nsRefPtr<AsyncPanZoomController>& aTarget)
|
||||
{
|
||||
while (HasEvents()) {
|
||||
TBS_LOG("%p returning first of %lu events\n", this, mEvents.Length());
|
||||
ScrollWheelInput event = mEvents[0];
|
||||
mEvents.RemoveElementAt(0);
|
||||
aTarget->HandleInputEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WheelBlockState::MustStayActive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char*
|
||||
WheelBlockState::Type()
|
||||
{
|
||||
return "scroll wheel";
|
||||
}
|
||||
|
||||
TouchBlockState::TouchBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed)
|
||||
: CancelableBlockState(aTargetApzc, aTargetConfirmed)
|
||||
|
@ -17,6 +17,8 @@ namespace layers {
|
||||
class AsyncPanZoomController;
|
||||
class OverscrollHandoffChain;
|
||||
class CancelableBlockState;
|
||||
class TouchBlockState;
|
||||
class WheelBlockState;
|
||||
|
||||
/**
|
||||
* A base class that stores state common to various input blocks.
|
||||
@ -67,6 +69,9 @@ public:
|
||||
virtual TouchBlockState *AsTouchBlock() {
|
||||
return nullptr;
|
||||
}
|
||||
virtual WheelBlockState *AsWheelBlock() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record whether or not content cancelled this block of events.
|
||||
@ -125,6 +130,32 @@ private:
|
||||
bool mContentResponseTimerExpired;
|
||||
};
|
||||
|
||||
/**
|
||||
* A single block of wheel events.
|
||||
*/
|
||||
class WheelBlockState : public CancelableBlockState
|
||||
{
|
||||
public:
|
||||
WheelBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed);
|
||||
|
||||
bool IsReadyForHandling() const MOZ_OVERRIDE;
|
||||
bool HasEvents() const MOZ_OVERRIDE;
|
||||
void DropEvents() MOZ_OVERRIDE;
|
||||
void HandleEvents(const nsRefPtr<AsyncPanZoomController>& aTarget) MOZ_OVERRIDE;
|
||||
bool MustStayActive() MOZ_OVERRIDE;
|
||||
const char* Type() MOZ_OVERRIDE;
|
||||
|
||||
void AddEvent(const ScrollWheelInput& aEvent);
|
||||
|
||||
WheelBlockState *AsWheelBlock() MOZ_OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
nsTArray<ScrollWheelInput> mEvents;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a single touch block. A touch block is
|
||||
* a set of touch events that can be cancelled by web content via
|
||||
|
@ -39,6 +39,11 @@ InputQueue::ReceiveInputEvent(const nsRefPtr<AsyncPanZoomController>& aTarget,
|
||||
return ReceiveTouchInput(aTarget, aTargetConfirmed, event, aOutInputBlockId);
|
||||
}
|
||||
|
||||
case SCROLLWHEEL_INPUT: {
|
||||
const ScrollWheelInput& event = aEvent.AsScrollWheelInput();
|
||||
return ReceiveScrollWheelInput(aTarget, aTargetConfirmed, event, aOutInputBlockId);
|
||||
}
|
||||
|
||||
default:
|
||||
// The return value for non-touch input is only used by tests, so just pass
|
||||
// through the return value for now. This can be changed later if needed.
|
||||
@ -115,6 +120,46 @@ InputQueue::ReceiveTouchInput(const nsRefPtr<AsyncPanZoomController>& aTarget,
|
||||
return result;
|
||||
}
|
||||
|
||||
nsEventStatus
|
||||
InputQueue::ReceiveScrollWheelInput(const nsRefPtr<AsyncPanZoomController>& aTarget,
|
||||
bool aTargetConfirmed,
|
||||
const ScrollWheelInput& aEvent,
|
||||
uint64_t* aOutInputBlockId) {
|
||||
WheelBlockState* block = nullptr;
|
||||
if (!mInputBlockQueue.IsEmpty()) {
|
||||
block = mInputBlockQueue.LastElement().get()->AsWheelBlock();
|
||||
}
|
||||
|
||||
if (!block) {
|
||||
block = new WheelBlockState(aTarget, aTargetConfirmed);
|
||||
INPQ_LOG("started new scroll wheel block %p for target %p\n", block, aTarget.get());
|
||||
|
||||
SweepDepletedBlocks();
|
||||
mInputBlockQueue.AppendElement(block);
|
||||
|
||||
CancelAnimationsForNewBlock(block);
|
||||
MaybeRequestContentResponse(aTarget, block);
|
||||
} else {
|
||||
INPQ_LOG("received new event in block %p\n", block);
|
||||
}
|
||||
|
||||
if (aOutInputBlockId) {
|
||||
*aOutInputBlockId = block->GetBlockId();
|
||||
}
|
||||
|
||||
// Note that the |aTarget| the APZCTM sent us may contradict the confirmed
|
||||
// target set on the block. In this case the confirmed target (which may be
|
||||
// null) should take priority. This is equivalent to just always using the
|
||||
// target (confirmed or not) from the block.
|
||||
nsRefPtr<AsyncPanZoomController> target = block->GetTargetApzc();
|
||||
|
||||
if (!MaybeHandleCurrentBlock(target, block, aEvent)) {
|
||||
block->AddEvent(aEvent.AsScrollWheelInput());
|
||||
}
|
||||
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
void
|
||||
InputQueue::CancelAnimationsForNewBlock(CancelableBlockState* aBlock)
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ namespace mozilla {
|
||||
|
||||
class InputData;
|
||||
class MultiTouchInput;
|
||||
class ScrollWheelInput;
|
||||
|
||||
namespace layers {
|
||||
|
||||
@ -115,6 +116,10 @@ private:
|
||||
bool aTargetConfirmed,
|
||||
const MultiTouchInput& aEvent,
|
||||
uint64_t* aOutInputBlockId);
|
||||
nsEventStatus ReceiveScrollWheelInput(const nsRefPtr<AsyncPanZoomController>& aTarget,
|
||||
bool aTargetConfirmed,
|
||||
const ScrollWheelInput& aEvent,
|
||||
uint64_t* aOutInputBlockId);
|
||||
|
||||
/**
|
||||
* Remove any blocks that are inactive - not ready, and having no events.
|
||||
|
Loading…
Reference in New Issue
Block a user