mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 719320 part.12 Replace legacy mouse scroll event dispatchers with D3E wheel event dispatcher on Windows r=smaug+jimm
This commit is contained in:
parent
1d01f06d4d
commit
f5096646cb
@ -393,12 +393,6 @@ class nsHashKey;
|
||||
// Query if the DOM element under nsEvent::refPoint belongs to our widget
|
||||
// or not.
|
||||
#define NS_QUERY_DOM_WIDGET_HITTEST (NS_QUERY_CONTENT_EVENT_START + 9)
|
||||
// Query for some information about mouse wheel event's target
|
||||
// XXX This is used only for supporting high resolution mouse scroll on Windows
|
||||
// and it's going to be reimplemented with another approach. At that time,
|
||||
// this even is going to be removed. Therefore, DON'T use this event for
|
||||
// other purpose.
|
||||
#define NS_QUERY_SCROLL_TARGET_INFO (NS_QUERY_CONTENT_EVENT_START + 99)
|
||||
|
||||
// Video events
|
||||
#define NS_MEDIA_EVENT_START 3300
|
||||
@ -1356,23 +1350,9 @@ public:
|
||||
// When kHasPixels is set, the event is guaranteed to
|
||||
// be followed up by an event that contains pixel
|
||||
// scrolling information.
|
||||
kNoLines = 1 << 4, // Marks pixel scroll events that will not be
|
||||
// followed by a line scroll events. EventStateManager
|
||||
// will compute the appropriate height/width based on
|
||||
// view lineHeight and generate line scroll events
|
||||
// as needed.
|
||||
kNoDefer = 1 << 5, // For scrollable views, indicates scroll should not
|
||||
// occur asynchronously.
|
||||
kIsMomentum = 1 << 6, // Marks scroll events that aren't controlled by the
|
||||
kIsMomentum = 1 << 6 // Marks scroll events that aren't controlled by the
|
||||
// user but fire automatically as the result of a
|
||||
// "momentum" scroll.
|
||||
kAllowSmoothScroll = 1 << 7, // Allow smooth scroll for the pixel scroll
|
||||
// event.
|
||||
kFromLines = 1 << 8 // For a pixels scroll event, indicates that it
|
||||
// originated from a lines scroll event.
|
||||
// (Only used on windows which generates "faked"
|
||||
// pixel scroll events even for simple mouse wheel
|
||||
// scroll)
|
||||
};
|
||||
|
||||
nsMouseScrollEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
|
||||
@ -1564,13 +1544,6 @@ public:
|
||||
refPoint = aPoint;
|
||||
}
|
||||
|
||||
void InitForQueryScrollTargetInfo(nsMouseScrollEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(message == NS_QUERY_SCROLL_TARGET_INFO,
|
||||
"wrong initializer is called");
|
||||
mInput.mMouseScrollEvent = aEvent;
|
||||
}
|
||||
|
||||
PRUint32 GetSelectionStart(void) const
|
||||
{
|
||||
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
||||
@ -1590,8 +1563,6 @@ public:
|
||||
struct {
|
||||
PRUint32 mOffset;
|
||||
PRUint32 mLength;
|
||||
// used by NS_QUERY_SCROLL_TARGET_INFO
|
||||
nsMouseScrollEvent* mMouseScrollEvent;
|
||||
} mInput;
|
||||
struct {
|
||||
void* mContentsRoot;
|
||||
@ -1605,18 +1576,6 @@ public:
|
||||
bool mWidgetIsHit; // true if DOM element under mouse belongs to widget
|
||||
// used by NS_QUERY_SELECTION_AS_TRANSFERABLE
|
||||
nsCOMPtr<nsITransferable> mTransferable;
|
||||
// used by NS_QUERY_SCROLL_TARGET_INFO
|
||||
PRInt32 mLineHeight;
|
||||
PRInt32 mPageWidth;
|
||||
PRInt32 mPageHeight;
|
||||
// used by NS_QUERY_SCROLL_TARGET_INFO
|
||||
// the mouse wheel scrolling amount may be overridden by prefs or
|
||||
// overriding system scrolling speed mechanism.
|
||||
// If mMouseScrollEvent is a line scroll event, the unit of this value is
|
||||
// line. If mMouseScrollEvent is a page scroll event, the unit of this
|
||||
// value is page.
|
||||
PRInt32 mComputedScrollAmount;
|
||||
PRInt32 mComputedScrollAction;
|
||||
} mReply;
|
||||
|
||||
enum {
|
||||
@ -2017,8 +1976,7 @@ enum nsDragDropEventStatus {
|
||||
// cases, you should use NS_IS_IME_RELATED_EVENT instead.
|
||||
#define NS_IS_IME_RELATED_EVENT(evnt) \
|
||||
(NS_IS_IME_EVENT(evnt) || \
|
||||
(NS_IS_QUERY_CONTENT_EVENT(evnt) && \
|
||||
evnt->message != NS_QUERY_SCROLL_TARGET_INFO) || \
|
||||
NS_IS_QUERY_CONTENT_EVENT(evnt) || \
|
||||
NS_IS_SELECTION_EVENT(evnt))
|
||||
|
||||
/*
|
||||
|
@ -395,18 +395,12 @@ struct ParamTraits<nsQueryContentEvent>
|
||||
WriteParam(aMsg, aParam.mSucceeded);
|
||||
WriteParam(aMsg, aParam.mInput.mOffset);
|
||||
WriteParam(aMsg, aParam.mInput.mLength);
|
||||
WriteParam(aMsg, *aParam.mInput.mMouseScrollEvent);
|
||||
WriteParam(aMsg, aParam.mReply.mOffset);
|
||||
WriteParam(aMsg, aParam.mReply.mString);
|
||||
WriteParam(aMsg, aParam.mReply.mRect);
|
||||
WriteParam(aMsg, aParam.mReply.mReversed);
|
||||
WriteParam(aMsg, aParam.mReply.mHasSelection);
|
||||
WriteParam(aMsg, aParam.mReply.mWidgetIsHit);
|
||||
WriteParam(aMsg, aParam.mReply.mLineHeight);
|
||||
WriteParam(aMsg, aParam.mReply.mPageHeight);
|
||||
WriteParam(aMsg, aParam.mReply.mPageWidth);
|
||||
WriteParam(aMsg, aParam.mReply.mComputedScrollAmount);
|
||||
WriteParam(aMsg, aParam.mReply.mComputedScrollAction);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
@ -416,18 +410,12 @@ struct ParamTraits<nsQueryContentEvent>
|
||||
ReadParam(aMsg, aIter, &aResult->mSucceeded) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mInput.mOffset) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mInput.mLength) &&
|
||||
ReadParam(aMsg, aIter, aResult->mInput.mMouseScrollEvent) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mOffset) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mString) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mReversed) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mHasSelection) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mWidgetIsHit) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mLineHeight) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mPageHeight) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mPageWidth) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mComputedScrollAmount) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mComputedScrollAction);
|
||||
ReadParam(aMsg, aIter, &aResult->mReply.mWidgetIsHit);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,6 @@ const kShiftKeyDeltaMultiplierYPref = "mousewheel.with_shift.delta_multiplier_y"
|
||||
const kWinKeyDeltaMultiplierXPref = "mousewheel.with_win.delta_multiplier_x";
|
||||
const kWinKeyDeltaMultiplierYPref = "mousewheel.with_win.delta_multiplier_y";
|
||||
|
||||
const kPixelEnabledPref = "mousewheel.enable_pixel_scrolling";
|
||||
const kEmulateWheelByWMSCROLLPref = "mousewheel.emulate_at_wm_scroll";
|
||||
const kVAmountPref = "mousewheel.windows.vertical_amount_override";
|
||||
const kHAmountPref = "mousewheel.windows.horizontal_amount_override";
|
||||
@ -122,7 +121,6 @@ function onUnload()
|
||||
SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref);
|
||||
|
||||
SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref);
|
||||
SpecialPowers.clearUserPref(kPixelEnabledPref);
|
||||
SpecialPowers.clearUserPref(kEmulateWheelByWMSCROLLPref);
|
||||
SpecialPowers.clearUserPref(kVAmountPref);
|
||||
SpecialPowers.clearUserPref(kHAmountPref);
|
||||
@ -224,8 +222,8 @@ function cut(aNum)
|
||||
|
||||
// First, get the computed line height, char width, page height and page width.
|
||||
var gPreparingSteps = [
|
||||
{ description: "Preparing gLineHeight #1",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
{ description: "Preparing gLineHeight",
|
||||
message: WM_MOUSEWHEEL, delta: -120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
@ -237,31 +235,15 @@ var gPreparingSteps = [
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 1,
|
||||
axis: kVAxis, lines: 1, pixels: 1,
|
||||
},
|
||||
init: function () {
|
||||
SpecialPowers.setIntPref(kVAmountPref, 1);
|
||||
SpecialPowers.setIntPref(kHAmountPref, 1);
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gLineHeight #2",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
onLineScrollEvent: function (aEvent) {
|
||||
return true;
|
||||
},
|
||||
onPixelScrollEvent: function (aEvent) {
|
||||
gLineHeight += aEvent.detail;
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kVAxis, lines: 1, pixels: 1,
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gCharWidth #1",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
{ description: "Preparing gCharWidth",
|
||||
message: WM_MOUSEHWHEEL, delta: 120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
@ -272,28 +254,12 @@ var gPreparingSteps = [
|
||||
gCharWidth = aEvent.detail;
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 1,
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gCharWidth #2",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
onLineScrollEvent: function (aEvent) {
|
||||
return true;
|
||||
},
|
||||
onPixelScrollEvent: function (aEvent) {
|
||||
gCharWidth += aEvent.detail;
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kVAxis, lines: 1, pixels: 1,
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gPageHeight #1",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
{ description: "Preparing gPageHeight",
|
||||
message: WM_MOUSEWHEEL, delta: -120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
@ -305,31 +271,15 @@ var gPreparingSteps = [
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 1,
|
||||
axis: kHAxis, lines: 1, pixels: 1,
|
||||
},
|
||||
init: function () {
|
||||
SpecialPowers.setIntPref(kVAmountPref, 0xFFFF);
|
||||
SpecialPowers.setIntPref(kHAmountPref, 0xFFFF);
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gPageHeight #2",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
onLineScrollEvent: function (aEvent) {
|
||||
return true;
|
||||
},
|
||||
onPixelScrollEvent: function (aEvent) {
|
||||
gPageHeight += aEvent.detail;
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kHAxis, lines: 1, pixels: 1,
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gPageWidth #1",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
{ description: "Preparing gPageWidth",
|
||||
message: WM_MOUSEHWHEEL, delta: 120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
@ -340,22 +290,6 @@ var gPreparingSteps = [
|
||||
gPageWidth = aEvent.detail;
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 1,
|
||||
},
|
||||
},
|
||||
{ description: "Preparing gPageWidth",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
onLineScrollEvent: function (aEvent) {
|
||||
return true;
|
||||
},
|
||||
onPixelScrollEvent: function (aEvent) {
|
||||
gPageWidth += aEvent.detail;
|
||||
return true;
|
||||
},
|
||||
expected: {
|
||||
axis: kHAxis, lines: 1, pixels: 1,
|
||||
},
|
||||
@ -421,9 +355,8 @@ var gBasicTests = [
|
||||
},
|
||||
},
|
||||
|
||||
// When pixel scroll is enabled (default), pixel scroll event should be fired
|
||||
// always but line scroll event should be fired only when accumulated
|
||||
// delta value is over a line.
|
||||
// Pixel scroll event should be fired always but line scroll event should be
|
||||
// fired only when accumulated delta value is over a line.
|
||||
{ description: "WM_MOUSEWHEEL, -20, 0.5 lines",
|
||||
message: WM_MOUSEWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
@ -439,8 +372,7 @@ var gBasicTests = [
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 1,
|
||||
pixels: function () { return ((gLineHeight / 2) + (gLineHeight % 2)); },
|
||||
axis: kVAxis, lines: 1, pixels: function () { return gLineHeight / 2; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, -20, 0.5 lines",
|
||||
@ -468,8 +400,7 @@ var gBasicTests = [
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: -1,
|
||||
pixels: function () { return -((gLineHeight / 2) + (gLineHeight % 2)); },
|
||||
axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight / 2; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, 20, -0.5 lines",
|
||||
@ -497,8 +428,7 @@ var gBasicTests = [
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 1,
|
||||
pixels: function () { return ((gCharWidth / 2) + (gCharWidth % 2)); },
|
||||
axis: kHAxis, lines: 1, pixels: function () { return gCharWidth / 2; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, 20, 0.5 chars",
|
||||
@ -526,8 +456,7 @@ var gBasicTests = [
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: -1,
|
||||
pixels: function () { return -((gCharWidth / 2) + (gCharWidth % 2)); },
|
||||
axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth / 2; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, -20, -0.5 chars",
|
||||
@ -540,126 +469,6 @@ var gBasicTests = [
|
||||
},
|
||||
},
|
||||
|
||||
// When pixel scroll is disabled, pixel scroll event shouldn't be fired
|
||||
// without line scroll event.
|
||||
{ description: "WM_MOUSEWHEEL, -20, 0.5 lines, pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
init: function () {
|
||||
SpecialPowers.setBoolPref(kPixelEnabledPref, false);
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, -20, 0.5 lines (pending: 0.5 lines), pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, -20, 0.5 lines, pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEWHEEL, 20, -0.5 lines (pending: 0.5 lines), pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: 20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, 20, -0.5 lines (pending: -0.5 lines), pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: 20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, 20, -0.5 lines, pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: 20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEHWHEEL, 20, 0.5 chars, pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: 20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, 20, 0.5 chars (pending: 0.5 chars), pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: 20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, 20, 0.5 chars, pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: 20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEHWHEEL, -20, -0.5 chars (pending: 0.5 chars), pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, -20, -0.5 chars (pending: -0.5 chars), pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, -20, -0.5 chars, pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: -20,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
finish: function () {
|
||||
SpecialPowers.setBoolPref(kPixelEnabledPref, true);
|
||||
},
|
||||
},
|
||||
|
||||
// Even if the mouse cursor is an element whose font-size is different than
|
||||
// the scrollable element, the pixel scroll amount shouldn't be changed.
|
||||
// Widget shouldn't dispatch a pixel event if the delta can be devided by
|
||||
@ -821,60 +630,8 @@ var gBasicTests = [
|
||||
];
|
||||
|
||||
var gPageScrllTests = [
|
||||
// Widget shouldn't dispatch a pixel event if the delta means one page scroll.
|
||||
// However, pixel events should be fired by ESM.
|
||||
{ description: "WM_MOUSEWHEEL, -120, 1 page",
|
||||
message: WM_MOUSEWHEEL, delta: -120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return gPageHeight; },
|
||||
},
|
||||
init: function () {
|
||||
SpecialPowers.setIntPref(kVAmountPref, WHEEL_PAGESCROLL);
|
||||
SpecialPowers.setIntPref(kHAmountPref, WHEEL_PAGESCROLL);
|
||||
SpecialPowers.setBoolPref(kPixelEnabledPref, true);
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEWHEEL, 120, -1 page",
|
||||
message: WM_MOUSEWHEEL, delta: 120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return gPageHeight; },
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEHWHEEL, 120, 1 page",
|
||||
message: WM_MOUSEHWHEEL, delta: 120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return gPageWidth; },
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEHWHEEL, -120, -1 page",
|
||||
message: WM_MOUSEHWHEEL, delta: -120,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return gPageWidth; },
|
||||
},
|
||||
},
|
||||
|
||||
// When pixel scroll is enabled (default), pixel scroll event should be fired
|
||||
// always but line scroll event should be fired only when accumulated
|
||||
// delta value is over a line.
|
||||
// Pixel scroll event should be fired always but line scroll event should be
|
||||
// fired only when accumulated delta value is over a line.
|
||||
{ description: "WM_MOUSEWHEEL, -60, 0.5 pages",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
@ -990,130 +747,6 @@ var gPageScrllTests = [
|
||||
axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; },
|
||||
},
|
||||
},
|
||||
|
||||
// When pixel scroll is disabled, pixel scroll event shouldn't be fired
|
||||
// without line scroll event.
|
||||
{ description: "WM_MOUSEWHEEL, -60, 0.5 pages, pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
init: function () {
|
||||
SpecialPowers.setBoolPref(kPixelEnabledPref, false);
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, -60, 0.5 pages (pending: 0.5 pages), pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return gPageHeight; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, -60, 0.5 pages, pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEWHEEL, 60, -0.5 pages (pending: 0.5 pages), pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, 60, -0.5 pages (pending: -0.5 pages), pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, pixels: -gPageHeight,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEWHEEL, 60, -0.5 pages, pixel scrolling is disabled",
|
||||
message: WM_MOUSEWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kVAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEHWHEEL, 60, 0.5 pages, pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, 60, 0.5 pages (pending: 0.5 pages), pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return gPageWidth; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, 60, 0.5 pages, pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: 60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
|
||||
{ description: "WM_MOUSEHWHEEL, -60, -0.5 pages (pending: 0.5 pages), pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, -60, -0.5 pages (pending: -0.5 pages), pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
|
||||
pixels: function () { return -gPageWidth; },
|
||||
},
|
||||
},
|
||||
{ description: "WM_MOUSEHWHEEL, -60, -0.5 pages, pixel scrolling is disabled",
|
||||
message: WM_MOUSEHWHEEL, delta: -60,
|
||||
target: gP1, x: 10, y: 10, window: window,
|
||||
modifiers: 0,
|
||||
additionalFlags: 0,
|
||||
expected: {
|
||||
axis: kHAxis, lines: 0, pixels: 0,
|
||||
},
|
||||
|
||||
finish: function () {
|
||||
runNextTest(gScrollMessageTests, 0);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
var gScrollMessageTests = [
|
||||
@ -1889,7 +1522,6 @@ function prepareTests()
|
||||
SpecialPowers.setIntPref(kWinKeyDeltaMultiplierYPref, 100);
|
||||
|
||||
SpecialPowers.setBoolPref(kSystemScrollSpeedOverridePref, false);
|
||||
SpecialPowers.setBoolPref(kPixelEnabledPref, true);
|
||||
SpecialPowers.setIntPref(kTimeoutPref, -1);
|
||||
|
||||
runNextTest(gPreparingSteps, 0);
|
||||
|
@ -128,7 +128,7 @@ void
|
||||
ModifierKeyState::InitMouseEvent(nsInputEvent& aMouseEvent) const
|
||||
{
|
||||
NS_ASSERTION(aMouseEvent.eventStructType == NS_MOUSE_EVENT ||
|
||||
aMouseEvent.eventStructType == NS_MOUSE_SCROLL_EVENT ||
|
||||
aMouseEvent.eventStructType == NS_WHEEL_EVENT ||
|
||||
aMouseEvent.eventStructType == NS_DRAG_EVENT ||
|
||||
aMouseEvent.eventStructType == NS_SIMPLE_GESTURE_EVENT ||
|
||||
aMouseEvent.eventStructType == NS_MOZTOUCH_EVENT,
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "WinUtils.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDOMWindowUtils.h"
|
||||
#include "nsIDOMWheelEvent.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
@ -359,91 +360,6 @@ MouseScrollHandler::ComputeMessagePos(UINT aMessage,
|
||||
return point;
|
||||
}
|
||||
|
||||
MouseScrollHandler::ScrollTargetInfo
|
||||
MouseScrollHandler::GetScrollTargetInfo(
|
||||
nsWindow* aWindow,
|
||||
const EventInfo& aEventInfo,
|
||||
const ModifierKeyState& aModifierKeyState)
|
||||
{
|
||||
ScrollTargetInfo result;
|
||||
result.dispatchPixelScrollEvent = false;
|
||||
result.reversePixelScrollDirection = false;
|
||||
result.actualScrollAmount = aEventInfo.GetScrollAmount();
|
||||
result.actualScrollAction = nsQueryContentEvent::SCROLL_ACTION_NONE;
|
||||
result.pixelsPerUnit = 0;
|
||||
if (!mUserPrefs.IsPixelScrollingEnabled()) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::GetPixelScrollInfo: Succeeded, aWindow=%p, "
|
||||
"result: { dispatchPixelScrollEvent: %s, actualScrollAmount: %d }",
|
||||
aWindow, GetBoolName(result.dispatchPixelScrollEvent),
|
||||
result.actualScrollAmount));
|
||||
return result;
|
||||
}
|
||||
|
||||
nsMouseScrollEvent testEvent(true, NS_MOUSE_SCROLL, aWindow);
|
||||
InitEvent(aWindow, testEvent);
|
||||
aModifierKeyState.InitInputEvent(testEvent);
|
||||
|
||||
testEvent.scrollFlags = aEventInfo.GetScrollFlags();
|
||||
testEvent.delta = result.actualScrollAmount;
|
||||
if ((aEventInfo.IsVertical() && aEventInfo.IsPositive()) ||
|
||||
(!aEventInfo.IsVertical() && !aEventInfo.IsPositive())) {
|
||||
testEvent.delta *= -1;
|
||||
}
|
||||
|
||||
nsQueryContentEvent queryEvent(true, NS_QUERY_SCROLL_TARGET_INFO, aWindow);
|
||||
InitEvent(aWindow, queryEvent);
|
||||
queryEvent.InitForQueryScrollTargetInfo(&testEvent);
|
||||
DispatchEvent(aWindow, queryEvent);
|
||||
|
||||
// If the necessary interger isn't larger than 0, we should assume that
|
||||
// the event failed for us.
|
||||
if (!queryEvent.mSucceeded) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::GetPixelScrollInfo: Failed to query the "
|
||||
"scroll target information, aWindow=%p"
|
||||
"result: { dispatchPixelScrollEvent: %s, actualScrollAmount: %d }",
|
||||
aWindow, GetBoolName(result.dispatchPixelScrollEvent),
|
||||
result.actualScrollAmount));
|
||||
return result;
|
||||
}
|
||||
|
||||
result.actualScrollAction = queryEvent.mReply.mComputedScrollAction;
|
||||
|
||||
if (result.actualScrollAction == nsQueryContentEvent::SCROLL_ACTION_PAGE) {
|
||||
result.pixelsPerUnit =
|
||||
aEventInfo.IsVertical() ? queryEvent.mReply.mPageHeight :
|
||||
queryEvent.mReply.mPageWidth;
|
||||
} else {
|
||||
result.pixelsPerUnit = queryEvent.mReply.mLineHeight;
|
||||
}
|
||||
|
||||
result.actualScrollAmount = queryEvent.mReply.mComputedScrollAmount;
|
||||
|
||||
if (result.pixelsPerUnit > 0 && result.actualScrollAmount != 0 &&
|
||||
result.actualScrollAction != nsQueryContentEvent::SCROLL_ACTION_NONE) {
|
||||
result.dispatchPixelScrollEvent = true;
|
||||
// If original delta's sign and computed delta's one are different,
|
||||
// we need to reverse the pixel scroll direction at dispatching it.
|
||||
result.reversePixelScrollDirection =
|
||||
(testEvent.delta > 0 && result.actualScrollAmount < 0) ||
|
||||
(testEvent.delta < 0 && result.actualScrollAmount > 0);
|
||||
// scroll amount must be positive.
|
||||
result.actualScrollAmount = NS_ABS(result.actualScrollAmount);
|
||||
}
|
||||
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::GetPixelScrollInfo: Succeeded, aWindow=%p, "
|
||||
"result: { dispatchPixelScrollEvent: %s, reversePixelScrollDirection: %s, "
|
||||
"actualScrollAmount: %d, actualScrollAction: 0x%01X, "
|
||||
"pixelsPerUnit: %d }",
|
||||
aWindow, GetBoolName(result.dispatchPixelScrollEvent),
|
||||
GetBoolName(result.reversePixelScrollDirection), result.actualScrollAmount,
|
||||
result.actualScrollAction, result.pixelsPerUnit));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
MouseScrollHandler::ProcessNativeMouseWheelMessage(nsWindow* aWindow,
|
||||
UINT aMessage,
|
||||
@ -673,7 +589,7 @@ MouseScrollHandler::HandleMouseWheelMessage(nsWindow* aWindow,
|
||||
|
||||
EventInfo eventInfo(aWindow, WinUtils::GetNativeMessage(aMessage),
|
||||
aWParam, aLParam);
|
||||
if (!eventInfo.CanDispatchMouseScrollEvent()) {
|
||||
if (!eventInfo.CanDispatchWheelEvent()) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: Cannot dispatch the events"));
|
||||
mLastEventInfo.ResetTransaction();
|
||||
@ -691,27 +607,19 @@ MouseScrollHandler::HandleMouseWheelMessage(nsWindow* aWindow,
|
||||
|
||||
ModifierKeyState modKeyState = GetModifierKeyState(aMessage);
|
||||
|
||||
// Before dispatching line scroll event, we should get the current scroll
|
||||
// event target information for pixel scroll.
|
||||
ScrollTargetInfo scrollTargetInfo =
|
||||
GetScrollTargetInfo(aWindow, eventInfo, modKeyState);
|
||||
|
||||
// Grab the widget, it might be destroyed by a DOM event handler.
|
||||
nsRefPtr<nsWindow> kungFuDethGrip(aWindow);
|
||||
|
||||
bool fromLines = false;
|
||||
nsMouseScrollEvent scrollEvent(true, NS_MOUSE_SCROLL, aWindow);
|
||||
if (mLastEventInfo.InitMouseScrollEvent(aWindow, scrollEvent,
|
||||
scrollTargetInfo, modKeyState)) {
|
||||
WheelEvent wheelEvent(true, NS_WHEEL_WHEEL, aWindow);
|
||||
if (mLastEventInfo.InitWheelEvent(aWindow, wheelEvent, modKeyState)) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: dispatching "
|
||||
"NS_MOUSE_SCROLL event"));
|
||||
fromLines = true;
|
||||
DispatchEvent(aWindow, scrollEvent);
|
||||
"NS_WHEEL_WHEEL event"));
|
||||
DispatchEvent(aWindow, wheelEvent);
|
||||
if (aWindow->Destroyed()) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: The window was destroyed "
|
||||
"by NS_MOUSE_SCROLL event"));
|
||||
"by NS_WHEEL_WHEEL event"));
|
||||
mLastEventInfo.ResetTransaction();
|
||||
return;
|
||||
}
|
||||
@ -719,34 +627,10 @@ MouseScrollHandler::HandleMouseWheelMessage(nsWindow* aWindow,
|
||||
#ifdef PR_LOGGING
|
||||
else {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: NS_MOUSE_SCROLL event is not "
|
||||
("MouseScroll::HandleMouseWheelMessage: NS_WHEEL_WHEEL event is not "
|
||||
"dispatched"));
|
||||
}
|
||||
#endif
|
||||
|
||||
nsMouseScrollEvent pixelEvent(true, NS_MOUSE_PIXEL_SCROLL, aWindow);
|
||||
if (mLastEventInfo.InitMousePixelScrollEvent(aWindow, pixelEvent,
|
||||
scrollTargetInfo, modKeyState)) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: dispatching "
|
||||
"NS_MOUSE_PIXEL_SCROLL event"));
|
||||
pixelEvent.scrollFlags |= fromLines ? nsMouseScrollEvent::kFromLines : 0;
|
||||
DispatchEvent(aWindow, pixelEvent);
|
||||
if (aWindow->Destroyed()) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: The window was destroyed "
|
||||
"by NS_MOUSE_PIXEL_SCROLL event"));
|
||||
mLastEventInfo.ResetTransaction();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#ifdef PR_LOGGING
|
||||
else {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleMouseWheelMessage: NS_MOUSE_PIXEL_SCROLL event is "
|
||||
"not dispatched"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -764,44 +648,56 @@ MouseScrollHandler::HandleScrollMessageAsMouseWheelMessage(nsWindow* aWindow,
|
||||
|
||||
ModifierKeyState modKeyState = GetModifierKeyState(aMessage);
|
||||
|
||||
nsMouseScrollEvent scrollEvent(true, NS_MOUSE_SCROLL, aWindow);
|
||||
scrollEvent.scrollFlags =
|
||||
(aMessage == MOZ_WM_VSCROLL) ? nsMouseScrollEvent::kIsVertical :
|
||||
nsMouseScrollEvent::kIsHorizontal;
|
||||
WheelEvent wheelEvent(true, NS_WHEEL_WHEEL, aWindow);
|
||||
double& delta =
|
||||
(aMessage == MOZ_WM_VSCROLL) ? wheelEvent.deltaY : wheelEvent.deltaX;
|
||||
PRInt32& lineOrPageDelta =
|
||||
(aMessage == MOZ_WM_VSCROLL) ? wheelEvent.lineOrPageDeltaY :
|
||||
wheelEvent.lineOrPageDeltaX;
|
||||
|
||||
delta = 1.0;
|
||||
lineOrPageDelta = 1;
|
||||
|
||||
switch (LOWORD(aWParam)) {
|
||||
case SB_PAGEDOWN:
|
||||
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
|
||||
case SB_LINEDOWN:
|
||||
scrollEvent.delta = 1;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
|
||||
case SB_LINEUP:
|
||||
scrollEvent.delta = -1;
|
||||
delta = -1.0;
|
||||
lineOrPageDelta = -1;
|
||||
case SB_PAGEDOWN:
|
||||
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_PAGE;
|
||||
break;
|
||||
|
||||
case SB_LINEUP:
|
||||
delta = -1.0;
|
||||
lineOrPageDelta = -1;
|
||||
case SB_LINEDOWN:
|
||||
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
modKeyState.InitInputEvent(scrollEvent);
|
||||
modKeyState.InitInputEvent(wheelEvent);
|
||||
// XXX Current mouse position may not be same as when the original message
|
||||
// is received. We need to know the actual mouse cursor position when
|
||||
// the original message was received.
|
||||
InitEvent(aWindow, scrollEvent);
|
||||
InitEvent(aWindow, wheelEvent);
|
||||
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::HandleScrollMessageAsMouseWheelMessage: aWindow=%p, "
|
||||
"aMessage=MOZ_WM_%sSCROLL, aWParam=0x%08X, aLParam=0x%08X, "
|
||||
"scrollEvent { refPoint: { x: %d, y: %d }, delta: %d, "
|
||||
"scrollFlags: 0x%04X, isShift: %s, isControl: %s, isAlt: %s, isMeta: %s }",
|
||||
aWindow, (aMessage == MOZ_WM_VSCROLL) ? "V" : "H",
|
||||
aWParam, aLParam, scrollEvent.refPoint.x, scrollEvent.refPoint.y,
|
||||
scrollEvent.delta, scrollEvent.scrollFlags,
|
||||
GetBoolName(scrollEvent.IsShift()),
|
||||
GetBoolName(scrollEvent.IsControl()),
|
||||
GetBoolName(scrollEvent.IsAlt()),
|
||||
GetBoolName(scrollEvent.IsMeta())));
|
||||
"wheelEvent { refPoint: { x: %d, y: %d }, deltaX: %f, deltaY: %f, "
|
||||
"lineOrPageDeltaX: %d, lineOrPageDeltaY: %d, "
|
||||
"isShift: %s, isControl: %s, isAlt: %s, isMeta: %s }",
|
||||
aWindow, (aMessage == MOZ_WM_VSCROLL) ? "V" : "H", aWParam, aLParam,
|
||||
wheelEvent.refPoint.x, wheelEvent.refPoint.y,
|
||||
wheelEvent.deltaX, wheelEvent.deltaY,
|
||||
wheelEvent.lineOrPageDeltaX, wheelEvent.lineOrPageDeltaY,
|
||||
GetBoolName(wheelEvent.IsShift()),
|
||||
GetBoolName(wheelEvent.IsControl()),
|
||||
GetBoolName(wheelEvent.IsAlt()),
|
||||
GetBoolName(wheelEvent.IsMeta())));
|
||||
|
||||
DispatchEvent(aWindow, scrollEvent);
|
||||
DispatchEvent(aWindow, wheelEvent);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -828,7 +724,7 @@ MouseScrollHandler::EventInfo::EventInfo(nsWindow* aWindow,
|
||||
}
|
||||
|
||||
bool
|
||||
MouseScrollHandler::EventInfo::CanDispatchMouseScrollEvent() const
|
||||
MouseScrollHandler::EventInfo::CanDispatchWheelEvent() const
|
||||
{
|
||||
if (!GetScrollAmount()) {
|
||||
// XXX I think that we should dispatch mouse wheel events even if the
|
||||
@ -850,15 +746,6 @@ MouseScrollHandler::EventInfo::GetScrollAmount() const
|
||||
mSystemSettings.GetScrollAmount(mIsVertical);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
MouseScrollHandler::EventInfo::GetScrollFlags() const
|
||||
{
|
||||
PRInt32 result = mIsPage ? nsMouseScrollEvent::kIsFullPage : 0;
|
||||
result |= mIsVertical ? nsMouseScrollEvent::kIsVertical :
|
||||
nsMouseScrollEvent::kIsHorizontal;
|
||||
return result;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* LastEventInfo
|
||||
@ -892,8 +779,7 @@ MouseScrollHandler::LastEventInfo::ResetTransaction()
|
||||
("MouseScroll::LastEventInfo::ResetTransaction()"));
|
||||
|
||||
mWnd = nullptr;
|
||||
mRemainingDeltaForScroll = 0;
|
||||
mRemainingDeltaForPixel = 0;
|
||||
mAccumulatedDelta = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -914,135 +800,58 @@ MouseScrollHandler::LastEventInfo::RoundDelta(double aDelta)
|
||||
}
|
||||
|
||||
bool
|
||||
MouseScrollHandler::LastEventInfo::InitMouseScrollEvent(
|
||||
MouseScrollHandler::LastEventInfo::InitWheelEvent(
|
||||
nsWindow* aWindow,
|
||||
nsMouseScrollEvent& aMouseScrollEvent,
|
||||
const ScrollTargetInfo& aScrollTargetInfo,
|
||||
WheelEvent& aWheelEvent,
|
||||
const ModifierKeyState& aModKeyState)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aMouseScrollEvent.message == NS_MOUSE_SCROLL,
|
||||
"aMouseScrollEvent must be NS_MOUSE_SCROLL");
|
||||
MOZ_ASSERT(aWheelEvent.message == NS_WHEEL_WHEEL);
|
||||
|
||||
// XXX Why don't we use lParam value? We should use lParam value because
|
||||
// our internal message is always posted by original message handler.
|
||||
// So, GetMessagePos() may return different cursor position.
|
||||
InitEvent(aWindow, aMouseScrollEvent);
|
||||
InitEvent(aWindow, aWheelEvent);
|
||||
|
||||
aModKeyState.InitInputEvent(aMouseScrollEvent);
|
||||
|
||||
// If we dispatch pixel scroll event after the line scroll event,
|
||||
// we should set kHasPixels flag to the line scroll event.
|
||||
aMouseScrollEvent.scrollFlags =
|
||||
aScrollTargetInfo.dispatchPixelScrollEvent ?
|
||||
nsMouseScrollEvent::kHasPixels : 0;
|
||||
aMouseScrollEvent.scrollFlags |= GetScrollFlags();
|
||||
aModKeyState.InitInputEvent(aWheelEvent);
|
||||
|
||||
// Our positive delta value means to bottom or right.
|
||||
// But positive native delta value means to top or right.
|
||||
// Use orienter for computing our delta value with native delta value.
|
||||
PRInt32 orienter = mIsVertical ? -1 : 1;
|
||||
|
||||
// NOTE: Don't use aScrollTargetInfo.actualScrollAmount for computing the
|
||||
// delta value of line/page scroll event. The value will be recomputed
|
||||
// in ESM.
|
||||
PRInt32 nativeDelta = mDelta + mRemainingDeltaForScroll;
|
||||
if (IsPage()) {
|
||||
aMouseScrollEvent.delta = nativeDelta * orienter / WHEEL_DELTA;
|
||||
PRInt32 recomputedNativeDelta =
|
||||
aMouseScrollEvent.delta * orienter / WHEEL_DELTA;
|
||||
mRemainingDeltaForScroll = nativeDelta - recomputedNativeDelta;
|
||||
} else {
|
||||
double deltaPerUnit = (double)WHEEL_DELTA / GetScrollAmount();
|
||||
aMouseScrollEvent.delta =
|
||||
RoundDelta((double)nativeDelta * orienter / deltaPerUnit);
|
||||
PRInt32 recomputedNativeDelta =
|
||||
(PRInt32)(aMouseScrollEvent.delta * orienter * deltaPerUnit);
|
||||
mRemainingDeltaForScroll = nativeDelta - recomputedNativeDelta;
|
||||
}
|
||||
aWheelEvent.deltaMode = mIsPage ? nsIDOMWheelEvent::DOM_DELTA_PAGE :
|
||||
nsIDOMWheelEvent::DOM_DELTA_LINE;
|
||||
|
||||
double& delta = mIsVertical ? aWheelEvent.deltaY : aWheelEvent.deltaX;
|
||||
PRInt32& lineOrPageDelta = mIsVertical ? aWheelEvent.lineOrPageDeltaY :
|
||||
aWheelEvent.lineOrPageDeltaX;
|
||||
|
||||
double nativeDeltaPerUnit =
|
||||
mIsPage ? static_cast<double>(WHEEL_DELTA) :
|
||||
static_cast<double>(WHEEL_DELTA) / GetScrollAmount();
|
||||
|
||||
delta = static_cast<double>(mDelta) * orienter / nativeDeltaPerUnit;
|
||||
mAccumulatedDelta += mDelta;
|
||||
lineOrPageDelta =
|
||||
mAccumulatedDelta * orienter / RoundDelta(nativeDeltaPerUnit);
|
||||
mAccumulatedDelta -=
|
||||
lineOrPageDelta * orienter * RoundDelta(nativeDeltaPerUnit);
|
||||
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::LastEventInfo::InitMouseScrollEvent: aWindow=%p, "
|
||||
"aMouseScrollEvent { refPoint: { x: %d, y: %d }, delta: %d, "
|
||||
"scrollFlags: 0x%04X, isShift: %s, isControl: %s, isAlt: %s, "
|
||||
"isMeta: %s }, mRemainingDeltaForScroll: %d",
|
||||
aWindow, aMouseScrollEvent.refPoint.x, aMouseScrollEvent.refPoint.y,
|
||||
aMouseScrollEvent.delta, aMouseScrollEvent.scrollFlags,
|
||||
GetBoolName(aMouseScrollEvent.IsShift()),
|
||||
GetBoolName(aMouseScrollEvent.IsControl()),
|
||||
GetBoolName(aMouseScrollEvent.IsAlt()),
|
||||
GetBoolName(aMouseScrollEvent.IsMeta()), mRemainingDeltaForScroll));
|
||||
("MouseScroll::LastEventInfo::InitWheelEvent: aWindow=%p, "
|
||||
"aWheelEvent { refPoint: { x: %d, y: %d }, deltaX: %f, deltaY: %f, "
|
||||
"lineOrPageDeltaX: %d, lineOrPageDeltaY: %d, "
|
||||
"isShift: %s, isControl: %s, isAlt: %s, isMeta: %s }, "
|
||||
"mAccumulatedDelta: %d",
|
||||
aWindow, aWheelEvent.refPoint.x, aWheelEvent.refPoint.y,
|
||||
aWheelEvent.deltaX, aWheelEvent.deltaY,
|
||||
aWheelEvent.lineOrPageDeltaX, aWheelEvent.lineOrPageDeltaY,
|
||||
GetBoolName(aWheelEvent.IsShift()),
|
||||
GetBoolName(aWheelEvent.IsControl()),
|
||||
GetBoolName(aWheelEvent.IsAlt()),
|
||||
GetBoolName(aWheelEvent.IsMeta()), mAccumulatedDelta));
|
||||
|
||||
return (aMouseScrollEvent.delta != 0);
|
||||
}
|
||||
|
||||
bool
|
||||
MouseScrollHandler::LastEventInfo::InitMousePixelScrollEvent(
|
||||
nsWindow* aWindow,
|
||||
nsMouseScrollEvent& aPixelScrollEvent,
|
||||
const ScrollTargetInfo& aScrollTargetInfo,
|
||||
const ModifierKeyState& aModKeyState)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aPixelScrollEvent.message == NS_MOUSE_PIXEL_SCROLL,
|
||||
"aPixelScrollEvent must be NS_MOUSE_PIXEL_SCROLL");
|
||||
|
||||
if (!aScrollTargetInfo.dispatchPixelScrollEvent) {
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::LastEventInfo::InitMousePixelScrollEvent: aWindow=%p, "
|
||||
"PixelScroll is disabled",
|
||||
aWindow, mRemainingDeltaForPixel));
|
||||
|
||||
mRemainingDeltaForPixel = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXX Why don't we use lParam value? We should use lParam value because
|
||||
// our internal message is always posted by original message handler.
|
||||
// So, GetMessagePos() may return different cursor position.
|
||||
InitEvent(aWindow, aPixelScrollEvent);
|
||||
|
||||
aModKeyState.InitInputEvent(aPixelScrollEvent);
|
||||
|
||||
aPixelScrollEvent.scrollFlags = nsMouseScrollEvent::kAllowSmoothScroll;
|
||||
aPixelScrollEvent.scrollFlags |= mIsVertical ?
|
||||
nsMouseScrollEvent::kIsVertical : nsMouseScrollEvent::kIsHorizontal;
|
||||
if (aScrollTargetInfo.actualScrollAction ==
|
||||
nsQueryContentEvent::SCROLL_ACTION_PAGE) {
|
||||
aPixelScrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
|
||||
}
|
||||
|
||||
// Our positive delta value means to bottom or right.
|
||||
// But positive native delta value means to top or right.
|
||||
// Use orienter for computing our delta value with native delta value.
|
||||
PRInt32 orienter = mIsVertical ? -1 : 1;
|
||||
// However, pixel scroll event won't be recomputed the scroll amout and
|
||||
// direction by ESM. Therefore, we need to set the computed amout and
|
||||
// direction here.
|
||||
if (aScrollTargetInfo.reversePixelScrollDirection) {
|
||||
orienter *= -1;
|
||||
}
|
||||
|
||||
PRInt32 nativeDelta = mDelta + mRemainingDeltaForPixel;
|
||||
double deltaPerPixel = (double)WHEEL_DELTA /
|
||||
aScrollTargetInfo.actualScrollAmount / aScrollTargetInfo.pixelsPerUnit;
|
||||
aPixelScrollEvent.delta =
|
||||
RoundDelta((double)nativeDelta * orienter / deltaPerPixel);
|
||||
PRInt32 recomputedNativeDelta =
|
||||
(PRInt32)(aPixelScrollEvent.delta * orienter * deltaPerPixel);
|
||||
mRemainingDeltaForPixel = nativeDelta - recomputedNativeDelta;
|
||||
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::LastEventInfo::InitMousePixelScrollEvent: aWindow=%p, "
|
||||
"aPixelScrollEvent { refPoint: { x: %d, y: %d }, delta: %d, "
|
||||
"scrollFlags: 0x%04X, isShift: %s, isControl: %s, isAlt: %s, "
|
||||
"isMeta: %s }, mRemainingDeltaForScroll: %d",
|
||||
aWindow, aPixelScrollEvent.refPoint.x, aPixelScrollEvent.refPoint.y,
|
||||
aPixelScrollEvent.delta, aPixelScrollEvent.scrollFlags,
|
||||
GetBoolName(aPixelScrollEvent.IsShift()),
|
||||
GetBoolName(aPixelScrollEvent.IsControl()),
|
||||
GetBoolName(aPixelScrollEvent.IsAlt()),
|
||||
GetBoolName(aPixelScrollEvent.IsMeta()), mRemainingDeltaForPixel));
|
||||
|
||||
return (aPixelScrollEvent.delta != 0);
|
||||
return (delta != 0);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@ -1172,8 +981,6 @@ MouseScrollHandler::UserPrefs::Init()
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
mPixelScrollingEnabled =
|
||||
Preferences::GetBool("mousewheel.enable_pixel_scrolling", true);
|
||||
mScrollMessageHandledAsWheelMessage =
|
||||
Preferences::GetBool("mousewheel.emulate_at_wm_scroll", false);
|
||||
mOverriddenVerticalScrollAmount =
|
||||
@ -1186,11 +993,10 @@ MouseScrollHandler::UserPrefs::Init()
|
||||
|
||||
PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
|
||||
("MouseScroll::UserPrefs::Init(): initialized, "
|
||||
"mPixelScrollingEnabled=%s, mScrollMessageHandledAsWheelMessage=%s, "
|
||||
"mScrollMessageHandledAsWheelMessage=%s, "
|
||||
"mOverriddenVerticalScrollAmount=%d, "
|
||||
"mOverriddenHorizontalScrollAmount=%d, "
|
||||
"mMouseScrollTransactionTimeout=%d",
|
||||
GetBoolName(mPixelScrollingEnabled),
|
||||
GetBoolName(mScrollMessageHandledAsWheelMessage),
|
||||
mOverriddenVerticalScrollAmount, mOverriddenHorizontalScrollAmount,
|
||||
mMouseScrollTransactionTimeout));
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
class nsWindow;
|
||||
class nsGUIEvent;
|
||||
class nsMouseScrollEvent;
|
||||
struct nsIntPoint;
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
||||
class ModifierKeyState;
|
||||
class WheelEvent;
|
||||
|
||||
class MouseScrollHandler {
|
||||
public:
|
||||
@ -180,34 +180,6 @@ private:
|
||||
WPARAM aWParam,
|
||||
LPARAM aLParam);
|
||||
|
||||
class EventInfo;
|
||||
/**
|
||||
* GetScrollTargetInfo() returns scroll target information which is
|
||||
* computed from the result of NS_QUERY_SCROLL_TARGET_INFO event.
|
||||
*
|
||||
* @param aWindow An nsWindow which is handling the event.
|
||||
* @param aEventInfo The EventInfo which is being handled.
|
||||
* @param aModifierKeyState The modifier key state.
|
||||
*/
|
||||
struct ScrollTargetInfo {
|
||||
// TRUE if pixel scroll event is needed. Otherwise, FALSE.
|
||||
bool dispatchPixelScrollEvent;
|
||||
// TRUE if pixel scroll event's delta value should be reversed.
|
||||
// Otherwise, FALSE.
|
||||
bool reversePixelScrollDirection;
|
||||
// Actual scroll amount. It might be computed with user prefs.
|
||||
PRInt32 actualScrollAmount;
|
||||
// Actual scroll action. It might be computed with user prefs.
|
||||
// The value is one of nsQueryContentEvent::SCROLL_ACTION_*.
|
||||
PRInt32 actualScrollAction;
|
||||
// Pixels per unit (line or page, depends on the action).
|
||||
PRInt32 pixelsPerUnit;
|
||||
};
|
||||
ScrollTargetInfo GetScrollTargetInfo(
|
||||
nsWindow* aWindow,
|
||||
const EventInfo& aEvent,
|
||||
const ModifierKeyState& aModiferKeyState);
|
||||
|
||||
class EventInfo {
|
||||
public:
|
||||
/**
|
||||
@ -216,7 +188,7 @@ private:
|
||||
*/
|
||||
EventInfo(nsWindow* aWindow, UINT aMessage, WPARAM aWParam, LPARAM aLParam);
|
||||
|
||||
bool CanDispatchMouseScrollEvent() const;
|
||||
bool CanDispatchWheelEvent() const;
|
||||
|
||||
PRInt32 GetNativeDelta() const { return mDelta; }
|
||||
HWND GetWindowHandle() const { return mWnd; }
|
||||
@ -230,12 +202,6 @@ private:
|
||||
*/
|
||||
PRInt32 GetScrollAmount() const;
|
||||
|
||||
/**
|
||||
* @return One or more values of
|
||||
* nsMouseScrollEvent::nsMouseScrollFlags.
|
||||
*/
|
||||
PRInt32 GetScrollFlags() const;
|
||||
|
||||
protected:
|
||||
EventInfo() :
|
||||
mIsVertical(false), mIsPage(false), mDelta(0), mWnd(nullptr)
|
||||
@ -257,7 +223,7 @@ private:
|
||||
class LastEventInfo : public EventInfo {
|
||||
public:
|
||||
LastEventInfo() :
|
||||
EventInfo(), mRemainingDeltaForScroll(0), mRemainingDeltaForPixel(0)
|
||||
EventInfo(), mAccumulatedDelta(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -280,50 +246,26 @@ private:
|
||||
void RecordEvent(const EventInfo& aEvent);
|
||||
|
||||
/**
|
||||
* InitMouseScrollEvent() initializes NS_MOUSE_SCROLL event and
|
||||
* InitWheelEvent() initializes NS_WHEEL_WHEEL event and
|
||||
* recomputes the remaning detla for the event.
|
||||
* This must be called only once during handling a message and after
|
||||
* RecordEvent() is called.
|
||||
*
|
||||
* @param aWindow A window which will dispatch the event.
|
||||
* @param aMouseScrollEvent An NS_MOUSE_SCROLL event, this will be
|
||||
* @param aWheelEvent An NS_WHEEL_WHEEL event, this will be
|
||||
* initialized.
|
||||
* @param aScrollTargetInfo The result of GetScrollTargetInfo().
|
||||
* @param aModKeyState Current modifier key state.
|
||||
* @return TRUE if the event is ready to dispatch.
|
||||
* Otherwise, FALSE.
|
||||
*/
|
||||
bool InitMouseScrollEvent(nsWindow* aWindow,
|
||||
nsMouseScrollEvent& aMouseScrollEvent,
|
||||
const ScrollTargetInfo& aScrollTargetInfo,
|
||||
const ModifierKeyState& aModKeyState);
|
||||
|
||||
/**
|
||||
* InitMousePixelScrollEvent() initializes NS_MOUSE_PIXEL_SCROLL event and
|
||||
* recomputes the remaning detla for the event.
|
||||
* This must be called only once during handling a message and after
|
||||
* RecordEvent() is called.
|
||||
*
|
||||
* @param aWindow A window which will dispatch the event.
|
||||
* @param aMouseScrollEvent An NS_MOUSE_PIXEL_SCROLL event, this will be
|
||||
* initialized.
|
||||
* @param aScrollTargetInfo The result of GetScrollTargetInfo().
|
||||
* @param aModKeyState Current modifier key state.
|
||||
* @return TRUE if the event is ready to dispatch.
|
||||
* Otherwise, FALSE.
|
||||
*/
|
||||
bool InitMousePixelScrollEvent(nsWindow* aWindow,
|
||||
nsMouseScrollEvent& aPixelScrollEvent,
|
||||
const ScrollTargetInfo& aScrollTargetInfo,
|
||||
const ModifierKeyState& aModKeyState);
|
||||
bool InitWheelEvent(nsWindow* aWindow,
|
||||
WheelEvent& aWheelEvent,
|
||||
const ModifierKeyState& aModKeyState);
|
||||
|
||||
private:
|
||||
static PRInt32 RoundDelta(double aDelta);
|
||||
|
||||
// The remaining native delta value (i.e., not handled by previous
|
||||
// message handler).
|
||||
PRInt32 mRemainingDeltaForScroll;
|
||||
PRInt32 mRemainingDeltaForPixel;
|
||||
PRInt32 mAccumulatedDelta;
|
||||
};
|
||||
|
||||
LastEventInfo mLastEventInfo;
|
||||
@ -364,12 +306,6 @@ private:
|
||||
|
||||
void MarkDirty();
|
||||
|
||||
bool IsPixelScrollingEnabled()
|
||||
{
|
||||
Init();
|
||||
return mPixelScrollingEnabled;
|
||||
}
|
||||
|
||||
bool IsScrollMessageHandledAsWheelMessage()
|
||||
{
|
||||
Init();
|
||||
@ -404,7 +340,6 @@ private:
|
||||
}
|
||||
|
||||
bool mInitialized;
|
||||
bool mPixelScrollingEnabled;
|
||||
bool mScrollMessageHandledAsWheelMessage;
|
||||
PRInt32 mOverriddenVerticalScrollAmount;
|
||||
PRInt32 mOverriddenHorizontalScrollAmount;
|
||||
|
@ -12,10 +12,12 @@
|
||||
#include "nsUXThemeData.h"
|
||||
#include "nsIDOMSimpleGestureEvent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIDOMWheelEvent.h"
|
||||
#include "mozilla/Constants.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* gWindowsLog;
|
||||
@ -554,53 +556,29 @@ nsWinGesture::PanFeedbackFinalize(HWND hWnd, bool endFeedback)
|
||||
}
|
||||
|
||||
bool
|
||||
nsWinGesture::PanDeltaToPixelScrollX(nsMouseScrollEvent& evt)
|
||||
nsWinGesture::PanDeltaToPixelScroll(WheelEvent& aWheelEvent)
|
||||
{
|
||||
evt.delta = 0;
|
||||
evt.scrollOverflow = 0;
|
||||
aWheelEvent.deltaX = aWheelEvent.deltaY = aWheelEvent.deltaZ = 0.0;
|
||||
aWheelEvent.lineOrPageDeltaX = aWheelEvent.lineOrPageDeltaY = 0;
|
||||
|
||||
aWheelEvent.refPoint.x = mPanRefPoint.x;
|
||||
aWheelEvent.refPoint.y = mPanRefPoint.y;
|
||||
aWheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_PIXEL;
|
||||
aWheelEvent.scrollType = WheelEvent::SCROLL_SYNCHRONOUSLY;
|
||||
aWheelEvent.isPixelOnlyDevice = true;
|
||||
|
||||
aWheelEvent.overflowDeltaX = 0.0;
|
||||
aWheelEvent.overflowDeltaY = 0.0;
|
||||
|
||||
// Don't scroll the view if we are currently at a bounds, or, if we are
|
||||
// panning back from a max feedback position. This keeps the original drag point
|
||||
// constant.
|
||||
if (mXAxisFeedback)
|
||||
return false;
|
||||
|
||||
if (mPixelScrollDelta.x != 0)
|
||||
{
|
||||
evt.scrollFlags = nsMouseScrollEvent::kIsHorizontal|
|
||||
nsMouseScrollEvent::kHasPixels|
|
||||
nsMouseScrollEvent::kNoLines|
|
||||
nsMouseScrollEvent::kNoDefer;
|
||||
evt.delta = mPixelScrollDelta.x;
|
||||
evt.refPoint.x = mPanRefPoint.x;
|
||||
evt.refPoint.y = mPanRefPoint.y;
|
||||
return true;
|
||||
if (!mXAxisFeedback) {
|
||||
aWheelEvent.deltaX = mPixelScrollDelta.x;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsWinGesture::PanDeltaToPixelScrollY(nsMouseScrollEvent& evt)
|
||||
{
|
||||
evt.delta = 0;
|
||||
evt.scrollOverflow = 0;
|
||||
|
||||
// Don't scroll the view if we are currently at a bounds, or, if we are
|
||||
// panning back from a max feedback position. This keeps the original drag point
|
||||
// constant.
|
||||
if (mYAxisFeedback)
|
||||
return false;
|
||||
|
||||
if (mPixelScrollDelta.y != 0)
|
||||
{
|
||||
evt.scrollFlags = nsMouseScrollEvent::kIsVertical|
|
||||
nsMouseScrollEvent::kHasPixels|
|
||||
nsMouseScrollEvent::kNoLines|
|
||||
nsMouseScrollEvent::kNoDefer;
|
||||
evt.delta = mPixelScrollDelta.y;
|
||||
evt.refPoint.x = mPanRefPoint.x;
|
||||
evt.refPoint.y = mPanRefPoint.y;
|
||||
return true;
|
||||
if (!mYAxisFeedback) {
|
||||
aWheelEvent.deltaY = mPixelScrollDelta.y;
|
||||
}
|
||||
return false;
|
||||
|
||||
return (aWheelEvent.deltaX != 0 || aWheelEvent.deltaY != 0);
|
||||
}
|
||||
|
@ -211,8 +211,7 @@ public:
|
||||
// Pan processing
|
||||
bool IsPanEvent(LPARAM lParam);
|
||||
bool ProcessPanMessage(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
bool PanDeltaToPixelScrollX(nsMouseScrollEvent& evt);
|
||||
bool PanDeltaToPixelScrollY(nsMouseScrollEvent& evt);
|
||||
bool PanDeltaToPixelScroll(mozilla::widget::WheelEvent& aWheelEvent);
|
||||
void UpdatePanFeedbackX(HWND hWnd, PRInt32 scrollOverflow, bool& endFeedback);
|
||||
void UpdatePanFeedbackY(HWND hWnd, PRInt32 scrollOverflow, bool& endFeedback);
|
||||
void PanFeedbackFinalize(HWND hWnd, bool endFeedback);
|
||||
|
@ -6273,43 +6273,42 @@ bool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam)
|
||||
return true;
|
||||
}
|
||||
|
||||
static PRInt32 RoundDown(double aDouble)
|
||||
{
|
||||
return aDouble > 0 ? static_cast<PRInt32>(floor(aDouble)) :
|
||||
static_cast<PRInt32>(ceil(aDouble));
|
||||
}
|
||||
|
||||
// Gesture event processing. Handles WM_GESTURE events.
|
||||
bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Treatment for pan events which translate into scroll events:
|
||||
if (mGesture.IsPanEvent(lParam)) {
|
||||
nsMouseScrollEvent event(true, NS_MOUSE_PIXEL_SCROLL, this);
|
||||
|
||||
if ( !mGesture.ProcessPanMessage(mWnd, wParam, lParam) )
|
||||
return false; // ignore
|
||||
|
||||
nsEventStatus status;
|
||||
|
||||
ModifierKeyState modifierKeyState;
|
||||
modifierKeyState.InitInputEvent(event);
|
||||
WheelEvent wheelEvent(true, NS_WHEEL_WHEEL, this);
|
||||
|
||||
event.button = 0;
|
||||
event.time = ::GetMessageTime();
|
||||
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
|
||||
ModifierKeyState modifierKeyState;
|
||||
modifierKeyState.InitInputEvent(wheelEvent);
|
||||
|
||||
wheelEvent.button = 0;
|
||||
wheelEvent.time = ::GetMessageTime();
|
||||
wheelEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
|
||||
|
||||
bool endFeedback = true;
|
||||
|
||||
PRInt32 scrollOverflowX = 0;
|
||||
PRInt32 scrollOverflowY = 0;
|
||||
|
||||
if (mGesture.PanDeltaToPixelScrollX(event)) {
|
||||
DispatchEvent(&event, status);
|
||||
scrollOverflowX = event.scrollOverflow;
|
||||
}
|
||||
|
||||
if (mGesture.PanDeltaToPixelScrollY(event)) {
|
||||
DispatchEvent(&event, status);
|
||||
scrollOverflowY = event.scrollOverflow;
|
||||
if (mGesture.PanDeltaToPixelScroll(wheelEvent)) {
|
||||
DispatchEvent(&wheelEvent, status);
|
||||
}
|
||||
|
||||
if (mDisplayPanFeedback) {
|
||||
mGesture.UpdatePanFeedbackX(mWnd, scrollOverflowX, endFeedback);
|
||||
mGesture.UpdatePanFeedbackY(mWnd, scrollOverflowY, endFeedback);
|
||||
mGesture.UpdatePanFeedbackX(mWnd, RoundDown(wheelEvent.overflowDeltaX),
|
||||
endFeedback);
|
||||
mGesture.UpdatePanFeedbackY(mWnd, RoundDown(wheelEvent.overflowDeltaY),
|
||||
endFeedback);
|
||||
mGesture.PanFeedbackFinalize(mWnd, endFeedback);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user