Bug 719320 part.8-8 widget should be able to speicify the scroll type r=smaug

This commit is contained in:
Masayuki Nakano 2012-08-12 10:42:36 +09:00
parent 3cdce54608
commit 737ff36abf
4 changed files with 54 additions and 15 deletions

View File

@ -755,6 +755,7 @@ nsDOMEvent::DuplicatePrivateData()
wheelEvent->isPixelOnlyDevice = oldWheelEvent->isPixelOnlyDevice;
wheelEvent->lineOrPageDeltaX = oldWheelEvent->lineOrPageDeltaX;
wheelEvent->lineOrPageDeltaY = oldWheelEvent->lineOrPageDeltaY;
wheelEvent->scrollType = oldWheelEvent->scrollType;
wheelEvent->overflowDeltaX = oldWheelEvent->overflowDeltaX;
wheelEvent->overflowDeltaY = oldWheelEvent->overflowDeltaY;
newEvent = wheelEvent;

View File

@ -2901,8 +2901,28 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
-devPixelPageSize.height;
}
nsIScrollableFrame::ScrollMode mode =
isDeltaModePixel ? nsIScrollableFrame::NORMAL : nsIScrollableFrame::SMOOTH;
nsIScrollableFrame::ScrollMode mode;
switch (aEvent->scrollType) {
case widget::WheelEvent::SCROLL_DEFAULT:
if (isDeltaModePixel) {
mode = nsIScrollableFrame::NORMAL;
} else {
mode = nsIScrollableFrame::SMOOTH;
}
break;
case widget::WheelEvent::SCROLL_SYNCHRONOUSLY:
mode = nsIScrollableFrame::INSTANT;
break;
case widget::WheelEvent::SCROLL_ASYNCHRONOUSELY:
mode = nsIScrollableFrame::NORMAL;
break;
case widget::WheelEvent::SCROLL_SMOOTHLY:
mode = nsIScrollableFrame::SMOOTH;
break;
default:
MOZ_NOT_REACHED("Invalid scrollType value comes");
return;
}
nsIntPoint overflow;
aScrollableFrame->ScrollBy(actualDevPixelScrollAmount,

View File

@ -1409,7 +1409,7 @@ public:
deltaX(0.0), deltaY(0.0), deltaZ(0.0),
deltaMode(nsIDOMWheelEvent::DOM_DELTA_PIXEL),
customizedByUserPrefs(false), isMomentum(false), isPixelOnlyDevice(false),
lineOrPageDeltaX(0), lineOrPageDeltaY(0),
lineOrPageDeltaX(0), lineOrPageDeltaY(0), scrollType(SCROLL_DEFAULT),
overflowDeltaX(0.0), overflowDeltaY(0.0)
{
}
@ -1463,6 +1463,17 @@ public:
lineOrPageDeltaX : lineOrPageDeltaY;
}
// Scroll type
// The default value is SCROLL_DEFAULT, which means nsEventStateManager will
// select preferred scroll type automatically.
enum ScrollType {
SCROLL_DEFAULT,
SCROLL_SYNCHRONOUSLY,
SCROLL_ASYNCHRONOUSELY,
SCROLL_SMOOTHLY
};
ScrollType scrollType;
// overflowed delta values, these values are the result of dispatching this
// event.
double overflowDeltaX;

View File

@ -134,24 +134,31 @@ struct ParamTraits<mozilla::widget::WheelEvent>
WriteParam(aMsg, aParam.isPixelOnlyDevice);
WriteParam(aMsg, aParam.lineOrPageDeltaX);
WriteParam(aMsg, aParam.lineOrPageDeltaY);
WriteParam(aMsg, static_cast<PRInt32>(aParam.scrollType));
WriteParam(aMsg, aParam.overflowDeltaX);
WriteParam(aMsg, aParam.overflowDeltaY);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return ReadParam(aMsg, aIter, static_cast<nsMouseEvent_base*>(aResult)) &&
ReadParam(aMsg, aIter, &aResult->deltaX) &&
ReadParam(aMsg, aIter, &aResult->deltaY) &&
ReadParam(aMsg, aIter, &aResult->deltaZ) &&
ReadParam(aMsg, aIter, &aResult->deltaMode) &&
ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) &&
ReadParam(aMsg, aIter, &aResult->isMomentum) &&
ReadParam(aMsg, aIter, &aResult->isPixelOnlyDevice) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) &&
ReadParam(aMsg, aIter, &aResult->overflowDeltaX) &&
ReadParam(aMsg, aIter, &aResult->overflowDeltaY);
PRInt32 scrollType;
bool rv =
ReadParam(aMsg, aIter, static_cast<nsMouseEvent_base*>(aResult)) &&
ReadParam(aMsg, aIter, &aResult->deltaX) &&
ReadParam(aMsg, aIter, &aResult->deltaY) &&
ReadParam(aMsg, aIter, &aResult->deltaZ) &&
ReadParam(aMsg, aIter, &aResult->deltaMode) &&
ReadParam(aMsg, aIter, &aResult->customizedByUserPrefs) &&
ReadParam(aMsg, aIter, &aResult->isMomentum) &&
ReadParam(aMsg, aIter, &aResult->isPixelOnlyDevice) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaX) &&
ReadParam(aMsg, aIter, &aResult->lineOrPageDeltaY) &&
ReadParam(aMsg, aIter, &scrollType) &&
ReadParam(aMsg, aIter, &aResult->overflowDeltaX) &&
ReadParam(aMsg, aIter, &aResult->overflowDeltaY);
aResult->scrollType =
static_cast<mozilla::widget::WheelEvent::ScrollType>(scrollType);
return rv;
}
};