michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_a11y_ImageAccessible_h__ michael@0: #define mozilla_a11y_ImageAccessible_h__ michael@0: michael@0: #include "BaseAccessibles.h" michael@0: #include "nsIAccessibleImage.h" michael@0: michael@0: class nsGenericHTMLElement; michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: /* Accessible for supporting images michael@0: * supports: michael@0: * - gets name, role michael@0: * - support basic state michael@0: */ michael@0: class ImageAccessible : public LinkableAccessible, michael@0: public nsIAccessibleImage michael@0: { michael@0: public: michael@0: ImageAccessible(nsIContent* aContent, DocAccessible* aDoc); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIAccessible michael@0: NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName); michael@0: NS_IMETHOD DoAction(uint8_t index); michael@0: michael@0: // nsIAccessibleImage michael@0: NS_DECL_NSIACCESSIBLEIMAGE michael@0: michael@0: // Accessible michael@0: virtual a11y::role NativeRole(); michael@0: virtual uint64_t NativeState(); michael@0: virtual already_AddRefed NativeAttributes() MOZ_OVERRIDE; michael@0: michael@0: // ActionAccessible michael@0: virtual uint8_t ActionCount(); michael@0: michael@0: protected: michael@0: // Accessible michael@0: virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: /** michael@0: * Return whether the element has a longdesc URI. michael@0: */ michael@0: bool HasLongDesc() const michael@0: { michael@0: nsCOMPtr uri = GetLongDescURI(); michael@0: return uri; michael@0: } michael@0: michael@0: /** michael@0: * Return an URI for showlongdesc action if any. michael@0: */ michael@0: already_AddRefed GetLongDescURI() const; michael@0: michael@0: /** michael@0: * Used by GetActionName and DoAction to ensure the index for opening the michael@0: * longdesc URL is valid. michael@0: * It is always assumed that the highest possible index opens the longdesc. michael@0: * This doesn't check that there is actually a longdesc, just that the index michael@0: * would be correct if there was one. michael@0: * michael@0: * @param aIndex The 0-based index to be tested. michael@0: * michael@0: * @returns true if index is valid for longdesc action. michael@0: */ michael@0: inline bool IsLongDescIndex(uint8_t aIndex); michael@0: michael@0: }; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // Accessible downcasting method michael@0: michael@0: inline ImageAccessible* michael@0: Accessible::AsImage() michael@0: { michael@0: return IsImage() ? static_cast(this) : nullptr; michael@0: } michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif michael@0: