diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /accessible/generic/ImageAccessible.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'accessible/generic/ImageAccessible.h')
-rw-r--r-- | accessible/generic/ImageAccessible.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/accessible/generic/ImageAccessible.h b/accessible/generic/ImageAccessible.h new file mode 100644 index 000000000..f2324ae4c --- /dev/null +++ b/accessible/generic/ImageAccessible.h @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_a11y_ImageAccessible_h__ +#define mozilla_a11y_ImageAccessible_h__ + +#include "BaseAccessibles.h" + +namespace mozilla { +namespace a11y { + +/* Accessible for supporting images + * supports: + * - gets name, role + * - support basic state + */ +class ImageAccessible : public LinkableAccessible +{ +public: + ImageAccessible(nsIContent* aContent, DocAccessible* aDoc); + + // Accessible + virtual a11y::role NativeRole() override; + virtual uint64_t NativeState() override; + virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override; + + // ActionAccessible + virtual uint8_t ActionCount() override; + virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override; + virtual bool DoAction(uint8_t aIndex) override; + + // ImageAccessible + nsIntPoint Position(uint32_t aCoordType); + nsIntSize Size(); + +protected: + virtual ~ImageAccessible(); + + // Accessible + virtual ENameValueFlag NativeName(nsString& aName) override; + +private: + /** + * Return whether the element has a longdesc URI. + */ + bool HasLongDesc() const + { + nsCOMPtr<nsIURI> uri = GetLongDescURI(); + return uri; + } + + /** + * Return an URI for showlongdesc action if any. + */ + already_AddRefed<nsIURI> GetLongDescURI() const; + + /** + * Used by ActionNameAt and DoAction to ensure the index for opening the + * longdesc URL is valid. + * It is always assumed that the highest possible index opens the longdesc. + * This doesn't check that there is actually a longdesc, just that the index + * would be correct if there was one. + * + * @param aIndex The 0-based index to be tested. + * + * @returns true if index is valid for longdesc action. + */ + inline bool IsLongDescIndex(uint8_t aIndex); + +}; + +//////////////////////////////////////////////////////////////////////////////// +// Accessible downcasting method + +inline ImageAccessible* +Accessible::AsImage() +{ + return IsImage() ? static_cast<ImageAccessible*>(this) : nullptr; +} + +} // namespace a11y +} // namespace mozilla + +#endif + |