2001-09-25 00:48:50 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2012-06-02 11:30:34 +00:00
|
|
|
#ifndef mozilla_a11y_ImageAccessible_h__
|
|
|
|
#define mozilla_a11y_ImageAccessible_h__
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2012-06-04 12:32:29 +00:00
|
|
|
#include "BaseAccessibles.h"
|
2001-05-11 21:11:38 +00:00
|
|
|
|
2012-06-02 11:30:34 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2001-05-11 21:11:38 +00:00
|
|
|
/* Accessible for supporting images
|
|
|
|
* supports:
|
|
|
|
* - gets name, role
|
|
|
|
* - support basic state
|
|
|
|
*/
|
2018-11-30 10:46:48 +00:00
|
|
|
class ImageAccessible : public LinkableAccessible {
|
|
|
|
public:
|
2012-06-02 11:30:34 +00:00
|
|
|
ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
2007-02-12 07:04:58 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
// Accessible
|
2018-05-07 19:05:50 +00:00
|
|
|
virtual a11y::role NativeRole() const override;
|
2018-05-15 18:04:50 +00:00
|
|
|
virtual uint64_t NativeState() const override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
|
2008-04-23 06:03:02 +00:00
|
|
|
|
2011-06-05 19:35:43 +00:00
|
|
|
// ActionAccessible
|
2018-05-15 17:40:22 +00:00
|
|
|
virtual uint8_t ActionCount() const override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
|
2018-05-15 17:40:22 +00:00
|
|
|
virtual bool DoAction(uint8_t aIndex) const override;
|
2011-06-05 19:35:43 +00:00
|
|
|
|
2014-09-23 12:23:02 +00:00
|
|
|
// ImageAccessible
|
|
|
|
nsIntPoint Position(uint32_t aCoordType);
|
|
|
|
nsIntSize Size();
|
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
protected:
|
2014-07-08 21:23:18 +00:00
|
|
|
virtual ~ImageAccessible();
|
|
|
|
|
2012-10-14 04:18:39 +00:00
|
|
|
// Accessible
|
2018-05-15 16:13:02 +00:00
|
|
|
virtual ENameValueFlag NativeName(nsString& aName) const override;
|
2012-10-14 04:18:39 +00:00
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
private:
|
2008-08-26 07:39:17 +00:00
|
|
|
/**
|
2012-04-11 06:16:00 +00:00
|
|
|
* Return whether the element has a longdesc URI.
|
|
|
|
*/
|
2018-11-30 10:46:48 +00:00
|
|
|
bool HasLongDesc() const {
|
2012-04-11 06:16:00 +00:00
|
|
|
nsCOMPtr<nsIURI> uri = GetLongDescURI();
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an URI for showlongdesc action if any.
|
2008-08-26 07:39:17 +00:00
|
|
|
*/
|
2012-04-11 06:16:00 +00:00
|
|
|
already_AddRefed<nsIURI> GetLongDescURI() const;
|
|
|
|
|
2008-08-26 07:39:17 +00:00
|
|
|
/**
|
2014-09-16 17:30:23 +00:00
|
|
|
* Used by ActionNameAt and DoAction to ensure the index for opening the
|
2008-08-26 07:39:17 +00:00
|
|
|
* longdesc URL is valid.
|
|
|
|
* It is always assumed that the highest possible index opens the longdesc.
|
2012-04-11 06:16:00 +00:00
|
|
|
* This doesn't check that there is actually a longdesc, just that the index
|
|
|
|
* would be correct if there was one.
|
2008-08-26 07:39:17 +00:00
|
|
|
*
|
|
|
|
* @param aIndex The 0-based index to be tested.
|
|
|
|
*
|
|
|
|
* @returns true if index is valid for longdesc action.
|
|
|
|
*/
|
2018-05-15 17:40:22 +00:00
|
|
|
inline bool IsLongDescIndex(uint8_t aIndex) const;
|
2001-05-11 21:11:38 +00:00
|
|
|
};
|
|
|
|
|
2012-01-06 04:05:03 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-29 01:18:45 +00:00
|
|
|
// Accessible downcasting method
|
2012-04-11 06:16:00 +00:00
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
inline ImageAccessible* Accessible::AsImage() {
|
2012-11-18 02:01:44 +00:00
|
|
|
return IsImage() ? static_cast<ImageAccessible*>(this) : nullptr;
|
2012-01-06 04:05:03 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 10:46:48 +00:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
2012-11-18 02:01:44 +00:00
|
|
|
|
2007-07-16 12:42:36 +00:00
|
|
|
#endif
|