forked from mirrors/gecko-dev
b=544211 preparation for handling synthesized button-up events for ending element pointer capture r=smaug
This commit is contained in:
parent
f4e7af4fcc
commit
110f627e7b
4 changed files with 29 additions and 13 deletions
|
|
@ -54,6 +54,9 @@ nsDOMMouseEvent::nsDOMMouseEvent(nsPresContext* aPresContext,
|
||||||
// DOM event.
|
// DOM event.
|
||||||
|
|
||||||
if (aEvent) {
|
if (aEvent) {
|
||||||
|
NS_ASSERTION(static_cast<nsMouseEvent*>(mEvent)->reason
|
||||||
|
!= nsMouseEvent::eSynthesized,
|
||||||
|
"Don't dispatch DOM events from synthesized mouse events");
|
||||||
mEventIsInternal = PR_FALSE;
|
mEventIsInternal = PR_FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,15 @@ static PRUint32 gPixelScrollDeltaTimeout = 0;
|
||||||
static nscoord
|
static nscoord
|
||||||
GetScrollableLineHeight(nsIFrame* aTargetFrame);
|
GetScrollableLineHeight(nsIFrame* aTargetFrame);
|
||||||
|
|
||||||
|
static inline PRBool
|
||||||
|
IsMouseEventReal(nsEvent* aEvent)
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(aEvent->eventStructType == NS_MOUSE_EVENT,
|
||||||
|
"Not a mouse event");
|
||||||
|
// Return true if not synthesized.
|
||||||
|
return static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DOCSHELL_FOCUS
|
#ifdef DEBUG_DOCSHELL_FOCUS
|
||||||
static void
|
static void
|
||||||
PrintDocTree(nsIDocShellTreeItem* aParentItem, int aLevel)
|
PrintDocTree(nsIDocShellTreeItem* aParentItem, int aLevel)
|
||||||
|
|
@ -509,7 +518,7 @@ nsMouseWheelTransaction::OnEvent(nsEvent* aEvent)
|
||||||
return;
|
return;
|
||||||
case NS_MOUSE_MOVE:
|
case NS_MOUSE_MOVE:
|
||||||
case NS_DRAGDROP_OVER:
|
case NS_DRAGDROP_OVER:
|
||||||
if (((nsMouseEvent*)aEvent)->reason == nsMouseEvent::eReal) {
|
if (IsMouseEventReal(aEvent)) {
|
||||||
// If the cursor is moving to be outside the frame,
|
// If the cursor is moving to be outside the frame,
|
||||||
// terminate the scrollwheel transaction.
|
// terminate the scrollwheel transaction.
|
||||||
nsIntPoint pt = GetScreenPoint((nsGUIEvent*)aEvent);
|
nsIntPoint pt = GetScreenPoint((nsGUIEvent*)aEvent);
|
||||||
|
|
@ -1031,7 +1040,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
// when user is not active doesn't change the state to active.
|
// when user is not active doesn't change the state to active.
|
||||||
if (NS_IS_TRUSTED_EVENT(aEvent) &&
|
if (NS_IS_TRUSTED_EVENT(aEvent) &&
|
||||||
((aEvent->eventStructType == NS_MOUSE_EVENT &&
|
((aEvent->eventStructType == NS_MOUSE_EVENT &&
|
||||||
static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal &&
|
IsMouseEventReal(aEvent) &&
|
||||||
aEvent->message != NS_MOUSE_ENTER &&
|
aEvent->message != NS_MOUSE_ENTER &&
|
||||||
aEvent->message != NS_MOUSE_EXIT) ||
|
aEvent->message != NS_MOUSE_EXIT) ||
|
||||||
aEvent->eventStructType == NS_MOUSE_SCROLL_EVENT ||
|
aEvent->eventStructType == NS_MOUSE_SCROLL_EVENT ||
|
||||||
|
|
@ -2819,13 +2828,15 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||||
case NS_MOUSE_BUTTON_UP:
|
case NS_MOUSE_BUTTON_UP:
|
||||||
{
|
{
|
||||||
SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
|
SetContentState(nsnull, NS_EVENT_STATE_ACTIVE);
|
||||||
if (!mCurrentTarget) {
|
if (IsMouseEventReal(aEvent)) {
|
||||||
nsIFrame* targ;
|
if (!mCurrentTarget) {
|
||||||
GetEventTarget(&targ);
|
nsIFrame* targ;
|
||||||
}
|
GetEventTarget(&targ);
|
||||||
if (mCurrentTarget) {
|
}
|
||||||
ret =
|
if (mCurrentTarget) {
|
||||||
CheckForAndDispatchClick(presContext, (nsMouseEvent*)aEvent, aStatus);
|
ret = CheckForAndDispatchClick(presContext, (nsMouseEvent*)aEvent,
|
||||||
|
aStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIPresShell *shell = presContext->GetPresShell();
|
nsIPresShell *shell = presContext->GetPresShell();
|
||||||
|
|
|
||||||
|
|
@ -6330,8 +6330,8 @@ PresShell::HandleEventWithTarget(nsEvent* aEvent, nsIFrame* aFrame,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PRBool
|
static inline PRBool
|
||||||
IsSynthesizedMouseMove(nsEvent* aEvent)
|
IsSynthesizedMouseEvent(nsEvent* aEvent)
|
||||||
{
|
{
|
||||||
return aEvent->eventStructType == NS_MOUSE_EVENT &&
|
return aEvent->eventStructType == NS_MOUSE_EVENT &&
|
||||||
static_cast<nsMouseEvent*>(aEvent)->reason != nsMouseEvent::eReal;
|
static_cast<nsMouseEvent*>(aEvent)->reason != nsMouseEvent::eReal;
|
||||||
|
|
@ -6458,7 +6458,9 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
|
||||||
if (GetCurrentEventFrame() && NS_SUCCEEDED(rv)) {
|
if (GetCurrentEventFrame() && NS_SUCCEEDED(rv)) {
|
||||||
// We want synthesized mouse moves to cause mouseover and mouseout
|
// We want synthesized mouse moves to cause mouseover and mouseout
|
||||||
// DOM events (PreHandleEvent above), but not mousemove DOM events.
|
// DOM events (PreHandleEvent above), but not mousemove DOM events.
|
||||||
if (!IsSynthesizedMouseMove(aEvent)) {
|
// Synthesized button up events also do not cause DOM events
|
||||||
|
// because they do not have a reliable refPoint.
|
||||||
|
if (!IsSynthesizedMouseEvent(aEvent)) {
|
||||||
nsPresShellEventCB eventCB(this);
|
nsPresShellEventCB eventCB(this);
|
||||||
if (mCurrentEventContent) {
|
if (mCurrentEventContent) {
|
||||||
nsEventDispatcher::Dispatch(mCurrentEventContent, mPresContext,
|
nsEventDispatcher::Dispatch(mCurrentEventContent, mPresContext,
|
||||||
|
|
|
||||||
|
|
@ -948,7 +948,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if ((NS_IS_MOUSE_EVENT(aEvent) &&
|
if ((NS_IS_MOUSE_EVENT(aEvent) &&
|
||||||
// Ignore moves that we synthesize.
|
// Ignore mouse events that we synthesize.
|
||||||
static_cast<nsMouseEvent*>(aEvent)->reason ==
|
static_cast<nsMouseEvent*>(aEvent)->reason ==
|
||||||
nsMouseEvent::eReal &&
|
nsMouseEvent::eReal &&
|
||||||
// Ignore mouse exit and enter (we'll get moves if the user
|
// Ignore mouse exit and enter (we'll get moves if the user
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue