Files
palemoon27/accessible/base/nsAccUtils.h
T
roytam1 2eb290e0d3 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1197954 - Extract GLXFBConfig selection code for X11 windows. r=lsalzman (2816a11bdd)
- Bug 1261439 - replace nsAccUtils::IsEmbeddedObject on a bit flag check, r=marcoz (16319b9295)
- bug 1262563 - add IsFromUserInput to show / hide event messages r=davidb (dc96903cfa)
- bug 1262563 - fire show / hide events for proxied accessibles r=davidb (9b1deb77c9)
- bug 1255009 - make AccShowEvent store the insertion index of the new child r=davidb (5b3d984446)
- bug 1261144 - remove filters::GetEmbeddedObj() because it is unused r=lsocks (837bb1777c)
- bug 1261144 - devirtualize AppendObject() because the base class impl is never called r=lsocks (a8fe470965)
- bug 1261144 - move Count() from AccCollector to EmbeddedObjCollector r=lsocks (11d9734561)
- bug 1261144 - move GetAccessibleAt to EmbeddedObjCollector r=lsocks (6ac2731ec1)
- bug 1261144 - devirtualize GetIndexAt() because the base class version is never called r=lsocks (54cc48712e)
- bug 1261144 - move EnsureNGetObject to EmbeddedObjCollector r=lsocks (225b123fb0)
- bug 1261144 - move EnsureNGetIndex() to EmbeddedObjCollector r=lsocks (81986c9a95)
- bug 1261144 - move the data members of AccCollector to EmbeddedObjCollector r=lsocks (5ba20f1c30)
- bug 1261144 - remove the AccCollector class r=lsocks (6f52909c58)
- bug 1261144 - use filters::GetEmbeddedObject() directly in EmbeddedObjCollector r=lsocks (cb86410837)
- bug 1261144 - devirtualize the dtor of EmbeddedObjCollector r=lsocks (b3d23cf341)
- Bug 1261144 - stop including Filters.h in EmbeddedObjCollector.h r=lsocks (2940a4dc3d)
- bug 1261144 - call Accessible::IsText() directly from EmbeddedObjCollector r=lsocks (b93a86aa2a)
- bug 1262233 - stop using a sync message to implement ProxyAccessible::EmbeddedChildCount() r=lsocks (e2d3b6d608)
- bug 1262233 - stop implementing ProxyAccessible::IndexOfEmbeddedChild() with a sync message r=lsocks (dcedecd9d4)
- bug 1262233 - add ProxyAccessible::IsEmbeddedObject() r=lsocks (084915a784)
- bug 1262233 - stop implementing ProxyAccessible::EmbeddedChildAt() with a sync message r=lsocks (2924d04c4a)
- bug 1241453 - fire nsIAccessibleStateChangeEvents for proxied accessibles r=davidb (e423829903)
- bug 1241453 - fire nsIAccessibleEvents for proxied accessibles r=davidb (6a02c2f8a3)
- bug 1241453 - fire nsIAccessibleCaretMoveEvents for proxies r=davidb (4fb1f5be4f)
- bug 1241453 - fire nsIAccessibleTextChangeEvents for proxies r=davidb (c53a5b5122)
- Bug 1264526 - process ARIA owns relocations for in-the-document accessibles only, r=yzen (e19887eee4)
- Bug 1261174 - more events logging, r=yzen (14b83c693d)
- Bug 1257350 - Use intptr_t to avoid C4312 on VS2015; r=tbsaunde (1fc3ee9b6d)
- bug 1250882 - make xpcAccessible::GetAttributes() work with proxied accessibles r=davidb (fa676531c2)
- bug 1210741 - make AccessibleWrap::get_accLocation work with proxied accessibles r=davidb (6600987ec8)
- bug 1219528 - make NAVDIR_{FIRST,LAST}CHILD and NAVDIR_{NEXT,PREVIOUS} cases of AccessibleWrap::accNavigate deal with proxies r=davidb (c011ebcd2b)
- bug 1219528 - make AccessibleWrap::accNavigate cases using relations work with proxies r=davidb (de20c76bcc)
- bug 1215657 - make AccessibleWrap::accHitTest() work with proxies r=davidb (25da22a733)
- bug 1215657 - make AccessibleWrap::accDoDefaultAction work with proxies r=davidb (029d34d135)
- bug 1208779 - null check aAccessible in GetChildIDFor() for 32 bit as well as 64 bit windows r=davidb (08319d45e7)
- bug 1207862 - refactor GetXPAccessibleFor() so proxies and non proxies are handle in the same place for each type of id r=davidb (3ff1646e02)
- bug 1207862 - make AccessibleWrap::GetXPAccessibleFor() return the AccessibleWrap for proxies r=davidb (1184a0efeb)
- bug 1218564 - remove check for password roles in AccessibleWrap::get_accValue r=surkov (477e0bb92b)
- bug 1219528 - don't bail out of AccessibleWrap::accNavigate if the accessible wraps a proxy r=davidb (9540866b5b)
- Bug 1257303 - Cast to intptr_t to avoid C4312 on VS2015; r=tbsaunde (93af27e0db)
- Bug 1210549 - Fix AccessibleWrap::GetXPAccessibleFor for proxied accessibles r=tbsaunde (b4ed017706)
2024-06-03 11:45:01 +08:00

