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