/src/mozilla-central/accessible/generic/ImageAccessible.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
5 | | |
6 | | #ifndef mozilla_a11y_ImageAccessible_h__ |
7 | | #define mozilla_a11y_ImageAccessible_h__ |
8 | | |
9 | | #include "BaseAccessibles.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace a11y { |
13 | | |
14 | | /* Accessible for supporting images |
15 | | * supports: |
16 | | * - gets name, role |
17 | | * - support basic state |
18 | | */ |
19 | | class ImageAccessible : public LinkableAccessible |
20 | | { |
21 | | public: |
22 | | ImageAccessible(nsIContent* aContent, DocAccessible* aDoc); |
23 | | |
24 | | // Accessible |
25 | | virtual a11y::role NativeRole() const override; |
26 | | virtual uint64_t NativeState() const override; |
27 | | virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; |
28 | | |
29 | | // ActionAccessible |
30 | | virtual uint8_t ActionCount() const override; |
31 | | virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; |
32 | | virtual bool DoAction(uint8_t aIndex) const override; |
33 | | |
34 | | // ImageAccessible |
35 | | nsIntPoint Position(uint32_t aCoordType); |
36 | | nsIntSize Size(); |
37 | | |
38 | | protected: |
39 | | virtual ~ImageAccessible(); |
40 | | |
41 | | // Accessible |
42 | | virtual ENameValueFlag NativeName(nsString& aName) const override; |
43 | | |
44 | | private: |
45 | | /** |
46 | | * Return whether the element has a longdesc URI. |
47 | | */ |
48 | | bool HasLongDesc() const |
49 | 0 | { |
50 | 0 | nsCOMPtr<nsIURI> uri = GetLongDescURI(); |
51 | 0 | return uri; |
52 | 0 | } |
53 | | |
54 | | /** |
55 | | * Return an URI for showlongdesc action if any. |
56 | | */ |
57 | | already_AddRefed<nsIURI> GetLongDescURI() const; |
58 | | |
59 | | /** |
60 | | * Used by ActionNameAt and DoAction to ensure the index for opening the |
61 | | * longdesc URL is valid. |
62 | | * It is always assumed that the highest possible index opens the longdesc. |
63 | | * This doesn't check that there is actually a longdesc, just that the index |
64 | | * would be correct if there was one. |
65 | | * |
66 | | * @param aIndex The 0-based index to be tested. |
67 | | * |
68 | | * @returns true if index is valid for longdesc action. |
69 | | */ |
70 | | inline bool IsLongDescIndex(uint8_t aIndex) const; |
71 | | |
72 | | }; |
73 | | |
74 | | //////////////////////////////////////////////////////////////////////////////// |
75 | | // Accessible downcasting method |
76 | | |
77 | | inline ImageAccessible* |
78 | | Accessible::AsImage() |
79 | 0 | { |
80 | 0 | return IsImage() ? static_cast<ImageAccessible*>(this) : nullptr; |
81 | 0 | } |
82 | | |
83 | | } // namespace a11y |
84 | | } // namespace mozilla |
85 | | |
86 | | #endif |
87 | | |