HTMLImageMapAccessible.h 2.4 KB

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