Bug 813008 - get rid nsEventStateManager::IsHandlingUserInputExternal, r=tbsaunde, smaug

This commit is contained in:
Alexander Surkov 2012-11-21 14:25:20 +09:00
parent ebafbaa44d
commit 3b163f2f8c
3 changed files with 14 additions and 43 deletions

View File

@ -32,7 +32,10 @@ AccEvent::AccEvent(uint32_t aEventType, Accessible* aAccessible,
EIsFromUserInput aIsFromUserInput, EEventRule aEventRule) :
mEventType(aEventType), mEventRule(aEventRule), mAccessible(aAccessible)
{
CaptureIsFromUserInput(aIsFromUserInput);
if (aIsFromUserInput == eAutoDetect)
mIsFromUserInput = nsEventStateManager::IsHandlingUserInput();
else
mIsFromUserInput = aIsFromUserInput == eFromUserInput ? true : false;
}
////////////////////////////////////////////////////////////////////////////////
@ -63,29 +66,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AccEvent, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AccEvent, Release)
////////////////////////////////////////////////////////////////////////////////
// AccEvent protected methods
void
AccEvent::CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput)
{
if (aIsFromUserInput != eAutoDetect) {
mIsFromUserInput = aIsFromUserInput == eFromUserInput ? true : false;
return;
}
DocAccessible* document = mAccessible->Document();
if (!document) {
NS_ASSERTION(mAccessible == ApplicationAcc(),
"Accessible other than application should always have a doc!");
return;
}
mIsFromUserInput =
document->PresContext()->EventStateManager()->IsHandlingUserInputExternal();
}
////////////////////////////////////////////////////////////////////////////////
// AccStateChangeEvent
////////////////////////////////////////////////////////////////////////////////

View File

@ -115,13 +115,6 @@ public:
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(AccEvent)
protected:
/**
* Determine whether the event is from user input by event state manager if
* it's not pointed explicetly.
*/
void CaptureIsFromUserInput(EIsFromUserInput aIsFromUserInput);
bool mIsFromUserInput;
uint32_t mEventType;
EEventRule mEventRule;

View File

@ -163,6 +163,16 @@ public:
}
}
/**
* Returns true if the current code is being executed as a result of user input.
* This includes timers or anything else that is initiated from user input.
* However, mouse over events are not counted as user input, nor are
* page load events. If this method is called from asynchronously executed code,
* such as during layout reflows, it will return false. If more time has elapsed
* since the user input than is specified by the
* dom.event.handling-user-input-time-limit pref (default 1 second), this
* function also returns false.
*/
static bool IsHandlingUserInput()
{
if (sUserInputEventDepth <= 0) {
@ -173,18 +183,6 @@ public:
(TimeStamp::Now() - sHandlingInputStart) <= timeout;
}
/**
* Returns true if the current code is being executed as a result of user input.
* This includes timers or anything else that is initiated from user input.
* However, mouse hover events are not counted as user input, nor are
* page load events. If this method is called from asynchronously executed code,
* such as during layout reflows, it will return false. If more time has elapsed
* since the user input than is specified by the
* dom.event.handling-user-input-time-limit pref (default 1 second), this
* function also returns false.
*/
NS_IMETHOD_(bool) IsHandlingUserInputExternal() { return IsHandlingUserInput(); }
nsPresContext* GetPresContext() { return mPresContext; }
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsEventStateManager,