Bug 737758: part 1: Propagate mouse wheel event origin from ESM [r=roc]

This commit is contained in:
Avi Halachmi (:avih) 2012-03-26 11:50:30 +02:00
parent 0c86aa782d
commit 5d73a5eeb8
7 changed files with 36 additions and 20 deletions

View File

@ -1935,7 +1935,8 @@ GK_ATOM(VolumeUp, "VolumeUp")
GK_ATOM(VolumeDown, "VolumeDown")
GK_ATOM(Menu, "Menu")
// Smooth scroll profiles
// Smooth scroll events origins
GK_ATOM(mouseWheel, "mouseWheel") // For discrete wheel events (e.g. not OSX magic mouse)
GK_ATOM(pixels, "pixels")
GK_ATOM(lines, "lines")
GK_ATOM(pages, "pages")

View File

@ -2695,7 +2695,8 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aMouseEvent,
nsIScrollableFrame::ScrollUnit aScrollQuantity,
bool aAllowScrollSpeedOverride,
nsQueryContentEvent* aQueryEvent)
nsQueryContentEvent* aQueryEvent,
nsIAtom *aOrigin)
{
nsIScrollableFrame* frameToScroll = nsnull;
nsIFrame* scrollFrame = aTargetFrame;
@ -2857,7 +2858,7 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
nsIntPoint overflow;
frameToScroll->ScrollBy(nsIntPoint(scrollX, scrollY), aScrollQuantity,
mode, &overflow);
mode, &overflow, aOrigin);
aMouseEvent->scrollOverflow = isHorizontal ? overflow.x : overflow.y;
return NS_OK;
}
@ -2867,7 +2868,7 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
aTargetFrame->PresContext()->FrameManager()->GetRootFrame());
if (newFrame)
return DoScrollText(newFrame, aMouseEvent, aScrollQuantity,
aAllowScrollSpeedOverride, aQueryEvent);
aAllowScrollSpeedOverride, aQueryEvent, aOrigin);
}
aMouseEvent->scrollOverflow = numLines;
@ -3213,7 +3214,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
switch (action) {
case MOUSE_SCROLL_N_LINES:
DoScrollText(aTargetFrame, msEvent, nsIScrollableFrame::LINES,
useSysNumLines);
useSysNumLines, nsnull, nsGkAtoms::mouseWheel);
break;
case MOUSE_SCROLL_PAGE:

View File

@ -353,7 +353,8 @@ protected:
nsMouseScrollEvent* aMouseEvent,
nsIScrollableFrame::ScrollUnit aScrollQuantity,
bool aAllowScrollSpeedOverride,
nsQueryContentEvent* aQueryEvent = nsnull);
nsQueryContentEvent* aQueryEvent = nsnull,
nsIAtom *aOrigin = nsnull);
void DoScrollHistory(PRInt32 direction);
void DoScrollZoom(nsIFrame *aTargetFrame, PRInt32 adjustment);
nsresult GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv);

View File

