Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_a11y_ImageAccessible_h__
7 #define mozilla_a11y_ImageAccessible_h__
9 #include "BaseAccessibles.h"
10 #include "nsIAccessibleImage.h"
12 class nsGenericHTMLElement;
14 namespace mozilla {
15 namespace a11y {
17 /* Accessible for supporting images
18 * supports:
19 * - gets name, role
20 * - support basic state
21 */
22 class ImageAccessible : public LinkableAccessible,
23 public nsIAccessibleImage
24 {
25 public:
26 ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
28 // nsISupports
29 NS_DECL_ISUPPORTS_INHERITED
31 // nsIAccessible
32 NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
33 NS_IMETHOD DoAction(uint8_t index);
35 // nsIAccessibleImage
36 NS_DECL_NSIACCESSIBLEIMAGE
38 // Accessible
39 virtual a11y::role NativeRole();
40 virtual uint64_t NativeState();
41 virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
43 // ActionAccessible
44 virtual uint8_t ActionCount();
46 protected:
47 // Accessible
48 virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
50 private:
51 /**
52 * Return whether the element has a longdesc URI.
53 */
54 bool HasLongDesc() const
55 {
56 nsCOMPtr<nsIURI> uri = GetLongDescURI();
57 return uri;
58 }
60 /**
61 * Return an URI for showlongdesc action if any.
62 */
63 already_AddRefed<nsIURI> GetLongDescURI() const;
65 /**
66 * Used by GetActionName and DoAction to ensure the index for opening the
67 * longdesc URL is valid.
68 * It is always assumed that the highest possible index opens the longdesc.
69 * This doesn't check that there is actually a longdesc, just that the index
70 * would be correct if there was one.
71 *
72 * @param aIndex The 0-based index to be tested.
73 *
74 * @returns true if index is valid for longdesc action.
75 */
76 inline bool IsLongDescIndex(uint8_t aIndex);
78 };
80 ////////////////////////////////////////////////////////////////////////////////
81 // Accessible downcasting method
83 inline ImageAccessible*
84 Accessible::AsImage()
85 {
86 return IsImage() ? static_cast<ImageAccessible*>(this) : nullptr;
87 }
89 } // namespace a11y
90 } // namespace mozilla
92 #endif