Bug 890821 - Make nsIScrollableFrame::GetScrollPositionCSSPixels return CSSIntPoint; r=roc

This commit is contained in:
Ms2ger 2013-07-10 11:58:13 +02:00
parent 22cefefdd1
commit 5db9476062
5 changed files with 20 additions and 17 deletions

View File

@ -4850,7 +4850,7 @@ nsGlobalWindow::GetScrollXY(int32_t* aScrollX, int32_t* aScrollY,
return GetScrollXY(aScrollX, aScrollY, true);
}
nsIntPoint scrollPosCSSPixels = sf->GetScrollPositionCSSPixels();
CSSIntPoint scrollPosCSSPixels = sf->GetScrollPositionCSSPixels();
if (aScrollX) {
*aScrollX = scrollPosCSSPixels.x;
}
@ -6103,8 +6103,7 @@ nsGlobalWindow::ScrollBy(int32_t aXScrollDif, int32_t aYScrollDif)
if (sf) {
CSSIntPoint scrollPos =
CSSIntPoint::FromAppUnitsRounded(sf->GetScrollPosition()) +
CSSIntPoint(aXScrollDif, aYScrollDif);
sf->GetScrollPositionCSSPixels() + CSSIntPoint(aXScrollDif, aYScrollDif);
// It seems like it would make more sense for ScrollBy to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour.
// Perhaps Web content does too.

View File

@ -1580,7 +1580,7 @@ void
nsGfxScrollFrameInner::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition)
{
nsPoint current = GetScrollPosition();
nsIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
CSSIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition);
nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f);
nsRect range(pt.x - halfPixel, pt.y - halfPixel, 2*halfPixel - 1, 2*halfPixel - 1);
@ -1609,12 +1609,10 @@ nsGfxScrollFrameInner::ScrollToCSSPixelsApproximate(const CSSPoint& aScrollPosit
ScrollTo(pt, nsIScrollableFrame::INSTANT, &range);
}
nsIntPoint
CSSIntPoint
nsGfxScrollFrameInner::GetScrollPositionCSSPixels()
{
nsPoint pt = GetScrollPosition();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
nsPresContext::AppUnitsToIntCSSPixels(pt.y));
return CSSIntPoint::FromAppUnitsRounded(GetScrollPosition());
}
/*

View File

@ -47,6 +47,7 @@ class ScrollbarActivity;
class nsGfxScrollFrameInner : public nsIReflowCallback {
public:
typedef mozilla::CSSIntPoint CSSIntPoint;
typedef mozilla::layout::ScrollbarActivity ScrollbarActivity;
class AsyncScroll;
@ -170,9 +171,9 @@ public:
const nsRect* aRange = nullptr) {
ScrollToWithOrigin(aScrollPosition, aMode, nsGkAtoms::other, aRange);
}
void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition);
void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition);
void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition);
nsIntPoint GetScrollPositionCSSPixels();
CSSIntPoint GetScrollPositionCSSPixels();
void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange);
void ScrollVisual(nsPoint aOldScrolledFramePosition);
void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
@ -377,6 +378,7 @@ class nsHTMLScrollFrame : public nsContainerFrame,
public nsIAnonymousContentCreator,
public nsIStatefulFrame {
public:
typedef mozilla::CSSIntPoint CSSIntPoint;
friend nsIFrame* NS_NewHTMLScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot);
NS_DECL_QUERYFRAME
@ -519,13 +521,13 @@ public:
const nsRect* aRange = nullptr) MOZ_OVERRIDE {
mInner.ScrollTo(aScrollPosition, aMode, aRange);
}
virtual void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition) MOZ_OVERRIDE {
virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition) MOZ_OVERRIDE {
mInner.ScrollToCSSPixels(aScrollPosition);
}
virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition) MOZ_OVERRIDE {
mInner.ScrollToCSSPixelsApproximate(aScrollPosition);
}
virtual nsIntPoint GetScrollPositionCSSPixels() MOZ_OVERRIDE {
virtual CSSIntPoint GetScrollPositionCSSPixels() MOZ_OVERRIDE {
return mInner.GetScrollPositionCSSPixels();
}
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
@ -630,6 +632,8 @@ class nsXULScrollFrame : public nsBoxFrame,
public nsIAnonymousContentCreator,
public nsIStatefulFrame {
public:
typedef mozilla::CSSIntPoint CSSIntPoint;
NS_DECL_QUERYFRAME
NS_DECL_FRAMEARENA_HELPERS
@ -783,13 +787,13 @@ public:
const nsRect* aRange = nullptr) MOZ_OVERRIDE {
mInner.ScrollTo(aScrollPosition, aMode, aRange);
}
virtual void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition) MOZ_OVERRIDE {
virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition) MOZ_OVERRIDE {
mInner.ScrollToCSSPixels(aScrollPosition);
}
virtual void ScrollToCSSPixelsApproximate(const mozilla::CSSPoint& aScrollPosition) MOZ_OVERRIDE {
mInner.ScrollToCSSPixelsApproximate(aScrollPosition);
}
virtual nsIntPoint GetScrollPositionCSSPixels() MOZ_OVERRIDE {
virtual CSSIntPoint GetScrollPositionCSSPixels() MOZ_OVERRIDE {
return mInner.GetScrollPositionCSSPixels();
}
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,

View File

@ -31,6 +31,8 @@ class nsIFrame;
*/
class nsIScrollableFrame : public nsIScrollbarOwner {
public:
typedef mozilla::CSSIntPoint CSSIntPoint;
NS_DECL_QUERYFRAME_TARGET(nsIScrollableFrame)
/**
@ -156,7 +158,7 @@ public:
* rounding to CSS pixels) will be exactly aScrollPosition.
* The scroll mode is INSTANT.
*/
virtual void ScrollToCSSPixels(const mozilla::CSSIntPoint& aScrollPosition) = 0;
virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition) = 0;
/**
* Scrolls to a particular position in float CSS pixels.
* This does not guarantee that GetScrollPositionCSSPixels equals
@ -171,7 +173,7 @@ public:
* Returns the scroll position in integer CSS pixels, rounded to the nearest
* pixel.
*/
virtual nsIntPoint GetScrollPositionCSSPixels() = 0;
virtual CSSIntPoint GetScrollPositionCSSPixels() = 0;
/**
* When scrolling by a relative amount, we can choose various units.
*/

View File

@ -265,7 +265,7 @@ NS_IMETHODIMP nsScrollBoxObject::GetPosition(int32_t *x, int32_t *y)
if (!sf)
return NS_ERROR_FAILURE;
nsIntPoint pt = sf->GetScrollPositionCSSPixels();
CSSIntPoint pt = sf->GetScrollPositionCSSPixels();
*x = pt.x;
*y = pt.y;