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
|
|
|
|
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
|
|
|
|
*/
|
2014-10-21 17:49:28 -07:00
|
|
|
class ImageAccessible : public LinkableAccessible
|
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
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual a11y::role NativeRole() override;
|
|
|
|
virtual uint64_t NativeState() override;
|
|
|
|
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
|
2008-04-22 23:03:02 -07:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
// ActionAccessible
|
2015-03-21 09:28:04 -07: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 12:35:43 -07:00
|
|
|
|
2014-09-23 05:23:02 -07:00
|
|
|
// ImageAccessible
|
|
|
|
nsIntPoint Position(uint32_t aCoordType);
|
|
|
|
nsIntSize Size();
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
protected:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~ImageAccessible();
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
// Accessible
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual ENameValueFlag NativeName(nsString& aName) override;
|
2012-10-13 21:18:39 -07:00
|
|
|
|
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
|
|
|
/**
|
2014-09-16 10:30:23 -07:00
|
|
|
* Used by ActionNameAt and DoAction to ensure the index for opening the
|
2008-08-26 00:39:17 -07:00
|
|
|
* 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-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-11-17 18:01:44 -08:00
|
|
|
inline ImageAccessible*
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible::AsImage()
|
2012-01-05 20:05:03 -08:00
|
|
|
{
|
2012-11-17 18:01:44 -08:00
|
|
|
return IsImage() ? static_cast<ImageAccessible*>(this) : nullptr;
|
2012-01-05 20:05:03 -08:00
|
|
|
}
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-07-16 05:42:36 -07:00
|
|
|
#endif
|
|
|
|
|