Line data Source code
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/. */
5 :
6 : #ifndef mozilla_a11y_HTMLImageMapAccessible_h__
7 : #define mozilla_a11y_HTMLImageMapAccessible_h__
8 :
9 : #include "HTMLLinkAccessible.h"
10 : #include "ImageAccessibleWrap.h"
11 : #include "nsIDOMHTMLMapElement.h"
12 :
13 : namespace mozilla {
14 : namespace a11y {
15 :
16 : /**
17 : * Used for HTML image maps.
18 : */
19 : class HTMLImageMapAccessible final : public ImageAccessibleWrap
20 : {
21 : public:
22 : HTMLImageMapAccessible(nsIContent* aContent, DocAccessible* aDoc);
23 :
24 : // nsISupports and cycle collector
25 : NS_DECL_ISUPPORTS_INHERITED
26 :
27 : // Accessible
28 : virtual a11y::role NativeRole() override;
29 :
30 : // HyperLinkAccessible
31 : virtual uint32_t AnchorCount() override;
32 : virtual Accessible* AnchorAt(uint32_t aAnchorIndex) override;
33 : virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
34 :
35 : /**
36 : * Update area children of the image map.
37 : */
38 : void UpdateChildAreas(bool aDoFireEvents = true);
39 :
40 : /**
41 : * Return accessible of child node.
42 : */
43 : Accessible* GetChildAccessibleFor(const nsINode* aNode) const;
44 :
45 : protected:
46 0 : virtual ~HTMLImageMapAccessible() { }
47 : };
48 :
49 : /**
50 : * Accessible for image map areas - must be child of image.
51 : */
52 0 : class HTMLAreaAccessible final : public HTMLLinkAccessible
53 : {
54 : public:
55 :
56 : HTMLAreaAccessible(nsIContent* aContent, DocAccessible* aDoc);
57 :
58 : // Accessible
59 : virtual void Description(nsString& aDescription) override;
60 : virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
61 : EWhichChildAtPoint aWhichChild) override;
62 : virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const override;
63 :
64 : // HyperLinkAccessible
65 : virtual uint32_t StartOffset() override;
66 : virtual uint32_t EndOffset() override;
67 :
68 0 : virtual bool IsAcceptableChild(nsIContent* aEl) const override
69 0 : { return false; }
70 :
71 : protected:
72 : // Accessible
73 : virtual ENameValueFlag NativeName(nsString& aName) override;
74 : };
75 :
76 :
77 : ////////////////////////////////////////////////////////////////////////////////
78 : // Accessible downcasting method
79 :
80 : inline HTMLImageMapAccessible*
81 0 : Accessible::AsImageMap()
82 : {
83 0 : return IsImageMap() ? static_cast<HTMLImageMapAccessible*>(this) : nullptr;
84 : }
85 :
86 : } // namespace a11y
87 : } // namespace mozilla
88 :
89 : #endif
|