зеркало из https://github.com/mozilla/gecko-dev.git
Fix bug 16200 (mostly) for both GFX and native scrollbars by rounding scroll requests to the nearest pixel and, from then on, only using that rounded value. Previously, disagreements (of a fraction of a pixel) between what was on the screen and what was supposed to be there caused rounding problems (particularly at less common logical resolutions). There is a chance this may not be necessary in the future, because transform changes may fix this.
r=dcone
This commit is contained in:
Родитель
13e54cc8d1
Коммит
1946b31471
|
@ -232,21 +232,6 @@ NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdat
|
|||
nsIDeviceContext *dev;
|
||||
float t2p;
|
||||
float p2t;
|
||||
|
||||
// notify the listeners.
|
||||
PRUint32 listenerCount;
|
||||
const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener);
|
||||
nsIScrollPositionListener* listener;
|
||||
if (nsnull != mListeners) {
|
||||
if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
|
||||
for (PRUint32 i = 0; i < listenerCount; i++) {
|
||||
if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
|
||||
listener->ScrollPositionWillChange(this, aX, aY);
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mViewManager->GetDeviceContext(dev);
|
||||
dev->GetAppUnitsToDevUnits(t2p);
|
||||
|
@ -282,10 +267,34 @@ NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdat
|
|||
nscoord aXpx = NSTwipsToIntPixels(aX, t2p);
|
||||
nscoord aYpx = NSTwipsToIntPixels(aY, t2p);
|
||||
|
||||
aX = NSIntPixelsToTwips(aXpx,p2t);
|
||||
aY = NSIntPixelsToTwips(aYpx,p2t);
|
||||
|
||||
// do nothing if the we aren't scrolling.
|
||||
// this needs to be rechecked because of the clamping and
|
||||
// rounding
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
|
||||
// figure out the diff by comparing old pos to new
|
||||
dxPx = mOffsetXpx - aXpx;
|
||||
dyPx = mOffsetYpx - aYpx;
|
||||
|
||||
|
||||
// notify the listeners.
|
||||
PRUint32 listenerCount;
|
||||
const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener);
|
||||
nsIScrollPositionListener* listener;
|
||||
if (nsnull != mListeners) {
|
||||
if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
|
||||
for (PRUint32 i = 0; i < listenerCount; i++) {
|
||||
if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
|
||||
listener->ScrollPositionWillChange(this, aX, aY);
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != scrolledView)
|
||||
{
|
||||
// move the scrolled view to the new location
|
||||
|
|
|
@ -1266,27 +1266,41 @@ NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdate
|
|||
|
||||
mClipView->GetDimensions(&clipSize.width, &clipSize.height);
|
||||
|
||||
// Clamp aX
|
||||
|
||||
if ((aX + clipSize.width) > mSizeX)
|
||||
aX = mSizeX - clipSize.width;
|
||||
|
||||
if (aX < 0)
|
||||
aX = 0;
|
||||
|
||||
// Clamp aY
|
||||
|
||||
if ((aY + clipSize.height) > mSizeY)
|
||||
aY = mSizeY - clipSize.height;
|
||||
|
||||
if (aY < 0)
|
||||
aY = 0;
|
||||
|
||||
aX = NSIntPixelsToTwips(NSTwipsToIntPixels(aX, t2p), p2t);
|
||||
aY = NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t);
|
||||
|
||||
// do nothing if the we aren't scrolling.
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
|
||||
mVScrollBarView->GetWidget(widget);
|
||||
|
||||
if (nsnull != widget) {
|
||||
nsIScrollbar* scrollv = nsnull;
|
||||
if (NS_OK == widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv)) {
|
||||
// Clamp aY
|
||||
|
||||
if ((aY + clipSize.height) > mSizeY)
|
||||
aY = mSizeY - clipSize.height;
|
||||
|
||||
if (aY < 0)
|
||||
aY = 0;
|
||||
|
||||
// Move the scrollbar's thumb
|
||||
|
||||
PRUint32 oldpos = mOffsetY;
|
||||
PRUint32 newpos = NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t);
|
||||
|
||||
scrollv->SetPosition(newpos);
|
||||
scrollv->SetPosition(aY);
|
||||
|
||||
dy = NSTwipsToIntPixels((oldpos - newpos), t2p);
|
||||
dy = NSTwipsToIntPixels((oldpos - aY), t2p);
|
||||
|
||||
NS_RELEASE(scrollv);
|
||||
}
|
||||
|
@ -1299,22 +1313,13 @@ NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdate
|
|||
if (nsnull != widget) {
|
||||
nsIScrollbar* scrollh = nsnull;
|
||||
if (NS_OK == widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
// Clamp aX
|
||||
|
||||
if ((aX + clipSize.width) > mSizeX)
|
||||
aX = mSizeX - clipSize.width;
|
||||
|
||||
if (aX < 0)
|
||||
aX = 0;
|
||||
|
||||
// Move the scrollbar's thumb
|
||||
|
||||
PRUint32 oldpos = mOffsetX;
|
||||
PRUint32 newpos = NSIntPixelsToTwips(NSTwipsToIntPixels(aX, t2p), p2t);
|
||||
|
||||
scrollh->SetPosition(newpos);
|
||||
scrollh->SetPosition(aX);
|
||||
|
||||
dx = NSTwipsToIntPixels((oldpos - newpos), t2p);
|
||||
dx = NSTwipsToIntPixels((oldpos - aX), t2p);
|
||||
|
||||
NS_RELEASE(scrollh);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче