Bug 958868 - Add support for delta line and page accumulation; r=masayuki, sr=smaug

This commit is contained in:
Andrew Comminos 2014-07-07 18:54:14 +09:00
parent 00719c5ff5
commit 0ed1a0f5e1
10 changed files with 200 additions and 205 deletions

View File

@ -879,12 +879,8 @@ nsDOMWindowUtils::SendWheelEvent(float aX,
wheelEvent.deltaMode = aDeltaMode;
wheelEvent.isMomentum =
(aOptions & WHEEL_EVENT_CAUSED_BY_MOMENTUM) != 0;
wheelEvent.isPixelOnlyDevice =
(aOptions & WHEEL_EVENT_CAUSED_BY_PIXEL_ONLY_DEVICE) != 0;
NS_ENSURE_TRUE(
!wheelEvent.isPixelOnlyDevice ||
aDeltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL,
NS_ERROR_INVALID_ARG);
wheelEvent.mIsNoLineOrPageDelta =
(aOptions & WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE) != 0;
wheelEvent.customizedByUserPrefs =
(aOptions & WHEEL_EVENT_CUSTOMIZED_BY_USER_PREFS) != 0;
wheelEvent.lineOrPageDeltaX = aLineOrPageDeltaX;

View File

@ -5096,7 +5096,7 @@ EventStateManager::DeltaAccumulator::InitLineOrPageDelta(
if (IsInTransaction()) {
// If wheel event type is changed, reset the values.
if (mHandlingDeltaMode != aEvent->deltaMode ||
mHandlingPixelOnlyDevice != aEvent->isPixelOnlyDevice) {
mIsNoLineOrPageDeltaDevice != aEvent->mIsNoLineOrPageDelta) {
Reset();
} else {
// If the delta direction is changed, we should reset only the
@ -5111,13 +5111,12 @@ EventStateManager::DeltaAccumulator::InitLineOrPageDelta(
}
mHandlingDeltaMode = aEvent->deltaMode;
mHandlingPixelOnlyDevice = aEvent->isPixelOnlyDevice;
mIsNoLineOrPageDeltaDevice = aEvent->mIsNoLineOrPageDelta;
// If it's handling neither pixel scroll mode for pixel only device nor
// delta values multiplied by prefs, we must not modify lineOrPageDelta
// If it's handling neither a device that does not provide line or page deltas
// nor delta values multiplied by prefs, we must not modify lineOrPageDelta
// values.
if (!(mHandlingDeltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL &&
mHandlingPixelOnlyDevice) &&
if (!mIsNoLineOrPageDeltaDevice &&
!EventStateManager::WheelPrefs::GetInstance()->
NeedToComputeLineOrPageDelta(aEvent)) {
// Set the delta values to mX and mY. They would be used when above block
@ -5178,7 +5177,7 @@ EventStateManager::DeltaAccumulator::Reset()
mX = mY = 0.0;
mPendingScrollAmountX = mPendingScrollAmountY = 0.0;
mHandlingDeltaMode = UINT32_MAX;
mHandlingPixelOnlyDevice = false;
mIsNoLineOrPageDeltaDevice = false;
}
nsIntPoint

View File

@ -702,7 +702,7 @@ protected:
private:
DeltaAccumulator() :
mX(0.0), mY(0.0), mPendingScrollAmountX(0.0), mPendingScrollAmountY(0.0),
mHandlingDeltaMode(UINT32_MAX), mHandlingPixelOnlyDevice(false)
mHandlingDeltaMode(UINT32_MAX), mIsNoLineOrPageDeltaDevice(false)
{
}
@ -718,7 +718,7 @@ protected:
TimeStamp mLastTime;
uint32_t mHandlingDeltaMode;
bool mHandlingPixelOnlyDevice;
bool mIsNoLineOrPageDeltaDevice;
static DeltaAccumulator* sInstance;
};

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@ interface nsIRunnable;
interface nsICompositionStringSynthesizer;
interface nsITranslationNodeList;
[scriptable, uuid(6f10cbf8-bd4e-4c56-8a5a-35641efcf286)]
[scriptable, uuid(46e3f206-9a8f-4d66-8248-7ec6a37de45a)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -468,9 +468,11 @@ interface nsIDOMWindowUtils : nsISupports {
* scroll.
* @param aOptions Set following flags.
*/
const unsigned long WHEEL_EVENT_CAUSED_BY_PIXEL_ONLY_DEVICE = 0x0001;
const unsigned long WHEEL_EVENT_CAUSED_BY_MOMENTUM = 0x0002;
const unsigned long WHEEL_EVENT_CUSTOMIZED_BY_USER_PREFS = 0x0004;
const unsigned long WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE = 0x0001;
// @deprecated Use WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE.
const unsigned long WHEEL_EVENT_CAUSED_BY_PIXEL_ONLY_DEVICE = 0x0001;
const unsigned long WHEEL_EVENT_CAUSED_BY_MOMENTUM = 0x0002;
const unsigned long WHEEL_EVENT_CUSTOMIZED_BY_USER_PREFS = 0x0004;
// If any of the following flags is specified this method will throw an
// exception in case the relevant overflowDelta has an unexpected value.
const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_ZERO = 0x0010;

View File

@ -317,8 +317,9 @@ function synthesizeTouchAtCenter(aTarget, aEvent, aWindow)
*
* aEvent is an object which may contain the properties:
* shiftKey, ctrlKey, altKey, metaKey, accessKey, deltaX, deltaY, deltaZ,
* deltaMode, lineOrPageDeltaX, lineOrPageDeltaY, isMomentum, isPixelOnlyDevice,
* isCustomizedByPrefs, expectedOverflowDeltaX, expectedOverflowDeltaY
* deltaMode, lineOrPageDeltaX, lineOrPageDeltaY, isMomentum,
* isNoLineOrPageDelta, isCustomizedByPrefs, expectedOverflowDeltaX,
* expectedOverflowDeltaY
*
* deltaMode must be defined, others are ok even if undefined.
*
@ -336,9 +337,8 @@ function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
var modifiers = _parseModifiers(aEvent);
var options = 0;
if (aEvent.isPixelOnlyDevice &&
(aEvent.deltaMode == WheelEvent.DOM_DELTA_PIXEL)) {
options |= utils.WHEEL_EVENT_CAUSED_BY_PIXEL_ONLY_DEVICE;
if (aEvent.isNoLineOrPageDelta) {
options |= utils.WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE;
}
if (aEvent.isMomentum) {
options |= utils.WHEEL_EVENT_CAUSED_BY_MOMENTUM;
@ -364,8 +364,7 @@ function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
options |= utils.WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE;
}
}
var isPixelOnlyDevice =
aEvent.isPixelOnlyDevice && aEvent.deltaMode == WheelEvent.DOM_DELTA_PIXEL;
var isNoLineOrPageDelta = aEvent.isNoLineOrPageDelta;
// Avoid the JS warnings "reference to undefined property"
if (!aEvent.deltaX) {

View File

@ -342,8 +342,9 @@ function synthesizeTouchAtCenter(aTarget, aEvent, aWindow)
*
* aEvent is an object which may contain the properties:
* shiftKey, ctrlKey, altKey, metaKey, accessKey, deltaX, deltaY, deltaZ,
* deltaMode, lineOrPageDeltaX, lineOrPageDeltaY, isMomentum, isPixelOnlyDevice,
* isCustomizedByPrefs, expectedOverflowDeltaX, expectedOverflowDeltaY
* deltaMode, lineOrPageDeltaX, lineOrPageDeltaY, isMomentum,
* isNoLineOrPageDelta, isCustomizedByPrefs, expectedOverflowDeltaX,
* expectedOverflowDeltaY
*
* deltaMode must be defined, others are ok even if undefined.
*
@ -361,9 +362,8 @@ function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
var modifiers = _parseModifiers(aEvent);
var options = 0;
if (aEvent.isPixelOnlyDevice &&
(aEvent.deltaMode == WheelEvent.DOM_DELTA_PIXEL)) {
options |= utils.WHEEL_EVENT_CAUSED_BY_PIXEL_ONLY_DEVICE;
if (aEvent.isNoLineOrPageDelta) {
options |= utils.WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE;
}
if (aEvent.isMomentum) {
options |= utils.WHEEL_EVENT_CAUSED_BY_MOMENTUM;
@ -389,8 +389,7 @@ function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
options |= utils.WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE;
}
}
var isPixelOnlyDevice =
aEvent.isPixelOnlyDevice && aEvent.deltaMode == WheelEvent.DOM_DELTA_PIXEL;
var isNoLineOrPageDelta = aEvent.isNoLineOrPageDelta;
// Avoid the JS warnings "reference to undefined property"
if (!aEvent.deltaX) {

View File

@ -420,7 +420,7 @@ public:
WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, NS_WHEEL_EVENT),
deltaX(0.0), deltaY(0.0), deltaZ(0.0),
deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
customizedByUserPrefs(false), isMomentum(false), mIsNoLineOrPageDelta(false),
lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
overflowDeltaX(0.0), overflowDeltaY(0.0),
mViewPortIsOverscrolled(false)
@ -460,9 +460,9 @@ public:
// If device event handlers don't know when they should set lineOrPageDeltaX
// and lineOrPageDeltaY, this is true. Otherwise, false.
// If isPixelOnlyDevice is true, ESM will generate NS_MOUSE_SCROLL events
// when accumulated pixel delta values reach a line height.
bool isPixelOnlyDevice;
// If mIsNoLineOrPageDelta is true, ESM will generate NS_MOUSE_SCROLL events
// when accumulated delta values reach a line height.
bool mIsNoLineOrPageDelta;
// If widget sets lineOrPageDelta, EventStateManager will dispatch
// NS_MOUSE_SCROLL event for compatibility. Note that the delta value means
@ -531,7 +531,7 @@ public:
deltaMode = aEvent.deltaMode;
customizedByUserPrefs = aEvent.customizedByUserPrefs;
isMomentum = aEvent.isMomentum;
isPixelOnlyDevice = aEvent.isPixelOnlyDevice;
mIsNoLineOrPageDelta = aEvent.mIsNoLineOrPageDelta;
lineOrPageDeltaX = aEvent.lineOrPageDeltaX;
lineOrPageDeltaY = aEvent.lineOrPageDeltaY;
scrollType = aEvent.scrollType;

View File

@ -141,7 +141,7 @@ struct ParamTraits<mozilla::WidgetWheelEvent>
WriteParam(aMsg, aParam.deltaMode);
WriteParam(aMsg, aParam.customizedByUserPrefs);
WriteParam(aMsg, aParam.isMomentum);
WriteParam(aMsg, aParam.isPixelOnlyDevice);
WriteParam(aMsg, aParam.mIsNoLineOrPageDelta);
WriteParam(aMsg, aParam.lineOrPageDeltaX);
WriteParam(aMsg, aParam.lineOrPageDeltaY);
WriteParam(aMsg, static_cast<int32_t>(aParam.scrollType));
@ -161,7 +161,7 @@ struct ParamTraits<mozilla::WidgetWheelEvent>
ReadParam(aMsg, aIter, &aResult->deltaMode) &&
ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) &&
ReadParam(aMsg, aIter, &aResult->isMomentum) &&
ReadParam(aMsg, aIter, &aResult->isPixelOnlyDevice) &&
ReadParam(aMsg, aIter, &aResult->mIsNoLineOrPageDelta) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) &&
ReadParam(aMsg, aIter, &scrollType) &&

View File

@ -576,7 +576,7 @@ nsWinGesture::PanDeltaToPixelScroll(WidgetWheelEvent& aWheelEvent)
aWheelEvent.refPoint.y = mPanRefPoint.y;
aWheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_PIXEL;
aWheelEvent.scrollType = WidgetWheelEvent::SCROLL_SYNCHRONOUSLY;
aWheelEvent.isPixelOnlyDevice = true;
aWheelEvent.mIsNoLineOrPageDelta = true;
aWheelEvent.overflowDeltaX = 0.0;
aWheelEvent.overflowDeltaY = 0.0;