mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 158756. Need nsIViewManager::IsRectVisible to become GetRectVisisiblity, and return a reason why the rect wasn't visible. r=akk,roc+moz. sr=jst
This commit is contained in:
parent
c8215a38ee
commit
7321ffd8cb
@ -735,10 +735,12 @@ PRBool nsAccessible::IsPartiallyVisible()
|
||||
|
||||
float p2t;
|
||||
presContext->GetPixelsToTwips(&p2t);
|
||||
PRBool isVisible = PR_FALSE;
|
||||
viewManager->IsRectVisible(containingView, relFrameRect, NS_STATIC_CAST(PRUint16, (kMinPixels * p2t)), &isVisible);
|
||||
nsRectVisibility rectVisibility;
|
||||
viewManager->GetRectVisibility(containingView, relFrameRect,
|
||||
NS_STATIC_CAST(PRUint16, (kMinPixels * p2t)),
|
||||
&rectVisibility);
|
||||
|
||||
return isVisible;
|
||||
return rectVisibility == nsRectVisibility_kVisible;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetFocusedNode(nsIDOMNode **aFocusedNode)
|
||||
|
@ -58,6 +58,16 @@ enum nsContentQuality {
|
||||
nsContentQuality_kUnknown
|
||||
};
|
||||
|
||||
enum nsRectVisibility {
|
||||
nsRectVisibility_kVisible,
|
||||
nsRectVisibility_kAboveViewport,
|
||||
nsRectVisibility_kBelowViewport,
|
||||
nsRectVisibility_kLeftOfViewport,
|
||||
nsRectVisibility_kRightOfViewport,
|
||||
nsRectVisibility_kZeroAreaRect
|
||||
};
|
||||
|
||||
|
||||
#define NS_IVIEWMANAGER_IID \
|
||||
{ 0x3a8863d0, 0xa7f3, 0x11d1, \
|
||||
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
@ -522,14 +532,18 @@ public:
|
||||
NS_IMETHOD GetLastUserEventTime(PRUint32& aTime)=0;
|
||||
|
||||
/**
|
||||
* Determine if a rectangle specified in the view's coordinate system
|
||||
* is completely, or partially visible.
|
||||
* Determine if a rectangle specified in the view's coordinate system
|
||||
* is completely, or partially visible.
|
||||
* @param aView view that aRect coordinates are specified relative to
|
||||
* @param aRect rectangle in twips to test for visibility
|
||||
* @param aMinTwips is the min. pixel rows or cols at edge of screen needed for object to be counted visible
|
||||
* @param aIsVisible returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
|
||||
*/
|
||||
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible)=0;
|
||||
* @param aMinTwips is the min. pixel rows or cols at edge of screen
|
||||
* needed for object to be counted visible
|
||||
* @param aRectVisibility returns eVisible if the rect is visible,
|
||||
* otherwise it returns an enum indicating why not
|
||||
*/
|
||||
NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect,
|
||||
PRUint16 aMinTwips,
|
||||
nsRectVisibility *aRectVisibility)=0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1600,9 +1600,9 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU
|
||||
// enhancement since invalidating a native widget
|
||||
// can be expensive.
|
||||
// This also checks for silly request like damagedRect.width = 0 or damagedRect.height = 0
|
||||
PRBool isVisible;
|
||||
IsRectVisible(view, damagedRect, 0, &isVisible);
|
||||
if (!isVisible) {
|
||||
nsRectVisibility rectVisibility;
|
||||
GetRectVisibility(view, damagedRect, 0, &rectVisibility);
|
||||
if (rectVisibility != nsRectVisibility_kVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3845,14 +3845,17 @@ nsresult nsViewManager::GetAbsoluteRect(nsView *aView, const nsRect &aRect,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible)
|
||||
NS_IMETHODIMP nsViewManager::GetRectVisibility(nsIView *aView,
|
||||
const nsRect &aRect,
|
||||
PRUint16 aMinTwips,
|
||||
nsRectVisibility *aRectVisibility)
|
||||
{
|
||||
nsView* view = NS_STATIC_CAST(nsView*, aView);
|
||||
|
||||
// The parameter aMinTwips determines how many rows/cols of pixels must be visible on each side of the element,
|
||||
// in order to be counted as visible
|
||||
|
||||
*aIsVisible = PR_FALSE;
|
||||
*aRectVisibility = nsRectVisibility_kZeroAreaRect;
|
||||
if (aRect.width == 0 || aRect.height == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3867,7 +3870,7 @@ NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect,
|
||||
// Calculate the absolute coordinates for the visible rectangle
|
||||
nsRect visibleRect;
|
||||
if (GetVisibleRect(visibleRect) == NS_ERROR_FAILURE) {
|
||||
*aIsVisible = PR_TRUE;
|
||||
*aRectVisibility = nsRectVisibility_kVisible;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3875,22 +3878,33 @@ NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect,
|
||||
// aRects values are relative to aView
|
||||
nsRect absRect;
|
||||
if ((GetAbsoluteRect(view, aRect, absRect)) == NS_ERROR_FAILURE) {
|
||||
*aIsVisible = PR_TRUE;
|
||||
*aRectVisibility = nsRectVisibility_kVisible;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* If aMinTwips > 0, ensure at least aMinTwips of space around object is visible
|
||||
* The object is visible if:
|
||||
* ((objectTop >= windowTop || objectBottom >= windowTop) &&
|
||||
* (objectLeft >= windowLeft || objectRight >= windowLeft) &&
|
||||
* (objectBottom <= windowBottom || objectTop <= windowBottom) &&
|
||||
* (objectRight <= windowRight || objectLeft <= windowRight))
|
||||
* The object is not visible if:
|
||||
* ((objectTop < windowTop && objectBottom < windowTop) ||
|
||||
* (objectBottom > windowBottom && objectTop > windowBottom) ||
|
||||
* (objectLeft < windowLeft && objectRight < windowLeft) ||
|
||||
* (objectRight > windowRight && objectLeft > windowRight))
|
||||
*/
|
||||
*aIsVisible = ((absRect.y >= visibleRect.y || absRect.y + absRect.height >= visibleRect.y + aMinTwips) &&
|
||||
(absRect.x >= visibleRect.x || absRect.x + absRect.width >= visibleRect.x + aMinTwips) &&
|
||||
(absRect.y + absRect.height <= visibleRect.y + visibleRect.height || absRect.y <= visibleRect.y + visibleRect.height - aMinTwips) &&
|
||||
(absRect.x + absRect.width <= visibleRect.x + visibleRect.width || absRect.x <= visibleRect.x + visibleRect.width - aMinTwips));
|
||||
|
||||
if (absRect.y < visibleRect.y &&
|
||||
absRect.y + absRect.height < visibleRect.y + aMinTwips)
|
||||
*aRectVisibility = nsRectVisibility_kAboveViewport;
|
||||
else if (absRect.y + absRect.height > visibleRect.y + visibleRect.height &&
|
||||
absRect.y > visibleRect.y + visibleRect.height - aMinTwips)
|
||||
*aRectVisibility = nsRectVisibility_kBelowViewport;
|
||||
else if (absRect.x < visibleRect.x &&
|
||||
absRect.x + absRect.width < visibleRect.x + aMinTwips)
|
||||
*aRectVisibility = nsRectVisibility_kLeftOfViewport;
|
||||
else if (absRect.x + absRect.width > visibleRect.x + visibleRect.width &&
|
||||
absRect.x > visibleRect.x + visibleRect.width - aMinTwips)
|
||||
*aRectVisibility = nsRectVisibility_kRightOfViewport;
|
||||
else
|
||||
*aRectVisibility = nsRectVisibility_kVisible;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -226,14 +226,18 @@ public:
|
||||
static PRUint32 gLastUserEventTime;
|
||||
|
||||
/**
|
||||
* Determine if a rectangle specified in the view's coordinate system
|
||||
* is completely, or partially visible.
|
||||
* Determine if a rectangle specified in the view's coordinate system
|
||||
* is completely, or partially visible.
|
||||
* @param aView view that aRect coordinates are specified relative to
|
||||
* @param aRect rectangle in twips to test for visibility
|
||||
* @param aMinTwips is the min. pixel rows or cols at edge of screen needed for object to be counted visible
|
||||
* @param aIsVisible returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
|
||||
*/
|
||||
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible);
|
||||
* @param aMinTwips is the min. pixel rows or cols at edge of screen
|
||||
* needed for object to be counted visible
|
||||
* @param aRectVisibility returns eVisible if the rect is visible,
|
||||
* otherwise it returns an enum indicating why not
|
||||
*/
|
||||
NS_IMETHOD GetRectVisibility(nsIView *aView, const nsRect &aRect,
|
||||
PRUint16 aMinTwips,
|
||||
nsRectVisibility *aRectVisibility);
|
||||
|
||||
protected:
|
||||
virtual ~nsViewManager();
|
||||
|
Loading…
Reference in New Issue
Block a user