mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 719320 part.17 Replace legacy mouse scroll event dispatchers with D3E wheel event dispatcher on nsWidgetUtils r=smaug
This commit is contained in:
parent
fd86ca36bb
commit
270b3586a0
@ -33,6 +33,7 @@
|
||||
#include "nsIDOMCompositionListener.h"
|
||||
#include "nsIDOMTextListener.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMWheelEvent.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIViewManager.h"
|
||||
@ -41,6 +42,8 @@
|
||||
#include "nsIContent.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
const int MIN_INT =((int) (1 << (sizeof(int) * 8 - 1)));
|
||||
|
||||
static int g_lastX=MIN_INT;
|
||||
@ -232,27 +235,20 @@ nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent)
|
||||
if (NS_FAILED(UpdateFromEvent(aDOMEvent)))
|
||||
return NS_OK;
|
||||
|
||||
nsEventStatus statusX;
|
||||
nsMouseScrollEvent scrollEventX(true, NS_MOUSE_SCROLL, mWidget);
|
||||
scrollEventX.delta = dx;
|
||||
scrollEventX.scrollFlags = nsMouseScrollEvent::kIsHorizontal | nsMouseScrollEvent::kHasPixels;
|
||||
mViewManager->DispatchEvent(&scrollEventX, aView, &statusX);
|
||||
if(statusX != nsEventStatus_eIgnore ){
|
||||
if (dx > 5)
|
||||
nsEventStatus status;
|
||||
widget::WheelEvent wheelEvent(true, NS_WHEEL_WHEEL, mWidget);
|
||||
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
|
||||
wheelEvent.deltaX = wheelEvent.lineOrPageDeltaX = dx;
|
||||
wheelEvent.deltaY = wheelEvent.lineOrPageDeltaY = dy;
|
||||
mViewManager->DispatchEvent(&wheelEvent, aView, &status);
|
||||
if (status != nsEventStatus_eIgnore) {
|
||||
if (dx > 5 || dy > 5) {
|
||||
g_panning = true;
|
||||
}
|
||||
g_lastX = x;
|
||||
}
|
||||
|
||||
nsEventStatus statusY;
|
||||
nsMouseScrollEvent scrollEventY(true, NS_MOUSE_SCROLL, mWidget);
|
||||
scrollEventY.delta = dy;
|
||||
scrollEventY.scrollFlags = nsMouseScrollEvent::kIsVertical | nsMouseScrollEvent::kHasPixels;
|
||||
mViewManager->DispatchEvent(&scrollEventY, aView, &statusY);
|
||||
if(statusY != nsEventStatus_eIgnore ){
|
||||
if (dy > 5)
|
||||
g_panning = true;
|
||||
g_lastY = y;
|
||||
}
|
||||
|
||||
if (g_panning) {
|
||||
aDOMEvent->StopPropagation();
|
||||
aDOMEvent->PreventDefault();
|
||||
|
@ -1340,17 +1340,8 @@ public:
|
||||
enum nsMouseScrollFlags {
|
||||
kIsFullPage = 1 << 0,
|
||||
kIsVertical = 1 << 1,
|
||||
kIsHorizontal = 1 << 2,
|
||||
kHasPixels = 1 << 3 // Marks line scroll events that are provided as
|
||||
// a fallback for pixel scroll events.
|
||||
// These scroll events are used by things that can't
|
||||
// be scrolled pixel-wise, like trees. You should
|
||||
// ignore them when processing pixel scroll events
|
||||
// to avoid double-processing the same scroll gesture.
|
||||
// When kHasPixels is set, the event is guaranteed to
|
||||
// be followed up by an event that contains pixel
|
||||
// scrolling information.
|
||||
};
|
||||
kIsHorizontal = 1 << 2
|
||||
};
|
||||
|
||||
nsMouseScrollEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
|
||||
: nsMouseEvent_base(isTrusted, msg, w, NS_MOUSE_SCROLL_EVENT),
|
||||
|
Loading…
Reference in New Issue
Block a user