mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-14 05:44:20 +00:00
Factor out content-handling code from TouchBlockState. (bug 1013432 part 1, r=kats)
--HG-- extra : rebase_source : 12a4f865dda6777c146cfec24184ce45d5d54072
This commit is contained in:
parent
603f482db6
commit
fd05150dca
@ -78,21 +78,17 @@ InputBlockState::IsTargetConfirmed() const
|
||||
return mTargetConfirmed;
|
||||
}
|
||||
|
||||
TouchBlockState::TouchBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed)
|
||||
CancelableBlockState::CancelableBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed)
|
||||
: InputBlockState(aTargetApzc, aTargetConfirmed)
|
||||
, mAllowedTouchBehaviorSet(false)
|
||||
, mPreventDefault(false)
|
||||
, mContentResponded(false)
|
||||
, mContentResponseTimerExpired(false)
|
||||
, mDuringFastMotion(false)
|
||||
, mSingleTapOccurred(false)
|
||||
{
|
||||
TBS_LOG("Creating %p\n", this);
|
||||
}
|
||||
|
||||
bool
|
||||
TouchBlockState::SetContentResponse(bool aPreventDefault)
|
||||
CancelableBlockState::SetContentResponse(bool aPreventDefault)
|
||||
{
|
||||
if (mContentResponded) {
|
||||
return false;
|
||||
@ -107,7 +103,7 @@ TouchBlockState::SetContentResponse(bool aPreventDefault)
|
||||
}
|
||||
|
||||
bool
|
||||
TouchBlockState::TimeoutContentResponse()
|
||||
CancelableBlockState::TimeoutContentResponse()
|
||||
{
|
||||
if (mContentResponseTimerExpired) {
|
||||
return false;
|
||||
@ -121,6 +117,31 @@ TouchBlockState::TimeoutContentResponse()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CancelableBlockState::IsDefaultPrevented() const
|
||||
{
|
||||
MOZ_ASSERT(mContentResponded || mContentResponseTimerExpired);
|
||||
return mPreventDefault;
|
||||
}
|
||||
|
||||
bool
|
||||
CancelableBlockState::IsReadyForHandling() const
|
||||
{
|
||||
if (!IsTargetConfirmed())
|
||||
return false;
|
||||
return mContentResponded || mContentResponseTimerExpired;
|
||||
}
|
||||
|
||||
TouchBlockState::TouchBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed)
|
||||
: CancelableBlockState(aTargetApzc, aTargetConfirmed)
|
||||
, mAllowedTouchBehaviorSet(false)
|
||||
, mDuringFastMotion(false)
|
||||
, mSingleTapOccurred(false)
|
||||
{
|
||||
TBS_LOG("Creating %p\n", this);
|
||||
}
|
||||
|
||||
bool
|
||||
TouchBlockState::SetAllowedTouchBehaviors(const nsTArray<TouchBehaviorFlags>& aBehaviors)
|
||||
{
|
||||
@ -144,26 +165,17 @@ TouchBlockState::CopyAllowedTouchBehaviorsFrom(const TouchBlockState& aOther)
|
||||
bool
|
||||
TouchBlockState::IsReadyForHandling() const
|
||||
{
|
||||
if (!IsTargetConfirmed()) {
|
||||
if (!CancelableBlockState::IsReadyForHandling()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: for long-tap blocks we probably don't need the touch behaviour?
|
||||
if (gfxPrefs::TouchActionEnabled() && !mAllowedTouchBehaviorSet) {
|
||||
return false;
|
||||
}
|
||||
if (!mContentResponded && !mContentResponseTimerExpired) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TouchBlockState::IsDefaultPrevented() const
|
||||
{
|
||||
MOZ_ASSERT(mContentResponded || mContentResponseTimerExpired);
|
||||
return mPreventDefault;
|
||||
}
|
||||
|
||||
void
|
||||
TouchBlockState::SetDuringFastMotion()
|
||||
{
|
||||
|
@ -43,6 +43,54 @@ private:
|
||||
const uint64_t mBlockId;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a set of events that can be cancelled by web content
|
||||
* via event listeners.
|
||||
*
|
||||
* Each cancelable input block can be cancelled by web content, and
|
||||
* this information is stored in the mPreventDefault flag. Because web
|
||||
* content runs on the Gecko main thread, we cannot always wait for web content's
|
||||
* response. Instead, there is a timeout that sets this flag in the case
|
||||
* where web content doesn't respond in time. The mContentResponded
|
||||
* and mContentResponseTimerExpired flags indicate which of these scenarios
|
||||
* occurred.
|
||||
*/
|
||||
class CancelableBlockState : public InputBlockState
|
||||
{
|
||||
public:
|
||||
CancelableBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed);
|
||||
|
||||
/**
|
||||
* Record whether or not content cancelled this block of events.
|
||||
* @param aPreventDefault true iff the block is cancelled.
|
||||
* @return false if this block has already received a response from
|
||||
* web content, true if not.
|
||||
*/
|
||||
bool SetContentResponse(bool aPreventDefault);
|
||||
|
||||
/**
|
||||
* Record that content didn't respond in time.
|
||||
* @return false if this block already timed out, true if not.
|
||||
*/
|
||||
bool TimeoutContentResponse();
|
||||
|
||||
/**
|
||||
* @return true iff web content cancelled this block of events.
|
||||
*/
|
||||
bool IsDefaultPrevented() const;
|
||||
|
||||
/**
|
||||
* @returns true if web content responded or timed out.
|
||||
*/
|
||||
virtual bool IsReadyForHandling() const;
|
||||
|
||||
private:
|
||||
bool mPreventDefault;
|
||||
bool mContentResponded;
|
||||
bool mContentResponseTimerExpired;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a single touch block. A touch block is
|
||||
* a set of touch events that can be cancelled by web content via
|
||||
@ -60,21 +108,13 @@ private:
|
||||
* dispatched to web content, a new touch block is started to hold the remaining
|
||||
* touch events, up to but not including the next touch start (or long-tap).
|
||||
*
|
||||
* Conceptually, each touch block can be cancelled by web content, and
|
||||
* this information is stored in the mPreventDefault flag. Because web
|
||||
* content runs on the Gecko main thread, we cannot always wait for web content's
|
||||
* response. Instead, there is a timeout that sets this flag in the case
|
||||
* where web content doesn't respond in time. The mContentResponded
|
||||
* and mContentResponseTimerExpired flags indicate which of these scenarios
|
||||
* occurred.
|
||||
*
|
||||
* Additionally, if touch-action is enabled, each touch block should
|
||||
* have a set of allowed touch behavior flags; one for each touch point.
|
||||
* This also requires running code on the Gecko main thread, and so may
|
||||
* be populated with some latency. The mAllowedTouchBehaviorSet and
|
||||
* mAllowedTouchBehaviors variables track this information.
|
||||
*/
|
||||
class TouchBlockState : public InputBlockState
|
||||
class TouchBlockState : public CancelableBlockState
|
||||
{
|
||||
public:
|
||||
typedef uint32_t TouchBehaviorFlags;
|
||||
@ -82,18 +122,6 @@ public:
|
||||
explicit TouchBlockState(const nsRefPtr<AsyncPanZoomController>& aTargetApzc,
|
||||
bool aTargetConfirmed);
|
||||
|
||||
/**
|
||||
* Record whether or not content cancelled this block of events.
|
||||
* @param aPreventDefault true iff the block is cancelled.
|
||||
* @return false if this block has already received a response from
|
||||
* web content, true if not.
|
||||
*/
|
||||
bool SetContentResponse(bool aPreventDefault);
|
||||
/**
|
||||
* Record that content didn't respond in time.
|
||||
* @return false if this block already timed out, true if not.
|
||||
*/
|
||||
bool TimeoutContentResponse();
|
||||
/**
|
||||
* Set the allowed touch behavior flags for this block.
|
||||
* @return false if this block already has these flags set, true if not.
|
||||
@ -109,11 +137,7 @@ public:
|
||||
* @return true iff this block has received all the information needed
|
||||
* to properly dispatch the events in the block.
|
||||
*/
|
||||
bool IsReadyForHandling() const;
|
||||
/**
|
||||
* @return true iff web content cancelled this block of events.
|
||||
*/
|
||||
bool IsDefaultPrevented() const;
|
||||
bool IsReadyForHandling() const MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Sets a flag that indicates this input block occurred while the APZ was
|
||||
@ -176,9 +200,6 @@ public:
|
||||
private:
|
||||
nsTArray<TouchBehaviorFlags> mAllowedTouchBehaviors;
|
||||
bool mAllowedTouchBehaviorSet;
|
||||
bool mPreventDefault;
|
||||
bool mContentResponded;
|
||||
bool mContentResponseTimerExpired;
|
||||
bool mDuringFastMotion;
|
||||
bool mSingleTapOccurred;
|
||||
nsTArray<MultiTouchInput> mEvents;
|
||||
|
Loading…
x
Reference in New Issue
Block a user