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"
14 /* LocalAccessible for supporting images
17 * - support basic state
19 class ImageAccessible
: public LinkableAccessible
{
21 ImageAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
);
24 virtual a11y::role
NativeRole() const override
;
25 virtual uint64_t NativeState() const override
;
26 virtual already_AddRefed
<nsIPersistentProperties
> NativeAttributes() override
;
29 virtual uint8_t ActionCount() const override
;
30 virtual void ActionNameAt(uint8_t aIndex
, nsAString
& aName
) override
;
31 virtual bool DoAction(uint8_t aIndex
) const override
;
34 nsIntPoint
Position(uint32_t aCoordType
);
38 virtual ~ImageAccessible();
41 virtual ENameValueFlag
NativeName(nsString
& aName
) const override
;
45 * Return whether the element has a longdesc URI.
47 bool HasLongDesc() const {
48 nsCOMPtr
<nsIURI
> uri
= GetLongDescURI();
53 * Return an URI for showlongdesc action if any.
55 already_AddRefed
<nsIURI
> GetLongDescURI() const;
58 * Used by ActionNameAt and DoAction to ensure the index for opening the
59 * longdesc URL is valid.
60 * It is always assumed that the highest possible index opens the longdesc.
61 * This doesn't check that there is actually a longdesc, just that the index
62 * would be correct if there was one.
64 * @param aIndex The 0-based index to be tested.
66 * @returns true if index is valid for longdesc action.
68 inline bool IsLongDescIndex(uint8_t aIndex
) const;
71 ////////////////////////////////////////////////////////////////////////////////
72 // LocalAccessible downcasting method
74 inline ImageAccessible
* LocalAccessible::AsImage() {
75 return IsImage() ? static_cast<ImageAccessible
*>(this) : nullptr;
79 } // namespace mozilla