mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 120176. Active Accessibility: tweaks to STATE_OFFSCREEN. r=kmcclusk, sr=waterson
This commit is contained in:
parent
5f8c7a55cf
commit
917db0977f
@ -601,8 +601,13 @@ nsresult nsAccessible::GetTranslatedString(const nsAReadableString& aKey, nsAWri
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsAccessible::IsEntirelyVisible()
|
||||
PRBool nsAccessible::IsPartiallyVisible()
|
||||
{
|
||||
// We need to know if at least a kMinPixels around the object is visible
|
||||
// Otherwise it will be marked STATE_OFFSCREEN and STATE_INVISIBLE
|
||||
|
||||
const PRUint16 kMinPixels = 12;
|
||||
|
||||
// Set up the variables we need, return false if we can't get at them all
|
||||
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
|
||||
if (!shell)
|
||||
@ -643,8 +648,10 @@ PRBool nsAccessible::IsEntirelyVisible()
|
||||
relFrameRect.y = frameOffset.y;
|
||||
}
|
||||
|
||||
float p2t;
|
||||
presContext->GetPixelsToTwips(&p2t);
|
||||
PRBool isVisible = PR_FALSE;
|
||||
viewManager->IsRectVisible(containingView, relFrameRect, PR_TRUE, &isVisible);
|
||||
viewManager->IsRectVisible(containingView, relFrameRect, kMinPixels * p2t, &isVisible);
|
||||
|
||||
return isVisible;
|
||||
}
|
||||
@ -702,7 +709,7 @@ NS_IMETHODIMP nsAccessible::GetAccState(PRUint32 *aAccState)
|
||||
}
|
||||
|
||||
// Check if STATE_OFFSCREEN bitflag should be turned on for this object
|
||||
if (!IsEntirelyVisible())
|
||||
if (!IsPartiallyVisible())
|
||||
*aAccState |= STATE_OFFSCREEN | STATE_INVISIBLE;
|
||||
|
||||
return rv;
|
||||
|
@ -95,7 +95,7 @@ protected:
|
||||
virtual nsIFrame* GetBoundsFrame();
|
||||
virtual void GetBounds(nsRect& aRect, nsIFrame** aRelativeFrame);
|
||||
virtual void GetPresContext(nsCOMPtr<nsIPresContext>& aContext);
|
||||
PRBool IsEntirelyVisible();
|
||||
PRBool IsPartiallyVisible();
|
||||
NS_IMETHOD AppendLabelText(nsIDOMNode *aLabelNode, nsAWritableString& _retval);
|
||||
NS_IMETHOD AppendLabelFor(nsIContent *aLookNode, nsAReadableString *aId, nsAWritableString *aLabel);
|
||||
NS_IMETHOD GetHTMLAccName(nsAWritableString& _retval);
|
||||
|
@ -520,12 +520,12 @@ public:
|
||||
/**
|
||||
* Determine if a rectangle specified in the view's coordinate system
|
||||
* is completely, or partially visible.
|
||||
* The view must be in the view hierarchy.
|
||||
* @param aView view that aRect coordinates are specified relative to
|
||||
* @param aRect rectangle in twips to test for visibility
|
||||
* @returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
|
||||
* @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, PRBool aMustBeFullyVisible, PRBool *aIsVisible)=0;
|
||||
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible)=0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1623,7 +1623,7 @@ NS_IMETHODIMP nsViewManager::UpdateView(nsIView *aView, const nsRect &aRect, PRU
|
||||
// can be expensive.
|
||||
// This also checks for silly request like damagedRect.width = 0 or damagedRect.height = 0
|
||||
PRBool isVisible;
|
||||
IsRectVisible(view, damagedRect, PR_FALSE, &isVisible);
|
||||
IsRectVisible(view, damagedRect, 0, &isVisible);
|
||||
if (!isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3426,12 +3426,12 @@ nsresult nsViewManager::GetAbsoluteRect(nsView *aView, const nsRect &aRect,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeEntirelyVisible, PRBool *aIsVisible)
|
||||
NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible)
|
||||
{
|
||||
nsView* view = NS_STATIC_CAST(nsView*, aView);
|
||||
|
||||
// The parameter PRBool aMustBeEntirelyVisible determines if rectangle that is partially on the screen
|
||||
// and partially off the screen should be counted as visible
|
||||
// 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;
|
||||
if (aRect.width == 0 || aRect.height == 0) {
|
||||
@ -3460,11 +3460,18 @@ NS_IMETHODIMP nsViewManager::IsRectVisible(nsIView *aView, const nsRect &aRect,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Compare the visible rect against the rect passed in.
|
||||
if (aMustBeEntirelyVisible)
|
||||
*aIsVisible = visibleRect.Contains(absRect);
|
||||
else
|
||||
*aIsVisible = absRect.IntersectRect(absRect, visibleRect);
|
||||
/*
|
||||
* 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))
|
||||
*/
|
||||
*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));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -238,9 +238,10 @@ public:
|
||||
* is completely, or partially visible.
|
||||
* @param aView view that aRect coordinates are specified relative to
|
||||
* @param aRect rectangle in twips to test for visibility
|
||||
* @returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
|
||||
* @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, PRBool aMustBeFullyVisible, PRBool *isVisible);
|
||||
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible);
|
||||
|
||||
protected:
|
||||
virtual ~nsViewManager();
|
||||
|
@ -1184,7 +1184,7 @@ NS_IMETHODIMP nsViewManager2::UpdateView(nsIView *aView, const nsRect &aRect, PR
|
||||
// can be expensive.
|
||||
// This also checks for silly request like damagedRect.width = 0 or damagedRect.height = 0
|
||||
PRBool isVisible;
|
||||
IsRectVisible(aView, damagedRect, PR_FALSE, &isVisible);
|
||||
IsRectVisible(aView, damagedRect, 0, &isVisible);
|
||||
if (!isVisible) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2849,10 +2849,10 @@ nsresult nsViewManager2::GetAbsoluteRect(nsIView *aView, const nsRect &aRect,
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsViewManager2::IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeEntirelyVisible, PRBool *aIsVisible)
|
||||
NS_IMETHODIMP nsViewManager2::IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible)
|
||||
{
|
||||
// The parameter PRBool aMustBeEntirelyVisible determines if rectangle that is partially on the screen
|
||||
// and partially off the screen should be counted as visible
|
||||
// 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;
|
||||
if (aRect.width == 0 || aRect.height == 0) {
|
||||
@ -2881,11 +2881,18 @@ NS_IMETHODIMP nsViewManager2::IsRectVisible(nsIView *aView, const nsRect &aRect,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Compare the visible rect against the rect passed in.
|
||||
if (aMustBeEntirelyVisible)
|
||||
*aIsVisible = visibleRect.Contains(absRect);
|
||||
else
|
||||
*aIsVisible = absRect.IntersectRect(absRect, visibleRect);
|
||||
/*
|
||||
* 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))
|
||||
*/
|
||||
*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 0
|
||||
// Debugging code
|
||||
|
@ -254,9 +254,10 @@ private:
|
||||
* is completely, or partially visible.
|
||||
* @param aView view that aRect coordinates are specified relative to
|
||||
* @param aRect rectangle in twips to test for visibility
|
||||
* @returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
|
||||
* @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, PRBool aMustBeFullyVisible, PRBool *isVisible);
|
||||
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRUint16 aMinTwips, PRBool *aIsVisible);
|
||||
|
||||
nsresult ProcessWidgetChanges(nsIView* aView);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user