зеркало из https://github.com/mozilla/gecko-dev.git
Bug 719320 part.8-2 GetScrollAmount() should return both width and height for oblique wheel event r=smaug
This commit is contained in:
Родитель
77ea1504a6
Коммит
9058c2c050
|
@ -2582,9 +2582,13 @@ nsEventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
||||||
// we're using nearest scrollable frame's information.
|
// we're using nearest scrollable frame's information.
|
||||||
nsIScrollableFrame* scrollableFrame =
|
nsIScrollableFrame* scrollableFrame =
|
||||||
ComputeScrollTarget(aTargetFrame, aEvent, true);
|
ComputeScrollTarget(aTargetFrame, aEvent, true);
|
||||||
PRInt32 pixelsPerUnit = nsPresContext::AppUnitsToIntCSSPixels(
|
nsSize scrollAmount =
|
||||||
GetScrollAmount(aPresContext, aEvent, aTargetFrame,
|
GetScrollAmount(aPresContext, aEvent, aTargetFrame, scrollableFrame);
|
||||||
scrollableFrame));
|
bool isHorizontal =
|
||||||
|
(aEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) != 0;
|
||||||
|
PRInt32 pixelsPerUnit =
|
||||||
|
nsPresContext::AppUnitsToIntCSSPixels(isHorizontal ? scrollAmount.width :
|
||||||
|
scrollAmount.height);
|
||||||
|
|
||||||
bool isTrusted = (aEvent->flags & NS_EVENT_FLAG_TRUSTED) != 0;
|
bool isTrusted = (aEvent->flags & NS_EVENT_FLAG_TRUSTED) != 0;
|
||||||
nsMouseScrollEvent event(isTrusted, NS_MOUSE_PIXEL_SCROLL, nullptr);
|
nsMouseScrollEvent event(isTrusted, NS_MOUSE_PIXEL_SCROLL, nullptr);
|
||||||
|
@ -2734,7 +2738,7 @@ nsEventStateManager::ComputeScrollTarget(nsIFrame* aTargetFrame,
|
||||||
ComputeScrollTarget(newFrame, aEvent, aForDefaultAction) : nullptr;
|
ComputeScrollTarget(newFrame, aEvent, aForDefaultAction) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord
|
nsSize
|
||||||
nsEventStateManager::GetScrollAmount(nsPresContext* aPresContext,
|
nsEventStateManager::GetScrollAmount(nsPresContext* aPresContext,
|
||||||
nsMouseScrollEvent* aEvent,
|
nsMouseScrollEvent* aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
|
@ -2745,31 +2749,27 @@ nsEventStateManager::GetScrollAmount(nsPresContext* aPresContext,
|
||||||
MOZ_ASSERT(aTargetFrame);
|
MOZ_ASSERT(aTargetFrame);
|
||||||
|
|
||||||
bool isPage = (aEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage) != 0;
|
bool isPage = (aEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage) != 0;
|
||||||
bool isHorizontal =
|
|
||||||
(aEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) != 0;
|
|
||||||
|
|
||||||
if (aScrollableFrame) {
|
if (aScrollableFrame) {
|
||||||
nsSize size = isPage ? aScrollableFrame->GetPageScrollAmount() :
|
return isPage ? aScrollableFrame->GetPageScrollAmount() :
|
||||||
aScrollableFrame->GetLineScrollAmount();
|
aScrollableFrame->GetLineScrollAmount();
|
||||||
return isHorizontal ? size.width : size.height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no scrollable frame and page scrolling, use view port size.
|
// If there is no scrollable frame and page scrolling, use view port size.
|
||||||
if (isPage) {
|
if (isPage) {
|
||||||
nsRect visibleRect = aPresContext->GetVisibleArea();
|
return aPresContext->GetVisibleArea().Size();
|
||||||
return isHorizontal ? visibleRect.width : visibleRect.height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no scrollable frame, we should use root frame's information.
|
// If there is no scrollable frame, we should use root frame's information.
|
||||||
nsIFrame* rootFrame = aPresContext->PresShell()->GetRootFrame();
|
nsIFrame* rootFrame = aPresContext->PresShell()->GetRootFrame();
|
||||||
if (!rootFrame) {
|
if (!rootFrame) {
|
||||||
return 0;
|
return nsSize(0, 0);
|
||||||
}
|
}
|
||||||
nsRefPtr<nsFontMetrics> fm;
|
nsRefPtr<nsFontMetrics> fm;
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(rootFrame, getter_AddRefs(fm),
|
nsLayoutUtils::GetFontMetricsForFrame(rootFrame, getter_AddRefs(fm),
|
||||||
nsLayoutUtils::FontSizeInflationFor(rootFrame));
|
nsLayoutUtils::FontSizeInflationFor(rootFrame));
|
||||||
NS_ENSURE_TRUE(fm, 0);
|
NS_ENSURE_TRUE(fm, nsSize(0, 0));
|
||||||
return fm->MaxHeight();
|
PRInt32 fontHeight = fm->MaxHeight();
|
||||||
|
return nsSize(fontHeight, fontHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -5054,9 +5054,13 @@ nsEventStateManager::PixelDeltaAccumulator::OnMousePixelScrollEvent(
|
||||||
|
|
||||||
nsIScrollableFrame* scrollTarget =
|
nsIScrollableFrame* scrollTarget =
|
||||||
aESM->ComputeScrollTarget(aTargetFrame, aEvent, false);
|
aESM->ComputeScrollTarget(aTargetFrame, aEvent, false);
|
||||||
PRInt32 pixelsPerLine = nsPresContext::AppUnitsToIntCSSPixels(
|
nsSize scrollAmount =
|
||||||
aESM->GetScrollAmount(aPresContext, aEvent,
|
aESM->GetScrollAmount(aPresContext, aEvent, aTargetFrame, scrollTarget);
|
||||||
aTargetFrame, scrollTarget));
|
bool isHorizontal =
|
||||||
|
(aEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) != 0;
|
||||||
|
PRInt32 pixelsPerLine =
|
||||||
|
nsPresContext::AppUnitsToIntCSSPixels(isHorizontal ? scrollAmount.width :
|
||||||
|
scrollAmount.height);
|
||||||
|
|
||||||
if (!mLastTime.IsNull()) {
|
if (!mLastTime.IsNull()) {
|
||||||
TimeDuration duration = TimeStamp::Now() - mLastTime;
|
TimeDuration duration = TimeStamp::Now() - mLastTime;
|
||||||
|
@ -5067,9 +5071,6 @@ nsEventStateManager::PixelDeltaAccumulator::OnMousePixelScrollEvent(
|
||||||
|
|
||||||
mLastTime = TimeStamp::Now();
|
mLastTime = TimeStamp::Now();
|
||||||
|
|
||||||
bool isHorizontal =
|
|
||||||
(aEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) != 0;
|
|
||||||
|
|
||||||
// If the delta direction is changed, we should reset the accumulated values.
|
// If the delta direction is changed, we should reset the accumulated values.
|
||||||
if (mX && isHorizontal && aEvent->delta &&
|
if (mX && isHorizontal && aEvent->delta &&
|
||||||
((aEvent->delta > 0) != (mX > 0))) {
|
((aEvent->delta > 0) != (mX > 0))) {
|
||||||
|
|
|
@ -421,7 +421,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* GetScrollAmount() returns the scroll amount in app units of one line or
|
* GetScrollAmount() returns the scroll amount in app units of one line or
|
||||||
* one page. If the mouse scroll event scrolls a page, returns the page width
|
* one page. If the mouse scroll event scrolls a page, returns the page width
|
||||||
* or height. Otherwise, returns line height.
|
* and height. Otherwise, returns line height by both .width and .height.
|
||||||
*
|
*
|
||||||
* @param aTargetFrame The event target of the wheel event.
|
* @param aTargetFrame The event target of the wheel event.
|
||||||
* Must not be NULL.
|
* Must not be NULL.
|
||||||
|
@ -432,10 +432,10 @@ protected:
|
||||||
* frame. Then, this method uses root frame's
|
* frame. Then, this method uses root frame's
|
||||||
* line height or visible area's width or height.
|
* line height or visible area's width or height.
|
||||||
*/
|
*/
|
||||||
nscoord GetScrollAmount(nsPresContext* aPresContext,
|
nsSize GetScrollAmount(nsPresContext* aPresContext,
|
||||||
nsMouseScrollEvent* aEvent,
|
nsMouseScrollEvent* aEvent,
|
||||||
nsIFrame* aTargetFrame,
|
nsIFrame* aTargetFrame,
|
||||||
nsIScrollableFrame* aScrollableFrame);
|
nsIScrollableFrame* aScrollableFrame);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DoScrollText() scrolls the scrollable frame for aEvent.
|
* DoScrollText() scrolls the scrollable frame for aEvent.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче