Bug 920425 part.28 Use mozilla::WidgetEvent::AsMouseEvent() r=smaug

This commit is contained in:
Masayuki Nakano 2013-10-22 17:55:20 +09:00
Родитель 8cf255ee75
Коммит c2d6606a1c
33 изменённых файлов: 281 добавлений и 340 удалений

Просмотреть файл

@ -1451,10 +1451,11 @@ Element::DispatchClickEvent(nsPresContext* aPresContext,
uint32_t clickCount = 1;
float pressure = 0;
uint16_t inputSource = 0;
if (aSourceEvent->eventStructType == NS_MOUSE_EVENT) {
clickCount = static_cast<WidgetMouseEvent*>(aSourceEvent)->clickCount;
pressure = static_cast<WidgetMouseEvent*>(aSourceEvent)->pressure;
inputSource = static_cast<WidgetMouseEvent*>(aSourceEvent)->inputSource;
WidgetMouseEvent* sourceMouseEvent = aSourceEvent->AsMouseEvent();
if (sourceMouseEvent) {
clickCount = sourceMouseEvent->clickCount;
pressure = sourceMouseEvent->pressure;
inputSource = sourceMouseEvent->inputSource;
} else if (aSourceEvent->eventStructType == NS_KEY_EVENT) {
inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
}
@ -2225,8 +2226,7 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
switch (aVisitor.mEvent->message) {
case NS_MOUSE_BUTTON_DOWN:
{
if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
if (aVisitor.mEvent->AsMouseEvent()->button ==
WidgetMouseEvent::eLeftButton) {
// don't make the link grab the focus if there is no link handler
nsILinkHandler *handler = aVisitor.mPresContext->GetLinkHandler();

Просмотреть файл

@ -694,8 +694,7 @@ nsIContent::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
((this == aVisitor.mEvent->originalTarget &&
!ChromeOnlyAccess()) || isAnonForEvents)) {
nsCOMPtr<nsIContent> relatedTarget =
do_QueryInterface(
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->relatedTarget);
do_QueryInterface(aVisitor.mEvent->AsMouseEvent()->relatedTarget);
if (relatedTarget &&
relatedTarget->OwnerDoc() == OwnerDoc()) {

Просмотреть файл

@ -24,8 +24,7 @@ nsDOMDragEvent::nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
mEventIsInternal = true;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
static_cast<WidgetMouseEvent*>(mEvent)->inputSource =
nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
mEvent->AsMouseEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
}
}

Просмотреть файл

@ -543,7 +543,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_MOUSE_EVENT:
{
WidgetMouseEvent* oldMouseEvent = static_cast<WidgetMouseEvent*>(mEvent);
WidgetMouseEvent* oldMouseEvent = mEvent->AsMouseEvent();
WidgetMouseEvent* mouseEvent =
new WidgetMouseEvent(false, msg, nullptr, oldMouseEvent->reason);
mouseEvent->AssignMouseEventData(*oldMouseEvent, true);
@ -925,8 +925,7 @@ nsDOMEvent::GetEventPopupControlState(WidgetEvent* aEvent)
break;
case NS_MOUSE_EVENT :
if (aEvent->mFlags.mIsTrusted &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
switch(aEvent->message) {
case NS_MOUSE_BUTTON_UP :
if (::PopupAllowedForEvent("mouseup"))

Просмотреть файл

@ -21,7 +21,8 @@ nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
// There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
// It's not that important, though, since a scroll event is not a real
// DOM event.
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
if (aEvent) {
mEventIsInternal = false;
}
@ -29,20 +30,13 @@ nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
mEventIsInternal = true;
mEvent->time = PR_Now();
mEvent->refPoint.x = mEvent->refPoint.y = 0;
static_cast<WidgetMouseEvent*>(mEvent)->inputSource =
nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
}
switch (mEvent->eventStructType)
{
case NS_MOUSE_EVENT:
NS_ASSERTION(static_cast<WidgetMouseEvent*>(mEvent)->reason
!= WidgetMouseEvent::eSynthesized,
"Don't dispatch DOM events from synthesized mouse events");
mDetail = static_cast<WidgetMouseEvent*>(mEvent)->clickCount;
break;
default:
break;
if (mouseEvent) {
MOZ_ASSERT(mouseEvent->reason != WidgetMouseEvent::eSynthesized,
"Don't dispatch DOM events from synthesized mouse events");
mDetail = mouseEvent->clickCount;
}
}
@ -78,8 +72,8 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool a
mouseEventBase->refPoint.x = aScreenX;
mouseEventBase->refPoint.y = aScreenY;
if (mEvent->eventStructType == NS_MOUSE_EVENT) {
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(mEvent);
WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
if (mouseEvent) {
mouseEvent->clickCount = aDetail;
}
break;

Просмотреть файл

@ -136,8 +136,7 @@ IsMouseEventReal(WidgetEvent* aEvent)
{
NS_ABORT_IF_FALSE(aEvent->IsMouseDerivedEvent(), "Not a mouse event");
// Return true if not synthesized.
return static_cast<WidgetMouseEvent*>(aEvent)->reason ==
WidgetMouseEvent::eReal;
return aEvent->AsMouseEvent()->reason == WidgetMouseEvent::eReal;
}
#ifdef DEBUG_DOCSHELL_FOCUS
@ -1043,38 +1042,34 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
nsMouseWheelTransaction::OnEvent(aEvent);
switch (aEvent->message) {
case NS_MOUSE_BUTTON_DOWN:
switch (static_cast<WidgetMouseEvent*>(aEvent)->button) {
case NS_MOUSE_BUTTON_DOWN: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
switch (mouseEvent->button) {
case WidgetMouseEvent::eLeftButton:
#ifndef XP_OS2
BeginTrackingDragGesture(aPresContext,
static_cast<WidgetMouseEvent*>(aEvent),
aTargetFrame);
BeginTrackingDragGesture(aPresContext, mouseEvent, aTargetFrame);
#endif
mLClickCount = static_cast<WidgetMouseEvent*>(aEvent)->clickCount;
SetClickCount(aPresContext, static_cast<WidgetMouseEvent*>(aEvent),
aStatus);
mLClickCount = mouseEvent->clickCount;
SetClickCount(aPresContext, mouseEvent, aStatus);
sNormalLMouseEventInProcess = true;
break;
case WidgetMouseEvent::eMiddleButton:
mMClickCount = static_cast<WidgetMouseEvent*>(aEvent)->clickCount;
SetClickCount(aPresContext, static_cast<WidgetMouseEvent*>(aEvent),
aStatus);
mMClickCount = mouseEvent->clickCount;
SetClickCount(aPresContext, mouseEvent, aStatus);
break;
case WidgetMouseEvent::eRightButton:
#ifdef XP_OS2
BeginTrackingDragGesture(aPresContext,
static_cast<WidgetMouseEvent*>(aEvent),
aTargetFrame);
BeginTrackingDragGesture(aPresContext, mouseEvent, aTargetFrame);
#endif
mRClickCount = static_cast<WidgetMouseEvent*>(aEvent)->clickCount;
SetClickCount(aPresContext, static_cast<WidgetMouseEvent*>(aEvent),
aStatus);
mRClickCount = mouseEvent->clickCount;
SetClickCount(aPresContext, mouseEvent, aStatus);
break;
}
break;
case NS_MOUSE_BUTTON_UP:
switch (static_cast<WidgetMouseEvent*>(aEvent)->button) {
}
case NS_MOUSE_BUTTON_UP: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
switch (mouseEvent->button) {
case WidgetMouseEvent::eLeftButton:
if (Prefs::ClickHoldContextMenu()) {
KillClickHoldTimer();
@ -1090,17 +1085,17 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
#endif
// then fall through...
case WidgetMouseEvent::eMiddleButton:
SetClickCount(aPresContext, static_cast<WidgetMouseEvent*>(aEvent),
aStatus);
SetClickCount(aPresContext, mouseEvent, aStatus);
break;
}
break;
}
case NS_MOUSE_EXIT:
// If the event is not a top-level window exit, then it's not
// really an exit --- we may have traversed widget boundaries but
// we're still in our toplevel window.
{
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(aEvent);
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->exit != WidgetMouseEvent::eTopLevel) {
// Treat it as a synthetic move so we don't generate spurious
// "exit" or "move" events. Any necessary "out" or "over" events
@ -1109,26 +1104,28 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
mouseEvent->reason = WidgetMouseEvent::eSynthesized;
// then fall through...
} else {
GenerateMouseEnterExit(static_cast<WidgetGUIEvent*>(aEvent));
GenerateMouseEnterExit(mouseEvent);
//This is a window level mouse exit event and should stop here
aEvent->message = 0;
break;
}
}
case NS_MOUSE_MOVE:
case NS_MOUSE_MOVE: {
// on the Mac, GenerateDragGesture() may not return until the drag
// has completed and so |aTargetFrame| may have been deleted (moving
// a bookmark, for example). If this is the case, however, we know
// that ClearFrameRefs() has been called and it cleared out
// |mCurrentTarget|. As a result, we should pass |mCurrentTarget|
// into UpdateCursor().
GenerateDragGesture(aPresContext, static_cast<WidgetMouseEvent*>(aEvent));
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
GenerateDragGesture(aPresContext, mouseEvent);
UpdateCursor(aPresContext, aEvent, mCurrentTarget, aStatus);
GenerateMouseEnterExit(static_cast<WidgetGUIEvent*>(aEvent));
GenerateMouseEnterExit(mouseEvent);
// Flush pending layout changes, so that later mouse move events
// will go to the right nodes.
FlushPendingEvents(aPresContext);
break;
}
case NS_DRAGDROP_GESTURE:
if (Prefs::ClickHoldContextMenu()) {
// an external drag gesture event came in, not generated internally
@ -1139,8 +1136,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case NS_DRAGDROP_OVER:
// NS_DRAGDROP_DROP is fired before NS_DRAGDROP_DRAGDROP so send
// the enter/exit events before NS_DRAGDROP_DROP.
GenerateDragDropEnterExit(aPresContext,
static_cast<WidgetGUIEvent*>(aEvent));
GenerateDragDropEnterExit(aPresContext, aEvent->AsDragEvent());
break;
case NS_KEY_PRESS:
@ -1597,8 +1593,7 @@ nsEventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
switch (aEvent->eventStructType) {
case NS_MOUSE_EVENT: {
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(aEvent);
return remote->SendRealMouseEvent(*mouseEvent);
return remote->SendRealMouseEvent(*aEvent->AsMouseEvent());
}
case NS_KEY_EVENT: {
return remote->SendRealKeyEvent(*aEvent->AsKeyboardEvent());
@ -3180,8 +3175,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
switch (aEvent->message) {
case NS_MOUSE_BUTTON_DOWN:
{
if (static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton &&
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->button == WidgetMouseEvent::eLeftButton &&
!sNormalLMouseEventInProcess) {
// We got a mouseup event while a mousedown event was being processed.
// Make sure that the capturing content is cleared.
@ -3310,9 +3305,9 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
// The rest is left button-specific.
if (static_cast<WidgetMouseEvent*>(aEvent)->button !=
WidgetMouseEvent::eLeftButton)
if (mouseEvent->button != WidgetMouseEvent::eLeftButton) {
break;
}
if (activeContent) {
// The nearest enclosing element goes into the
@ -3369,8 +3364,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
// Make sure to dispatch the click even if there is no frame for
// the current target element. This is required for Web compatibility.
ret = CheckForAndDispatchClick(presContext,
static_cast<WidgetMouseEvent*>(aEvent),
ret = CheckForAndDispatchClick(presContext, aEvent->AsMouseEvent(),
aStatus);
}
@ -3599,7 +3593,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
WidgetDragEvent event(aEvent->mFlags.mIsTrusted,
NS_DRAGDROP_DRAGDROP, widget);
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(aEvent);
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
event.refPoint = mouseEvent->refPoint;
if (mouseEvent->widget) {
event.refPoint += LayoutDeviceIntPoint::FromUntyped(mouseEvent->widget->WidgetToScreenOffset());
@ -3623,8 +3617,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
case NS_DRAGDROP_EXIT:
// make sure to fire the enter and exit_synth events after the
// NS_DRAGDROP_EXIT event, otherwise we'll clean up too early
GenerateDragDropEnterExit(presContext,
static_cast<WidgetGUIEvent*>(aEvent));
GenerateDragDropEnterExit(presContext, aEvent->AsDragEvent());
break;
case NS_KEY_UP:
@ -4026,7 +4019,7 @@ nsEventStateManager::IsHandlingUserInput()
}
nsIFrame*
nsEventStateManager::DispatchMouseEvent(WidgetGUIEvent* aEvent,
nsEventStateManager::DispatchMouseEvent(WidgetMouseEvent* aMouseEvent,
uint32_t aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent)
@ -4052,14 +4045,14 @@ nsEventStateManager::DispatchMouseEvent(WidgetGUIEvent* aEvent,
PROFILER_LABEL("Input", "DispatchMouseEvent");
nsEventStatus status = nsEventStatus_eIgnore;
WidgetMouseEvent event(aEvent->mFlags.mIsTrusted, aMessage, aEvent->widget,
WidgetMouseEvent::eReal);
event.refPoint = aEvent->refPoint;
event.modifiers = static_cast<WidgetMouseEvent*>(aEvent)->modifiers;
event.buttons = static_cast<WidgetMouseEvent*>(aEvent)->buttons;
event.pluginEvent = static_cast<WidgetMouseEvent*>(aEvent)->pluginEvent;
WidgetMouseEvent event(aMouseEvent->mFlags.mIsTrusted, aMessage,
aMouseEvent->widget, WidgetMouseEvent::eReal);
event.refPoint = aMouseEvent->refPoint;
event.modifiers = aMouseEvent->modifiers;
event.buttons = aMouseEvent->buttons;
event.pluginEvent = aMouseEvent->pluginEvent;
event.relatedTarget = aRelatedContent;
event.inputSource = static_cast<WidgetMouseEvent*>(aEvent)->inputSource;
event.inputSource = aMouseEvent->inputSource;
nsWeakFrame previousTarget = mCurrentTarget;
@ -4090,8 +4083,8 @@ class MouseEnterLeaveDispatcher
public:
MouseEnterLeaveDispatcher(nsEventStateManager* aESM,
nsIContent* aTarget, nsIContent* aRelatedTarget,
WidgetGUIEvent* aEvent, uint32_t aType)
: mESM(aESM), mEvent(aEvent), mType(aType)
WidgetMouseEvent* aMouseEvent, uint32_t aType)
: mESM(aESM), mMouseEvent(aMouseEvent), mType(aType)
{
nsPIDOMWindow* win =
aTarget ? aTarget->OwnerDoc()->GetInnerWindow() : nullptr;
@ -4119,11 +4112,13 @@ public:
{
if (mType == NS_MOUSEENTER) {
for (int32_t i = mTargets.Count() - 1; i >= 0; --i) {
mESM->DispatchMouseEvent(mEvent, mType, mTargets[i], mRelatedTarget);
mESM->DispatchMouseEvent(mMouseEvent, mType, mTargets[i],
mRelatedTarget);
}
} else {
for (int32_t i = 0; i < mTargets.Count(); ++i) {
mESM->DispatchMouseEvent(mEvent, mType, mTargets[i], mRelatedTarget);
mESM->DispatchMouseEvent(mMouseEvent, mType, mTargets[i],
mRelatedTarget);
}
}
}
@ -4131,12 +4126,12 @@ public:
nsEventStateManager* mESM;
nsCOMArray<nsIContent> mTargets;
nsCOMPtr<nsIContent> mRelatedTarget;
WidgetGUIEvent* mEvent;
WidgetMouseEvent* mMouseEvent;
uint32_t mType;
};
void
nsEventStateManager::NotifyMouseOut(WidgetGUIEvent* aEvent,
nsEventStateManager::NotifyMouseOut(WidgetMouseEvent* aMouseEvent,
nsIContent* aMovingInto)
{
if (!mLastMouseOverElement)
@ -4159,7 +4154,7 @@ nsEventStateManager::NotifyMouseOut(WidgetGUIEvent* aEvent,
if (presContext) {
nsEventStateManager* kidESM = presContext->EventStateManager();
// Not moving into any element in this subdocument
kidESM->NotifyMouseOut(aEvent, nullptr);
kidESM->NotifyMouseOut(aMouseEvent, nullptr);
}
}
}
@ -4183,10 +4178,10 @@ nsEventStateManager::NotifyMouseOut(WidgetGUIEvent* aEvent,
}
MouseEnterLeaveDispatcher leaveDispatcher(this, mLastMouseOverElement, aMovingInto,
aEvent, NS_MOUSELEAVE);
aMouseEvent, NS_MOUSELEAVE);
// Fire mouseout
DispatchMouseEvent(aEvent, NS_MOUSE_EXIT_SYNTH,
DispatchMouseEvent(aMouseEvent, NS_MOUSE_EXIT_SYNTH,
mLastMouseOverElement, aMovingInto);
mLastMouseOverFrame = nullptr;
@ -4197,7 +4192,7 @@ nsEventStateManager::NotifyMouseOut(WidgetGUIEvent* aEvent,
}
void
nsEventStateManager::NotifyMouseOver(WidgetGUIEvent* aEvent,
nsEventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent,
nsIContent* aContent)
{
NS_ASSERTION(aContent, "Mouse must be over something");
@ -4220,7 +4215,7 @@ nsEventStateManager::NotifyMouseOver(WidgetGUIEvent* aEvent,
nsIPresShell *parentShell = parentDoc->GetShell();
if (parentShell) {
nsEventStateManager* parentESM = parentShell->GetPresContext()->EventStateManager();
parentESM->NotifyMouseOver(aEvent, docContent);
parentESM->NotifyMouseOver(aMouseEvent, docContent);
}
}
}
@ -4234,9 +4229,9 @@ nsEventStateManager::NotifyMouseOver(WidgetGUIEvent* aEvent,
nsCOMPtr<nsIContent> lastMouseOverElement = mLastMouseOverElement;
MouseEnterLeaveDispatcher enterDispatcher(this, aContent, lastMouseOverElement,
aEvent, NS_MOUSEENTER);
aMouseEvent, NS_MOUSEENTER);
NotifyMouseOut(aEvent, aContent);
NotifyMouseOut(aMouseEvent, aContent);
// Store the first mouseOver event we fire and don't refire mouseOver
// to that element while the first mouseOver is still ongoing.
@ -4245,7 +4240,7 @@ nsEventStateManager::NotifyMouseOver(WidgetGUIEvent* aEvent,
SetContentState(aContent, NS_EVENT_STATE_HOVER);
// Fire mouseover
mLastMouseOverFrame = DispatchMouseEvent(aEvent, NS_MOUSE_ENTER_SYNTH,
mLastMouseOverFrame = DispatchMouseEvent(aMouseEvent, NS_MOUSE_ENTER_SYNTH,
aContent, lastMouseOverElement);
mLastMouseOverElement = aContent;
@ -4297,7 +4292,7 @@ GetWindowInnerRectCenter(nsPIDOMWindow* aWindow,
}
void
nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
nsEventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
{
EnsureDocument(mPresContext);
if (!mDocument)
@ -4306,13 +4301,13 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
// Hold onto old target content through the event and reset after.
nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
switch(aEvent->message) {
switch(aMouseEvent->message) {
case NS_MOUSE_MOVE:
{
// Mouse movement is reported on the MouseEvent.movement{X,Y} fields.
// Movement is calculated in nsDOMUIEvent::GetMovementPoint() as:
// previous_mousemove_refPoint - current_mousemove_refPoint.
if (sIsPointerLocked && aEvent->widget) {
if (sIsPointerLocked && aMouseEvent->widget) {
// The pointer is locked. If the pointer is not located at the center of
// the window, dispatch a synthetic mousemove to return the pointer there.
// Doing this between "real" pointer moves gives the impression that the
@ -4320,22 +4315,23 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
// boundary. We cancel the synthetic event so that we don't end up
// dispatching the centering move event to content.
LayoutDeviceIntPoint center =
GetWindowInnerRectCenter(mDocument->GetWindow(), aEvent->widget,
GetWindowInnerRectCenter(mDocument->GetWindow(), aMouseEvent->widget,
mPresContext);
aEvent->lastRefPoint = center;
if (aEvent->refPoint != center) {
aMouseEvent->lastRefPoint = center;
if (aMouseEvent->refPoint != center) {
// Mouse move doesn't finish at the center of the window. Dispatch a
// synthetic native mouse event to move the pointer back to the center
// of the window, to faciliate more movement. But first, record that
// we've dispatched a synthetic mouse movement, so we can cancel it
// in the other branch here.
sSynthCenteringPoint = center;
aEvent->widget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(center) + aEvent->widget->WidgetToScreenOffset());
} else if (aEvent->refPoint == sSynthCenteringPoint) {
aMouseEvent->widget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(center) +
aMouseEvent->widget->WidgetToScreenOffset());
} else if (aMouseEvent->refPoint == sSynthCenteringPoint) {
// This is the "synthetic native" event we dispatched to re-center the
// pointer. Cancel it so we don't expose the centering move to content.
aEvent->mFlags.mPropagationStopped = true;
aMouseEvent->mFlags.mPropagationStopped = true;
// Clear sSynthCenteringPoint so we don't cancel other events
// targeted at the center.
sSynthCenteringPoint = kInvalidRefPoint;
@ -4345,16 +4341,16 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
// the first move we've encountered, or the mouse has just re-entered
// the application window. We should report (0,0) movement for this
// case, so make the current and previous refPoints the same.
aEvent->lastRefPoint = aEvent->refPoint;
aMouseEvent->lastRefPoint = aMouseEvent->refPoint;
} else {
aEvent->lastRefPoint = sLastRefPoint;
aMouseEvent->lastRefPoint = sLastRefPoint;
}
// Update the last known refPoint with the current refPoint.
sLastRefPoint = aEvent->refPoint;
sLastRefPoint = aMouseEvent->refPoint;
// Get the target content target (mousemove target == mouseover target)
nsCOMPtr<nsIContent> targetElement = GetEventTargetContent(aEvent);
nsCOMPtr<nsIContent> targetElement = GetEventTargetContent(aMouseEvent);
if (!targetElement) {
// We're always over the document root, even if we're only
// over dead space in a page (whose frame is not associated with
@ -4362,7 +4358,7 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
targetElement = mDocument->GetRootElement();
}
if (targetElement) {
NotifyMouseOver(aEvent, targetElement);
NotifyMouseOver(aMouseEvent, targetElement);
}
}
break;
@ -4372,7 +4368,7 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
// into any new element.
if (mLastMouseOverFrame &&
nsContentUtils::GetTopLevelWidget(aEvent->widget) !=
nsContentUtils::GetTopLevelWidget(aMouseEvent->widget) !=
nsContentUtils::GetTopLevelWidget(mLastMouseOverFrame->GetNearestWidget())) {
// the MouseOut event widget doesn't have same top widget with
// mLastMouseOverFrame, it's a spurious event for mLastMouseOverFrame
@ -4383,7 +4379,7 @@ nsEventStateManager::GenerateMouseEnterExit(WidgetGUIEvent* aEvent)
// movement the next time we re-enter the window.
sLastRefPoint = kInvalidRefPoint;
NotifyMouseOut(aEvent, nullptr);
NotifyMouseOut(aMouseEvent, nullptr);
}
break;
}
@ -4451,12 +4447,12 @@ nsEventStateManager::SetPointerLock(nsIWidget* aWidget,
void
nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent)
WidgetDragEvent* aDragEvent)
{
//Hold onto old target content through the event and reset after.
nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
switch(aEvent->message) {
switch(aDragEvent->message) {
case NS_DRAGDROP_OVER:
{
// when dragging from one frame to another, events are fired in the
@ -4465,23 +4461,25 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
//We'll need the content, too, to check if it changed separately from the frames.
nsCOMPtr<nsIContent> lastContent;
nsCOMPtr<nsIContent> targetContent;
mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
mCurrentTarget->GetContentForEvent(aDragEvent,
getter_AddRefs(targetContent));
if (sLastDragOverFrame) {
//The frame has changed but the content may not have. Check before dispatching to content
sLastDragOverFrame->GetContentForEvent(aEvent, getter_AddRefs(lastContent));
sLastDragOverFrame->GetContentForEvent(aDragEvent,
getter_AddRefs(lastContent));
FireDragEnterOrExit(sLastDragOverFrame->PresContext(),
aEvent, NS_DRAGDROP_EXIT_SYNTH,
aDragEvent, NS_DRAGDROP_EXIT_SYNTH,
targetContent, lastContent, sLastDragOverFrame);
}
FireDragEnterOrExit(aPresContext, aEvent, NS_DRAGDROP_ENTER,
FireDragEnterOrExit(aPresContext, aDragEvent, NS_DRAGDROP_ENTER,
lastContent, targetContent, mCurrentTarget);
if (sLastDragOverFrame) {
FireDragEnterOrExit(sLastDragOverFrame->PresContext(),
aEvent, NS_DRAGDROP_LEAVE_SYNTH,
aDragEvent, NS_DRAGDROP_LEAVE_SYNTH,
targetContent, lastContent, sLastDragOverFrame);
}
@ -4495,14 +4493,15 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
//This is actually the window mouse exit event.
if (sLastDragOverFrame) {
nsCOMPtr<nsIContent> lastContent;
sLastDragOverFrame->GetContentForEvent(aEvent, getter_AddRefs(lastContent));
sLastDragOverFrame->GetContentForEvent(aDragEvent,
getter_AddRefs(lastContent));
nsRefPtr<nsPresContext> lastDragOverFramePresContext = sLastDragOverFrame->PresContext();
FireDragEnterOrExit(lastDragOverFramePresContext,
aEvent, NS_DRAGDROP_EXIT_SYNTH,
aDragEvent, NS_DRAGDROP_EXIT_SYNTH,
nullptr, lastContent, sLastDragOverFrame);
FireDragEnterOrExit(lastDragOverFramePresContext,
aEvent, NS_DRAGDROP_LEAVE_SYNTH,
aDragEvent, NS_DRAGDROP_LEAVE_SYNTH,
nullptr, lastContent, sLastDragOverFrame);
sLastDragOverFrame = nullptr;
@ -4520,19 +4519,20 @@ nsEventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
void
nsEventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
WidgetDragEvent* aDragEvent,
uint32_t aMsg,
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,
nsWeakFrame& aTargetFrame)
{
nsEventStatus status = nsEventStatus_eIgnore;
WidgetDragEvent event(aEvent->mFlags.mIsTrusted, aMsg, aEvent->widget);
event.refPoint = aEvent->refPoint;
event.modifiers = static_cast<WidgetMouseEvent*>(aEvent)->modifiers;
event.buttons = static_cast<WidgetMouseEvent*>(aEvent)->buttons;
WidgetDragEvent event(aDragEvent->mFlags.mIsTrusted, aMsg,
aDragEvent->widget);
event.refPoint = aDragEvent->refPoint;
event.modifiers = aDragEvent->modifiers;
event.buttons = aDragEvent->buttons;
event.relatedTarget = aRelatedTarget;
event.inputSource = static_cast<WidgetMouseEvent*>(aEvent)->inputSource;
event.inputSource = aDragEvent->inputSource;
mCurrentTargetContent = aTargetContent;
@ -5093,8 +5093,7 @@ bool
nsEventStateManager::EventStatusOK(WidgetGUIEvent* aEvent)
{
return !(aEvent->message == NS_MOUSE_BUTTON_DOWN &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton &&
!sNormalLMouseEventInProcess);
}

Просмотреть файл

@ -256,7 +256,7 @@ protected:
* content. This returns the primary frame for the content (or null
* if it goes away during the event).
*/
nsIFrame* DispatchMouseEvent(mozilla::WidgetGUIEvent* aEvent,
nsIFrame* DispatchMouseEvent(mozilla::WidgetMouseEvent* aMouseEvent,
uint32_t aMessage,
nsIContent* aTargetContent,
nsIContent* aRelatedContent);
@ -264,24 +264,26 @@ protected:
* Synthesize DOM and frame mouseover and mouseout events from this
* MOUSE_MOVE or MOUSE_EXIT event.
*/
void GenerateMouseEnterExit(mozilla::WidgetGUIEvent* aEvent);
void GenerateMouseEnterExit(mozilla::WidgetMouseEvent* aMouseEvent);
/**
* Tell this ESM and ESMs in parent documents that the mouse is
* over some content in this document.
*/
void NotifyMouseOver(mozilla::WidgetGUIEvent* aEvent, nsIContent* aContent);
void NotifyMouseOver(mozilla::WidgetMouseEvent* aMouseEvent,
nsIContent* aContent);
/**
* Tell this ESM and ESMs in affected child documents that the mouse
* has exited this document's currently hovered content.
* @param aEvent the event that triggered the mouseout
* @param aMouseEvent the event that triggered the mouseout
* @param aMovingInto the content node we've moved into. This is used to set
* the relatedTarget for mouseout events. Also, if it's non-null
* NotifyMouseOut will NOT change the current hover content to null;
* in that case the caller is responsible for updating hover state.
*/
void NotifyMouseOut(mozilla::WidgetGUIEvent* aEvent, nsIContent* aMovingInto);
void NotifyMouseOut(mozilla::WidgetMouseEvent* aMouseEvent,
nsIContent* aMovingInto);
void GenerateDragDropEnterExit(nsPresContext* aPresContext,
mozilla::WidgetGUIEvent* aEvent);
mozilla::WidgetDragEvent* aDragEvent);
/**
* Fire the dragenter and dragexit/dragleave events when the mouse moves to a
* new target.
@ -291,7 +293,7 @@ protected:
* @param aTargetFrame target frame for the event
*/
void FireDragEnterOrExit(nsPresContext* aPresContext,
mozilla::WidgetGUIEvent* aEvent,
mozilla::WidgetDragEvent* aDragEvent,
uint32_t aMsg,
nsIContent* aRelatedTarget,
nsIContent* aTargetContent,

Просмотреть файл

@ -281,30 +281,25 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
case NS_MOUSE_BUTTON_DOWN:
{
if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT) {
if (static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aVisitor.mEvent->mFlags.mIsTrusted) {
nsEventStateManager* esm =
aVisitor.mPresContext->EventStateManager();
nsEventStateManager::SetActiveManager(
static_cast<nsEventStateManager*>(esm), this);
}
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm)
fm->SetFocus(this, nsIFocusManager::FLAG_BYMOUSE |
nsIFocusManager::FLAG_NOSCROLL);
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
} else if (
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eMiddleButton ||
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eRightButton) {
// cancel all of these events for buttons
//XXXsmaug What to do with these events? Why these should be cancelled?
if (aVisitor.mDOMEvent) {
aVisitor.mDOMEvent->StopPropagation();
}
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (mouseEvent->button == WidgetMouseEvent::eLeftButton) {
if (mouseEvent->mFlags.mIsTrusted) {
nsEventStateManager* esm =
aVisitor.mPresContext->EventStateManager();
nsEventStateManager::SetActiveManager(
static_cast<nsEventStateManager*>(esm), this);
}
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm)
fm->SetFocus(this, nsIFocusManager::FLAG_BYMOUSE |
nsIFocusManager::FLAG_NOSCROLL);
mouseEvent->mFlags.mMultipleActionsPrevented = true;
} else if (mouseEvent->button == WidgetMouseEvent::eMiddleButton ||
mouseEvent->button == WidgetMouseEvent::eRightButton) {
// cancel all of these events for buttons
//XXXsmaug What to do with these events? Why these should be cancelled?
if (aVisitor.mDOMEvent) {
aVisitor.mDOMEvent->StopPropagation();
}
}
}
@ -315,12 +310,10 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
case NS_MOUSE_BUTTON_UP:
case NS_MOUSE_DOUBLECLICK:
{
if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT &&
aVisitor.mDOMEvent &&
(static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eMiddleButton ||
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eRightButton)) {
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (aVisitor.mDOMEvent &&
(mouseEvent->button == WidgetMouseEvent::eMiddleButton ||
mouseEvent->button == WidgetMouseEvent::eRightButton)) {
aVisitor.mDOMEvent->StopPropagation();
}
}

Просмотреть файл

@ -373,10 +373,7 @@ HTMLImageElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
// the Generic Element as this could cause a click event to fire
// twice, once by the image frame for the map and once by the Anchor
// element. (bug 39723)
if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT &&
aVisitor.mEvent->message == NS_MOUSE_CLICK &&
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aVisitor.mEvent->IsLeftClickEvent()) {
bool isMap = false;
GetIsMap(&isMap);
if (isMap) {

Просмотреть файл

@ -3172,8 +3172,7 @@ HTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
if (IsSingleLineTextControl(false) &&
aVisitor.mEvent->message == NS_MOUSE_CLICK &&
aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
aVisitor.mEvent->AsMouseEvent()->button ==
WidgetMouseEvent::eMiddleButton) {
aVisitor.mEvent->mFlags.mNoContentDispatch = false;
}
@ -3674,11 +3673,9 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
{
// cancel all of these events for buttons
//XXXsmaug Why?
if (aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT &&
(static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eMiddleButton ||
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
WidgetMouseEvent::eRightButton)) {
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
if (mouseEvent->button == WidgetMouseEvent::eMiddleButton ||
mouseEvent->button == WidgetMouseEvent::eRightButton) {
if (mType == NS_FORM_INPUT_BUTTON ||
mType == NS_FORM_INPUT_RESET ||
mType == NS_FORM_INPUT_SUBMIT) {
@ -3797,9 +3794,8 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor
break; // ignore
}
if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN) {
WidgetMouseEvent* mouseEvent =
static_cast<WidgetMouseEvent*>(aVisitor.mEvent);
if (mouseEvent->buttons == WidgetMouseEvent::eLeftButtonFlag) {
if (aVisitor.mEvent->AsMouseEvent()->buttons ==
WidgetMouseEvent::eLeftButtonFlag) {
StartRangeThumbDrag(inputEvent);
} else if (mIsDraggingRange) {
CancelRangeThumbDrag();

Просмотреть файл

@ -131,9 +131,7 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
mHandlingEvent = true;
switch (aVisitor.mEvent->message) {
case NS_MOUSE_BUTTON_DOWN:
NS_ASSERTION(aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT,
"wrong event struct for event");
if (static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
if (aVisitor.mEvent->AsMouseEvent()->button ==
WidgetMouseEvent::eLeftButton) {
// We reset the mouse-down point on every event because there is
// no guarantee we will reach the NS_MOUSE_CLICK code below.
@ -147,8 +145,7 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
case NS_MOUSE_CLICK:
if (aVisitor.mEvent->IsLeftClickEvent()) {
const WidgetMouseEvent* event =
static_cast<const WidgetMouseEvent*>(aVisitor.mEvent);
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
LayoutDeviceIntPoint* mouseDownPoint =
static_cast<LayoutDeviceIntPoint*>(
GetProperty(nsGkAtoms::labelMouseDownPtProperty));
@ -158,7 +155,7 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
LayoutDeviceIntPoint dragDistance = *mouseDownPoint;
DeleteProperty(nsGkAtoms::labelMouseDownPtProperty);
dragDistance -= aVisitor.mEvent->refPoint;
dragDistance -= mouseEvent->refPoint;
const int CLICK_DISTANCE = 2;
dragSelect = dragDistance.x > CLICK_DISTANCE ||
dragDistance.x < -CLICK_DISTANCE ||
@ -167,13 +164,13 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
}
// Don't click the for-content if we did drag-select text or if we
// have a kbd modifier (which adjusts a selection).
if (dragSelect || event->IsShift() || event->IsControl() ||
event->IsAlt() || event->IsMeta()) {
if (dragSelect || mouseEvent->IsShift() || mouseEvent->IsControl() ||
mouseEvent->IsAlt() || mouseEvent->IsMeta()) {
break;
}
// Only set focus on the first click of multiple clicks to prevent
// to prevent immediate de-focus.
if (event->clickCount <= 1) {
if (mouseEvent->clickCount <= 1) {
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
// Use FLAG_BYMOVEFOCUS here so that the label is scrolled to.
@ -196,12 +193,11 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
// will actually create a new event.
EventFlags eventFlags;
eventFlags.mMultipleActionsPrevented = true;
DispatchClickEvent(aVisitor.mPresContext,
aVisitor.mEvent->AsInputEvent(),
DispatchClickEvent(aVisitor.mPresContext, mouseEvent,
content, false, &eventFlags, &status);
// Do we care about the status this returned? I don't think we do...
// Don't run another <label> off of this click
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
mouseEvent->mFlags.mMultipleActionsPrevented = true;
}
break;
}

Просмотреть файл

@ -477,8 +477,7 @@ HTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
aVisitor.mItemFlags |= NS_NO_CONTENT_DISPATCH;
}
if (aVisitor.mEvent->message == NS_MOUSE_CLICK &&
aVisitor.mEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aVisitor.mEvent)->button ==
aVisitor.mEvent->AsMouseEvent()->button ==
WidgetMouseEvent::eMiddleButton) {
aVisitor.mEvent->mFlags.mNoContentDispatch = false;
}

Просмотреть файл

@ -11796,12 +11796,10 @@ nsGlobalChromeWindow::BeginWindowMove(nsIDOMEvent *aMouseDownEvent, nsIDOMElemen
}
NS_ENSURE_TRUE(aMouseDownEvent, NS_ERROR_FAILURE);
WidgetEvent* internalEvent = aMouseDownEvent->GetInternalNSEvent();
NS_ENSURE_TRUE(internalEvent &&
internalEvent->eventStructType == NS_MOUSE_EVENT,
WidgetMouseEvent* mouseEvent =
aMouseDownEvent->GetInternalNSEvent()->AsMouseEvent();
NS_ENSURE_TRUE(mouseEvent && mouseEvent->eventStructType == NS_MOUSE_EVENT,
NS_ERROR_FAILURE);
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(internalEvent);
return widget->BeginMoveDrag(mouseEvent);
}

Просмотреть файл

@ -1864,10 +1864,11 @@ nsPluginInstanceOwner::ProcessMouseDown(nsIDOMEvent* aMouseEvent)
}
}
WidgetEvent* event = aMouseEvent->GetInternalNSEvent();
if (event && event->eventStructType == NS_MOUSE_EVENT) {
mLastMouseDownButtonType = static_cast<WidgetMouseEvent*>(event)->button;
nsEventStatus rv = ProcessEvent(*static_cast<WidgetGUIEvent*>(event));
WidgetMouseEvent* mouseEvent =
aMouseEvent->GetInternalNSEvent()->AsMouseEvent();
if (mouseEvent && mouseEvent->eventStructType == NS_MOUSE_EVENT) {
mLastMouseDownButtonType = mouseEvent->button;
nsEventStatus rv = ProcessEvent(*mouseEvent);
if (nsEventStatus_eConsumeNoDefault == rv) {
return aMouseEvent->PreventDefault(); // consume event
}
@ -1926,9 +1927,9 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
// element above the plugin, the mouse is still above the plugin, and the
// mouse-down event caused the element to disappear. See bug 627649 and
// bug 909678.
WidgetMouseEvent *event =
static_cast<WidgetMouseEvent*>(aEvent->GetInternalNSEvent());
if (event && ((int) event->button != mLastMouseDownButtonType)) {
WidgetMouseEvent* mouseEvent = aEvent->GetInternalNSEvent()->AsMouseEvent();
if (mouseEvent &&
static_cast<int>(mouseEvent->button) != mLastMouseDownButtonType) {
aEvent->PreventDefault();
return NS_OK;
}
@ -2038,8 +2039,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// If we're in a dragging operation that started over another frame,
// convert it into a mouse-entered event (in the Cocoa Event Model).
// See bug 525078.
if ((static_cast<const WidgetMouseEvent&>(anEvent).button ==
WidgetMouseEvent::eLeftButton) &&
if (anEvent.AsMouseEvent()->button == WidgetMouseEvent::eLeftButton &&
(nsIPresShell::GetCapturingContent() != mObjectFrame->GetContent())) {
synthCocoaEvent.type = NPCocoaEventMouseEntered;
synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
@ -2074,12 +2074,11 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
}
if ((response == kNPEventHandled || response == kNPEventStartIME) &&
!(anEvent.eventStructType == NS_MOUSE_EVENT &&
anEvent.message == NS_MOUSE_BUTTON_DOWN &&
static_cast<const WidgetMouseEvent&>(anEvent).button ==
WidgetMouseEvent::eLeftButton &&
!mContentFocused))
!(anEvent.message == NS_MOUSE_BUTTON_DOWN &&
anEvent.AsMouseEvent()->button == WidgetMouseEvent::eLeftButton &&
!mContentFocused)) {
rv = nsEventStatus_eConsumeNoDefault;
}
pluginWidget->EndDrawPlugin();
#endif
@ -2095,8 +2094,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// XXX Should extend this list to synthesize events for more event
// types
pluginEvent.event = 0;
const WidgetMouseEvent* mouseEvent =
static_cast<const WidgetMouseEvent*>(&anEvent);
const WidgetMouseEvent* mouseEvent = anEvent.AsMouseEvent();
switch (anEvent.message) {
case NS_MOUSE_MOVE:
pluginEvent.event = WM_MOUSEMOVE;
@ -2215,8 +2213,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
mObjectFrame->GetContentRectRelativeToSelf().TopLeft();
nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
presContext->AppUnitsToDevPixels(appPoint.y));
const WidgetMouseEvent& mouseEvent =
static_cast<const WidgetMouseEvent&>(anEvent);
const WidgetMouseEvent& mouseEvent = *anEvent.AsMouseEvent();
// Get reference point relative to screen:
LayoutDeviceIntPoint rootPoint(-1, -1);
if (widget)

Просмотреть файл

@ -372,8 +372,7 @@ APZCTreeManager::ProcessMouseEvent(const WidgetMouseEvent& aEvent,
MultiTouchInput inputForApzc(aEvent);
ApplyTransform(&(inputForApzc.mTouches[0].mScreenPoint), transformToApzc);
gfx3DMatrix outTransform = transformToApzc * transformToScreen;
ApplyTransform(&(static_cast<WidgetMouseEvent*>(aOutEvent)->refPoint),
outTransform);
ApplyTransform(&aOutEvent->refPoint, outTransform);
return apzc->ReceiveInputEvent(inputForApzc);
}
@ -418,10 +417,9 @@ APZCTreeManager::ReceiveInputEvent(const WidgetInputEvent& aEvent,
}
case NS_MOUSE_EVENT: {
// For b2g emulation
const WidgetMouseEvent& mouseEvent =
static_cast<const WidgetMouseEvent&>(aEvent);
WidgetMouseEvent* outEvent = static_cast<WidgetMouseEvent*>(aOutEvent);
return ProcessMouseEvent(mouseEvent, outEvent);
const WidgetMouseEvent& mouseEvent = *aEvent.AsMouseEvent();
WidgetMouseEvent* outMouseEvent = aOutEvent->AsMouseEvent();
return ProcessMouseEvent(mouseEvent, outMouseEvent);
}
default: {
return ProcessEvent(aEvent, aOutEvent);

Просмотреть файл

@ -347,9 +347,9 @@ FindFrameTargetedByInputEvent(const WidgetGUIEvent* aEvent,
// events generated by touch-screen hardware.
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
prefs->mTouchOnly &&
static_cast<const WidgetMouseEvent*>(aEvent)->inputSource !=
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
return target;
aEvent->AsMouseEvent()->inputSource !=
nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
return target;
}
nsRect targetRect = GetTargetRect(aRootFrame, aPointRelativeToRootFrame, prefs);

Просмотреть файл

@ -5888,8 +5888,7 @@ PresShell::RecordMouseLocation(WidgetGUIEvent* aEvent)
}
if ((aEvent->message == NS_MOUSE_MOVE &&
static_cast<WidgetMouseEvent*>(aEvent)->reason ==
WidgetMouseEvent::eReal) ||
aEvent->AsMouseEvent()->reason == WidgetMouseEvent::eReal) ||
aEvent->message == NS_MOUSE_ENTER ||
aEvent->message == NS_MOUSE_BUTTON_DOWN ||
aEvent->message == NS_MOUSE_BUTTON_UP) {
@ -6185,9 +6184,9 @@ PresShell::HandleEvent(nsIFrame* aFrame,
captureRetarget = true;
}
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
bool isWindowLevelMouseExit = (aEvent->message == NS_MOUSE_EXIT) &&
(static_cast<WidgetMouseEvent*>(aEvent)->exit ==
WidgetMouseEvent::eTopLevel);
(mouseEvent && mouseEvent->exit == WidgetMouseEvent::eTopLevel);
// Get the frame at the event point. However, don't do this if we're
// capturing and retargeting the event because the captured frame will
@ -6278,8 +6277,8 @@ PresShell::HandleEvent(nsIFrame* aFrame,
} else {
eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
}
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->ignoreRootScrollFrame) {
if (mouseEvent && mouseEvent->eventStructType == NS_MOUSE_EVENT &&
mouseEvent->ignoreRootScrollFrame) {
flags |= INPUT_IGNORE_ROOT_SCROLL_FRAME;
}
nsIFrame* target =
@ -6314,8 +6313,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
if (aEvent->message == NS_MOUSE_BUTTON_DOWN) {
mNoDelayedMouseEvents = true;
} else if (!mNoDelayedMouseEvents && aEvent->message == NS_MOUSE_BUTTON_UP) {
nsDelayedEvent* event =
new nsDelayedMouseEvent(static_cast<WidgetMouseEvent*>(aEvent));
nsDelayedEvent* event = new nsDelayedMouseEvent(aEvent->AsMouseEvent());
if (!mDelayedEvents.AppendElement(event)) {
delete event;
}
@ -6834,15 +6832,15 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus)
}
if (aEvent->message == NS_CONTEXTMENU) {
WidgetMouseEvent* me = static_cast<WidgetMouseEvent*>(aEvent);
if (!CanHandleContextMenuEvent(me, GetCurrentEventFrame())) {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (!CanHandleContextMenuEvent(mouseEvent, GetCurrentEventFrame())) {
return NS_OK;
}
if (me->context == WidgetMouseEvent::eContextMenuKey &&
!AdjustContextMenuKeyEvent(me)) {
if (mouseEvent->context == WidgetMouseEvent::eContextMenuKey &&
!AdjustContextMenuKeyEvent(mouseEvent)) {
return NS_OK;
}
if (me->IsShift()) {
if (mouseEvent->IsShift()) {
aEvent->mFlags.mOnlyChromeDispatch = true;
aEvent->mFlags.mRetargetToNonNativeAnonymous = true;
}

Просмотреть файл

@ -584,13 +584,14 @@ protected:
nsDelayedMouseEvent(mozilla::WidgetMouseEvent* aEvent) :
nsDelayedInputEvent()
{
mEvent = new mozilla::WidgetMouseEvent(aEvent->mFlags.mIsTrusted,
aEvent->message,
aEvent->widget,
aEvent->reason,
aEvent->context);
static_cast<mozilla::WidgetMouseEvent*>(mEvent)->
AssignMouseEventData(*aEvent, false);
mozilla::WidgetMouseEvent* mouseEvent =
new mozilla::WidgetMouseEvent(aEvent->mFlags.mIsTrusted,
aEvent->message,
aEvent->widget,
aEvent->reason,
aEvent->context);
mouseEvent->AssignMouseEventData(*aEvent, false);
mEvent = mouseEvent;
}
};

Просмотреть файл

@ -169,10 +169,8 @@ nsImageControlFrame::HandleEvent(nsPresContext* aPresContext,
*aEventStatus = nsEventStatus_eIgnore;
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_UP &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aEvent->message == NS_MOUSE_BUTTON_UP &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
// Store click point for HTMLInputElement::SubmitNamesValues
// Do this on MouseUp because the specs don't say and that's what IE does
nsIntPoint* lastClickPoint =

Просмотреть файл

@ -1608,7 +1608,7 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
// So we cheat here by either setting or unsetting the clcikCount in the native event
// so the right thing happens for the onclick event
WidgetMouseEvent* mouseEvent =
static_cast<WidgetMouseEvent*>(aMouseEvent->GetInternalNSEvent());
aMouseEvent->GetInternalNSEvent()->AsMouseEvent();
int32_t selectedIndex;
if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, selectedIndex))) {

Просмотреть файл

@ -2345,12 +2345,13 @@ nsFrame::HandleEvent(nsPresContext* aPresContext,
{
if (aEvent->message == NS_MOUSE_MOVE) {
// XXX If the second argument of HandleDrag() is WidgetMouseEvent,
// the implementation becomes simpler.
return HandleDrag(aPresContext, aEvent, aEventStatus);
}
if ((aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) ||
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) ||
aEvent->eventStructType == NS_TOUCH_EVENT) {
if (aEvent->message == NS_MOUSE_BUTTON_DOWN || aEvent->message == NS_TOUCH_START) {
HandlePress(aPresContext, aEvent, aEventStatus);
@ -2585,15 +2586,18 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
//weaaak. only the editor can display frame selection not just text and images
isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
if (!aEvent->AsInputEvent()->IsAlt()) {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (!mouseEvent->IsAlt()) {
for (nsIContent* content = mContent; content;
content = content->GetParent()) {
if (nsContentUtils::ContentIsDraggable(content) &&
!content->IsEditable()) {
// coordinate stuff is the fix for bug #55921
if ((mRect - GetPosition()).Contains(
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this)))
nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, this))) {
return NS_OK;
}
}
}
}
@ -2641,27 +2645,24 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
if (!frameselection || frameselection->GetDisplaySelection() == nsISelectionController::SELECTION_OFF)
return NS_OK;//nothing to do we cannot affect selection from here
WidgetMouseEvent* me = static_cast<WidgetMouseEvent*>(aEvent);
#ifdef XP_MACOSX
if (me->IsControl())
if (mouseEvent->IsControl())
return NS_OK;//short circuit. hard coded for mac due to time restraints.
bool control = me->IsMeta();
bool control = mouseEvent->IsMeta();
#else
bool control = me->IsControl();
bool control = mouseEvent->IsControl();
#endif
nsRefPtr<nsFrameSelection> fc = const_cast<nsFrameSelection*>(frameselection);
if (me->clickCount > 1)
{
if (mouseEvent->clickCount > 1) {
// These methods aren't const but can't actually delete anything,
// so no need for nsWeakFrame.
fc->SetMouseDownState(true);
fc->SetMouseDoubleDown(true);
return HandleMultiplePress(aPresContext, aEvent, aEventStatus, control);
return HandleMultiplePress(aPresContext, mouseEvent, aEventStatus, control);
}
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, this);
ContentOffsets offsets = GetContentOffsetsFromPoint(pt, SKIP_HIDDEN);
if (!offsets.content)
@ -2682,11 +2683,14 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
nsCOMPtr<nsIContent>parentContent;
int32_t contentOffset;
int32_t target;
rv = GetDataForTableSelection(frameselection, shell, me, getter_AddRefs(parentContent), &contentOffset, &target);
rv = GetDataForTableSelection(frameselection, shell, mouseEvent,
getter_AddRefs(parentContent), &contentOffset,
&target);
if (NS_SUCCEEDED(rv) && parentContent)
{
fc->SetMouseDownState(true);
return fc->HandleTableSelection(parentContent, contentOffset, target, me);
return fc->HandleTableSelection(parentContent, contentOffset, target,
mouseEvent);
}
fc->SetDelayedCaretData(0);
@ -2734,7 +2738,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
if (inSelection) {
fc->SetMouseDownState(false);
fc->SetDelayedCaretData(me);
fc->SetDelayedCaretData(mouseEvent);
return NS_OK;
}
}
@ -2744,7 +2748,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
// Do not touch any nsFrame members after this point without adding
// weakFrame checks.
rv = fc->HandleClick(offsets.content, offsets.StartOffset(),
offsets.EndOffset(), me->IsShift(), control,
offsets.EndOffset(), mouseEvent->IsShift(), control,
offsets.associateWithNext);
if (NS_FAILED(rv))
@ -2753,7 +2757,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
if (offsets.offset != offsets.secondaryOffset)
fc->MaintainSelection();
if (isEditor && !me->IsShift() &&
if (isEditor && !mouseEvent->IsShift() &&
(offsets.EndOffset() - offsets.StartOffset()) == 1)
{
// A single node is selected and we aren't extending an existing
@ -2838,26 +2842,29 @@ nsFrame::HandleMultiplePress(nsPresContext* aPresContext,
// Otherwise, triple-click selects line, and quadruple-click selects paragraph
// (on platforms that support quadruple-click).
nsSelectionAmount beginAmount, endAmount;
WidgetMouseEvent* me = static_cast<WidgetMouseEvent*>(aEvent);
if (!me) return NS_OK;
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (!mouseEvent) {
return NS_OK;
}
if (me->clickCount == 4) {
if (mouseEvent->clickCount == 4) {
beginAmount = endAmount = eSelectParagraph;
} else if (me->clickCount == 3) {
} else if (mouseEvent->clickCount == 3) {
if (Preferences::GetBool("browser.triple_click_selects_paragraph")) {
beginAmount = endAmount = eSelectParagraph;
} else {
beginAmount = eSelectBeginLine;
endAmount = eSelectEndLine;
}
} else if (me->clickCount == 2) {
} else if (mouseEvent->clickCount == 2) {
// We only want inline frames; PeekBackwardAndForward dislikes blocks
beginAmount = endAmount = eSelectWord;
} else {
return NS_OK;
}
nsPoint relPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
nsPoint relPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, this);
return SelectByTypeAtPoint(aPresContext, relPoint, beginAmount, endAmount,
(aControlHeld ? SELECT_ACCUMULATE : 0));
}
@ -2968,17 +2975,18 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext,
nsCOMPtr<nsIContent> parentContent;
int32_t contentOffset;
int32_t target;
WidgetMouseEvent* me = static_cast<WidgetMouseEvent*>(aEvent);
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
nsresult result;
result = GetDataForTableSelection(frameselection, presShell, me,
result = GetDataForTableSelection(frameselection, presShell, mouseEvent,
getter_AddRefs(parentContent),
&contentOffset, &target);
nsWeakFrame weakThis = this;
if (NS_SUCCEEDED(result) && parentContent) {
frameselection->HandleTableSelection(parentContent, contentOffset, target, me);
frameselection->HandleTableSelection(parentContent, contentOffset, target,
mouseEvent);
} else {
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, this);
frameselection->HandleDrag(this, pt);
}
@ -2997,8 +3005,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext,
if (scrollFrame) {
nsIFrame* capturingFrame = scrollFrame->GetScrolledFrame();
if (capturingFrame) {
nsPoint pt =
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, capturingFrame);
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent,
capturingFrame);
frameselection->StartAutoScrollTimer(capturingFrame, pt, 30);
}
}
@ -3058,7 +3066,7 @@ HandleFrameSelection(nsFrameSelection* aFrameSelection,
aParentContentForTableSel,
aContentOffsetForTableSel,
aTargetForTableSel,
static_cast<WidgetMouseEvent*>(aEvent));
aEvent->AsMouseEvent());
if (NS_FAILED(rv)) {
return rv;
}
@ -3114,7 +3122,7 @@ NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext,
handleTableSelection = false;
} else {
GetDataForTableSelection(frameselection, PresContext()->PresShell(),
static_cast<WidgetMouseEvent*>(aEvent),
aEvent->AsMouseEvent(),
getter_AddRefs(parentContent),
&contentOffsetForTableSel,
&targetForTableSel);

Просмотреть файл

@ -692,9 +692,7 @@ NS_METHOD nsHTMLFramesetFrame::HandleEvent(nsPresContext* aPresContext,
MouseDrag(aPresContext, aEvent);
break;
case NS_MOUSE_BUTTON_UP:
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
EndMouseDrag(aPresContext);
}
break;
@ -1590,10 +1588,8 @@ nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK;
}
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_DOWN &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aEvent->message == NS_MOUSE_BUTTON_DOWN &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
nsHTMLFramesetFrame* parentFrame = do_QueryFrame(GetParent());
if (parentFrame) {
parentFrame->StartMouseDrag(aPresContext, this, aEvent);

Просмотреть файл

@ -1636,10 +1636,8 @@ nsImageFrame::HandleEvent(nsPresContext* aPresContext,
{
NS_ENSURE_ARG_POINTER(aEventStatus);
if ((aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_UP &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) ||
if ((aEvent->message == NS_MOUSE_BUTTON_UP &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) ||
aEvent->message == NS_MOUSE_MOVE) {
nsImageMap* map = GetImageMap();
bool isServerMap = IsServerImageMap();

Просмотреть файл

@ -425,10 +425,8 @@ nsMenuFrame::HandleEvent(nsPresContext* aPresContext,
}
#endif
}
else if (aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_DOWN &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton &&
else if (aEvent->message == NS_MOUSE_BUTTON_DOWN &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton &&
!IsDisabled() && IsMenu()) {
// The menu item was selected. Bring up the menu.
// We have children.
@ -445,14 +443,12 @@ nsMenuFrame::HandleEvent(nsPresContext* aPresContext,
}
else if (
#ifndef NSCONTEXTMENUISMOUSEUP
(aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_UP &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eRightButton) &&
(aEvent->message == NS_MOUSE_BUTTON_UP &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eRightButton) &&
#else
aEvent->message == NS_CONTEXTMENU &&
aEvent->message == NS_CONTEXTMENU &&
#endif
onmenu && !IsMenu() && !IsDisabled()) {
onmenu && !IsMenu() && !IsDisabled()) {
// if this menu is a context menu it accepts right-clicks...fire away!
// Make sure we cancel default processing of the context menu event so
// that it doesn't bubble and get seen again by the popuplistener and show
@ -468,10 +464,8 @@ nsMenuFrame::HandleEvent(nsPresContext* aPresContext,
Execute(aEvent);
}
}
else if (aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->message == NS_MOUSE_BUTTON_UP &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton &&
else if (aEvent->message == NS_MOUSE_BUTTON_UP &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton &&
!IsMenu() && !IsDisabled()) {
// Execute the execute event handler.
*aEventStatus = nsEventStatus_eConsumeNoDefault;

Просмотреть файл

@ -67,9 +67,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_BUTTON_DOWN: {
if (aEvent->eventStructType == NS_TOUCH_EVENT ||
(aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton))
{
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton)) {
nsCOMPtr<nsIBaseWindow> window;
nsIPresShell* presShell = aPresContext->GetPresShell();
nsIContent* contentToResize =
@ -132,12 +130,9 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
case NS_TOUCH_END:
case NS_MOUSE_BUTTON_UP: {
if (aEvent->eventStructType == NS_TOUCH_EVENT ||
(aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton))
{
if (aEvent->eventStructType == NS_TOUCH_EVENT ||
(aEvent->eventStructType == NS_MOUSE_EVENT &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton)) {
// we're done tracking.
mTrackingMouseMove = false;
@ -296,10 +291,7 @@ nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
break;
case NS_MOUSE_DOUBLECLICK:
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton)
{
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
nsCOMPtr<nsIBaseWindow> window;
nsIPresShell* presShell = aPresContext->GetPresShell();
nsIContent* contentToResize =

Просмотреть файл

@ -86,7 +86,7 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext,
{
// Get the desired action for the scrollbar button.
LookAndFeel::IntID tmpAction;
uint16_t button = static_cast<WidgetMouseEvent*>(aEvent)->button;
uint16_t button = aEvent->AsMouseEvent()->button;
if (button == WidgetMouseEvent::eLeftButton) {
tmpAction = LookAndFeel::eIntID_ScrollButtonLeftMouseButtonAction;
} else if (button == WidgetMouseEvent::eMiddleButton) {

Просмотреть файл

@ -947,7 +947,7 @@ nsSliderFrame::ShouldScrollForEvent(WidgetGUIEvent* aEvent)
return true;
case NS_MOUSE_BUTTON_DOWN:
case NS_MOUSE_BUTTON_UP: {
uint16_t button = static_cast<WidgetMouseEvent*>(aEvent)->button;
uint16_t button = aEvent->AsMouseEvent()->button;
return (button == WidgetMouseEvent::eLeftButton) ||
(button == WidgetMouseEvent::eMiddleButton && gMiddlePref);
}
@ -978,7 +978,7 @@ nsSliderFrame::ShouldScrollToClickForEvent(WidgetGUIEvent* aEvent)
}
#endif
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(aEvent);
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->button == WidgetMouseEvent::eLeftButton) {
#ifdef XP_MACOSX
bool invertPref = mouseEvent->IsAlt();

Просмотреть файл

@ -392,9 +392,7 @@ nsSplitterFrame::HandleEvent(nsPresContext* aPresContext,
break;
case NS_MOUSE_BUTTON_UP:
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
mInner->MouseUp(aPresContext, aEvent);
}
break;

Просмотреть файл

@ -70,9 +70,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
switch (aEvent->message) {
case NS_MOUSE_BUTTON_DOWN: {
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
// titlebar has no effect in non-chrome shells
nsCOMPtr<nsISupports> cont = aPresContext->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(cont);
@ -99,9 +97,8 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_BUTTON_UP: {
if(mTrackingMouseMove && aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<WidgetMouseEvent*>(aEvent)->button ==
WidgetMouseEvent::eLeftButton) {
if (mTrackingMouseMove &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
// we're done tracking.
mTrackingMouseMove = false;

Просмотреть файл

@ -704,8 +704,7 @@ nsViewManager::DispatchEvent(WidgetGUIEvent *aEvent,
if ((aEvent->HasMouseEventMessage() &&
// Ignore mouse events that we synthesize.
static_cast<WidgetMouseEvent*>(aEvent)->reason ==
WidgetMouseEvent::eReal &&
aEvent->AsMouseEvent()->reason == WidgetMouseEvent::eReal &&
// Ignore mouse exit and enter (we'll get moves if the user
// is really moving the mouse) since we get them when we
// create and destroy widgets.

Просмотреть файл

@ -6137,11 +6137,10 @@ nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent,
return NS_ERROR_INVALID_ARG;
}
WidgetMouseEvent* mouse_event = static_cast<WidgetMouseEvent*>(aEvent);
GdkWindow *gdk_window;
gint button, screenX, screenY;
if (!GetDragInfo(mouse_event, &gdk_window, &button, &screenX, &screenY)) {
if (!GetDragInfo(aEvent->AsMouseEvent(), &gdk_window, &button,
&screenX, &screenY)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -2747,9 +2747,7 @@ nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent,
return NS_ERROR_INVALID_ARG;
}
WidgetMouseEvent* mouse_event = static_cast<WidgetMouseEvent*>(aEvent);
if (mouse_event->button != WidgetMouseEvent::eLeftButton) {
if (aEvent->AsMouseEvent()->button != WidgetMouseEvent::eLeftButton) {
// you can only begin a resize drag with the left mouse button
return NS_ERROR_INVALID_ARG;
}

Просмотреть файл

@ -1515,8 +1515,7 @@ nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent,
return NS_ERROR_INVALID_ARG;
}
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(aEvent);
if (mouseEvent->button != WidgetMouseEvent::eLeftButton) {
if (aEvent->AsMouseEvent()->button != WidgetMouseEvent::eLeftButton) {
// you can only begin a resize drag with the left mouse button
return NS_ERROR_INVALID_ARG;
}