зеркало из https://github.com/mozilla/pjs.git
Bug 132158. Active Accessibility: expose correct bounds information and accessible value for HTML areas. r=saari, sr=alecf.
This commit is contained in:
Родитель
ca8e66bd5e
Коммит
96b6202731
|
@ -119,6 +119,7 @@ class nsRootAccessible : public nsAccessible,
|
|||
NS_IMETHOD Select(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Input(nsIDOMEvent* aEvent);
|
||||
|
||||
// ----- nsIDOMXULListener ---------------------------
|
||||
NS_IMETHOD PopupShowing(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupShown(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD PopupHiding(nsIDOMEvent* aEvent);
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "nsIImageMap.h"
|
||||
|
||||
|
||||
// --- area -----
|
||||
|
@ -62,6 +65,8 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccName(nsAString & _retval)
|
|||
if (elt) {
|
||||
nsAutoString hrefString;
|
||||
elt->GetAttribute(NS_LITERAL_STRING("title"), _retval);
|
||||
if (_retval.IsEmpty())
|
||||
GetAccValue(_retval);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -73,15 +78,6 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccRole(PRUint32 *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getAccValue (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccValue(nsAString& _retval)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(mDOMNode));
|
||||
if (elt)
|
||||
elt->GetAttribute(NS_LITERAL_STRING("href"), _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* wstring getAccDescription (); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::GetAccDescription(nsAString& _retval)
|
||||
{
|
||||
|
@ -159,11 +155,51 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetAccPreviousSibling(nsIAccessible * *aAccP
|
|||
/* void accGetBounds (out long x, out long y, out long width, out long height); */
|
||||
NS_IMETHODIMP nsHTMLAreaAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
//nsIFrame *frame;
|
||||
// Do a better job on this later - need to use GetRect on mAreas of nsImageMap from nsImageFrame
|
||||
//return mAccParent->nsAccessible::AccGetBounds(x,y,width,height);
|
||||
// Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame
|
||||
|
||||
*x = *y = *width = *height = 0;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mPresShell));
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIContent> ourContent(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(ourContent, NS_ERROR_FAILURE);
|
||||
|
||||
nsIFrame *frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(ourContent, &frame);
|
||||
nsIImageFrame *imageFrame;
|
||||
nsresult rv = frame->QueryInterface(NS_GET_IID(nsIImageFrame), (void**)&imageFrame);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIImageMap> map;
|
||||
imageFrame->GetImageMap(presContext, getter_AddRefs(map));
|
||||
NS_ENSURE_TRUE(map, NS_ERROR_FAILURE);
|
||||
|
||||
nsRect rect, orgRectPixels, pageRectPixels;
|
||||
rv = map->GetBoundsForAreaContent(ourContent, presContext, rect);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Convert from twips to pixels
|
||||
float t2p;
|
||||
presContext->GetTwipsToPixels(&t2p); // Get pixels conversion factor
|
||||
*x = NSTwipsToIntPixels(rect.x, t2p);
|
||||
*y = NSTwipsToIntPixels(rect.y, t2p);
|
||||
|
||||
// XXX aaronl not sure why we have to subtract the x,y from the width, height
|
||||
// -- but it works perfectly!
|
||||
*width = NSTwipsToIntPixels(rect.width, t2p) - *x;
|
||||
*height = NSTwipsToIntPixels(rect.height, t2p) - *y;
|
||||
|
||||
// Put coords in absolute screen coords
|
||||
GetScreenOrigin(presContext, frame, &orgRectPixels);
|
||||
GetScrollOffset(&pageRectPixels);
|
||||
*x += orgRectPixels.x - pageRectPixels.x;
|
||||
*y += orgRectPixels.y - pageRectPixels.y;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ public:
|
|||
nsHTMLAreaAccessible(nsIDOMNode *domNode, nsIAccessible *accParent, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccName(nsAString & _retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccValue(nsAString& _retval);
|
||||
NS_IMETHOD GetAccFirstChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccLastChild(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccChildCount(PRInt32 *_retval);
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIImageMap_h___
|
||||
#define nsIImageMap_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIContent;
|
||||
struct nsRect;
|
||||
|
||||
#define NS_IIMAGEMAP_IID \
|
||||
{ 0x36a48085, 0xc213, 0x4464, { 0xab, 0x60, 0x41, 0x2e, 0xc8, 0xe8, 0xb1, 0xfe } }
|
||||
|
||||
|
||||
class nsIImageMap : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEMAP_IID)
|
||||
|
||||
NS_IMETHOD GetBoundsForAreaContent(nsIContent *aContent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsRect& aBounds) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIImageMap_h___ */
|
|
@ -46,6 +46,7 @@ nsIFrameSelection.h \
|
|||
nsIFrameTraversal.h \
|
||||
nsIFrameUtil.h \
|
||||
nsIImageFrame.h \
|
||||
nsIImageMap.h \
|
||||
nsIIndependentSelection.h \
|
||||
nsILayoutDebugger.h \
|
||||
nsILayoutHistoryState.h \
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "nsISupports.h"
|
||||
struct nsSize;
|
||||
class imgIRequest;
|
||||
class nsIPresContext;
|
||||
class nsIImageMap;
|
||||
|
||||
// {B261A0D5-E696-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_IIMAGEFRAME_IID \
|
||||
|
@ -57,6 +59,8 @@ public:
|
|||
NS_IMETHOD GetImageRequest(imgIRequest **aRequest) = 0;
|
||||
|
||||
NS_IMETHOD IsImageComplete(PRBool* aComplete) = 0;
|
||||
|
||||
NS_IMETHOD GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIImageFrame_h___ */
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIImageMap_h___
|
||||
#define nsIImageMap_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIContent;
|
||||
struct nsRect;
|
||||
|
||||
#define NS_IIMAGEMAP_IID \
|
||||
{ 0x36a48085, 0xc213, 0x4464, { 0xab, 0x60, 0x41, 0x2e, 0xc8, 0xe8, 0xb1, 0xfe } }
|
||||
|
||||
|
||||
class nsIImageMap : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGEMAP_IID)
|
||||
|
||||
NS_IMETHOD GetBoundsForAreaContent(nsIContent *aContent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsRect& aBounds) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIImageMap_h___ */
|
|
@ -40,6 +40,8 @@
|
|||
#include "nsISupports.h"
|
||||
struct nsSize;
|
||||
class imgIRequest;
|
||||
class nsIPresContext;
|
||||
class nsIImageMap;
|
||||
|
||||
// {B261A0D5-E696-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_IIMAGEFRAME_IID \
|
||||
|
@ -57,6 +59,8 @@ public:
|
|||
NS_IMETHOD GetImageRequest(imgIRequest **aRequest) = 0;
|
||||
|
||||
NS_IMETHOD IsImageComplete(PRBool* aComplete) = 0;
|
||||
|
||||
NS_IMETHOD GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIImageFrame_h___ */
|
||||
|
|
|
@ -1455,6 +1455,13 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, nsISelectionDisplay::DISPLAY_IMAGES);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap)
|
||||
{
|
||||
nsImageMap *map = GetImageMap(aPresContext);
|
||||
return map->QueryInterface(NS_GET_IID(nsIImageMap), (void**)aImageMap);
|
||||
}
|
||||
|
||||
nsImageMap*
|
||||
nsImageFrame::GetImageMap(nsIPresContext* aPresContext)
|
||||
{
|
||||
|
|
|
@ -140,6 +140,8 @@ public:
|
|||
NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap);
|
||||
|
||||
NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize);
|
||||
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsIFrameManager.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsIImageMap.h"
|
||||
|
||||
class Area {
|
||||
public:
|
||||
|
@ -786,6 +787,9 @@ nsImageMap::QueryInterface(REFNSIID iid, void** result)
|
|||
iid.Equals(NS_GET_IID(nsIDOMEventListener))) {
|
||||
*result = NS_STATIC_CAST(nsIDOMFocusListener*, this);
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIImageMap))) {
|
||||
*result = NS_STATIC_CAST(nsIImageMap*, this);
|
||||
}
|
||||
else {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
@ -794,6 +798,23 @@ nsImageMap::QueryInterface(REFNSIID iid, void** result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageMap::GetBoundsForAreaContent(nsIContent *aContent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsRect& aBounds)
|
||||
{
|
||||
// Find the Area struct associated with this content node, and return bounds
|
||||
PRInt32 i, n = mAreas.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
Area* area = (Area*) mAreas.ElementAt(i);
|
||||
if (area->mArea == aContent) {
|
||||
area->GetRect(aPresContext, aBounds);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageMap::FreeAreas()
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImageMap.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMHTMLAreaElement;
|
||||
|
@ -53,7 +54,8 @@ class nsIURI;
|
|||
class nsString;
|
||||
class nsIDOMEvent;
|
||||
|
||||
class nsImageMap : public nsIDocumentObserver, public nsIDOMFocusListener
|
||||
class nsImageMap : public nsIDocumentObserver, public nsIDOMFocusListener,
|
||||
public nsIImageMap
|
||||
{
|
||||
public:
|
||||
nsImageMap();
|
||||
|
@ -156,6 +158,11 @@ public:
|
|||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
//nsIImageMap
|
||||
NS_IMETHOD GetBoundsForAreaContent(nsIContent *aContent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsRect& aBounds);
|
||||
|
||||
protected:
|
||||
virtual ~nsImageMap();
|
||||
|
||||
|
|
|
@ -1455,6 +1455,13 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, nsISelectionDisplay::DISPLAY_IMAGES);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap)
|
||||
{
|
||||
nsImageMap *map = GetImageMap(aPresContext);
|
||||
return map->QueryInterface(NS_GET_IID(nsIImageMap), (void**)aImageMap);
|
||||
}
|
||||
|
||||
nsImageMap*
|
||||
nsImageFrame::GetImageMap(nsIPresContext* aPresContext)
|
||||
{
|
||||
|
|
|
@ -140,6 +140,8 @@ public:
|
|||
NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap);
|
||||
|
||||
NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize);
|
||||
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsIFrameManager.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsIImageMap.h"
|
||||
|
||||
class Area {
|
||||
public:
|
||||
|
@ -786,6 +787,9 @@ nsImageMap::QueryInterface(REFNSIID iid, void** result)
|
|||
iid.Equals(NS_GET_IID(nsIDOMEventListener))) {
|
||||
*result = NS_STATIC_CAST(nsIDOMFocusListener*, this);
|
||||
}
|
||||
else if (iid.Equals(NS_GET_IID(nsIImageMap))) {
|
||||
*result = NS_STATIC_CAST(nsIImageMap*, this);
|
||||
}
|
||||
else {
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
@ -794,6 +798,23 @@ nsImageMap::QueryInterface(REFNSIID iid, void** result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageMap::GetBoundsForAreaContent(nsIContent *aContent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsRect& aBounds)
|
||||
{
|
||||
// Find the Area struct associated with this content node, and return bounds
|
||||
PRInt32 i, n = mAreas.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
Area* area = (Area*) mAreas.ElementAt(i);
|
||||
if (area->mArea == aContent) {
|
||||
area->GetRect(aPresContext, aBounds);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageMap::FreeAreas()
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImageMap.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMHTMLAreaElement;
|
||||
|
@ -53,7 +54,8 @@ class nsIURI;
|
|||
class nsString;
|
||||
class nsIDOMEvent;
|
||||
|
||||
class nsImageMap : public nsIDocumentObserver, public nsIDOMFocusListener
|
||||
class nsImageMap : public nsIDocumentObserver, public nsIDOMFocusListener,
|
||||
public nsIImageMap
|
||||
{
|
||||
public:
|
||||
nsImageMap();
|
||||
|
@ -156,6 +158,11 @@ public:
|
|||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
//nsIImageMap
|
||||
NS_IMETHOD GetBoundsForAreaContent(nsIContent *aContent,
|
||||
nsIPresContext* aPresContext,
|
||||
nsRect& aBounds);
|
||||
|
||||
protected:
|
||||
virtual ~nsImageMap();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче