Bug 299748 On listbox, Sometimes, We cannot scroll the page to bottom by mouse wheel r+sr=roc, a=asa

This commit is contained in:
masayuki%d-toybox.com 2005-07-07 15:53:07 +00:00
Родитель bc1083033a
Коммит 1ffaf0e3af
4 изменённых файлов: 70 добавлений и 25 удалений

Просмотреть файл

@ -1722,21 +1722,11 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext,
scrollView->GetLineHeight(&lineHeight);
if (lineHeight != 0) {
nscoord xPos, yPos;
scrollView->GetScrollPosition(xPos, yPos);
if (aNumLines < 0) {
passToParent = aScrollHorizontal ? (xPos <= 0) : (yPos <= 0);
} else {
nsSize scrolledSize;
scrollView->GetContainerSize(&scrolledSize.width, &scrolledSize.height);
nsRect portRect = scrollView->View()->GetBounds();
passToParent = (aScrollHorizontal ?
(xPos + portRect.width >= scrolledSize.width) :
(yPos + portRect.height >= scrolledSize.height));
}
PRBool canScroll;
nsresult rv = scrollView->CanScroll(aScrollHorizontal,
(aNumLines > 0), canScroll);
if (NS_SUCCEEDED(rv))
passToParent = !canScroll;
// Comboboxes need special care.
nsIComboboxControlFrame* comboBox = nsnull;

Просмотреть файл

@ -175,6 +175,15 @@ public:
*/
NS_IMETHOD ScrollByWhole(PRBool aTop) = 0;
/**
* Check the view can scroll from current offset.
* @param aHorizontal If checking to Left or to Right, true. Otherwise, false.
* @param aForward If checking to Right or Bottom, true. Otherwise, false.
* @param aResult If the view can scroll, true. Otherwise, false.
* @return error status
*/
NS_IMETHOD CanScroll(PRBool aHorizontal, PRBool aForward, PRBool &aResult) = 0;
/**
* Returns the view as an nsIView*
*/

Просмотреть файл

@ -468,6 +468,55 @@ NS_IMETHODIMP nsScrollPortView::ScrollByWhole(PRBool aTop)
return NS_OK;
}
NS_IMETHODIMP nsScrollPortView::CanScroll(PRBool aHorizontal,
PRBool aForward,
PRBool &aResult)
{
nscoord offset = aHorizontal ? mOffsetX : mOffsetY;
// Can scroll to Top or to Left?
if (!aForward) {
aResult = (offset > 0) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
nsView* scrolledView = GetScrolledView();
if (!scrolledView) {
aResult = PR_FALSE;
return NS_ERROR_FAILURE;
}
nsSize scrolledSize;
scrolledView->GetDimensions(scrolledSize);
nsSize portSize;
GetDimensions(portSize);
nsCOMPtr<nsIDeviceContext> dev;
mViewManager->GetDeviceContext(*getter_AddRefs(dev));
float t2p, p2t;
t2p = dev->AppUnitsToDevUnits();
p2t = dev->DevUnitsToAppUnits();
nscoord max;
if (aHorizontal) {
max = scrolledSize.width - portSize.width;
// Round by pixel
nscoord maxPx = NSTwipsToIntPixels(max, t2p);
max = NSIntPixelsToTwips(maxPx, p2t);
} else {
max = scrolledSize.height - portSize.height;
// Round by pixel
nscoord maxPx = NSTwipsToIntPixels(max, t2p);
max = NSIntPixelsToTwips(maxPx, p2t);
}
// Can scroll to Bottom or to Right?
aResult = (offset < max) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
PRBool nsScrollPortView::CannotBitBlt(nsView* aScrolledView)
{
PRUint32 scrolledViewFlags = aScrolledView->GetViewFlags();
@ -565,16 +614,12 @@ NS_IMETHODIMP nsScrollPortView::ScrollToImpl(nscoord aX, nscoord aY, PRUint32 aU
PRInt32 dxPx = 0, dyPx = 0;
// convert to pixels
nsIDeviceContext *dev;
float t2p;
float p2t;
mViewManager->GetDeviceContext(dev);
nsCOMPtr<nsIDeviceContext> dev;
mViewManager->GetDeviceContext(*getter_AddRefs(dev));
float t2p, p2t;
t2p = dev->AppUnitsToDevUnits();
p2t = dev->DevUnitsToAppUnits();
NS_RELEASE(dev);
// Update the scrolled view's position
nsresult rv = ClampScrollValues(aX, aY, this);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -77,6 +77,7 @@ public:
NS_IMETHOD GetPageScrollDistances(nsSize *aDistances);
NS_IMETHOD ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY);
NS_IMETHOD ScrollByWhole(PRBool aTop);
NS_IMETHOD CanScroll(PRBool aHorizontal, PRBool aForward, PRBool &aResult);
NS_IMETHOD_(nsIView*) View();