Bug 1856976 [wpt PR 42335] - Update mutation event suppression for <details name...
[gecko.git] / accessible / generic / LocalAccessible.h
blobe4627f3cf77bb1df0d1b2a0db4e486c057f441ee
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/ComputedStyle.h"
10 #include "mozilla/a11y/Accessible.h"
11 #include "mozilla/a11y/AccTypes.h"
12 #include "mozilla/a11y/RelationType.h"
13 #include "mozilla/a11y/States.h"
15 #include "mozilla/UniquePtr.h"
17 #include "nsIContent.h"
18 #include "nsTArray.h"
19 #include "nsRefPtrHashtable.h"
20 #include "nsRect.h"
22 struct nsRoleMapEntry;
24 class nsIFrame;
26 class nsAttrValue;
28 namespace mozilla::dom {
29 class Element;
32 namespace mozilla {
33 namespace a11y {
35 class LocalAccessible;
36 class AccAttributes;
37 class AccEvent;
38 class AccGroupInfo;
39 class ApplicationAccessible;
40 class CacheData;
41 class DocAccessible;
42 class EmbeddedObjCollector;
43 class EventTree;
44 class HTMLImageMapAccessible;
45 class HTMLLIAccessible;
46 class HTMLLinkAccessible;
47 class HyperTextAccessible;
48 class HyperTextAccessibleBase;
49 class ImageAccessible;
50 class KeyBinding;
51 class OuterDocAccessible;
52 class RemoteAccessible;
53 class Relation;
54 class RootAccessible;
55 class TableAccessible;
56 class TableCellAccessible;
57 class TextLeafAccessible;
58 class XULLabelAccessible;
59 class XULTreeAccessible;
61 enum class CacheUpdateType;
63 #ifdef A11Y_LOG
64 namespace logging {
65 typedef const char* (*GetTreePrefix)(void* aData, LocalAccessible*);
66 void Tree(const char* aTitle, const char* aMsgText, LocalAccessible* aRoot,
67 GetTreePrefix aPrefixFunc, void* GetTreePrefixData);
68 void TreeSize(const char* aTitle, const char* aMsgText, LocalAccessible* aRoot);
69 }; // namespace logging
70 #endif
72 typedef nsRefPtrHashtable<nsPtrHashKey<const void>, LocalAccessible>
73 AccessibleHashtable;
75 #define NS_ACCESSIBLE_IMPL_IID \
76 { /* 133c8bf4-4913-4355-bd50-426bd1d6e1ad */ \
77 0x133c8bf4, 0x4913, 0x4355, { \
78 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad \
79 } \
82 /**
83 * An accessibility tree node that originated in mDoc's content process.
85 class LocalAccessible : public nsISupports, public Accessible {
86 public:
87 LocalAccessible(nsIContent* aContent, DocAccessible* aDoc);
89 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
90 NS_DECL_CYCLE_COLLECTION_CLASS(LocalAccessible)
92 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
94 //////////////////////////////////////////////////////////////////////////////
95 // Public methods
97 /**
98 * Return the document accessible for this accessible.
100 DocAccessible* Document() const { return mDoc; }
103 * Return the root document accessible for this accessible.
105 a11y::RootAccessible* RootAccessible() const;
108 * Return frame for this accessible.
109 * Note that this will return null for display: contents. Also,
110 * DocAccessible::GetFrame can return null if the frame tree hasn't been
111 * created yet.
113 virtual nsIFrame* GetFrame() const;
116 * Return DOM node associated with the accessible.
118 virtual nsINode* GetNode() const;
120 nsIContent* GetContent() const { return mContent; }
121 dom::Element* Elm() const;
124 * Return node type information of DOM node associated with the accessible.
126 bool IsContent() const { return GetNode() && GetNode()->IsContent(); }
129 * Return the unique identifier of the accessible.
130 * ID() should be preferred, but this method still exists because many
131 * LocalAccessible callers expect a void*.
133 void* UniqueID() { return static_cast<void*>(this); }
135 virtual uint64_t ID() const override {
136 return IsDoc() ? 0 : reinterpret_cast<uintptr_t>(this);
139 virtual void Language(nsAString& aLocale) override;
142 * Get the description of this accessible.
144 virtual void Description(nsString& aDescription) const override;
147 * Get the value of this accessible.
149 virtual void Value(nsString& aValue) const override;
152 * Get the name of this accessible.
154 virtual ENameValueFlag Name(nsString& aName) const override;
157 * Maps ARIA state attributes to state of accessible. Note the given state
158 * argument should hold states for accessible before you pass it into this
159 * method.
161 * @param [in/out] where to fill the states into.
163 virtual void ApplyARIAState(uint64_t* aState) const;
166 * Return enumerated accessible role (see constants in Role.h).
168 virtual mozilla::a11y::role Role() const override;
171 * Return accessible role specified by ARIA (see constants in
172 * roles).
174 inline mozilla::a11y::role ARIARole();
177 * Returns enumerated accessible role from native markup (see constants in
178 * Role.h). Doesn't take into account ARIA roles.
180 virtual mozilla::a11y::role NativeRole() const;
182 virtual uint64_t State() override;
185 * Return interactive states present on the accessible
186 * (@see NativeInteractiveState).
188 uint64_t InteractiveState() const {
189 uint64_t state = NativeInteractiveState();
190 ApplyARIAState(&state);
191 return state;
195 * Return link states present on the accessible.
197 uint64_t LinkState() const {
198 uint64_t state = NativeLinkState();
199 ApplyARIAState(&state);
200 return state;
204 * Return the states of accessible, not taking into account ARIA states.
205 * Use State() to get complete set of states.
207 virtual uint64_t NativeState() const;
210 * Return native interactice state (unavailable, focusable or selectable).
212 virtual uint64_t NativeInteractiveState() const;
215 * Return native link states present on the accessible.
217 virtual uint64_t NativeLinkState() const;
220 * Return bit set of invisible and offscreen states.
222 uint64_t VisibilityState() const;
225 * Return true if native unavailable state present.
227 virtual bool NativelyUnavailable() const;
229 virtual already_AddRefed<AccAttributes> Attributes() override;
232 * Return direct or deepest child at the given point.
234 * @param aX [in] x coordinate relative screen
235 * @param aY [in] y coordinate relative screen
236 * @param aWhichChild [in] flag points if deepest or direct child
237 * should be returned
239 virtual LocalAccessible* LocalChildAtPoint(int32_t aX, int32_t aY,
240 EWhichChildAtPoint aWhichChild);
243 * Similar to LocalChildAtPoint but crosses process boundaries.
245 virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
246 EWhichChildAtPoint aWhichChild) override;
248 virtual Relation RelationByType(RelationType aType) const override;
250 //////////////////////////////////////////////////////////////////////////////
251 // Initializing methods
254 * Shutdown this accessible object.
256 virtual void Shutdown();
259 * Set the ARIA role map entry for a new accessible.
261 inline void SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry);
264 * Append/insert/remove a child. Return true if operation was successful.
266 bool AppendChild(LocalAccessible* aChild) {
267 return InsertChildAt(mChildren.Length(), aChild);
269 virtual bool InsertChildAt(uint32_t aIndex, LocalAccessible* aChild);
272 * Inserts a child after given sibling. If the child cannot be inserted,
273 * then the child is unbound from the document, and false is returned. Make
274 * sure to null out any references on the child object as it may be destroyed.
276 inline bool InsertAfter(LocalAccessible* aNewChild,
277 LocalAccessible* aRefChild);
279 virtual bool RemoveChild(LocalAccessible* aChild);
282 * Reallocates the child within its parent.
284 virtual void RelocateChild(uint32_t aNewIndex, LocalAccessible* aChild);
286 // Accessible hierarchy method overrides
288 virtual Accessible* Parent() const override { return LocalParent(); }
290 virtual Accessible* ChildAt(uint32_t aIndex) const override {
291 return LocalChildAt(aIndex);
294 virtual Accessible* NextSibling() const override {
295 return LocalNextSibling();
298 virtual Accessible* PrevSibling() const override {
299 return LocalPrevSibling();
302 //////////////////////////////////////////////////////////////////////////////
303 // LocalAccessible tree traverse methods
306 * Return parent accessible.
308 LocalAccessible* LocalParent() const { return mParent; }
311 * Return child accessible at the given index.
313 virtual LocalAccessible* LocalChildAt(uint32_t aIndex) const;
316 * Return child accessible count.
318 virtual uint32_t ChildCount() const override;
321 * Return index of the given child accessible.
323 int32_t GetIndexOf(const LocalAccessible* aChild) const {
324 return (aChild->mParent != this) ? -1 : aChild->IndexInParent();
328 * Return index in parent accessible.
330 virtual int32_t IndexInParent() const override;
333 * Return first/last/next/previous sibling of the accessible.
335 inline LocalAccessible* LocalNextSibling() const {
336 return GetSiblingAtOffset(1);
338 inline LocalAccessible* LocalPrevSibling() const {
339 return GetSiblingAtOffset(-1);
341 inline LocalAccessible* LocalFirstChild() const { return LocalChildAt(0); }
342 inline LocalAccessible* LocalLastChild() const {
343 uint32_t childCount = ChildCount();
344 return childCount != 0 ? LocalChildAt(childCount - 1) : nullptr;
347 virtual uint32_t EmbeddedChildCount() override;
350 * Return embedded accessible child at the given index.
352 virtual Accessible* EmbeddedChildAt(uint32_t aIndex) override;
354 virtual int32_t IndexOfEmbeddedChild(Accessible* aChild) override;
357 * Return number of content children/content child at index. The content
358 * child is created from markup in contrast to it's never constructed by its
359 * parent accessible (like treeitem accessibles for XUL trees).
361 uint32_t ContentChildCount() const { return mChildren.Length(); }
362 LocalAccessible* ContentChildAt(uint32_t aIndex) const {
363 return mChildren.ElementAt(aIndex);
367 * Return true if the accessible is attached to tree.
369 bool IsBoundToParent() const { return !!mParent; }
371 //////////////////////////////////////////////////////////////////////////////
372 // Miscellaneous methods
375 * Handle accessible event, i.e. process it, notifies observers and fires
376 * platform specific event.
378 virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
381 * Return true if the accessible is an acceptable child.
383 virtual bool IsAcceptableChild(nsIContent* aEl) const {
384 return aEl &&
385 !aEl->IsAnyOfHTMLElements(nsGkAtoms::option, nsGkAtoms::optgroup);
388 virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
389 uint32_t aLength = UINT32_MAX) override;
391 virtual nsRect BoundsInAppUnits() const override;
393 virtual LayoutDeviceIntRect Bounds() const override;
396 * Return boundaries rect relative the bounding frame.
398 virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const;
401 * Return boundaries rect relative to the frame of the parent accessible.
402 * The returned bounds are the same regardless of whether the parent is
403 * scrolled. This means the scroll position must be later subtracted to
404 * calculate absolute coordinates.
406 virtual nsRect ParentRelativeBounds();
409 * Selects the accessible within its container if applicable.
411 virtual void SetSelected(bool aSelect) override;
414 * Select the accessible within its container.
416 virtual void TakeSelection() override;
419 * Focus the accessible.
421 MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void TakeFocus() const override;
423 MOZ_CAN_RUN_SCRIPT
424 virtual void ScrollTo(uint32_t aHow) const override;
426 virtual void ScrollToPoint(uint32_t aCoordinateType, int32_t aX,
427 int32_t aY) override;
430 * Get a pointer to accessibility interface for this node, which is specific
431 * to the OS/accessibility toolkit we're running on.
433 virtual void GetNativeInterface(void** aNativeAccessible);
435 virtual Maybe<int32_t> GetIntARIAAttr(nsAtom* aAttrName) const override;
437 //////////////////////////////////////////////////////////////////////////////
438 // Downcasting and types
440 inline bool IsAbbreviation() const {
441 return mContent &&
442 mContent->IsAnyOfHTMLElements(nsGkAtoms::abbr, nsGkAtoms::acronym);
445 ApplicationAccessible* AsApplication();
447 DocAccessible* AsDoc();
449 HyperTextAccessible* AsHyperText();
450 virtual HyperTextAccessibleBase* AsHyperTextBase() override;
452 HTMLLIAccessible* AsHTMLListItem();
454 HTMLLinkAccessible* AsHTMLLink();
456 ImageAccessible* AsImage();
458 HTMLImageMapAccessible* AsImageMap();
460 OuterDocAccessible* AsOuterDoc();
462 a11y::RootAccessible* AsRoot();
464 virtual TableAccessible* AsTable() override;
465 virtual TableCellAccessible* AsTableCell() override;
467 TextLeafAccessible* AsTextLeaf();
469 XULLabelAccessible* AsXULLabel();
471 XULTreeAccessible* AsXULTree();
473 //////////////////////////////////////////////////////////////////////////////
474 // ActionAccessible
476 virtual bool HasPrimaryAction() const override;
478 virtual uint8_t ActionCount() const override;
480 virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
482 virtual bool DoAction(uint8_t aIndex) const override;
484 virtual KeyBinding AccessKey() const override;
487 * Return global keyboard shortcut for default action, such as Ctrl+O for
488 * Open file menuitem.
490 virtual KeyBinding KeyboardShortcut() const;
492 //////////////////////////////////////////////////////////////////////////////
493 // HyperLinkAccessible (any embedded object in text can implement HyperLink,
494 // which helps determine where it is located within containing text).
497 * Return true if the accessible is hyper link accessible.
499 virtual bool IsLink() const override;
501 //////////////////////////////////////////////////////////////////////////////
502 // SelectAccessible
505 * Return an array of selected items.
507 virtual void SelectedItems(nsTArray<Accessible*>* aItems) override;
510 * Return the number of selected items.
512 virtual uint32_t SelectedItemCount() override;
515 * Return selected item at the given index.
517 virtual Accessible* GetSelectedItem(uint32_t aIndex) override;
520 * Determine if item at the given index is selected.
522 virtual bool IsItemSelected(uint32_t aIndex) override;
525 * Add item at the given index the selection. Return true if success.
527 virtual bool AddItemToSelection(uint32_t aIndex) override;
530 * Remove item at the given index from the selection. Return if success.
532 virtual bool RemoveItemFromSelection(uint32_t aIndex) override;
535 * Select all items. Return true if success.
537 virtual bool SelectAll() override;
540 * Unselect all items. Return true if success.
542 virtual bool UnselectAll() override;
544 //////////////////////////////////////////////////////////////////////////////
545 // Value (numeric value interface)
547 virtual double MaxValue() const override;
548 virtual double MinValue() const override;
549 virtual double CurValue() const override;
550 virtual double Step() const override;
551 virtual bool SetCurValue(double aValue) override;
553 //////////////////////////////////////////////////////////////////////////////
554 // Widgets
557 * Return true if accessible is a widget, i.e. control or accessible that
558 * manages its items. Note, being a widget the accessible may be a part of
559 * composite widget.
561 virtual bool IsWidget() const;
564 * Return true if the widget is active, i.e. has a focus within it.
566 virtual bool IsActiveWidget() const;
569 * Return true if the widget has items and items are operable by user and
570 * can be activated.
572 virtual bool AreItemsOperable() const;
575 * Return the current item of the widget, i.e. an item that has or will have
576 * keyboard focus when widget gets active.
578 virtual LocalAccessible* CurrentItem() const;
581 * Set the current item of the widget.
583 virtual void SetCurrentItem(const LocalAccessible* aItem);
586 * Return container widget this accessible belongs to.
588 virtual LocalAccessible* ContainerWidget() const;
590 bool IsActiveDescendant(LocalAccessible** aWidget = nullptr) const;
593 * Return true if the accessible is defunct.
595 inline bool IsDefunct() const;
598 * Return false if the accessible is no longer in the document.
600 bool IsInDocument() const { return !(mStateFlags & eIsNotInDocument); }
603 * Return true if the accessible should be contained by document node map.
605 bool IsNodeMapEntry() const {
606 return HasOwnContent() && !(mStateFlags & eNotNodeMapEntry);
610 * Return true if the accessible has associated DOM content.
612 bool HasOwnContent() const {
613 return mContent && !(mStateFlags & eSharedNode);
617 * Return true if native markup has a numeric value.
619 inline bool NativeHasNumericValue() const;
622 * Return true if ARIA specifies support for a numeric value.
624 inline bool ARIAHasNumericValue() const;
627 * Return true if the accessible has a numeric value.
629 virtual bool HasNumericValue() const override;
632 * Return true if the accessible state change is processed by handling proper
633 * DOM UI event, if otherwise then false. For example, CheckboxAccessible
634 * created for HTML:input@type="checkbox" will process
635 * nsIDocumentObserver::ElementStateChanged instead of 'CheckboxStateChange'
636 * event.
638 bool NeedsDOMUIEvent() const { return !(mStateFlags & eIgnoreDOMUIEvent); }
641 * Get/set repositioned bit indicating that the accessible was moved in
642 * the accessible tree, i.e. the accessible tree structure differs from DOM.
644 bool IsRelocated() const { return mStateFlags & eRelocated; }
645 void SetRelocated(bool aRelocated) {
646 if (aRelocated) {
647 mStateFlags |= eRelocated;
648 } else {
649 mStateFlags &= ~eRelocated;
654 * Return true if the accessible allows accessible children from subtree of
655 * a DOM element of this accessible.
657 bool KidsFromDOM() const { return !(mStateFlags & eNoKidsFromDOM); }
660 * Return true if this accessible has a parent, relation or ancestor with a
661 * relation whose name depends on this accessible.
663 bool HasNameDependent() const { return mContextFlags & eHasNameDependent; }
666 * Return true if this accessible has a parent, relation or ancestor with a
667 * relation whose description depends on this accessible.
669 bool HasDescriptionDependent() const {
670 return mContextFlags & eHasDescriptionDependent;
674 * Return true if the element is inside an alert.
676 bool IsInsideAlert() const { return mContextFlags & eInsideAlert; }
679 * Return true if there is a pending reorder event for this accessible.
681 bool ReorderEventTarget() const { return mReorderEventTarget; }
684 * Return true if there is a pending show event for this accessible.
686 bool ShowEventTarget() const { return mShowEventTarget; }
689 * Return true if there is a pending hide event for this accessible.
691 bool HideEventTarget() const { return mHideEventTarget; }
694 * Set if there is a pending reorder event for this accessible.
696 void SetReorderEventTarget(bool aTarget) { mReorderEventTarget = aTarget; }
699 * Set if this accessible is a show event target.
701 void SetShowEventTarget(bool aTarget) { mShowEventTarget = aTarget; }
704 * Set if this accessible is a hide event target.
706 void SetHideEventTarget(bool aTarget) { mHideEventTarget = aTarget; }
708 void Announce(const nsAString& aAnnouncement, uint16_t aPriority);
710 virtual bool IsRemote() const override { return false; }
712 already_AddRefed<AccAttributes> BundleFieldsForCache(
713 uint64_t aCacheDomain, CacheUpdateType aUpdateType);
716 * Push fields to cache.
717 * aCacheDomain - describes which fields to bundle and ultimately send
718 * aUpdate - describes whether this is an initial or subsequent update
720 void SendCache(uint64_t aCacheDomain, CacheUpdateType aUpdate);
722 void MaybeQueueCacheUpdateForStyleChanges();
724 virtual nsAtom* TagName() const override;
726 virtual already_AddRefed<nsAtom> InputType() const override;
728 virtual already_AddRefed<nsAtom> DisplayStyle() const override;
730 virtual float Opacity() const override;
732 virtual void DOMNodeID(nsString& aID) const override;
734 virtual void LiveRegionAttributes(nsAString* aLive, nsAString* aRelevant,
735 Maybe<bool>* aAtomic,
736 nsAString* aBusy) const override;
738 virtual Maybe<bool> ARIASelected() const override;
740 protected:
741 virtual ~LocalAccessible();
744 * Return the accessible name provided by native markup. It doesn't take
745 * into account ARIA markup used to specify the name.
747 virtual mozilla::a11y::ENameValueFlag NativeName(nsString& aName) const;
750 * Return the accessible description provided by native markup. It doesn't
751 * take into account ARIA markup used to specify the description.
753 void NativeDescription(nsString& aDescription) const;
756 * Return object attributes provided by native markup. It doesn't take into
757 * account ARIA.
759 virtual already_AddRefed<AccAttributes> NativeAttributes();
762 * The given attribute has the potential of changing the accessible's state.
763 * This is used to capture the state before the attribute change and compare
764 * it with the state after.
766 virtual bool AttributeChangesState(nsAtom* aAttribute);
769 * Notify accessible that a DOM attribute on its associated content has
770 * changed. This allows the accessible to update its state and emit any
771 * relevant events.
773 virtual void DOMAttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
774 int32_t aModType,
775 const nsAttrValue* aOldValue,
776 uint64_t aOldState);
778 //////////////////////////////////////////////////////////////////////////////
779 // Initializing, cache and tree traverse methods
782 * Destroy the object.
784 void LastRelease();
787 * Set accessible parent and index in parent.
789 void BindToParent(LocalAccessible* aParent, uint32_t aIndexInParent);
790 void UnbindFromParent();
793 * Return sibling accessible at the given offset.
795 virtual LocalAccessible* GetSiblingAtOffset(int32_t aOffset,
796 nsresult* aError = nullptr) const;
798 void ModifySubtreeContextFlags(uint32_t aContextFlags, bool aAdd);
801 * Flags used to describe the state of this accessible.
803 enum StateFlags {
804 eIsDefunct = 1 << 0, // accessible is defunct
805 eIsNotInDocument = 1 << 1, // accessible is not in document
806 eSharedNode = 1 << 2, // accessible shares DOM node from another accessible
807 eNotNodeMapEntry = 1 << 3, // accessible shouldn't be in document node map
808 eGroupInfoDirty = 1 << 4, // accessible needs to update group info
809 eKidsMutating = 1 << 5, // subtree is being mutated
810 eIgnoreDOMUIEvent = 1 << 6, // don't process DOM UI events for a11y events
811 eRelocated = 1 << 7, // accessible was moved in tree
812 eNoKidsFromDOM = 1 << 8, // accessible doesn't allow children from DOM
813 eHasTextKids = 1 << 9, // accessible have a text leaf in children
814 eOldFrameHasValidTransformStyle =
815 1 << 10, // frame prior to most recent style change both has transform
816 // styling and supports transforms
818 eLastStateFlag = eOldFrameHasValidTransformStyle
822 * Flags used for contextual information about the accessible.
824 enum ContextFlags {
825 eHasNameDependent = 1 << 0, // See HasNameDependent().
826 eInsideAlert = 1 << 1,
827 eHasDescriptionDependent = 1 << 2, // See HasDescriptionDependent().
829 eLastContextFlag = eHasDescriptionDependent
832 protected:
833 //////////////////////////////////////////////////////////////////////////////
834 // Miscellaneous helpers
837 * Return ARIA role (helper method).
839 mozilla::a11y::role ARIATransformRole(mozilla::a11y::role aRole) const;
841 //////////////////////////////////////////////////////////////////////////////
842 // Name helpers
845 * Returns the accessible name specified by ARIA.
847 void ARIAName(nsString& aName) const;
850 * Returns the accessible description specified by ARIA.
852 void ARIADescription(nsString& aDescription) const;
855 * Returns the accessible name specified for this control using XUL
856 * <label control="id" ...>.
858 static void NameFromAssociatedXULLabel(DocAccessible* aDocument,
859 nsIContent* aElm, nsString& aName);
862 * Return the name for XUL element.
864 static void XULElmName(DocAccessible* aDocument, nsIContent* aElm,
865 nsString& aName);
867 // helper method to verify frames
868 static nsresult GetFullKeyName(const nsAString& aModifierName,
869 const nsAString& aKeyName,
870 nsAString& aStringOut);
872 //////////////////////////////////////////////////////////////////////////////
873 // Action helpers
876 * Prepares click action that will be invoked in timeout.
878 * @note DoCommand() prepares an action in timeout because when action
879 * command opens a modal dialog/window, it won't return until the
880 * dialog/window is closed. If executing action command directly in
881 * nsIAccessible::DoAction() method, it will block AT tools (e.g. GOK) that
882 * invoke action of mozilla accessibles direclty (see bug 277888 for
883 * details).
885 * @param aContent [in, optional] element to click
886 * @param aActionIndex [in, optional] index of accessible action
888 void DoCommand(nsIContent* aContent = nullptr,
889 uint32_t aActionIndex = 0) const;
892 * Dispatch click event.
894 MOZ_CAN_RUN_SCRIPT
895 virtual void DispatchClickEvent(nsIContent* aContent,
896 uint32_t aActionIndex) const;
898 //////////////////////////////////////////////////////////////////////////////
899 // Helpers
902 * Get the container node for an atomic region, defined by aria-atomic="true"
903 * @return the container node
905 nsIContent* GetAtomicRegion() const;
908 * Return numeric value of the given ARIA attribute, NaN if not applicable.
910 * @param aARIAProperty [in] the ARIA property we're using
911 * @return a numeric value
913 double AttrNumericValue(nsAtom* aARIAAttr) const;
916 * Return the action rule based on ARIA enum constants EActionRule
917 * (see ARIAMap.h). Used by ActionCount() and ActionNameAt().
919 uint32_t GetActionRule() const;
921 virtual AccGroupInfo* GetGroupInfo() const override;
923 virtual AccGroupInfo* GetOrCreateGroupInfo() override;
925 virtual void ARIAGroupPosition(int32_t* aLevel, int32_t* aSetSize,
926 int32_t* aPosInSet) const override;
928 // Data Members
929 // mContent can be null in a DocAccessible if the document has no body or
930 // root element.
931 nsCOMPtr<nsIContent> mContent;
932 RefPtr<DocAccessible> mDoc;
934 LocalAccessible* mParent;
935 nsTArray<LocalAccessible*> mChildren;
936 int32_t mIndexInParent;
938 // These are used to determine whether to send cache updates.
939 Maybe<nsRect> mBounds;
940 int32_t mFirstLineStart;
943 * Maintain a reference to the ComputedStyle of our frame so we can
944 * send cache updates when style changes are observed.
946 * This RefPtr is initialised in BundleFieldsForCache to the ComputedStyle
947 * for our initial frame.
948 * Style changes are observed in one of two ways:
949 * 1. Style changes on the same frame are observed in
950 * nsIFrame::DidSetComputedStyle.
951 * 2. Style changes for reconstructed frames are handled in
952 * DocAccessible::PruneOrInsertSubtree.
953 * In both cases, we call into MaybeQueueCacheUpdateForStyleChanges. There, we
954 * compare a11y-relevant properties in mOldComputedStyle with the current
955 * ComputedStyle fetched from GetFrame()->Style(). Finally, we send cache
956 * updates for attributes affected by the style change and update
957 * mOldComputedStyle to the style of our current frame.
959 RefPtr<const ComputedStyle> mOldComputedStyle;
961 static const uint8_t kStateFlagsBits = 11;
962 static const uint8_t kContextFlagsBits = 3;
965 * Keep in sync with StateFlags, ContextFlags, and AccTypes.
967 mutable uint32_t mStateFlags : kStateFlagsBits;
968 uint32_t mContextFlags : kContextFlagsBits;
969 uint32_t mReorderEventTarget : 1;
970 uint32_t mShowEventTarget : 1;
971 uint32_t mHideEventTarget : 1;
973 void StaticAsserts() const;
975 #ifdef A11Y_LOG
976 friend void logging::Tree(const char* aTitle, const char* aMsgText,
977 LocalAccessible* aRoot,
978 logging::GetTreePrefix aPrefixFunc,
979 void* aGetTreePrefixData);
980 friend void logging::TreeSize(const char* aTitle, const char* aMsgText,
981 LocalAccessible* aRoot);
982 #endif
983 friend class DocAccessible;
984 friend class xpcAccessible;
985 friend class TreeMutation;
987 UniquePtr<mozilla::a11y::EmbeddedObjCollector> mEmbeddedObjCollector;
988 int32_t mIndexOfEmbeddedChild;
990 friend class EmbeddedObjCollector;
992 mutable AccGroupInfo* mGroupInfo;
993 friend class AccGroupInfo;
995 private:
996 LocalAccessible() = delete;
997 LocalAccessible(const LocalAccessible&) = delete;
998 LocalAccessible& operator=(const LocalAccessible&) = delete;
1001 * Traverses the accessible's parent chain in search of an accessible with
1002 * a frame. Returns the frame when found. Includes special handling for
1003 * OOP iframe docs and tab documents.
1005 nsIFrame* FindNearestAccessibleAncestorFrame();
1008 NS_DEFINE_STATIC_IID_ACCESSOR(LocalAccessible, NS_ACCESSIBLE_IMPL_IID)
1010 ////////////////////////////////////////////////////////////////////////////////
1011 // LocalAccessible downcasting method
1013 inline LocalAccessible* Accessible::AsLocal() {
1014 return IsLocal() ? static_cast<LocalAccessible*>(this) : nullptr;
1017 } // namespace a11y
1018 } // namespace mozilla
1020 #endif