1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef _LocalAccessible_H_
7 #define _LocalAccessible_H_
9 #include "mozilla/a11y/Accessible.h"
10 #include "mozilla/a11y/AccTypes.h"
11 #include "mozilla/a11y/RelationType.h"
12 #include "mozilla/a11y/States.h"
14 #include "mozilla/UniquePtr.h"
16 #include "nsIContent.h"
18 #include "nsRefPtrHashtable.h"
21 struct nsRoleMapEntry
;
27 namespace mozilla::dom
{
34 class LocalAccessible
;
38 class ApplicationAccessible
;
41 class EmbeddedObjCollector
;
43 class HTMLImageMapAccessible
;
44 class HTMLLIAccessible
;
45 class HTMLLinkAccessible
;
46 class HyperTextAccessible
;
47 class HyperTextAccessibleBase
;
48 class ImageAccessible
;
50 class OuterDocAccessible
;
51 class RemoteAccessible
;
54 class TableAccessible
;
55 class TableCellAccessible
;
56 class TextLeafAccessible
;
57 class XULLabelAccessible
;
58 class XULTreeAccessible
;
60 enum class CacheUpdateType
;
64 typedef const char* (*GetTreePrefix
)(void* aData
, LocalAccessible
*);
65 void Tree(const char* aTitle
, const char* aMsgText
, LocalAccessible
* aRoot
,
66 GetTreePrefix aPrefixFunc
, void* GetTreePrefixData
);
67 void TreeSize(const char* aTitle
, const char* aMsgText
, LocalAccessible
* aRoot
);
68 }; // namespace logging
72 * Group position (level, position in set and set size).
75 GroupPos() : level(0), posInSet(0), setSize(0) {}
76 GroupPos(int32_t aLevel
, int32_t aPosInSet
, int32_t aSetSize
)
77 : level(aLevel
), posInSet(aPosInSet
), setSize(aSetSize
) {}
84 typedef nsRefPtrHashtable
<nsPtrHashKey
<const void>, LocalAccessible
>
87 #define NS_ACCESSIBLE_IMPL_IID \
88 { /* 133c8bf4-4913-4355-bd50-426bd1d6e1ad */ \
89 0x133c8bf4, 0x4913, 0x4355, { \
90 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad \
94 class LocalAccessible
: public nsISupports
, public Accessible
{
96 LocalAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
);
98 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
99 NS_DECL_CYCLE_COLLECTION_CLASS(LocalAccessible
)
101 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID
)
103 //////////////////////////////////////////////////////////////////////////////
107 * Return the document accessible for this accessible.
109 DocAccessible
* Document() const { return mDoc
; }
112 * Return the root document accessible for this accessible.
114 a11y::RootAccessible
* RootAccessible() const;
117 * Return frame for this accessible.
119 virtual nsIFrame
* GetFrame() const;
122 * Return DOM node associated with the accessible.
124 virtual nsINode
* GetNode() const;
126 nsIContent
* GetContent() const { return mContent
; }
127 dom::Element
* Elm() const;
130 * Return node type information of DOM node associated with the accessible.
132 bool IsContent() const { return GetNode() && GetNode()->IsContent(); }
135 * Return the unique identifier of the accessible.
137 void* UniqueID() { return static_cast<void*>(this); }
140 * Return language associated with the accessible.
142 void Language(nsAString
& aLocale
);
145 * Get the description of this accessible.
147 virtual void Description(nsString
& aDescription
) const override
;
150 * Get the value of this accessible.
152 virtual void Value(nsString
& aValue
) const;
155 * Get help string for the accessible.
157 void Help(nsString
& aHelp
) const { aHelp
.Truncate(); }
160 * Get the name of this accessible.
162 * Note: aName.IsVoid() when name was left empty by the author on purpose.
163 * aName.IsEmpty() when the author missed name, AT can try to repair a name.
165 virtual ENameValueFlag
Name(nsString
& aName
) const override
;
168 * Maps ARIA state attributes to state of accessible. Note the given state
169 * argument should hold states for accessible before you pass it into this
172 * @param [in/out] where to fill the states into.
174 virtual void ApplyARIAState(uint64_t* aState
) const;
177 * Return enumerated accessible role (see constants in Role.h).
179 virtual mozilla::a11y::role
Role() const override
;
182 * Return accessible role specified by ARIA (see constants in
185 mozilla::a11y::role
ARIARole();
188 * Return a landmark role if applied.
190 virtual nsAtom
* LandmarkRole() const;
193 * Returns enumerated accessible role from native markup (see constants in
194 * Role.h). Doesn't take into account ARIA roles.
196 virtual mozilla::a11y::role
NativeRole() const;
199 * Return all states of accessible (including ARIA states).
201 virtual uint64_t State();
204 * Return interactive states present on the accessible
205 * (@see NativeInteractiveState).
207 uint64_t InteractiveState() const {
208 uint64_t state
= NativeInteractiveState();
209 ApplyARIAState(&state
);
214 * Return link states present on the accessible.
216 uint64_t LinkState() const {
217 uint64_t state
= NativeLinkState();
218 ApplyARIAState(&state
);
223 * Return the states of accessible, not taking into account ARIA states.
224 * Use State() to get complete set of states.
226 virtual uint64_t NativeState() const;
229 * Return native interactice state (unavailable, focusable or selectable).
231 virtual uint64_t NativeInteractiveState() const;
234 * Return native link states present on the accessible.
236 virtual uint64_t NativeLinkState() const;
239 * Return bit set of invisible and offscreen states.
241 uint64_t VisibilityState() const;
244 * Return true if native unavailable state present.
246 virtual bool NativelyUnavailable() const;
249 * Return object attributes for the accessible.
251 virtual already_AddRefed
<AccAttributes
> Attributes();
254 * Return group position (level, position in set and set size).
256 virtual mozilla::a11y::GroupPos
GroupPosition();
259 * Return direct or deepest child at the given point.
261 * @param aX [in] x coordinate relative screen
262 * @param aY [in] y coordinate relative screen
263 * @param aWhichChild [in] flag points if deepest or direct child
266 virtual LocalAccessible
* LocalChildAtPoint(int32_t aX
, int32_t aY
,
267 EWhichChildAtPoint aWhichChild
);
270 * Similar to LocalChildAtPoint but crosses process boundaries.
272 virtual Accessible
* ChildAtPoint(int32_t aX
, int32_t aY
,
273 EWhichChildAtPoint aWhichChild
) override
;
276 * Return the focused child if any.
278 virtual LocalAccessible
* FocusedChild();
281 * Return calculated group level based on accessible hierarchy.
283 virtual int32_t GetLevelInternal();
286 * Calculate position in group and group size ('posinset' and 'setsize') based
287 * on accessible hierarchy.
289 * @param aPosInSet [out] accessible position in the group
290 * @param aSetSize [out] the group size
292 virtual void GetPositionAndSizeInternal(int32_t* aPosInSet
,
296 * Get the relation of the given type.
298 virtual Relation
RelationByType(RelationType aType
) const;
300 //////////////////////////////////////////////////////////////////////////////
301 // Initializing methods
304 * Shutdown this accessible object.
306 virtual void Shutdown();
309 * Set the ARIA role map entry for a new accessible.
311 void SetRoleMapEntry(const nsRoleMapEntry
* aRoleMapEntry
);
314 * Append/insert/remove a child. Return true if operation was successful.
316 bool AppendChild(LocalAccessible
* aChild
) {
317 return InsertChildAt(mChildren
.Length(), aChild
);
319 virtual bool InsertChildAt(uint32_t aIndex
, LocalAccessible
* aChild
);
322 * Inserts a child after given sibling. If the child cannot be inserted,
323 * then the child is unbound from the document, and false is returned. Make
324 * sure to null out any references on the child object as it may be destroyed.
326 bool InsertAfter(LocalAccessible
* aNewChild
, LocalAccessible
* aRefChild
);
328 virtual bool RemoveChild(LocalAccessible
* aChild
);
331 * Reallocates the child within its parent.
333 virtual void RelocateChild(uint32_t aNewIndex
, LocalAccessible
* aChild
);
335 // Accessible hierarchy method overrides
337 virtual Accessible
* Parent() const override
{ return LocalParent(); }
339 virtual Accessible
* ChildAt(uint32_t aIndex
) const override
{
340 return LocalChildAt(aIndex
);
343 virtual Accessible
* NextSibling() const override
{
344 return LocalNextSibling();
347 virtual Accessible
* PrevSibling() const override
{
348 return LocalPrevSibling();
351 //////////////////////////////////////////////////////////////////////////////
352 // LocalAccessible tree traverse methods
355 * Return parent accessible.
357 LocalAccessible
* LocalParent() const { return mParent
; }
360 * Return child accessible at the given index.
362 virtual LocalAccessible
* LocalChildAt(uint32_t aIndex
) const;
365 * Return child accessible count.
367 virtual uint32_t ChildCount() const override
;
370 * Return index of the given child accessible.
372 int32_t GetIndexOf(const LocalAccessible
* aChild
) const {
373 return (aChild
->mParent
!= this) ? -1 : aChild
->IndexInParent();
377 * Return index in parent accessible.
379 virtual int32_t IndexInParent() const override
;
382 * Return first/last/next/previous sibling of the accessible.
384 inline LocalAccessible
* LocalNextSibling() const {
385 return GetSiblingAtOffset(1);
387 inline LocalAccessible
* LocalPrevSibling() const {
388 return GetSiblingAtOffset(-1);
390 inline LocalAccessible
* LocalFirstChild() const { return LocalChildAt(0); }
391 inline LocalAccessible
* LocalLastChild() const {
392 uint32_t childCount
= ChildCount();
393 return childCount
!= 0 ? LocalChildAt(childCount
- 1) : nullptr;
397 * Return embedded accessible children count.
399 uint32_t EmbeddedChildCount();
402 * Return embedded accessible child at the given index.
404 virtual LocalAccessible
* EmbeddedChildAt(uint32_t aIndex
) override
;
407 * Return index of the given embedded accessible child.
409 int32_t GetIndexOfEmbeddedChild(LocalAccessible
* aChild
);
412 * Return number of content children/content child at index. The content
413 * child is created from markup in contrast to it's never constructed by its
414 * parent accessible (like treeitem accessibles for XUL trees).
416 uint32_t ContentChildCount() const { return mChildren
.Length(); }
417 LocalAccessible
* ContentChildAt(uint32_t aIndex
) const {
418 return mChildren
.ElementAt(aIndex
);
422 * Return true if the accessible is attached to tree.
424 bool IsBoundToParent() const { return !!mParent
; }
426 //////////////////////////////////////////////////////////////////////////////
427 // Miscellaneous methods
430 * Handle accessible event, i.e. process it, notifies observers and fires
431 * platform specific event.
433 virtual nsresult
HandleAccEvent(AccEvent
* aAccEvent
);
436 * Return true if the accessible is an acceptable child.
438 virtual bool IsAcceptableChild(nsIContent
* aEl
) const {
440 !aEl
->IsAnyOfHTMLElements(nsGkAtoms::option
, nsGkAtoms::optgroup
);
443 virtual void AppendTextTo(nsAString
& aText
, uint32_t aStartOffset
= 0,
444 uint32_t aLength
= UINT32_MAX
) override
;
447 * Return boundaries in screen coordinates in app units.
449 virtual nsRect
BoundsInAppUnits() const;
452 * Return boundaries in screen coordinates.
454 virtual nsIntRect
Bounds() const override
;
457 * Return boundaries in screen coordinates in CSS pixels.
459 virtual nsIntRect
BoundsInCSSPixels() const;
462 * Return boundaries rect relative the bounding frame.
464 virtual nsRect
RelativeBounds(nsIFrame
** aRelativeFrame
) const;
467 * Return boundaries rect relative to the frame of the parent accessible.
469 virtual nsRect
ParentRelativeBounds();
472 * Selects the accessible within its container if applicable.
474 virtual void SetSelected(bool aSelect
);
477 * Select the accessible within its container.
479 void TakeSelection();
482 * Focus the accessible.
484 MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual void TakeFocus() const;
487 * Scroll the accessible into view.
490 virtual void ScrollTo(uint32_t aHow
) const;
493 * Scroll the accessible to the given point.
495 void ScrollToPoint(uint32_t aCoordinateType
, int32_t aX
, int32_t aY
);
498 * Get a pointer to accessibility interface for this node, which is specific
499 * to the OS/accessibility toolkit we're running on.
501 virtual void GetNativeInterface(void** aNativeAccessible
);
503 //////////////////////////////////////////////////////////////////////////////
504 // Downcasting and types
506 inline bool IsAbbreviation() const {
507 return mContent
->IsAnyOfHTMLElements(nsGkAtoms::abbr
, nsGkAtoms::acronym
);
510 ApplicationAccessible
* AsApplication();
512 DocAccessible
* AsDoc();
514 HyperTextAccessible
* AsHyperText();
515 virtual HyperTextAccessibleBase
* AsHyperTextBase() override
;
517 HTMLLIAccessible
* AsHTMLListItem();
519 HTMLLinkAccessible
* AsHTMLLink();
521 ImageAccessible
* AsImage();
523 HTMLImageMapAccessible
* AsImageMap();
525 RemoteAccessible
* Proxy() const {
526 MOZ_ASSERT(IsProxy());
530 OuterDocAccessible
* AsOuterDoc();
532 a11y::RootAccessible
* AsRoot();
534 bool IsSearchbox() const;
536 virtual TableAccessible
* AsTable() { return nullptr; }
538 virtual TableCellAccessible
* AsTableCell() { return nullptr; }
539 const TableCellAccessible
* AsTableCell() const {
540 return const_cast<LocalAccessible
*>(this)->AsTableCell();
543 TextLeafAccessible
* AsTextLeaf();
545 XULLabelAccessible
* AsXULLabel();
547 XULTreeAccessible
* AsXULTree();
549 //////////////////////////////////////////////////////////////////////////////
553 * Return the number of actions that can be performed on this accessible.
555 virtual uint8_t ActionCount() const;
558 * Return action name at given index.
560 virtual void ActionNameAt(uint8_t aIndex
, nsAString
& aName
);
563 * Default to localized action name.
565 void ActionDescriptionAt(uint8_t aIndex
, nsAString
& aDescription
) {
567 ActionNameAt(aIndex
, name
);
568 TranslateString(name
, aDescription
);
572 * Invoke the accessible action.
574 virtual bool DoAction(uint8_t aIndex
) const;
577 * Return access key, such as Alt+D.
579 virtual KeyBinding
AccessKey() const;
582 * Return global keyboard shortcut for default action, such as Ctrl+O for
583 * Open file menuitem.
585 virtual KeyBinding
KeyboardShortcut() const;
587 //////////////////////////////////////////////////////////////////////////////
588 // HyperLinkAccessible (any embedded object in text can implement HyperLink,
589 // which helps determine where it is located within containing text).
592 * Return true if the accessible is hyper link accessible.
594 virtual bool IsLink() const override
;
597 * Return the start offset of the link within the parent accessible.
599 virtual uint32_t StartOffset();
602 * Return the end offset of the link within the parent accessible.
604 virtual uint32_t EndOffset();
607 * Return true if the link is valid (e. g. points to a valid URL).
609 inline bool IsLinkValid() {
610 MOZ_ASSERT(IsLink(), "IsLinkValid is called on not hyper link!");
612 // XXX In order to implement this we would need to follow every link
613 // Perhaps we can get information about invalid links from the cache
614 // In the mean time authors can use role="link" aria-invalid="true"
615 // to force it for links they internally know to be invalid
616 return (0 == (State() & mozilla::a11y::states::INVALID
));
620 * Return the number of anchors within the link.
622 virtual uint32_t AnchorCount();
625 * Returns an anchor accessible at the given index.
627 virtual LocalAccessible
* AnchorAt(uint32_t aAnchorIndex
);
630 * Returns an anchor URI at the given index.
632 virtual already_AddRefed
<nsIURI
> AnchorURIAt(uint32_t aAnchorIndex
) const;
635 * Returns a text point for the accessible element.
637 void ToTextPoint(HyperTextAccessible
** aContainer
, int32_t* aOffset
,
638 bool aIsBefore
= true) const;
640 //////////////////////////////////////////////////////////////////////////////
644 * Return an array of selected items.
646 virtual void SelectedItems(nsTArray
<LocalAccessible
*>* aItems
);
649 * Return the number of selected items.
651 virtual uint32_t SelectedItemCount();
654 * Return selected item at the given index.
656 virtual LocalAccessible
* GetSelectedItem(uint32_t aIndex
);
659 * Determine if item at the given index is selected.
661 virtual bool IsItemSelected(uint32_t aIndex
);
664 * Add item at the given index the selection. Return true if success.
666 virtual bool AddItemToSelection(uint32_t aIndex
);
669 * Remove item at the given index from the selection. Return if success.
671 virtual bool RemoveItemFromSelection(uint32_t aIndex
);
674 * Select all items. Return true if success.
676 virtual bool SelectAll();
679 * Unselect all items. Return true if success.
681 virtual bool UnselectAll();
683 //////////////////////////////////////////////////////////////////////////////
684 // Value (numeric value interface)
686 virtual double MaxValue() const override
;
687 virtual double MinValue() const override
;
688 virtual double CurValue() const override
;
689 virtual double Step() const override
;
690 virtual bool SetCurValue(double aValue
);
692 //////////////////////////////////////////////////////////////////////////////
696 * Return true if accessible is a widget, i.e. control or accessible that
697 * manages its items. Note, being a widget the accessible may be a part of
700 virtual bool IsWidget() const;
703 * Return true if the widget is active, i.e. has a focus within it.
705 virtual bool IsActiveWidget() const;
708 * Return true if the widget has items and items are operable by user and
711 virtual bool AreItemsOperable() const;
714 * Return the current item of the widget, i.e. an item that has or will have
715 * keyboard focus when widget gets active.
717 virtual LocalAccessible
* CurrentItem() const;
720 * Set the current item of the widget.
722 virtual void SetCurrentItem(const LocalAccessible
* aItem
);
725 * Return container widget this accessible belongs to.
727 virtual LocalAccessible
* ContainerWidget() const;
730 * Return the localized string for the given key.
732 static void TranslateString(const nsString
& aKey
, nsAString
& aStringOut
);
735 * Return true if the accessible is defunct.
737 bool IsDefunct() const;
740 * Return false if the accessible is no longer in the document.
742 bool IsInDocument() const { return !(mStateFlags
& eIsNotInDocument
); }
745 * Return true if the accessible should be contained by document node map.
747 bool IsNodeMapEntry() const {
748 return HasOwnContent() && !(mStateFlags
& eNotNodeMapEntry
);
752 * Return true if the accessible's group info needs to be updated.
754 inline bool HasDirtyGroupInfo() const {
755 return mStateFlags
& eGroupInfoDirty
;
759 * Return true if the accessible has associated DOM content.
761 bool HasOwnContent() const {
762 return mContent
&& !(mStateFlags
& eSharedNode
);
766 * Return true if native markup has a numeric value.
768 bool NativeHasNumericValue() const;
771 * Return true if ARIA specifies support for a numeric value.
773 bool ARIAHasNumericValue() const;
776 * Return true if the accessible has a numeric value.
778 virtual bool HasNumericValue() const override
;
781 * Return true if the accessible state change is processed by handling proper
782 * DOM UI event, if otherwise then false. For example, CheckboxAccessible
783 * created for HTML:input@type="checkbox" will process
784 * nsIDocumentObserver::ContentStateChanged instead of 'CheckboxStateChange'
787 bool NeedsDOMUIEvent() const { return !(mStateFlags
& eIgnoreDOMUIEvent
); }
790 * Get/set repositioned bit indicating that the accessible was moved in
791 * the accessible tree, i.e. the accessible tree structure differs from DOM.
793 bool IsRelocated() const { return mStateFlags
& eRelocated
; }
794 void SetRelocated(bool aRelocated
) {
796 mStateFlags
|= eRelocated
;
798 mStateFlags
&= ~eRelocated
;
803 * Return true if the accessible allows accessible children from subtree of
804 * a DOM element of this accessible.
806 bool KidsFromDOM() const { return !(mStateFlags
& eNoKidsFromDOM
); }
809 * Return true if this accessible has a parent, relation or ancestor with a
810 * relation whose name depends on this accessible.
812 bool HasNameDependent() const { return mContextFlags
& eHasNameDependent
; }
815 * Return true if this accessible has a parent, relation or ancestor with a
816 * relation whose description depends on this accessible.
818 bool HasDescriptionDependent() const {
819 return mContextFlags
& eHasDescriptionDependent
;
823 * Return true if the element is inside an alert.
825 bool IsInsideAlert() const { return mContextFlags
& eInsideAlert
; }
828 * Return true if there is a pending reorder event for this accessible.
830 bool ReorderEventTarget() const { return mReorderEventTarget
; }
833 * Return true if there is a pending show event for this accessible.
835 bool ShowEventTarget() const { return mShowEventTarget
; }
838 * Return true if there is a pending hide event for this accessible.
840 bool HideEventTarget() const { return mHideEventTarget
; }
843 * Set if there is a pending reorder event for this accessible.
845 void SetReorderEventTarget(bool aTarget
) { mReorderEventTarget
= aTarget
; }
848 * Set if this accessible is a show event target.
850 void SetShowEventTarget(bool aTarget
) { mShowEventTarget
= aTarget
; }
853 * Set if this accessible is a hide event target.
855 void SetHideEventTarget(bool aTarget
) { mHideEventTarget
= aTarget
; }
857 void Announce(const nsAString
& aAnnouncement
, uint16_t aPriority
);
859 virtual bool IsRemote() const override
{ return false; }
861 already_AddRefed
<AccAttributes
> BundleFieldsForCache(
862 uint64_t aCacheDomain
, CacheUpdateType aUpdateType
);
865 virtual ~LocalAccessible();
868 * Return the accessible name provided by native markup. It doesn't take
869 * into account ARIA markup used to specify the name.
871 virtual mozilla::a11y::ENameValueFlag
NativeName(nsString
& aName
) const;
874 * Return the accessible description provided by native markup. It doesn't
875 * take into account ARIA markup used to specify the description.
877 void NativeDescription(nsString
& aDescription
) const;
880 * Return object attributes provided by native markup. It doesn't take into
883 virtual already_AddRefed
<AccAttributes
> NativeAttributes();
886 * The given attribute has the potential of changing the accessible's state.
887 * This is used to capture the state before the attribute change and compare
888 * it with the state after.
890 virtual bool AttributeChangesState(nsAtom
* aAttribute
);
893 * Notify accessible that a DOM attribute on its associated content has
894 * changed. This allows the accessible to update its state and emit any
897 virtual void DOMAttributeChanged(int32_t aNameSpaceID
, nsAtom
* aAttribute
,
899 const nsAttrValue
* aOldValue
,
902 //////////////////////////////////////////////////////////////////////////////
903 // Initializing, cache and tree traverse methods
906 * Destroy the object.
911 * Set accessible parent and index in parent.
913 void BindToParent(LocalAccessible
* aParent
, uint32_t aIndexInParent
);
914 void UnbindFromParent();
917 * Return sibling accessible at the given offset.
919 virtual LocalAccessible
* GetSiblingAtOffset(int32_t aOffset
,
920 nsresult
* aError
= nullptr) const;
922 void ModifySubtreeContextFlags(uint32_t aContextFlags
, bool aAdd
);
925 * Flags used to describe the state of this accessible.
928 eIsDefunct
= 1 << 0, // accessible is defunct
929 eIsNotInDocument
= 1 << 1, // accessible is not in document
930 eSharedNode
= 1 << 2, // accessible shares DOM node from another accessible
931 eNotNodeMapEntry
= 1 << 3, // accessible shouldn't be in document node map
932 eGroupInfoDirty
= 1 << 4, // accessible needs to update group info
933 eKidsMutating
= 1 << 5, // subtree is being mutated
934 eIgnoreDOMUIEvent
= 1 << 6, // don't process DOM UI events for a11y events
935 eRelocated
= 1 << 7, // accessible was moved in tree
936 eNoKidsFromDOM
= 1 << 8, // accessible doesn't allow children from DOM
937 eHasTextKids
= 1 << 9, // accessible have a text leaf in children
939 eLastStateFlag
= eHasTextKids
943 * Flags used for contextual information about the accessible.
946 eHasNameDependent
= 1 << 0, // See HasNameDependent().
947 eInsideAlert
= 1 << 1,
948 eHasDescriptionDependent
= 1 << 2, // See HasDescriptionDependent().
950 eLastContextFlag
= eHasDescriptionDependent
954 //////////////////////////////////////////////////////////////////////////////
955 // Miscellaneous helpers
958 * Return ARIA role (helper method).
960 mozilla::a11y::role
ARIATransformRole(mozilla::a11y::role aRole
) const;
962 //////////////////////////////////////////////////////////////////////////////
966 * Returns the accessible name specified by ARIA.
968 void ARIAName(nsString
& aName
) const;
971 * Returns the accessible description specified by ARIA.
973 void ARIADescription(nsString
& aDescription
) const;
976 * Returns the accessible name specified for this control using XUL
977 * <label control="id" ...>.
979 static void NameFromAssociatedXULLabel(DocAccessible
* aDocument
,
980 nsIContent
* aElm
, nsString
& aName
);
983 * Return the name for XUL element.
985 static void XULElmName(DocAccessible
* aDocument
, nsIContent
* aElm
,
988 // helper method to verify frames
989 static nsresult
GetFullKeyName(const nsAString
& aModifierName
,
990 const nsAString
& aKeyName
,
991 nsAString
& aStringOut
);
993 //////////////////////////////////////////////////////////////////////////////
997 * Prepares click action that will be invoked in timeout.
999 * @note DoCommand() prepares an action in timeout because when action
1000 * command opens a modal dialog/window, it won't return until the
1001 * dialog/window is closed. If executing action command directly in
1002 * nsIAccessible::DoAction() method, it will block AT tools (e.g. GOK) that
1003 * invoke action of mozilla accessibles direclty (see bug 277888 for
1006 * @param aContent [in, optional] element to click
1007 * @param aActionIndex [in, optional] index of accessible action
1009 void DoCommand(nsIContent
* aContent
= nullptr,
1010 uint32_t aActionIndex
= 0) const;
1013 * Dispatch click event.
1016 virtual void DispatchClickEvent(nsIContent
* aContent
,
1017 uint32_t aActionIndex
) const;
1019 //////////////////////////////////////////////////////////////////////////////
1023 * Get the container node for an atomic region, defined by aria-atomic="true"
1024 * @return the container node
1026 nsIContent
* GetAtomicRegion() const;
1029 * Return numeric value of the given ARIA attribute, NaN if not applicable.
1031 * @param aARIAProperty [in] the ARIA property we're using
1032 * @return a numeric value
1034 double AttrNumericValue(nsAtom
* aARIAAttr
) const;
1037 * Return the action rule based on ARIA enum constants EActionRule
1038 * (see ARIAMap.h). Used by ActionCount() and ActionNameAt().
1040 uint32_t GetActionRule() const;
1043 * Return group info.
1045 AccGroupInfo
* GetGroupInfo() const;
1048 * Push fields to cache.
1049 * aCacheDomain - describes which fields to bundle and ultimately send
1050 * aUpdate - describes whether this is an initial or subsequent update
1052 void SendCache(uint64_t aCacheDomain
, CacheUpdateType aUpdate
);
1055 nsCOMPtr
<nsIContent
> mContent
;
1056 RefPtr
<DocAccessible
> mDoc
;
1058 LocalAccessible
* mParent
;
1059 nsTArray
<LocalAccessible
*> mChildren
;
1060 int32_t mIndexInParent
;
1061 Maybe
<nsRect
> mBounds
;
1063 static const uint8_t kStateFlagsBits
= 11;
1064 static const uint8_t kContextFlagsBits
= 3;
1067 * Keep in sync with StateFlags, ContextFlags, and AccTypes.
1069 mutable uint32_t mStateFlags
: kStateFlagsBits
;
1070 uint32_t mContextFlags
: kContextFlagsBits
;
1071 uint32_t mReorderEventTarget
: 1;
1072 uint32_t mShowEventTarget
: 1;
1073 uint32_t mHideEventTarget
: 1;
1075 void StaticAsserts() const;
1078 friend void logging::Tree(const char* aTitle
, const char* aMsgText
,
1079 LocalAccessible
* aRoot
,
1080 logging::GetTreePrefix aPrefixFunc
,
1081 void* aGetTreePrefixData
);
1082 friend void logging::TreeSize(const char* aTitle
, const char* aMsgText
,
1083 LocalAccessible
* aRoot
);
1085 friend class DocAccessible
;
1086 friend class xpcAccessible
;
1087 friend class TreeMutation
;
1089 UniquePtr
<mozilla::a11y::EmbeddedObjCollector
> mEmbeddedObjCollector
;
1090 int32_t mIndexOfEmbeddedChild
;
1092 friend class EmbeddedObjCollector
;
1095 AccGroupInfo
* groupInfo
;
1096 RemoteAccessible
* proxy
;
1098 friend class AccGroupInfo
;
1101 LocalAccessible() = delete;
1102 LocalAccessible(const LocalAccessible
&) = delete;
1103 LocalAccessible
& operator=(const LocalAccessible
&) = delete;
1106 NS_DEFINE_STATIC_IID_ACCESSOR(LocalAccessible
, NS_ACCESSIBLE_IMPL_IID
)
1108 ////////////////////////////////////////////////////////////////////////////////
1109 // LocalAccessible downcasting method
1111 inline LocalAccessible
* Accessible::AsLocal() {
1112 return IsLocal() ? static_cast<LocalAccessible
*>(this) : nullptr;
1116 * Represent key binding associated with accessible (such as access key and
1117 * global keyboard shortcuts).
1122 * Modifier mask values.
1124 static const uint32_t kShift
= 1;
1125 static const uint32_t kControl
= 2;
1126 static const uint32_t kAlt
= 4;
1127 static const uint32_t kMeta
= 8;
1128 static const uint32_t kOS
= 16;
1130 static uint32_t AccelModifier();
1132 KeyBinding() : mKey(0), mModifierMask(0) {}
1133 KeyBinding(uint32_t aKey
, uint32_t aModifierMask
)
1134 : mKey(aKey
), mModifierMask(aModifierMask
) {}
1136 inline bool IsEmpty() const { return !mKey
; }
1137 inline uint32_t Key() const { return mKey
; }
1138 inline uint32_t ModifierMask() const { return mModifierMask
; }
1140 enum Format
{ ePlatformFormat
, eAtkFormat
};
1143 * Return formatted string for this key binding depending on the given format.
1145 inline void ToString(nsAString
& aValue
,
1146 Format aFormat
= ePlatformFormat
) const {
1148 AppendToString(aValue
, aFormat
);
1150 inline void AppendToString(nsAString
& aValue
,
1151 Format aFormat
= ePlatformFormat
) const {
1153 if (aFormat
== ePlatformFormat
) {
1154 ToPlatformFormat(aValue
);
1156 ToAtkFormat(aValue
);
1162 void ToPlatformFormat(nsAString
& aValue
) const;
1163 void ToAtkFormat(nsAString
& aValue
) const;
1166 uint32_t mModifierMask
;
1170 } // namespace mozilla