Bug 780397: Convert FrameMetrics.mViewportScrollOffset from nsIntPoint to gfx::Point r=roc

This commit is contained in:
Doug Sherk 2012-08-21 21:37:15 -07:00
parent b48d86899d
commit b018fea56e
15 changed files with 164 additions and 99 deletions

View File

@ -328,12 +328,6 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
return NS_ERROR_INVALID_ARG;
}
nsRect lastDisplayPort;
if (nsLayoutUtils::GetDisplayPort(content, &lastDisplayPort) &&
displayport.IsEqualInterior(lastDisplayPort)) {
return NS_OK;
}
content->SetProperty(nsGkAtoms::DisplayPort, new nsRect(displayport),
DestroyNsRect);

View File

@ -121,12 +121,17 @@ interface nsIDOMWindowUtils : nsISupports {
*
* It's legal to set a displayport that extends beyond the overflow
* area in any direction (left/right/top/bottom).
*
*
* It's also legal to set a displayport that extends beyond the
* area's bounds. No pixels are rendered outside the area bounds.
*
* The caller of this method must have UniversalXPConnect
* privileges.
*
* Calling this will always force a recomposite, so it should be
* avoided if at all possible. Client code should do checks before
* calling this so that duplicate sets are not made with the same
* displayport.
*/
void setDisplayPortForElement(in float aXPx, in float aYPx,
in float aWidthPx, in float aHeightPx,

View File

@ -726,8 +726,8 @@ TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
}
nsCString data;
data += nsPrintfCString("{ \"x\" : %d", aFrameMetrics.mViewportScrollOffset.x);
data += nsPrintfCString(", \"y\" : %d", aFrameMetrics.mViewportScrollOffset.y);
data += nsPrintfCString("{ \"x\" : %d", NS_lround(aFrameMetrics.mViewportScrollOffset.x));
data += nsPrintfCString(", \"y\" : %d", NS_lround(aFrameMetrics.mViewportScrollOffset.y));
// We don't treat the x and y scales any differently for this
// semi-platform-specific code.
data += nsPrintfCString(", \"zoom\" : %f", aFrameMetrics.mResolution.width);

View File

@ -71,7 +71,7 @@ public:
// These are all in layer coordinate space.
nsIntRect mViewport;
nsIntRect mContentRect;
nsIntPoint mViewportScrollOffset;
gfx::Point mViewportScrollOffset;
nsIntRect mDisplayPort;
ViewID mScrollId;

View File

@ -123,6 +123,15 @@ AppendToString(nsACString& s, const nsIntPoint& p,
return s += sfx;
}
nsACString&
AppendToString(nsACString& s, const Point& p,
const char* pfx="", const char* sfx="")
{
s += pfx;
s += nsPrintfCString("(x=%f, y=%f)", p.x, p.y);
return s += sfx;
}
nsACString&
AppendToString(nsACString& s, const nsIntRect& r,
const char* pfx="", const char* sfx="")

View File

@ -425,7 +425,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
float scale = mFrameMetrics.mResolution.width;
nsIntPoint focusPoint = aEvent.mFocusPoint;
PRInt32 xFocusChange = (mLastZoomFocus.x - focusPoint.x) / scale, yFocusChange = (mLastZoomFocus.y - focusPoint.y) / scale;
float xFocusChange = (mLastZoomFocus.x - focusPoint.x) / scale, yFocusChange = (mLastZoomFocus.y - focusPoint.y) / scale;
// If displacing by the change in focus point will take us off page bounds,
// then reduce the displacement such that it doesn't.
if (mX.DisplacementWillOverscroll(xFocusChange) != Axis::OVERSCROLL_NONE) {
@ -434,12 +434,12 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
if (mY.DisplacementWillOverscroll(yFocusChange) != Axis::OVERSCROLL_NONE) {
yFocusChange -= mY.DisplacementWillOverscrollAmount(yFocusChange);
}
ScrollBy(nsIntPoint(xFocusChange, yFocusChange));
ScrollBy(gfx::Point(xFocusChange, yFocusChange));
// When we zoom in with focus, we can zoom too much towards the boundaries
// that we actually go over them. These are the needed displacements along
// either axis such that we don't overscroll the boundaries when zooming.
PRInt32 neededDisplacementX = 0, neededDisplacementY = 0;
float neededDisplacementX = 0, neededDisplacementY = 0;
// Only do the scaling if we won't go over 8x zoom in or out.
bool doScale = (scale < MAX_ZOOM && spanRatio > 1.0f) || (scale > MIN_ZOOM && spanRatio < 1.0f);
@ -491,7 +491,7 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
focusPoint);
if (neededDisplacementX != 0 || neededDisplacementY != 0) {
ScrollBy(nsIntPoint(neededDisplacementX, neededDisplacementY));
ScrollBy(gfx::Point(neededDisplacementX, neededDisplacementY));
}
ScheduleComposite();
@ -614,7 +614,7 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
return;
}
ScrollBy(nsIntPoint(xDisplacement, yDisplacement));
ScrollBy(gfx::Point(xDisplacement, yDisplacement));
ScheduleComposite();
RequestContentRepaint();
@ -643,7 +643,7 @@ bool AsyncPanZoomController::DoFling(const TimeDuration& aDelta) {
// larger swipe should move you a shorter distance.
float inverseScale = 1 / mFrameMetrics.mResolution.width;
ScrollBy(nsIntPoint(
ScrollBy(gfx::Point(
mX.GetDisplacementForDuration(inverseScale, aDelta),
mY.GetDisplacementForDuration(inverseScale, aDelta)
));
@ -660,8 +660,8 @@ void AsyncPanZoomController::SetCompositorParent(CompositorParent* aCompositorPa
mCompositorParent = aCompositorParent;
}
void AsyncPanZoomController::ScrollBy(const nsIntPoint& aOffset) {
nsIntPoint newOffset(mFrameMetrics.mViewportScrollOffset.x + aOffset.x,
void AsyncPanZoomController::ScrollBy(const gfx::Point& aOffset) {
gfx::Point newOffset(mFrameMetrics.mViewportScrollOffset.x + aOffset.x,
mFrameMetrics.mViewportScrollOffset.y + aOffset.y);
FrameMetrics metrics(mFrameMetrics);
metrics.mViewportScrollOffset = newOffset;
@ -697,10 +697,10 @@ void AsyncPanZoomController::ScaleWithFocus(float aScale, const nsIntPoint& aFoc
// current CSS page rect (which is unchanged since it's not affected by zoom).
SetPageRect(mFrameMetrics.mCSSContentRect);
nsIntPoint scrollOffset = metrics.mViewportScrollOffset;
gfx::Point scrollOffset = metrics.mViewportScrollOffset;
scrollOffset.x += NS_lround(float(aFocus.x) * (scaleFactor - 1.0f) / oldScale);
scrollOffset.y += NS_lround(float(aFocus.y) * (scaleFactor - 1.0f) / oldScale);
scrollOffset.x += float(aFocus.x) * (scaleFactor - 1.0f) / oldScale;
scrollOffset.y += float(aFocus.y) * (scaleFactor - 1.0f) / oldScale;
metrics.mViewportScrollOffset = scrollOffset;
@ -729,7 +729,7 @@ const nsIntRect AsyncPanZoomController::CalculatePendingDisplayPort() {
nsIntRect viewport = mFrameMetrics.mViewport;
viewport.ScaleRoundIn(1 / scale);
nsIntPoint scrollOffset = mFrameMetrics.mViewportScrollOffset;
gfx::Point scrollOffset = mFrameMetrics.mViewportScrollOffset;
gfx::Point velocity = GetVelocityVector();
// The displayport is relative to the current scroll offset. Here's a little
@ -806,14 +806,30 @@ void AsyncPanZoomController::ScheduleComposite() {
void AsyncPanZoomController::RequestContentRepaint() {
mFrameMetrics.mDisplayPort = CalculatePendingDisplayPort();
gfx::Point oldScrollOffset = mLastPaintRequestMetrics.mViewportScrollOffset,
newScrollOffset = mFrameMetrics.mViewportScrollOffset;
// If we're trying to paint what we already think is painted, discard this
// request since it's a pointless paint.
nsIntRect oldDisplayPort = mLastPaintRequestMetrics.mDisplayPort,
newDisplayPort = mFrameMetrics.mDisplayPort;
oldDisplayPort.MoveBy(mLastPaintRequestMetrics.mViewportScrollOffset);
newDisplayPort.MoveBy(mFrameMetrics.mViewportScrollOffset);
nsRect oldDisplayPort = nsRect(
mLastPaintRequestMetrics.mDisplayPort.x,
mLastPaintRequestMetrics.mDisplayPort.y,
mLastPaintRequestMetrics.mDisplayPort.width,
mLastPaintRequestMetrics.mDisplayPort.height);
if (oldDisplayPort.IsEqualEdges(newDisplayPort) &&
gfx::Rect newDisplayPort = gfx::Rect(
mFrameMetrics.mDisplayPort.x,
mFrameMetrics.mDisplayPort.y,
mFrameMetrics.mDisplayPort.width,
mFrameMetrics.mDisplayPort.height);
oldDisplayPort.MoveBy(oldScrollOffset.x, oldScrollOffset.y);
newDisplayPort.MoveBy(newScrollOffset.x, newScrollOffset.y);
if (fabsf(oldDisplayPort.x - newDisplayPort.x) < EPSILON &&
fabsf(oldDisplayPort.y - newDisplayPort.y) < EPSILON &&
fabsf(oldDisplayPort.width - newDisplayPort.width) < EPSILON &&
fabsf(oldDisplayPort.height - newDisplayPort.height) < EPSILON &&
mFrameMetrics.mResolution.width == mLastPaintRequestMetrics.mResolution.width) {
return;
}
@ -843,8 +859,8 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
float rootScaleX = currentTransform.GetXScale(),
rootScaleY = currentTransform.GetYScale();
nsIntPoint metricsScrollOffset(0, 0);
nsIntPoint scrollOffset;
gfx::Point metricsScrollOffset(0, 0);
gfx::Point scrollOffset;
float localScaleX, localScaleY;
const FrameMetrics& frame = aLayer->GetFrameMetrics();
{
@ -868,7 +884,7 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
mEndZoomToMetrics.mResolution.width * sampledPosition +
mStartZoomToMetrics.mResolution.width * (1 - sampledPosition);
mFrameMetrics.mViewportScrollOffset = nsIntPoint(
mFrameMetrics.mViewportScrollOffset = gfx::Point(
mEndZoomToMetrics.mViewportScrollOffset.x * sampledPosition +
mStartZoomToMetrics.mViewportScrollOffset.x * (1 - sampledPosition),
mEndZoomToMetrics.mViewportScrollOffset.y * sampledPosition +
@ -903,8 +919,8 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
}
nsIntPoint scrollCompensation(
(scrollOffset.x / rootScaleX - metricsScrollOffset.x) * localScaleX,
(scrollOffset.y / rootScaleY - metricsScrollOffset.y) * localScaleY);
NS_lround((scrollOffset.x / rootScaleX - metricsScrollOffset.x) * localScaleX),
NS_lround((scrollOffset.y / rootScaleY - metricsScrollOffset.y) * localScaleY));
ViewTransform treeTransform(-scrollCompensation, localScaleX, localScaleY);
*aNewTransform = gfx3DMatrix(treeTransform) * currentTransform;
@ -979,7 +995,6 @@ void AsyncPanZoomController::CancelDefaultPanZoom() {
void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
gfx::Rect zoomToRect(gfx::Rect(aRect.x, aRect.y, aRect.width, aRect.height));
gfx::Rect cssPageRect = mFrameMetrics.mCSSContentRect;
SetState(ANIMATING_ZOOM);
@ -987,13 +1002,15 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
MonitorAutoLock mon(mMonitor);
nsIntRect viewport = mFrameMetrics.mViewport;
gfx::Rect cssPageRect = mFrameMetrics.mCSSContentRect;
gfx::Point scrollOffset = mFrameMetrics.mViewportScrollOffset;
// If the rect is empty, treat it as a request to zoom out to the full page
// size.
if (zoomToRect.IsEmpty()) {
nsIntRect cssViewport = viewport;
cssViewport.ScaleRoundIn(1 / mFrameMetrics.mResolution.width);
cssViewport.MoveBy(mFrameMetrics.mViewportScrollOffset);
cssViewport.MoveBy(nsIntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y)));
float y = mFrameMetrics.mViewportScrollOffset.y;
float newHeight = cssViewport.height * cssPageRect.width / cssViewport.width;
@ -1043,7 +1060,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
mStartZoomToMetrics = mFrameMetrics;
mEndZoomToMetrics.mViewportScrollOffset =
nsIntPoint(NS_lround(zoomToRect.x), NS_lround(zoomToRect.y));
gfx::Point(zoomToRect.x, zoomToRect.y);
mAnimationStartTime = TimeStamp::Now();

View File

@ -280,7 +280,7 @@ protected:
/**
* Scrolls the viewport by an X,Y offset.
*/
void ScrollBy(const nsIntPoint& aOffset);
void ScrollBy(const gfx::Point& aOffset);
/**
* Scales the viewport by an amount (note that it multiplies this scale in to

View File

@ -94,10 +94,10 @@ void Axis::StartTouch(PRInt32 aPos) {
mLockPanning = false;
}
PRInt32 Axis::GetDisplacementForDuration(float aScale, const TimeDuration& aDelta) {
float Axis::GetDisplacementForDuration(float aScale, const TimeDuration& aDelta) {
float velocityFactor = powf(ACCELERATION_MULTIPLIER,
NS_MAX(0, (mAcceleration - 4) * 3));
PRInt32 displacement = NS_lround(mVelocity * aScale * aDelta.ToMilliseconds() * velocityFactor);
float displacement = mVelocity * aScale * aDelta.ToMilliseconds() * velocityFactor;
// If this displacement will cause an overscroll, throttle it. Can potentially
// bring it to 0 even if the velocity is high.
if (DisplacementWillOverscroll(displacement) != OVERSCROLL_NONE) {
@ -158,7 +158,7 @@ Axis::Overscroll Axis::GetOverscroll() {
return OVERSCROLL_NONE;
}
PRInt32 Axis::GetExcess() {
float Axis::GetExcess() {
switch (GetOverscroll()) {
case OVERSCROLL_MINUS: return GetOrigin() - GetPageStart();
case OVERSCROLL_PLUS: return GetViewportEnd() - GetPageEnd();
@ -186,7 +186,7 @@ Axis::Overscroll Axis::DisplacementWillOverscroll(PRInt32 aDisplacement) {
return OVERSCROLL_NONE;
}
PRInt32 Axis::DisplacementWillOverscrollAmount(PRInt32 aDisplacement) {
float Axis::DisplacementWillOverscrollAmount(PRInt32 aDisplacement) {
switch (DisplacementWillOverscroll(aDisplacement)) {
case OVERSCROLL_MINUS: return (GetOrigin() + aDisplacement) - GetPageStart();
case OVERSCROLL_PLUS: return (GetViewportEnd() + aDisplacement) - GetPageEnd();
@ -197,11 +197,11 @@ PRInt32 Axis::DisplacementWillOverscrollAmount(PRInt32 aDisplacement) {
}
Axis::Overscroll Axis::ScaleWillOverscroll(float aScale, PRInt32 aFocus) {
PRInt32 originAfterScale = NS_lround((GetOrigin() + aFocus) * aScale - aFocus);
float originAfterScale = (GetOrigin() + aFocus) * aScale - aFocus;
bool both = ScaleWillOverscrollBothSides(aScale);
bool minus = originAfterScale < NS_lround(GetPageStart() * aScale);
bool plus = (originAfterScale + GetViewportLength()) > NS_lround(GetPageEnd() * aScale);
bool minus = originAfterScale < GetPageStart() * aScale;
bool plus = (originAfterScale + GetViewportLength()) > GetPageEnd() * aScale;
if ((minus && plus) || both) {
return OVERSCROLL_BOTH;
@ -215,11 +215,11 @@ Axis::Overscroll Axis::ScaleWillOverscroll(float aScale, PRInt32 aFocus) {
return OVERSCROLL_NONE;
}
PRInt32 Axis::ScaleWillOverscrollAmount(float aScale, PRInt32 aFocus) {
PRInt32 originAfterScale = NS_lround((GetOrigin() + aFocus) * aScale - aFocus);
float Axis::ScaleWillOverscrollAmount(float aScale, PRInt32 aFocus) {
float originAfterScale = (GetOrigin() + aFocus) * aScale - aFocus;
switch (ScaleWillOverscroll(aScale, aFocus)) {
case OVERSCROLL_MINUS: return originAfterScale - NS_lround(GetPageStart() * aScale);
case OVERSCROLL_PLUS: return (originAfterScale + GetViewportLength()) - NS_lround(GetPageEnd() * aScale);
case OVERSCROLL_MINUS: return originAfterScale - GetPageStart() * aScale;
case OVERSCROLL_PLUS: return (originAfterScale + GetViewportLength()) - GetPageEnd() * aScale;
// Don't handle OVERSCROLL_BOTH. Client code is expected to deal with it.
default: return 0;
}
@ -229,32 +229,32 @@ float Axis::GetVelocity() {
return mVelocity;
}
PRInt32 Axis::GetViewportEnd() {
float Axis::GetViewportEnd() {
return GetOrigin() + GetViewportLength();
}
PRInt32 Axis::GetPageEnd() {
float Axis::GetPageEnd() {
return GetPageStart() + GetPageLength();
}
PRInt32 Axis::GetOrigin() {
nsIntPoint origin = mAsyncPanZoomController->GetFrameMetrics().mViewportScrollOffset;
float Axis::GetOrigin() {
gfx::Point origin = mAsyncPanZoomController->GetFrameMetrics().mViewportScrollOffset;
return GetPointOffset(origin);
}
PRInt32 Axis::GetViewportLength() {
float Axis::GetViewportLength() {
nsIntRect viewport = mAsyncPanZoomController->GetFrameMetrics().mViewport;
gfx::Rect scaledViewport = gfx::Rect(viewport.x, viewport.y, viewport.width, viewport.height);
scaledViewport.ScaleRoundIn(1 / mAsyncPanZoomController->GetFrameMetrics().mResolution.width);
return GetRectLength(scaledViewport);
}
PRInt32 Axis::GetPageStart() {
float Axis::GetPageStart() {
gfx::Rect pageRect = mAsyncPanZoomController->GetFrameMetrics().mCSSContentRect;
return GetRectOffset(pageRect);
}
PRInt32 Axis::GetPageLength() {
float Axis::GetPageLength() {
gfx::Rect pageRect = mAsyncPanZoomController->GetFrameMetrics().mCSSContentRect;
return GetRectLength(pageRect);
}
@ -280,19 +280,19 @@ AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController)
}
PRInt32 AxisX::GetPointOffset(const nsIntPoint& aPoint)
float AxisX::GetPointOffset(const gfx::Point& aPoint)
{
return aPoint.x;
}
PRInt32 AxisX::GetRectLength(const gfx::Rect& aRect)
float AxisX::GetRectLength(const gfx::Rect& aRect)
{
return NS_lround(aRect.width);
return aRect.width;
}
PRInt32 AxisX::GetRectOffset(const gfx::Rect& aRect)
float AxisX::GetRectOffset(const gfx::Rect& aRect)
{
return NS_lround(aRect.x);
return aRect.x;
}
AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController)
@ -301,19 +301,19 @@ AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController)
}
PRInt32 AxisY::GetPointOffset(const nsIntPoint& aPoint)
float AxisY::GetPointOffset(const gfx::Point& aPoint)
{
return aPoint.y;
}
PRInt32 AxisY::GetRectLength(const gfx::Rect& aRect)
float AxisY::GetRectLength(const gfx::Rect& aRect)
{
return NS_lround(aRect.height);
return aRect.height;
}
PRInt32 AxisY::GetRectOffset(const gfx::Rect& aRect)
float AxisY::GetRectOffset(const gfx::Rect& aRect)
{
return NS_lround(aRect.y);
return aRect.y;
}
}

View File

@ -84,7 +84,7 @@ public:
* apply a displacement that takes you to the boundary of the page, then call
* it again. The result will be different in this case.
*/
PRInt32 GetDisplacementForDuration(float aScale, const TimeDuration& aDelta);
float GetDisplacementForDuration(float aScale, const TimeDuration& aDelta);
/**
* Gets the distance between the starting position of the touch supplied in
@ -114,7 +114,7 @@ public:
* in both directions, this returns 0; it assumes that you check
* GetOverscroll() first.
*/
PRInt32 GetExcess();
float GetExcess();
/**
* Gets the raw velocity of this axis at this moment.
@ -132,7 +132,7 @@ public:
* If a displacement will overscroll the axis, this returns the amount and in
* what direction. Similar to getExcess() but takes a displacement to apply.
*/
PRInt32 DisplacementWillOverscrollAmount(PRInt32 aDisplacement);
float DisplacementWillOverscrollAmount(PRInt32 aDisplacement);
/**
* Gets the overscroll state of the axis given a scaling of the page. That is
@ -153,7 +153,7 @@ public:
* scroll offset in such a way that it remains in the same place on the page
* relative.
*/
PRInt32 ScaleWillOverscrollAmount(float aScale, PRInt32 aFocus);
float ScaleWillOverscrollAmount(float aScale, PRInt32 aFocus);
/**
* Checks if an axis will overscroll in both directions by computing the
@ -164,16 +164,16 @@ public:
*/
bool ScaleWillOverscrollBothSides(float aScale);
PRInt32 GetOrigin();
PRInt32 GetViewportLength();
PRInt32 GetPageStart();
PRInt32 GetPageLength();
PRInt32 GetViewportEnd();
PRInt32 GetPageEnd();
float GetOrigin();
float GetViewportLength();
float GetPageStart();
float GetPageLength();
float GetViewportEnd();
float GetPageEnd();
virtual PRInt32 GetPointOffset(const nsIntPoint& aPoint) = 0;
virtual PRInt32 GetRectLength(const gfx::Rect& aRect) = 0;
virtual PRInt32 GetRectOffset(const gfx::Rect& aRect) = 0;
virtual float GetPointOffset(const gfx::Point& aPoint) = 0;
virtual float GetRectLength(const gfx::Rect& aRect) = 0;
virtual float GetRectOffset(const gfx::Rect& aRect) = 0;
protected:
PRInt32 mPos;
@ -192,17 +192,17 @@ protected:
class AxisX : public Axis {
public:
AxisX(AsyncPanZoomController* mAsyncPanZoomController);
virtual PRInt32 GetPointOffset(const nsIntPoint& aPoint);
virtual PRInt32 GetRectLength(const gfx::Rect& aRect);
virtual PRInt32 GetRectOffset(const gfx::Rect& aRect);
virtual float GetPointOffset(const gfx::Point& aPoint);
virtual float GetRectLength(const gfx::Rect& aRect);
virtual float GetRectOffset(const gfx::Rect& aRect);
};
class AxisY : public Axis {
public:
AxisY(AsyncPanZoomController* mAsyncPanZoomController);
virtual PRInt32 GetPointOffset(const nsIntPoint& aPoint);
virtual PRInt32 GetRectLength(const gfx::Rect& aRect);
virtual PRInt32 GetRectOffset(const gfx::Rect& aRect);
virtual float GetPointOffset(const gfx::Point& aPoint);
virtual float GetRectLength(const gfx::Rect& aRect);
virtual float GetRectOffset(const gfx::Rect& aRect);
};
}

View File

@ -761,7 +761,9 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
if (mIsFirstPaint) {
mContentRect = metrics.mContentRect;
SetFirstPaintViewport(metrics.mViewportScrollOffset,
const gfx::Point& scrollOffset = metrics.mViewportScrollOffset;
SetFirstPaintViewport(nsIntPoint(NS_lround(scrollOffset.x),
NS_lround(scrollOffset.y)),
1/rootScaleX,
mContentRect,
metrics.mCSSContentRect);
@ -775,9 +777,9 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
// notifications, so that Java can take these into account in its response.
// Calculate the absolute display port to send to Java
nsIntRect displayPort = metrics.mDisplayPort;
nsIntPoint scrollOffset = metrics.mViewportScrollOffset;
displayPort.x += scrollOffset.x;
displayPort.y += scrollOffset.y;
gfx::Point scrollOffset = metrics.mViewportScrollOffset;
displayPort.x += NS_lround(scrollOffset.x);
displayPort.y += NS_lround(scrollOffset.y);
SyncViewportInfo(displayPort, 1/rootScaleX, mLayersUpdated,
mScrollOffset, mXScale, mYScale);
@ -794,7 +796,8 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
nsIntPoint metricsScrollOffset(0, 0);
if (metrics.IsScrollable()) {
metricsScrollOffset = metrics.mViewportScrollOffset;
metricsScrollOffset =
nsIntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y));
}
nsIntPoint scrollCompensation(

View File

@ -220,7 +220,9 @@ ReusableTileStoreOGL::DrawTiles(TiledThebesLayerOGL* aLayer,
TransformBounds(gfxRect(parentMetrics.mDisplayPort));
const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics();
const nsIntSize& contentSize = metrics.mContentRect.Size();
const nsIntPoint& contentOrigin = metrics.mContentRect.TopLeft() - metrics.mViewportScrollOffset;
const gfx::Point& scrollOffset = metrics.mViewportScrollOffset;
const nsIntPoint& contentOrigin = metrics.mContentRect.TopLeft() -
nsIntPoint(NS_lround(scrollOffset.x), NS_lround(scrollOffset.y));
gfxRect contentRect = gfxRect(contentOrigin.x, contentOrigin.y,
contentSize.width, contentSize.height);
contentBounds = scrollableLayer->GetEffectiveTransform().TransformBounds(contentRect);

View File

@ -762,6 +762,24 @@ struct ParamTraits<nsIntSize>
}
};
template<>
struct ParamTraits<mozilla::gfx::Point>
{
typedef mozilla::gfx::Point paramType;
static void Write(Message* msg, const paramType& param)
{
WriteParam(msg, param.x);
WriteParam(msg, param.y);
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
return (ReadParam(msg, iter, &result->x) &&
ReadParam(msg, iter, &result->y));
}
};
template<>
struct ParamTraits<mozilla::gfx::Size>
{

View File

@ -591,8 +591,10 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
nsPresContext::AppUnitsToFloatCSSPixels(contentBounds.height));
metrics.mContentRect = contentBounds.ScaleToNearestPixels(
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
metrics.mViewportScrollOffset = scrollableFrame->GetScrollPosition().ScaleToNearestPixels(
aContainerParameters.mXScale, aContainerParameters.mYScale, auPerDevPixel);
nsPoint scrollPosition = scrollableFrame->GetScrollPosition();
metrics.mViewportScrollOffset = mozilla::gfx::Point(
NSAppUnitsToDoublePixels(scrollPosition.x, auPerDevPixel) * aContainerParameters.mXScale,
NSAppUnitsToDoublePixels(scrollPosition.y, auPerDevPixel) * aContainerParameters.mYScale);
}
else {
nsRect contentBounds = aForFrame->GetRect();

View File

@ -158,7 +158,9 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
nsIntPoint scrollOffset =
aConfig.mScrollOffset.ToNearestPixels(auPerDevPixel);
// metricsScrollOffset is in layer coordinates.
nsIntPoint metricsScrollOffset = aMetrics->mViewportScrollOffset;
gfx::Point metricsScrollOffset = aMetrics->mViewportScrollOffset;
nsIntPoint roundedMetricsScrollOffset =
nsIntPoint(NS_lround(metricsScrollOffset.x), NS_lround(metricsScrollOffset.y));
if (aRootFrameLoader->AsyncScrollEnabled() && !aMetrics->mDisplayPort.IsEmpty()) {
// Only use asynchronous scrolling if it is enabled and there is a
@ -166,8 +168,8 @@ ComputeShadowTreeTransform(nsIFrame* aContainerFrame,
// synchronously scrolled for identifying a scroll area before it is
// being actively scrolled.
nsIntPoint scrollCompensation(
(scrollOffset.x / aTempScaleX - metricsScrollOffset.x) * aConfig.mXScale,
(scrollOffset.y / aTempScaleY - metricsScrollOffset.y) * aConfig.mYScale);
(scrollOffset.x / aTempScaleX - roundedMetricsScrollOffset.x) * aConfig.mXScale,
(scrollOffset.y / aTempScaleY - roundedMetricsScrollOffset.y) * aConfig.mYScale);
return ViewTransform(-scrollCompensation, aConfig.mXScale, aConfig.mYScale);
} else {

View File

@ -2338,11 +2338,24 @@ Tab.prototype = {
aDisplayPort = this._dirtiestHackEverToWorkAroundGeckoRounding(aDisplayPort, geckoScrollX, geckoScrollY);
cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
cwu.setDisplayPortForElement((aDisplayPort.left / resolution) - geckoScrollX,
(aDisplayPort.top / resolution) - geckoScrollY,
(aDisplayPort.right - aDisplayPort.left) / resolution,
(aDisplayPort.bottom - aDisplayPort.top) / resolution,
element);
let displayPort = {
x: (aDisplayPort.left / resolution) - geckoScrollX,
y: (aDisplayPort.top / resolution) - geckoScrollY,
width: (aDisplayPort.right - aDisplayPort.left) / resolution,
height: (aDisplayPort.bottom - aDisplayPort.top) / resolution
};
let epsilon = 0.001;
if (this._oldDisplayPort == null ||
Math.abs(displayPort.x - this._oldDisplayPort.x) > epsilon ||
Math.abs(displayPort.y - this._oldDisplayPort.y) > epsilon ||
Math.abs(displayPort.width - this._oldDisplayPort.width) > epsilon ||
Math.abs(displayPort.height - this._oldDisplayPort.height) > epsilon) {
cwu.setDisplayPortForElement(displayPort.x, displayPort.y, displayPort.width, displayPort.height, element);
}
this._oldDisplayPort = displayPort;
},
/*