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 "imgINotificationObserver.h"
15 /* LocalAccessible for supporting images
18 * - support basic state
20 class ImageAccessible
: public LinkableAccessible
,
21 public imgINotificationObserver
{
23 ImageAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
);
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_IMGINOTIFICATIONOBSERVER
29 virtual void Shutdown() override
;
30 virtual a11y::role
NativeRole() const override
;
31 virtual uint64_t NativeState() const override
;
32 virtual already_AddRefed
<AccAttributes
> NativeAttributes() override
;
35 virtual uint8_t ActionCount() const override
;
36 virtual void ActionNameAt(uint8_t aIndex
, nsAString
& aName
) override
;
37 virtual bool DoAction(uint8_t aIndex
) const override
;
40 LayoutDeviceIntPoint
Position(uint32_t aCoordType
);
41 LayoutDeviceIntSize
Size();
44 * Return whether the element has a longdesc URI.
46 bool HasLongDesc() const {
47 nsCOMPtr
<nsIURI
> uri
= GetLongDescURI();
52 virtual ~ImageAccessible();
55 virtual ENameValueFlag
NativeName(nsString
& aName
) const override
;
57 virtual void DOMAttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
59 const nsAttrValue
* aOldValue
,
60 uint64_t aOldState
) override
;
64 * Return an URI for showlongdesc action if any.
66 already_AddRefed
<nsIURI
> GetLongDescURI() const;
69 * Used by ActionNameAt and DoAction to ensure the index for opening the
70 * longdesc URL is valid.
71 * It is always assumed that the highest possible index opens the longdesc.
72 * This doesn't check that there is actually a longdesc, just that the index
73 * would be correct if there was one.
75 * @param aIndex The 0-based index to be tested.
77 * @returns true if index is valid for longdesc action.
79 inline bool IsLongDescIndex(uint8_t aIndex
) const;
81 uint32_t mImageRequestStatus
;
84 ////////////////////////////////////////////////////////////////////////////////
85 // LocalAccessible downcasting method
87 inline ImageAccessible
* LocalAccessible::AsImage() {
88 return IsImage() ? static_cast<ImageAccessible
*>(this) : nullptr;
92 } // namespace mozilla