2001-09-25 00:48:50 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-05-11 21:11:38 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
2001-05-11 21:11:38 +00:00
|
|
|
*
|
2001-09-25 00:48:50 +00:00
|
|
|
* 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.
|
2001-05-11 21:11:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 00:48:50 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-05-11 21:11:38 +00:00
|
|
|
*
|
2001-09-25 00:48:50 +00:00
|
|
|
* Contributor(s):
|
2004-04-17 21:52:36 +00:00
|
|
|
* Author: Aaron Leventhal (aaronl@netscape.com)
|
2001-09-25 00:48:50 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of 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"),
|
2001-09-25 00:48:50 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 00:48:50 +00:00
|
|
|
* 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
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 00:48:50 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2003-04-22 07:38:18 +00:00
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "imgIRequest.h"
|
2007-07-16 12:42:36 +00:00
|
|
|
|
2001-05-11 21:11:38 +00:00
|
|
|
#include "nsHTMLImageAccessible.h"
|
2005-03-20 14:25:03 +00:00
|
|
|
#include "nsAccessibilityAtoms.h"
|
2007-07-16 12:42:36 +00:00
|
|
|
#include "nsHTMLAreaAccessible.h"
|
|
|
|
|
2003-04-22 07:38:18 +00:00
|
|
|
#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIDocument.h"
|
2001-05-11 21:11:38 +00:00
|
|
|
#include "nsIHTMLDocument.h"
|
2003-04-22 07:38:18 +00:00
|
|
|
#include "nsIImageLoadingContent.h"
|
2008-03-06 03:33:33 +00:00
|
|
|
#include "nsILink.h"
|
2003-04-15 08:45:55 +00:00
|
|
|
#include "nsIPresShell.h"
|
2001-05-11 21:11:38 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2006-07-31 05:21:46 +00:00
|
|
|
#include "nsIDOMHTMLImageElement.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2001-05-11 21:11:38 +00:00
|
|
|
|
|
|
|
// --- image -----
|
|
|
|
|
2007-07-16 12:42:36 +00:00
|
|
|
const PRUint32 kDefaultImageCacheSize = 256;
|
|
|
|
|
2008-03-06 03:33:33 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLImageAccessible
|
|
|
|
|
2001-09-25 22:32:32 +00:00
|
|
|
nsHTMLImageAccessible::nsHTMLImageAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell):
|
2007-07-16 12:42:36 +00:00
|
|
|
nsLinkableAccessible(aDOMNode, aShell), mAccessNodeCache(nsnull)
|
2001-05-11 21:11:38 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aDOMNode));
|
2003-04-15 08:45:55 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
|
2001-10-12 21:05:31 +00:00
|
|
|
if (!shell)
|
|
|
|
return;
|
2001-06-30 00:25:09 +00:00
|
|
|
|
2004-08-02 04:52:55 +00:00
|
|
|
nsIDocument *doc = shell->GetDocument();
|
2001-05-11 21:11:38 +00:00
|
|
|
nsAutoString mapElementName;
|
|
|
|
|
|
|
|
if (doc && element) {
|
|
|
|
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(doc));
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("usemap"),mapElementName);
|
|
|
|
if (htmlDoc && !mapElementName.IsEmpty()) {
|
|
|
|
if (mapElementName.CharAt(0) == '#')
|
|
|
|
mapElementName.Cut(0,1);
|
2004-02-03 23:23:10 +00:00
|
|
|
mMapElement = htmlDoc->GetImageMap(mapElementName);
|
2001-05-11 21:11:38 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-16 12:42:36 +00:00
|
|
|
|
|
|
|
if (mMapElement) {
|
|
|
|
mAccessNodeCache = new nsAccessNodeHashtable();
|
|
|
|
mAccessNodeCache->Init(kDefaultImageCacheSize);
|
|
|
|
}
|
2001-05-11 21:11:38 +00:00
|
|
|
}
|
|
|
|
|
2008-03-06 03:33:33 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLImageAccessible, nsAccessible,
|
|
|
|
nsIAccessibleImage)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessible
|
2007-02-12 07:04:58 +00:00
|
|
|
|
2007-04-02 15:56:24 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLImageAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
2001-08-14 00:18:04 +00:00
|
|
|
{
|
2007-03-15 14:18:33 +00:00
|
|
|
// The state is a bitfield, get our inherited state, then logically OR it with
|
|
|
|
// STATE_ANIMATED if this is an animated image.
|
2001-08-14 00:18:04 +00:00
|
|
|
|
2007-04-02 15:56:24 +00:00
|
|
|
nsresult rv = nsLinkableAccessible::GetState(aState, aExtraState);
|
2007-06-04 08:16:04 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-11-15 19:53:40 +00:00
|
|
|
if (!mDOMNode)
|
|
|
|
return NS_OK;
|
2001-08-14 02:27:30 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mDOMNode));
|
2001-08-14 00:18:04 +00:00
|
|
|
nsCOMPtr<imgIRequest> imageRequest;
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2007-04-02 15:56:24 +00:00
|
|
|
if (content)
|
2003-03-19 03:47:09 +00:00
|
|
|
content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(imageRequest));
|
2007-04-02 15:56:24 +00:00
|
|
|
|
2001-08-14 00:18:04 +00:00
|
|
|
nsCOMPtr<imgIContainer> imgContainer;
|
2007-04-02 15:56:24 +00:00
|
|
|
if (imageRequest)
|
2001-08-14 00:18:04 +00:00
|
|
|
imageRequest->GetImage(getter_AddRefs(imgContainer));
|
|
|
|
|
|
|
|
if (imgContainer) {
|
|
|
|
PRUint32 numFrames;
|
|
|
|
imgContainer->GetNumFrames(&numFrames);
|
|
|
|
if (numFrames > 1)
|
2007-04-02 15:56:24 +00:00
|
|
|
*aState |= nsIAccessibleStates::STATE_ANIMATED;
|
2001-08-14 00:18:04 +00:00
|
|
|
}
|
2001-08-14 02:27:30 +00:00
|
|
|
|
2001-08-14 00:18:04 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
/* wstring getName (); */
|
2005-03-20 14:25:03 +00:00
|
|
|
NS_IMETHODIMP nsHTMLImageAccessible::GetName(nsAString& aName)
|
2001-05-11 21:11:38 +00:00
|
|
|
{
|
2005-03-20 14:25:03 +00:00
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
|
|
|
if (!content) {
|
|
|
|
return NS_ERROR_FAILURE; // Node has been shut down
|
|
|
|
}
|
|
|
|
|
2005-10-28 11:25:24 +00:00
|
|
|
if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::alt,
|
|
|
|
aName)) {
|
2005-06-01 14:03:38 +00:00
|
|
|
if (mRoleMapEntry) {
|
|
|
|
// Use HTML label or DHTML accessibility's labelledby attribute for name
|
|
|
|
// GetHTMLName will also try title attribute as a last resort
|
|
|
|
return GetHTMLName(aName, PR_FALSE);
|
|
|
|
}
|
2005-10-28 11:25:24 +00:00
|
|
|
if (!content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title,
|
|
|
|
aName)) {
|
2005-06-01 14:03:38 +00:00
|
|
|
aName.SetIsVoid(PR_TRUE); // No alt or title
|
|
|
|
}
|
2001-05-11 21:11:38 +00:00
|
|
|
}
|
2005-03-20 14:25:03 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2001-05-11 21:11:38 +00:00
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
/* wstring getRole (); */
|
|
|
|
NS_IMETHODIMP nsHTMLImageAccessible::GetRole(PRUint32 *_retval)
|
2001-05-11 21:11:38 +00:00
|
|
|
{
|
2007-08-21 03:18:26 +00:00
|
|
|
*_retval = mMapElement ? nsIAccessibleRole::ROLE_IMAGE_MAP :
|
|
|
|
nsIAccessibleRole::ROLE_GRAPHIC;
|
2001-05-11 21:11:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-26 19:38:25 +00:00
|
|
|
void nsHTMLImageAccessible::CacheChildren()
|
2001-05-11 21:11:38 +00:00
|
|
|
{
|
2004-06-04 22:01:36 +00:00
|
|
|
if (!mWeakShell) {
|
|
|
|
// This node has been shut down
|
2006-09-11 06:18:06 +00:00
|
|
|
mAccChildCount = eChildCountUninitialized;
|
2004-06-04 22:01:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2004-06-04 22:01:36 +00:00
|
|
|
if (mAccChildCount != eChildCountUninitialized) {
|
|
|
|
return;
|
|
|
|
}
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2007-12-02 22:23:51 +00:00
|
|
|
mAccChildCount = 0;
|
2008-03-06 03:33:33 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> mapAreas = GetAreaCollection();
|
|
|
|
if (!mapAreas)
|
2004-06-04 22:01:36 +00:00
|
|
|
return;
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2004-06-04 22:01:36 +00:00
|
|
|
PRUint32 numMapAreas;
|
|
|
|
mapAreas->GetLength(&numMapAreas);
|
2006-08-11 17:21:56 +00:00
|
|
|
PRInt32 childCount = 0;
|
|
|
|
|
2004-06-04 22:01:36 +00:00
|
|
|
nsCOMPtr<nsIAccessible> areaAccessible;
|
|
|
|
nsCOMPtr<nsPIAccessible> privatePrevAccessible;
|
2006-08-11 17:21:56 +00:00
|
|
|
while (childCount < (PRInt32)numMapAreas &&
|
2008-03-06 03:33:33 +00:00
|
|
|
(areaAccessible = GetAreaAccessible(mapAreas, childCount)) != nsnull) {
|
2004-06-04 22:01:36 +00:00
|
|
|
if (privatePrevAccessible) {
|
|
|
|
privatePrevAccessible->SetNextSibling(areaAccessible);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetFirstChild(areaAccessible);
|
|
|
|
}
|
|
|
|
|
2006-08-11 17:21:56 +00:00
|
|
|
++ childCount;
|
2004-06-04 22:01:36 +00:00
|
|
|
|
|
|
|
privatePrevAccessible = do_QueryInterface(areaAccessible);
|
|
|
|
NS_ASSERTION(privatePrevAccessible, "nsIAccessible impl's should always support nsPIAccessible as well");
|
2006-07-12 04:21:52 +00:00
|
|
|
privatePrevAccessible->SetParent(this);
|
2004-06-04 22:01:36 +00:00
|
|
|
}
|
2006-08-11 17:21:56 +00:00
|
|
|
mAccChildCount = childCount;
|
2001-05-11 21:11:38 +00:00
|
|
|
}
|
2004-06-04 22:01:36 +00:00
|
|
|
|
2006-07-31 05:21:46 +00:00
|
|
|
NS_IMETHODIMP nsHTMLImageAccessible::DoAction(PRUint8 index)
|
|
|
|
{
|
|
|
|
if (index == eAction_ShowLongDescription) {
|
|
|
|
//get the long description uri and open in a new window
|
|
|
|
nsCOMPtr<nsIDOMHTMLImageElement> element(do_QueryInterface(mDOMNode));
|
|
|
|
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
|
|
|
|
nsAutoString longDesc;
|
|
|
|
nsresult rv = element->GetLongDesc(longDesc);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
|
|
rv = mDOMNode->GetOwnerDocument(getter_AddRefs(domDocument));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
|
|
|
|
nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
|
|
|
|
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(piWindow));
|
|
|
|
NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<nsIDOMWindow> tmp;
|
|
|
|
return win->Open(longDesc, NS_LITERAL_STRING(""), NS_LITERAL_STRING(""),
|
|
|
|
getter_AddRefs(tmp));
|
|
|
|
}
|
|
|
|
return nsLinkableAccessible::DoAction(index);
|
|
|
|
}
|
|
|
|
|
2008-03-06 03:33:33 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleHyperLink
|
|
|
|
NS_IMETHODIMP
|
2008-04-11 15:57:36 +00:00
|
|
|
nsHTMLImageAccessible::GetAnchorCount(PRInt32 *aAnchorCount)
|
2008-03-06 03:33:33 +00:00
|
|
|
{
|
2008-04-11 15:57:36 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aAnchorCount);
|
2008-03-06 03:33:33 +00:00
|
|
|
|
|
|
|
if (!mMapElement)
|
2008-04-11 15:57:36 +00:00
|
|
|
return nsLinkableAccessible::GetAnchorCount(aAnchorCount);
|
2008-03-06 03:33:33 +00:00
|
|
|
|
2008-04-11 15:57:36 +00:00
|
|
|
return GetChildCount(aAnchorCount);
|
2008-03-06 03:33:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLImageAccessible::GetURI(PRInt32 aIndex, nsIURI **aURI)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
|
|
|
*aURI = nsnull;
|
|
|
|
|
|
|
|
if (!mMapElement)
|
|
|
|
return nsLinkableAccessible::GetURI(aIndex, aURI);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> mapAreas = GetAreaCollection();
|
|
|
|
if (!mapAreas)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> domNode;
|
|
|
|
mapAreas->Item(aIndex, getter_AddRefs(domNode));
|
|
|
|
if (!domNode)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILink> link(do_QueryInterface(domNode));
|
|
|
|
if (link)
|
|
|
|
link->GetHrefURI(aURI);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2008-03-30 15:33:01 +00:00
|
|
|
nsHTMLImageAccessible::GetAnchor(PRInt32 aIndex, nsIAccessible **aAccessible)
|
2008-03-06 03:33:33 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAccessible);
|
|
|
|
*aAccessible = nsnull;
|
|
|
|
|
|
|
|
if (!mMapElement)
|
2008-03-30 15:33:01 +00:00
|
|
|
return nsLinkableAccessible::GetAnchor(aIndex, aAccessible);
|
2008-03-06 03:33:33 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLCollection> mapAreas = GetAreaCollection();
|
|
|
|
if (mapAreas) {
|
|
|
|
nsCOMPtr<nsIAccessible> accessible;
|
|
|
|
accessible = GetAreaAccessible(mapAreas, aIndex);
|
2008-03-30 03:24:02 +00:00
|
|
|
if (!accessible)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
NS_ADDREF(*aAccessible = accessible);
|
2008-03-06 03:33:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleImage
|
|
|
|
|
2007-12-01 17:30:09 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLImageAccessible::GetImagePosition(PRUint32 aCoordType,
|
|
|
|
PRInt32 *aX, PRInt32 *aY)
|
|
|
|
{
|
|
|
|
PRInt32 width, height;
|
|
|
|
nsresult rv = GetBounds(aX, aY, &width, &height);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
return nsAccUtils::ConvertScreenCoordsTo(aX, aY, aCoordType, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLImageAccessible::GetImageSize(PRInt32 *aWidth, PRInt32 *aHeight)
|
2007-02-12 07:04:58 +00:00
|
|
|
{
|
2007-12-01 17:30:09 +00:00
|
|
|
PRInt32 x, y;
|
|
|
|
return GetBounds(&x, &y, aWidth, aHeight);
|
2007-02-12 07:04:58 +00:00
|
|
|
}
|
2007-07-16 12:42:36 +00:00
|
|
|
|
2008-03-06 03:33:33 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsPIAccessNode
|
|
|
|
|
2007-07-16 12:42:36 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLImageAccessible::Shutdown()
|
|
|
|
{
|
|
|
|
nsLinkableAccessible::Shutdown();
|
|
|
|
|
|
|
|
if (mAccessNodeCache) {
|
|
|
|
ClearCache(*mAccessNodeCache);
|
|
|
|
delete mAccessNodeCache;
|
|
|
|
mAccessNodeCache = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-06 03:33:33 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLImageAccessible
|
|
|
|
|
|
|
|
already_AddRefed<nsIDOMHTMLCollection>
|
|
|
|
nsHTMLImageAccessible::GetAreaCollection()
|
|
|
|
{
|
|
|
|
if (!mMapElement)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsIDOMHTMLCollection *mapAreas = nsnull;
|
|
|
|
nsresult rv = mMapElement->GetAreas(&mapAreas);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
return mapAreas;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIAccessible>
|
|
|
|
nsHTMLImageAccessible::GetAreaAccessible(nsIDOMHTMLCollection *aAreaCollection,
|
|
|
|
PRInt32 aAreaNum)
|
|
|
|
{
|
|
|
|
if (!aAreaCollection)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> domNode;
|
|
|
|
aAreaCollection->Item(aAreaNum,getter_AddRefs(domNode));
|
|
|
|
if (!domNode)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessNode> accessNode;
|
|
|
|
GetCacheEntry(*mAccessNodeCache, (void*)(aAreaNum),
|
|
|
|
getter_AddRefs(accessNode));
|
|
|
|
|
|
|
|
if (!accessNode) {
|
|
|
|
accessNode = new nsHTMLAreaAccessible(domNode, this, mWeakShell);
|
|
|
|
if (!accessNode)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIAccessNode> privateAccessNode(do_QueryInterface(accessNode));
|
|
|
|
NS_ASSERTION(privateAccessNode,
|
|
|
|
"Accessible doesn't implement nsPIAccessNode");
|
|
|
|
|
|
|
|
nsresult rv = privateAccessNode->Init();
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
PutCacheEntry(*mAccessNodeCache, (void*)(aAreaNum), accessNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAccessible *accessible = nsnull;
|
|
|
|
CallQueryInterface(accessNode, &accessible);
|
|
|
|
|
|
|
|
return accessible;
|
|
|
|
}
|