From 8c842a59e317209bf427f8e60fe24ae873155607 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Tue, 16 Feb 2021 20:05:10 +0000 Subject: [PATCH] Bug 1692523 - P1: Prefix local heirarchy functions with 'Local'. r=Jamie Parent -> LocalParent GetChildAt -> LocalChildAt FirstChild -> LocalFirstChild LastChild -> LocalLastChild NextSibling -> LocalNextSibling PrevSibling -> LocalPrevSibling Differential Revision: https://phabricator.services.mozilla.com/D105034 --- accessible/android/AccessibleWrap.cpp | 6 +-- accessible/android/AccessibleWrap.h | 2 +- accessible/android/DocAccessibleWrap.cpp | 12 ++--- accessible/android/ProxyAccessibleWrap.cpp | 4 +- accessible/android/ProxyAccessibleWrap.h | 2 +- accessible/android/TraversalRule.cpp | 14 +++--- accessible/atk/AccessibleWrap.cpp | 13 ++++-- accessible/base/AccEvent.cpp | 4 +- accessible/base/AccEvent.h | 4 +- accessible/base/AccGroupInfo.cpp | 28 +++++------ accessible/base/AccIterator.cpp | 6 +-- accessible/base/AccessibleOrProxy.cpp | 2 +- accessible/base/AccessibleOrProxy.h | 10 ++-- accessible/base/EmbeddedObjCollector.cpp | 4 +- accessible/base/EventQueue.cpp | 4 +- accessible/base/EventTree.cpp | 18 ++++---- accessible/base/FocusManager.cpp | 14 +++--- accessible/base/Logging.cpp | 8 ++-- accessible/base/MarkupMap.h | 5 +- accessible/base/NotificationController.cpp | 20 ++++---- accessible/base/Pivot.cpp | 35 +++++++------- accessible/base/TextAttrs.cpp | 8 ++-- accessible/base/TextRange.cpp | 30 ++++++------ accessible/base/TextUpdater.cpp | 2 +- accessible/base/TreeWalker.cpp | 2 +- accessible/base/nsAccUtils.cpp | 14 +++--- accessible/base/nsAccessibilityService.cpp | 8 ++-- accessible/base/nsAccessiblePivot.cpp | 2 +- accessible/base/nsTextEquivUtils.cpp | 2 +- accessible/generic/ARIAGridAccessible.cpp | 8 ++-- accessible/generic/ARIAGridAccessible.h | 2 +- accessible/generic/Accessible-inl.h | 4 +- accessible/generic/Accessible.cpp | 45 +++++++++--------- accessible/generic/Accessible.h | 16 +++---- accessible/generic/ApplicationAccessible.cpp | 4 +- accessible/generic/BaseAccessibles.cpp | 2 +- accessible/generic/DocAccessible-inl.h | 2 +- accessible/generic/DocAccessible.cpp | 42 +++++++++-------- accessible/generic/HyperTextAccessible.cpp | 46 ++++++++++--------- accessible/generic/HyperTextAccessible.h | 4 +- accessible/generic/OuterDocAccessible.cpp | 6 +-- accessible/generic/OuterDocAccessible.h | 2 +- accessible/generic/RootAccessible.cpp | 4 +- accessible/generic/TableAccessible.cpp | 6 +-- accessible/html/HTMLElementAccessibles.cpp | 2 +- accessible/html/HTMLFormControlAccessible.cpp | 8 ++-- accessible/html/HTMLImageMapAccessible.cpp | 4 +- accessible/html/HTMLSelectAccessible.cpp | 10 ++-- accessible/html/HTMLSelectAccessible.h | 12 +++-- accessible/html/HTMLTableAccessible.cpp | 8 ++-- accessible/ipc/DocAccessibleChildBase.cpp | 4 +- accessible/mac/AccessibleWrap.mm | 2 +- accessible/mac/HyperTextAccessibleWrap.mm | 35 +++++++------- accessible/mac/mozSelectableElements.mm | 4 +- accessible/mac/mozTableAccessible.mm | 4 +- accessible/windows/ia2/ia2Accessible.cpp | 4 +- .../windows/ia2/ia2AccessibleComponent.cpp | 4 +- accessible/windows/msaa/AccessibleWrap.cpp | 18 ++++---- accessible/windows/msaa/EnumVariant.cpp | 10 ++-- accessible/windows/msaa/EnumVariant.h | 4 +- accessible/xul/XULElementAccessibles.cpp | 4 +- accessible/xul/XULFormControlAccessible.cpp | 6 +-- accessible/xul/XULListboxAccessible.cpp | 6 ++- accessible/xul/XULMenuAccessible.cpp | 12 ++--- accessible/xul/XULSelectControlAccessible.cpp | 6 +-- accessible/xul/XULTreeAccessible.cpp | 10 ++-- accessible/xul/XULTreeAccessible.h | 2 +- accessible/xul/XULTreeGridAccessible.cpp | 10 ++-- accessible/xul/XULTreeGridAccessible.h | 4 +- 69 files changed, 351 insertions(+), 318 deletions(-) diff --git a/accessible/android/AccessibleWrap.cpp b/accessible/android/AccessibleWrap.cpp index dc82e85e5630..19e830bda89f 100644 --- a/accessible/android/AccessibleWrap.cpp +++ b/accessible/android/AccessibleWrap.cpp @@ -367,7 +367,7 @@ void AccessibleWrap::NavigateText(int32_t aGranularity, int32_t aStartOffset, } if (newAnchor && (start != aStartOffset || end != aEndOffset)) { - if (IsTextLeaf() && newAnchor == Parent()) { + if (IsTextLeaf() && newAnchor == LocalParent()) { // For paragraphs, divs, spans, etc., we put a11y focus on the text leaf // node instead of the HyperTextAccessible. However, Pivot will always // return a HyperTextAccessible. Android doesn't support text navigation @@ -856,7 +856,7 @@ mozilla::java::GeckoBundle::LocalRef AccessibleWrap::ToBundle( auto childCount = ChildCount(); nsTArray children(childCount); for (uint32_t i = 0; i < childCount; i++) { - auto child = static_cast(GetChildAt(i)); + auto child = static_cast(LocalChildAt(i)); children.AppendElement(child->VirtualViewID()); } @@ -914,7 +914,7 @@ bool AccessibleWrap::HandleLiveRegionEvent(AccEvent* aEvent) { if (atomic.EqualsIgnoreCase("true")) { Accessible* atomicAncestor = nullptr; for (Accessible* parent = announcementTarget; parent; - parent = parent->Parent()) { + parent = parent->LocalParent()) { dom::Element* element = parent->Elm(); if (element && element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_atomic, diff --git a/accessible/android/AccessibleWrap.h b/accessible/android/AccessibleWrap.h index 7e621177e475..456258ffdee4 100644 --- a/accessible/android/AccessibleWrap.h +++ b/accessible/android/AccessibleWrap.h @@ -90,7 +90,7 @@ class AccessibleWrap : public Accessible { private: virtual AccessibleWrap* WrapperParent() { - return static_cast(Parent()); + return static_cast(LocalParent()); } virtual bool WrapperRangeInfo(double* aCurVal, double* aMinVal, diff --git a/accessible/android/DocAccessibleWrap.cpp b/accessible/android/DocAccessibleWrap.cpp index a9652c1e1b0c..288aa75e0c03 100644 --- a/accessible/android/DocAccessibleWrap.cpp +++ b/accessible/android/DocAccessibleWrap.cpp @@ -115,8 +115,8 @@ void DocAccessibleWrap::CacheViewportCallback(nsITimer* aTimer, continue; } - for (Accessible* acc = visibleAcc; acc && acc != docAcc->Parent(); - acc = acc->Parent()) { + for (Accessible* acc = visibleAcc; acc && acc != docAcc->LocalParent(); + acc = acc->LocalParent()) { if (inViewAccs.Contains(acc->UniqueID())) { break; } @@ -222,8 +222,8 @@ void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) { if (IPCAccessibilityActive()) { DocAccessibleChild* ipcDoc = IPCDoc(); nsTArray cacheData; - for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent(); - acc = static_cast(acc->Parent())) { + for (AccessibleWrap* acc = aAccessible; acc && acc != this->LocalParent(); + acc = static_cast(acc->LocalParent())) { nsAutoString name; acc->Name(name); nsAutoString textValue; @@ -247,8 +247,8 @@ void DocAccessibleWrap::CacheFocusPath(AccessibleWrap* aAccessible) { } else if (RefPtr sessionAcc = SessionAccessibility::GetInstanceFor(this)) { nsTArray accessibles; - for (AccessibleWrap* acc = aAccessible; acc && acc != this->Parent(); - acc = static_cast(acc->Parent())) { + for (AccessibleWrap* acc = aAccessible; acc && acc != this->LocalParent(); + acc = static_cast(acc->LocalParent())) { accessibles.AppendElement(acc); mFocusPath.Put(acc->UniqueID(), RefPtr{acc}); } diff --git a/accessible/android/ProxyAccessibleWrap.cpp b/accessible/android/ProxyAccessibleWrap.cpp index d8ab49e6d11b..e46a20f3ea2d 100644 --- a/accessible/android/ProxyAccessibleWrap.cpp +++ b/accessible/android/ProxyAccessibleWrap.cpp @@ -62,8 +62,8 @@ uint32_t ProxyAccessibleWrap::ChildCount() const { return Proxy()->ChildrenCount(); } -Accessible* ProxyAccessibleWrap::GetChildAt(uint32_t aIndex) const { - ProxyAccessible* child = Proxy()->ChildAt(aIndex); +ProxyAccessible* child = Proxy()->ChildAt(aIndex); +Accessible* ProxyAccessibleWrap::LocalChildAt(uint32_t aIndex) const { return child ? WrapperFor(child) : nullptr; } diff --git a/accessible/android/ProxyAccessibleWrap.h b/accessible/android/ProxyAccessibleWrap.h index 40286fcc45e7..171773196348 100644 --- a/accessible/android/ProxyAccessibleWrap.h +++ b/accessible/android/ProxyAccessibleWrap.h @@ -33,7 +33,7 @@ class ProxyAccessibleWrap : public AccessibleWrap { virtual uint32_t ChildCount() const override; - virtual Accessible* GetChildAt(uint32_t aIndex) const override; + virtual Accessible* LocalChildAt(uint32_t aIndex) const override; virtual ENameValueFlag Name(nsString& aName) const override; diff --git a/accessible/android/TraversalRule.cpp b/accessible/android/TraversalRule.cpp index 6bc0cda40ca2..3c904e63d197 100644 --- a/accessible/android/TraversalRule.cpp +++ b/accessible/android/TraversalRule.cpp @@ -79,14 +79,14 @@ bool TraversalRule::IsSingleLineage(Accessible* aAccessible) { case 0: return true; case 1: - child = child->FirstChild(); + child = child->LocalFirstChild(); break; case 2: if (Accessible* bullet = - child->Parent()->IsHTMLListItem() - ? child->Parent()->AsHTMLListItem()->Bullet() + child->LocalParent()->IsHTMLListItem() + ? child->LocalParent()->AsHTMLListItem()->Bullet() : nullptr) { - child = bullet->NextSibling(); + child = bullet->LocalNextSibling(); } else { return false; } @@ -100,14 +100,14 @@ bool TraversalRule::IsSingleLineage(Accessible* aAccessible) { } bool TraversalRule::IsListItemBullet(const Accessible* aAccessible) { - Accessible* parent = aAccessible->Parent(); + Accessible* parent = aAccessible->LocalParent(); return parent && parent->IsHTMLListItem() && parent->AsHTMLListItem()->Bullet() == aAccessible; } bool TraversalRule::IsFlatSubtree(const Accessible* aAccessible) { - for (auto child = aAccessible->FirstChild(); child; - child = child->NextSibling()) { + for (auto child = aAccessible->LocalFirstChild(); child; + child = child->LocalNextSibling()) { roles::Role role = child->Role(); if (role == roles::TEXT_LEAF || role == roles::STATICTEXT) { continue; diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index 96c81fc499c9..88b93742538c 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -812,7 +812,7 @@ gint getIndexInParentCB(AtkObject* aAtkObj) { return -1; } - Accessible* parent = accWrap->Parent(); + Accessible* parent = accWrap->LocalParent(); if (!parent) return -1; // No parent return parent->GetIndexOfEmbeddedChild(accWrap); @@ -1221,7 +1221,8 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) { case nsIAccessibleEvent::EVENT_SHOW: { AccMutationEvent* event = downcast_accEvent(aEvent); - Accessible* parentAcc = event ? event->Parent() : accessible->Parent(); + Accessible* parentAcc = + event ? event->LocalParent() : accessible->LocalParent(); AtkObject* parent = AccessibleWrap::GetAtkObject(parentAcc); NS_ENSURE_STATE(parent); auto obj = reinterpret_cast(atkObj); @@ -1238,7 +1239,8 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) { } AccMutationEvent* event = downcast_accEvent(aEvent); - Accessible* parentAcc = event ? event->Parent() : accessible->Parent(); + Accessible* parentAcc = + event ? event->LocalParent() : accessible->LocalParent(); AtkObject* parent = AccessibleWrap::GetAtkObject(parentAcc); NS_ENSURE_STATE(parent); auto obj = reinterpret_cast(atkObj); @@ -1485,7 +1487,7 @@ void AccessibleWrap::GetKeyBinding(Accessible* aAccessible, if (!keyBinding.IsEmpty()) { keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat); - Accessible* parent = aAccessible->Parent(); + Accessible* parent = aAccessible->LocalParent(); roles::Role role = parent ? parent->Role() : roles::NOTHING; if (role == roles::PARENT_MENUITEM || role == roles::MENUITEM || role == roles::RADIO_MENU_ITEM || role == roles::CHECK_MENU_ITEM) { @@ -1501,7 +1503,8 @@ void AccessibleWrap::GetKeyBinding(Accessible* aAccessible, keysInHierarchyStr.Insert(str, 0); } - } while ((parent = parent->Parent()) && parent->Role() != roles::MENUBAR); + } while ((parent = parent->LocalParent()) && + parent->Role() != roles::MENUBAR); keyBindingsStr.Append(';'); keyBindingsStr.Append(keysInHierarchyStr); diff --git a/accessible/base/AccEvent.cpp b/accessible/base/AccEvent.cpp index 021909c60bb6..e2fd05d84f88 100644 --- a/accessible/base/AccEvent.cpp +++ b/accessible/base/AccEvent.cpp @@ -104,8 +104,8 @@ AccTextChangeEvent::AccTextChangeEvent(Accessible* aAccessible, int32_t aStart, AccHideEvent::AccHideEvent(Accessible* aTarget, bool aNeedsShutdown) : AccMutationEvent(::nsIAccessibleEvent::EVENT_HIDE, aTarget), mNeedsShutdown(aNeedsShutdown) { - mNextSibling = mAccessible->NextSibling(); - mPrevSibling = mAccessible->PrevSibling(); + mNextSibling = mAccessible->LocalNextSibling(); + mPrevSibling = mAccessible->LocalPrevSibling(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/accessible/base/AccEvent.h b/accessible/base/AccEvent.h index ade3e01b27ff..0716fd453327 100644 --- a/accessible/base/AccEvent.h +++ b/accessible/base/AccEvent.h @@ -243,7 +243,7 @@ class AccMutationEvent : public AccTreeMutationEvent { : AccTreeMutationEvent(aEventType, aTarget) { // Don't coalesce these since they are coalesced by reorder event. Coalesce // contained text change events. - mParent = mAccessible->Parent(); + mParent = mAccessible->LocalParent(); } virtual ~AccMutationEvent() {} @@ -257,7 +257,7 @@ class AccMutationEvent : public AccTreeMutationEvent { bool IsShow() const { return mEventType == nsIAccessibleEvent::EVENT_SHOW; } bool IsHide() const { return mEventType == nsIAccessibleEvent::EVENT_HIDE; } - Accessible* Parent() const { return mParent; } + Accessible* LocalParent() const { return mParent; } protected: nsCOMPtr mNode; diff --git a/accessible/base/AccGroupInfo.cpp b/accessible/base/AccGroupInfo.cpp index 31153b87b55b..98b452b42bf3 100644 --- a/accessible/base/AccGroupInfo.cpp +++ b/accessible/base/AccGroupInfo.cpp @@ -20,7 +20,7 @@ AccGroupInfo::AccGroupInfo(const Accessible* aItem, role aRole) void AccGroupInfo::Update() { mParent = nullptr; - Accessible* parent = mItem->Parent(); + Accessible* parent = mItem->LocalParent(); if (!parent) return; int32_t indexInParent = mItem->IndexInParent(); @@ -36,7 +36,7 @@ void AccGroupInfo::Update() { // Compute position in set. mPosInSet = 1; for (int32_t idx = indexInParent - 1; idx >= 0; idx--) { - Accessible* sibling = parent->GetChildAt(idx); + Accessible* sibling = parent->LocalChildAt(idx); roles::Role siblingRole = sibling->Role(); // If the sibling is separator then the group is ended. @@ -82,7 +82,7 @@ void AccGroupInfo::Update() { mSetSize = mPosInSet; for (uint32_t idx = indexInParent + 1; idx < siblingCount; idx++) { - Accessible* sibling = parent->GetChildAt(idx); + Accessible* sibling = parent->LocalChildAt(idx); roles::Role siblingRole = sibling->Role(); @@ -131,7 +131,7 @@ void AccGroupInfo::Update() { // the previous tree item of the group is a conceptual parent of the tree // item. if (mRole == roles::OUTLINEITEM) { - Accessible* parentPrevSibling = parent->PrevSibling(); + Accessible* parentPrevSibling = parent->LocalPrevSibling(); if (parentPrevSibling && parentPrevSibling->Role() == mRole) { mParent = parentPrevSibling; return; @@ -142,7 +142,7 @@ void AccGroupInfo::Update() { // the parent of the item will be a group and containing item of the group is // a conceptual parent of the item. if (mRole == roles::LISTITEM || mRole == roles::OUTLINEITEM) { - Accessible* grandParent = parent->Parent(); + Accessible* grandParent = parent->LocalParent(); if (grandParent && grandParent->Role() == mRole) mParent = grandParent; } } @@ -151,10 +151,10 @@ Accessible* AccGroupInfo::FirstItemOf(const Accessible* aContainer) { // ARIA tree can be arranged by ARIA groups case #1 (previous sibling of a // group is a parent) or by aria-level. a11y::role containerRole = aContainer->Role(); - Accessible* item = aContainer->NextSibling(); + Accessible* item = aContainer->LocalNextSibling(); if (item) { if (containerRole == roles::OUTLINEITEM && item->Role() == roles::GROUPING) - item = item->FirstChild(); + item = item->LocalFirstChild(); if (item) { AccGroupInfo* itemGroupInfo = item->GetGroupInfo(); @@ -165,13 +165,13 @@ Accessible* AccGroupInfo::FirstItemOf(const Accessible* aContainer) { // ARIA list and tree can be arranged by ARIA groups case #2 (group is // a child of an item). - item = aContainer->LastChild(); + item = aContainer->LocalLastChild(); if (!item) return nullptr; if (item->Role() == roles::GROUPING && (containerRole == roles::LISTITEM || containerRole == roles::OUTLINEITEM)) { - item = item->FirstChild(); + item = item->LocalFirstChild(); if (item) { AccGroupInfo* itemGroupInfo = item->GetGroupInfo(); if (itemGroupInfo && itemGroupInfo->ConceptualParent() == aContainer) @@ -180,7 +180,7 @@ Accessible* AccGroupInfo::FirstItemOf(const Accessible* aContainer) { } // Otherwise, it can be a direct child if the container is a list or tree. - item = aContainer->FirstChild(); + item = aContainer->LocalFirstChild(); if (ShouldReportRelations(item->Role(), containerRole)) return item; return nullptr; @@ -231,10 +231,10 @@ uint32_t AccGroupInfo::TotalItemCount(Accessible* aContainer, case roles::PAGETABLIST: { Accessible* childItem = AccGroupInfo::FirstItemOf(aContainer); if (!childItem) { - childItem = aContainer->FirstChild(); + childItem = aContainer->LocalFirstChild(); if (childItem && childItem->IsTextLeaf()) { // First child can be a text leaf, check its sibling for an item. - childItem = childItem->NextSibling(); + childItem = childItem->LocalNextSibling(); } } @@ -261,10 +261,10 @@ Accessible* AccGroupInfo::NextItemTo(Accessible* aItem) { // If the item in middle of the group then search next item in siblings. if (groupInfo->PosInSet() >= groupInfo->SetSize()) return nullptr; - Accessible* parent = aItem->Parent(); + Accessible* parent = aItem->LocalParent(); uint32_t childCount = parent->ChildCount(); for (uint32_t idx = aItem->IndexInParent() + 1; idx < childCount; idx++) { - Accessible* nextItem = parent->GetChildAt(idx); + Accessible* nextItem = parent->LocalChildAt(idx); AccGroupInfo* nextGroupInfo = nextItem->GetGroupInfo(); if (nextGroupInfo && nextGroupInfo->ConceptualParent() == groupInfo->ConceptualParent()) { diff --git a/accessible/base/AccIterator.cpp b/accessible/base/AccIterator.cpp index 2314843f22c9..f5421a699a60 100644 --- a/accessible/base/AccIterator.cpp +++ b/accessible/base/AccIterator.cpp @@ -35,7 +35,7 @@ AccIterator::~AccIterator() { Accessible* AccIterator::Next() { while (mState) { - Accessible* child = mState->mParent->GetChildAt(mState->mIndex++); + Accessible* child = mState->mParent->LocalChildAt(mState->mIndex++); if (!child) { IteratorState* tmp = mState; mState = mState->mParentState; @@ -136,7 +136,7 @@ Accessible* HTMLLabelIterator::Next() { // Go up tree to get a name of ancestor label if there is one (an ancestor //