Bug 1700051: part 46) Const-qualify `mozInlineSpellStatus::mAnchorRange`. r=smaug
[gecko.git] / accessible / generic / ImageAccessible.h
blobacfd823d4d2ac044196c99bac1b7f170c07844cc
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"
11 namespace mozilla {
12 namespace a11y {
14 /* LocalAccessible for supporting images
15 * supports:
16 * - gets name, role
17 * - support basic state
19 class ImageAccessible : public LinkableAccessible {
20 public:
21 ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
23 // LocalAccessible
24 virtual a11y::role NativeRole() const override;
25 virtual uint64_t NativeState() const override;
26 virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
28 // ActionAccessible
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;
33 // ImageAccessible
34 nsIntPoint Position(uint32_t aCoordType);
35 nsIntSize Size();
37 protected:
38 virtual ~ImageAccessible();
40 // LocalAccessible
41 virtual ENameValueFlag NativeName(nsString& aName) const override;
43 private:
44 /**
45 * Return whether the element has a longdesc URI.
47 bool HasLongDesc() const {
48 nsCOMPtr<nsIURI> uri = GetLongDescURI();
49 return uri;
52 /**
53 * Return an URI for showlongdesc action if any.
55 already_AddRefed<nsIURI> GetLongDescURI() const;
57 /**
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;
78 } // namespace a11y
79 } // namespace mozilla
81 #endif