244 lines
7.6 KiB
C++

/* -*- 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 nsAccUtils_h_
#define nsAccUtils_h_
#include "mozilla/a11y/Accessible.h"
#include "nsAccessibilityService.h"
#include "nsCoreUtils.h"
#include "nsIDocShell.h"
#include "nsPoint.h"
namespace mozilla {
namespace dom {
class Element;
}
namespace a11y {
class HyperTextAccessible;
class DocAccessible;
class nsAccUtils
{
public:
/**
* Returns value of attribute from the given attributes container.
*
* @param aAttributes - attributes container
* @param aAttrName - the name of requested attribute
* @param aAttrValue - value of attribute
*/
static void GetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
nsAString& aAttrValue);
/**
* Set value of attribute for the given attributes container.
*
* @param aAttributes - attributes container
* @param aAttrName - the name of requested attribute
* @param aAttrValue - new value of attribute
*/
static void SetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom *aAttrName,
const nsAString& aAttrValue);
static void SetAccAttr(nsIPersistentProperties *aAttributes,
nsIAtom* aAttrName,
nsIAtom* aAttrValue);
/**
* Set group attributes ('level', 'setsize', 'posinset').
*/
static void SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
int32_t aLevel, int32_t aSetSize,
int32_t aPosInSet);
/**
* Get default value of the level for the given accessible.
*/
static int32_t GetDefaultLevel(Accessible* aAcc);
/**
* Return ARIA level value or the default one if ARIA is missed for the
* given accessible.
*/
static int32_t GetARIAOrDefaultLevel(Accessible* aAccessible);
/**
* Compute group level for nsIDOMXULContainerItemElement node.
*/
static int32_t GetLevelForXULContainerItem(nsIContent *aContent);
/**
* Set container-foo live region attributes for the given node.
*
* @param aAttributes where to store the attributes
* @param aStartContent node to start from
* @param aTopContent node to end at
*/
static void SetLiveContainerAttributes(nsIPersistentProperties *aAttributes,
nsIContent* aStartContent,
mozilla::dom::Element* aTopEl);
/**
* Any ARIA property of type boolean or NMTOKEN is undefined if the ARIA
* property is not present, or is "" or "undefined". Do not call
* this method for properties of type string, decimal, IDREF or IDREFS.
*
* Return true if the ARIA property is defined, otherwise false
*/
static bool HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom);
/**
* Return atomic value of ARIA attribute of boolean or NMTOKEN type.
*/
static nsIAtom* GetARIAToken(mozilla::dom::Element* aElement, nsIAtom* aAttr);
/**
* Return document accessible for the given DOM node.
*/
static DocAccessible* GetDocAccessibleFor(nsINode* aNode)
{
nsIPresShell *presShell = nsCoreUtils::GetPresShellFor(aNode);
return GetAccService()->GetDocAccessible(presShell);
}
/**
* Return document accessible for the given docshell.
*/
static DocAccessible* GetDocAccessibleFor(nsIDocShellTreeItem* aContainer)
{
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
return GetAccService()->GetDocAccessible(docShell->GetPresShell());
}
/**
* Return single or multi selectable container for the given item.
*
* @param aAccessible [in] the item accessible
* @param aState [in] the state of the item accessible
*/
static Accessible* GetSelectableContainer(Accessible* aAccessible,
uint64_t aState);
/**
* Return a text container accessible for the given node.
*/
static HyperTextAccessible* GetTextContainer(nsINode* aNode);
static Accessible* TableFor(Accessible* aRow);
/**
* Return true if the DOM node of given accessible has aria-selected="true"
* attribute.
*/
static bool IsARIASelected(Accessible* aAccessible);
/**
* Converts the given coordinates to coordinates relative screen.
*
* @param aX [in] the given x coord
* @param aY [in] the given y coord
* @param aCoordinateType [in] specifies coordinates origin (refer to
* nsIAccessibleCoordinateType)
* @param aAccessible [in] the accessible if coordinates are given
* relative it.
* @return converted coordinates
*/
static nsIntPoint ConvertToScreenCoords(int32_t aX, int32_t aY,
uint32_t aCoordinateType,
Accessible* aAccessible);
/**
* Converts the given coordinates relative screen to another coordinate
* system.
*
* @param aX [in, out] the given x coord
* @param aY [in, out] the given y coord
* @param aCoordinateType [in] specifies coordinates origin (refer to
* nsIAccessibleCoordinateType)
* @param aAccessible [in] the accessible if coordinates are given
* relative it
*/
static void ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
uint32_t aCoordinateType,
Accessible* aAccessible);
/**
* Returns coordinates relative screen for the parent of the given accessible.
*
* @param [in] aAccessible the accessible
*/
static nsIntPoint GetScreenCoordsForParent(Accessible* aAccessible);
/**
* Get the 'live' or 'container-live' object attribute value from the given
* ELiveAttrRule constant.
*
* @param aRule [in] rule constant (see ELiveAttrRule in nsAccMap.h)
* @param aValue [out] object attribute value
*
* @return true if object attribute should be exposed
*/
static bool GetLiveAttrValue(uint32_t aRule, nsAString& aValue);
#ifdef DEBUG
/**
* Detect whether the given accessible object implements nsIAccessibleText,
* when it is text or has text child node.
*/
static bool IsTextInterfaceSupportCorrect(Accessible* aAccessible);
#endif
/**
* Return text length of the given accessible, return 0 on failure.
*/
static uint32_t TextLength(Accessible* aAccessible);
/**
* Transform nsIAccessibleStates constants to internal state constant.
*/
static inline uint64_t To64State(uint32_t aState1, uint32_t aState2)
{
return static_cast<uint64_t>(aState1) +
(static_cast<uint64_t>(aState2) << 31);
}
/**
* Transform internal state constant to nsIAccessibleStates constants.
*/
static inline void To32States(uint64_t aState64,
uint32_t* aState1, uint32_t* aState2)
{
*aState1 = aState64 & 0x7fffffff;
if (aState2)
*aState2 = static_cast<uint32_t>(aState64 >> 31);
}
static uint32_t To32States(uint64_t aState, bool* aIsExtra)
{
uint32_t extraState = aState >> 31;
*aIsExtra = !!extraState;
return aState | extraState;
}
/**
* Return true if the given accessible can't have children. Used when exposing
* to platform accessibility APIs, should the children be pruned off?
*/
static bool MustPrune(Accessible* aAccessible);
};
} // namespace a11y
} // namespace mozilla
#endif