2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-02 04:30:34 -07:00
|
|
|
#ifndef mozilla_a11y_ImageAccessible_h__
|
|
|
|
#define mozilla_a11y_ImageAccessible_h__
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-04 05:32:29 -07:00
|
|
|
#include "BaseAccessibles.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAccessibleImage.h"
|
|
|
|
|
2012-04-10 23:16:00 -07:00
|
|
|
class nsGenericHTMLElement;
|
|
|
|
|
2012-06-02 04:30:34 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* Accessible for supporting images
|
|
|
|
* supports:
|
|
|
|
* - gets name, role
|
|
|
|
* - support basic state
|
|
|
|
*/
|
2012-06-04 05:32:29 -07:00
|
|
|
class ImageAccessible : public LinkableAccessible,
|
2012-06-02 04:30:34 -07:00
|
|
|
public nsIAccessibleImage
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-06-02 04:30:34 -07:00
|
|
|
ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-04-05 17:41:28 -07:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2007-07-16 05:42:36 -07:00
|
|
|
// nsIAccessible
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
|
|
|
NS_IMETHOD DoAction(uint8_t index);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-01 09:30:09 -08:00
|
|
|
// nsIAccessibleImage
|
|
|
|
NS_DECL_NSIACCESSIBLEIMAGE
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2012-06-02 04:30:34 -07:00
|
|
|
virtual a11y::role NativeRole();
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint64_t NativeState();
|
2012-10-19 00:15:23 -07:00
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
|
2008-04-22 23:03:02 -07:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint8_t ActionCount();
|
2011-06-05 12:35:43 -07:00
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
protected:
|
|
|
|
// Accessible
|
|
|
|
virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
|
|
|
|
|
2008-08-26 00:39:17 -07:00
|
|
|
private:
|
|
|
|
/**
|
2012-04-10 23:16:00 -07: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 00:39:17 -07:00
|
|
|
*/
|
2012-04-10 23:16:00 -07:00
|
|
|
already_AddRefed<nsIURI> GetLongDescURI() const;
|
|
|
|
|
2008-08-26 00:39:17 -07:00
|
|
|
/**
|
|
|
|
* Used by GetActionName 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.
|
2012-04-10 23:16:00 -07: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 00:39:17 -07:00
|
|
|
*
|
|
|
|
* @param aIndex The 0-based index to be tested.
|
|
|
|
*
|
|
|
|
* @returns true if index is valid for longdesc action.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
inline bool IsLongDescIndex(uint8_t aIndex);
|
2012-04-10 23:16:00 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-06-02 04:30:34 -07:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-01-05 20:05:03 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible downcasting method
|
2012-04-10 23:16:00 -07:00
|
|
|
|
2012-06-02 04:30:34 -07:00
|
|
|
inline mozilla::a11y::ImageAccessible*
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible::AsImage()
|
2012-01-05 20:05:03 -08:00
|
|
|
{
|
2012-05-22 09:40:56 -07:00
|
|
|
return IsImage() ?
|
2012-07-30 07:20:58 -07:00
|
|
|
static_cast<mozilla::a11y::ImageAccessible*>(this) : nullptr;
|
2012-01-05 20:05:03 -08:00
|
|
|
}
|
|
|
|
|
2007-07-16 05:42:36 -07:00
|
|
|
#endif
|
|
|
|
|