@ -2322,26 +2322,36 @@ void
nsGfxScrollFrameInner::ScrollBy(nsIntPoint aDelta,
nsIScrollableFrame::ScrollUnit aUnit,
nsIScrollableFrame::ScrollMode aMode,
nsIntPoint* aOverflow)
nsIntPoint* aOverflow,
nsIAtom *aOrigin)
{
nsSize deltaMultiplier;
nsCOMPtr<nsIAtom> aProfile = nsGkAtoms::other;
if (!aOrigin){
aOrigin = nsGkAtoms::other;
}
bool isGenericOrigin = (aOrigin == nsGkAtoms::other);
switch (aUnit) {
case nsIScrollableFrame::DEVICE_PIXELS: {
nscoord appUnitsPerDevPixel =
mOuter->PresContext()->AppUnitsPerDevPixel();
deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
aProfile = nsGkAtoms::pixels;
if (isGenericOrigin){
aOrigin = nsGkAtoms::pixels;
}
break;
}
case nsIScrollableFrame::LINES: {
deltaMultiplier = GetLineScrollAmount();
aProfile = nsGkAtoms::lines;
if (isGenericOrigin){
aOrigin = nsGkAtoms::lines;
}
break;
}
case nsIScrollableFrame::PAGES: {
deltaMultiplier = GetPageScrollAmount();
aProfile = nsGkAtoms::pages;
if (isGenericOrigin){
aOrigin = nsGkAtoms::pages;
}
break;
}
case nsIScrollableFrame::WHOLE: {
@ -2361,7 +2371,7 @@ nsGfxScrollFrameInner::ScrollBy(nsIntPoint aDelta,
nsPoint newPos = mDestination +
nsPoint(aDelta.x*deltaMultiplier.width, aDelta.y*deltaMultiplier.height);
ScrollToWithSmoothnessProfile(newPos, aMode, aProfile);
ScrollToWithSmoothnessProfile(newPos, aMode, aOrigin);
if (aOverflow) {
nsPoint clampAmount = mDestination - newPos;

View File

@ -186,7 +186,7 @@ public:
void ScrollToImpl(nsPoint aScrollPosition);
void ScrollVisual(nsPoint aOldScrolledFramePosition);
void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow);
nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow, nsIAtom *aOrigin = nsnull);
void ScrollToRestoredPosition();
nsSize GetLineScrollAmount() const;
nsSize GetPageScrollAmount() const;
@ -490,8 +490,8 @@ public:
mInner.ScrollTo(aScrollPosition, aMode);
}
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow) {
mInner.ScrollBy(aDelta, aUnit, aMode, aOverflow);
nsIntPoint* aOverflow, nsIAtom *aOrigin = nsnull) {
mInner.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin);
}
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
@ -728,8 +728,8 @@ public:
mInner.ScrollTo(aScrollPosition, aMode);
}
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow) {
mInner.ScrollBy(aDelta, aUnit, aMode, aOverflow);
nsIntPoint* aOverflow, nsIAtom *aOrigin = nsnull) {
mInner.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin);
}
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();

View File

@ -165,7 +165,7 @@ public:
* values are in device pixels.
*/
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow = nsnull) = 0;
nsIntPoint* aOverflow = nsnull, nsIAtom *aOrigin = nsnull) = 0;
/**
* This tells the scroll frame to try scrolling to the scroll
* position that was restored from the history. This must be called

View File

@ -1362,8 +1362,10 @@ pref("mousewheel.horizscroll.withmetakey.sysnumlines",true);
// Scrollbars: Clicking scrollbars arrows, clicking scrollbars tracks
// Note: Currently OS X trackpad and magic mouse don't use our smooth scrolling
// Note: These are relevant only when "general.smoothScroll" is enabled
pref("general.smoothScroll.pixels.durationMinMS", 200);
pref("general.smoothScroll.pixels.durationMaxMS", 400);
pref("general.smoothScroll.mouseWheel.durationMinMS", 200);
pref("general.smoothScroll.mouseWheel.durationMaxMS", 400);
pref("general.smoothScroll.pixels.durationMinMS", 150);
pref("general.smoothScroll.pixels.durationMaxMS", 150);
pref("general.smoothScroll.lines.durationMinMS", 150);
pref("general.smoothScroll.lines.durationMaxMS", 150);
pref("general.smoothScroll.pages.durationMinMS", 150);
@ -1372,6 +1374,7 @@ pref("general.smoothScroll.scrollbars.durationMinMS", 150);
pref("general.smoothScroll.scrollbars.durationMaxMS", 150);
pref("general.smoothScroll.other.durationMinMS", 150);
pref("general.smoothScroll.other.durationMaxMS", 150);
pref("general.smoothScroll.mouseWheel", true);
pref("general.smoothScroll.pixels", true);
pref("general.smoothScroll.lines", true);
pref("general.smoothScroll.pages", true);