1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Author: Aaron Leventhal (aaronl@netscape.com)
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
40#include "imgIRequest.h"
47#include "nsIDocument.h"
50#include "nsILink.h"
51#include "nsIPresShell.h"
57// --- image -----
59const PRUint32 kDefaultImageCacheSize = 256;
61////////////////////////////////////////////////////////////////////////////////
62// nsHTMLImageAccessible
66{
68 nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mWeakShell));
69 if (!shell)
70 return;
75 if (doc && element) {
79 if (mapElementName.CharAt(0) == '#')
82 }
83 }
87 mAccessNodeCache->Init(kDefaultImageCacheSize);
88 }
94////////////////////////////////////////////////////////////////////////////////
95// nsIAccessible
100 // The state is a bitfield, get our inherited state, then logically OR it with
101 // STATE_ANIMATED if this is an animated image.
111 getter_AddRefs(imageRequest));
120 if (numFrames > 1)
122 }
124 return NS_OK;
133 if (!aName.IsEmpty())
134 return NS_OK;
140 // No accessible name but empty 'alt' attribute is present. If further name
141 // computation algorithm doesn't provide non empty name then it means
142 // an empty 'alt' attribute was used to indicate a decorative image (see
143 // nsIAccessible::name attribute for details).
145 }
147 return NS_OK;
155 return NS_OK;
160 if (!mWeakShell) {
161 // This node has been shut down
162 mAccChildCount = eChildCountUninitialized;
163 return;
164 }
166 if (mAccChildCount != eChildCountUninitialized) {
167 return;
168 }
173 return;
185 else
192 }
202 if (IsDefunct())
211 return NS_OK;
219 if (IsDefunct())
223 aName.AssignLiteral("showlongdesc");
224 return NS_OK;
225 }
232 if (IsDefunct())
236 //get the long description uri and open in a new window
251 getter_AddRefs(tmp));
252 }
256////////////////////////////////////////////////////////////////////////////////
257// nsIAccessibleHyperLink
280 return NS_OK;
283 mapAreas->Item(aIndex, getter_AddRefs(domNode));
284 if (!domNode)
288 if (link)
291 return NS_OK;
304 if (mapAreas) {
311 }
313 return NS_OK;
316////////////////////////////////////////////////////////////////////////////////
317// nsIAccessibleImage
326 return rv;
335 return GetBounds(&x, &y, aWidth, aHeight);
338////////////////////////////////////////////////////////////////////////////////
339// nsHTMLImageAccessible. nsAccessNode
350 }
352 return NS_OK;
355////////////////////////////////////////////////////////////////////////////////
356// nsHTMLImageAccessible
361 if (IsDefunct())
370 content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::src, src);
371 if (!src.IsEmpty())
374 return NS_OK;
381 return nsnull;
386 return nsnull;
388 return mapAreas;
396 return nsnull;
400 if (!domNode)
401 return nsnull;
405 getter_AddRefs(accessNode));
407 if (!accessNode) {
410 return nsnull;
415 return nsnull;
418 }
423 return accessible;
426////////////////////////////////////////////////////////////////////////////////
427// Private methods
432 if (IsDefunct())
433 return PR_FALSE;
436 return (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::longDesc));
443 return PR_FALSE;
449 return (aIndex == numActions);