mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1009733 - Add thread safety checks for dealing with touch input blocks. r=botond
This commit is contained in:
parent
0611e0b922
commit
2debc466fa
@ -405,6 +405,26 @@ GetFrameTime() {
|
||||
return sFrameTime;
|
||||
}
|
||||
|
||||
static PRThread* sControllerThread;
|
||||
|
||||
static void
|
||||
AssertOnControllerThread() {
|
||||
if (!AsyncPanZoomController::GetThreadAssertionsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
static bool sControllerThreadDetermined = false;
|
||||
if (!sControllerThreadDetermined) {
|
||||
// Technically this may not actually pick up the correct controller thread,
|
||||
// if the first call to this method happens from a non-controller thread.
|
||||
// If the assertion below fires, it is possible that it is because
|
||||
// sControllerThread is not actually the controller thread.
|
||||
sControllerThread = PR_GetCurrentThread();
|
||||
sControllerThreadDetermined = true;
|
||||
}
|
||||
MOZ_ASSERT(sControllerThread == PR_GetCurrentThread());
|
||||
}
|
||||
|
||||
class FlingAnimation: public AsyncPanZoomAnimation {
|
||||
public:
|
||||
FlingAnimation(AsyncPanZoomController& aApzc,
|
||||
@ -796,6 +816,8 @@ AsyncPanZoomController::GetTouchStartTolerance()
|
||||
}
|
||||
|
||||
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
|
||||
AssertOnControllerThread();
|
||||
|
||||
if (aEvent.mInputType != MULTITOUCH_INPUT) {
|
||||
return HandleInputEvent(aEvent);
|
||||
}
|
||||
@ -843,6 +865,8 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent)
|
||||
}
|
||||
|
||||
nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent) {
|
||||
AssertOnControllerThread();
|
||||
|
||||
nsEventStatus rv = nsEventStatus_eIgnore;
|
||||
|
||||
switch (aEvent.mInputType) {
|
||||
@ -889,6 +913,8 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent)
|
||||
|
||||
nsEventStatus AsyncPanZoomController::HandleGestureEvent(const InputData& aEvent)
|
||||
{
|
||||
AssertOnControllerThread();
|
||||
|
||||
nsEventStatus rv = nsEventStatus_eIgnore;
|
||||
|
||||
switch (aEvent.mInputType) {
|
||||
@ -2470,6 +2496,8 @@ AsyncPanZoomController::ScheduleContentResponseTimeout() {
|
||||
|
||||
void
|
||||
AsyncPanZoomController::ContentResponseTimeout() {
|
||||
AssertOnControllerThread();
|
||||
|
||||
mTouchBlockBalance++;
|
||||
APZC_LOG("%p got a content response timeout; balance %d\n", this, mTouchBlockBalance);
|
||||
if (mTouchBlockBalance > 0) {
|
||||
@ -2492,6 +2520,8 @@ AsyncPanZoomController::ContentResponseTimeout() {
|
||||
|
||||
void
|
||||
AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) {
|
||||
AssertOnControllerThread();
|
||||
|
||||
mTouchBlockBalance--;
|
||||
APZC_LOG("%p got a content response; balance %d\n", this, mTouchBlockBalance);
|
||||
if (mTouchBlockBalance < 0) {
|
||||
@ -2514,6 +2544,8 @@ AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) {
|
||||
|
||||
void
|
||||
AsyncPanZoomController::SetAllowedTouchBehavior(const nsTArray<TouchBehaviorFlags>& aBehaviors) {
|
||||
AssertOnControllerThread();
|
||||
|
||||
bool found = false;
|
||||
for (size_t i = 0; i < mTouchBlockQueue.Length(); i++) {
|
||||
if (mTouchBlockQueue[i]->SetAllowedTouchBehaviors(aBehaviors)) {
|
||||
@ -2530,6 +2562,8 @@ AsyncPanZoomController::SetAllowedTouchBehavior(const nsTArray<TouchBehaviorFlag
|
||||
|
||||
void
|
||||
AsyncPanZoomController::ProcessPendingInputBlocks() {
|
||||
AssertOnControllerThread();
|
||||
|
||||
while (true) {
|
||||
TouchBlockState* curBlock = CurrentTouchBlock();
|
||||
if (!curBlock->IsReadyForHandling()) {
|
||||
@ -2590,6 +2624,8 @@ AsyncPanZoomController::StartNewTouchBlock(bool aCopyAllowedTouchBehaviorFromCur
|
||||
TouchBlockState*
|
||||
AsyncPanZoomController::CurrentTouchBlock()
|
||||
{
|
||||
AssertOnControllerThread();
|
||||
|
||||
MOZ_ASSERT(!mTouchBlockQueue.IsEmpty());
|
||||
return mTouchBlockQueue[0].get();
|
||||
}
|
||||
|
@ -719,6 +719,7 @@ private:
|
||||
|
||||
private:
|
||||
// The queue of touch blocks that have not yet been processed by this APZC.
|
||||
// This member must only be accessed on the controller/UI thread.
|
||||
nsTArray<UniquePtr<TouchBlockState>> mTouchBlockQueue;
|
||||
|
||||
// This variable requires some explanation. Strap yourself in.
|
||||
@ -767,6 +768,8 @@ private:
|
||||
// Therefore the information in that block is lost. An alternative approach would
|
||||
// be to keep around those blocks until they have received both the content response
|
||||
// and timeout expiration, but that involves a higher level of memory usage.
|
||||
//
|
||||
// This member must only be accessed on the controller/UI thread.
|
||||
int32_t mTouchBlockBalance;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user