Bug 1890277: part 4) Add CSPParser support for the `trusted-types` directive, guarded...
[gecko.git] / accessible / generic / ImageAccessible.h
blob1a072c5f906ea15ffeefd9cca0d9e08d86e52e2e
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"
12 namespace mozilla {
13 namespace a11y {
15 /* LocalAccessible for supporting images
16 * supports:
17 * - gets name, role
18 * - support basic state
20 class ImageAccessible : public LinkableAccessible,
21 public imgINotificationObserver {
22 public:
23 ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_IMGINOTIFICATIONOBSERVER
28 // LocalAccessible
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;
34 // ActionAccessible
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;
39 // ImageAccessible
40 LayoutDeviceIntPoint Position(uint32_t aCoordType);
41 LayoutDeviceIntSize Size();
43 /**
44 * Return whether the element has a longdesc URI.
46 bool HasLongDesc() const {
47 nsCOMPtr<nsIURI> uri = GetLongDescURI();
48 return uri;
51 protected:
52 virtual ~ImageAccessible();
54 // LocalAccessible
55 virtual ENameValueFlag NativeName(nsString& aName) const override;
57 virtual void DOMAttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
58 int32_t aModType,
59 const nsAttrValue* aOldValue,
60 uint64_t aOldState) override;
62 private:
63 /**
64 * Return an URI for showlongdesc action if any.
66 already_AddRefed<nsIURI> GetLongDescURI() const;
68 /**
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;
91 } // namespace a11y
92 } // namespace mozilla
94 #endif