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