diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /accessible/base/EmbeddedObjCollector.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'accessible/base/EmbeddedObjCollector.cpp')
-rw-r--r-- | accessible/base/EmbeddedObjCollector.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/accessible/base/EmbeddedObjCollector.cpp b/accessible/base/EmbeddedObjCollector.cpp new file mode 100644 index 000000000..226d1365f --- /dev/null +++ b/accessible/base/EmbeddedObjCollector.cpp @@ -0,0 +1,81 @@ +/* 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/. */ + +#include "EmbeddedObjCollector.h" + +#include "Accessible.h" + +using namespace mozilla::a11y; + +uint32_t +EmbeddedObjCollector::Count() +{ + EnsureNGetIndex(nullptr); + return mObjects.Length(); +} + +Accessible* +EmbeddedObjCollector::GetAccessibleAt(uint32_t aIndex) +{ + Accessible* accessible = mObjects.SafeElementAt(aIndex, nullptr); + if (accessible) + return accessible; + + return EnsureNGetObject(aIndex); +} + +Accessible* +EmbeddedObjCollector::EnsureNGetObject(uint32_t aIndex) +{ + uint32_t childCount = mRoot->ChildCount(); + while (mRootChildIdx < childCount) { + Accessible* child = mRoot->GetChildAt(mRootChildIdx++); + if (child->IsText()) + continue; + + AppendObject(child); + if (mObjects.Length() - 1 == aIndex) + return mObjects[aIndex]; + } + + return nullptr; +} + +int32_t +EmbeddedObjCollector::EnsureNGetIndex(Accessible* aAccessible) +{ + uint32_t childCount = mRoot->ChildCount(); + while (mRootChildIdx < childCount) { + Accessible* child = mRoot->GetChildAt(mRootChildIdx++); + if (child->IsText()) + continue; + + AppendObject(child); + if (child == aAccessible) + return mObjects.Length() - 1; + } + + return -1; +} + +int32_t +EmbeddedObjCollector::GetIndexAt(Accessible* aAccessible) +{ + if (aAccessible->mParent != mRoot) + return -1; + + MOZ_ASSERT(!aAccessible->IsProxy()); + if (aAccessible->mInt.mIndexOfEmbeddedChild != -1) + return aAccessible->mInt.mIndexOfEmbeddedChild; + + return !aAccessible->IsText() ? EnsureNGetIndex(aAccessible) : -1; +} + +void +EmbeddedObjCollector::AppendObject(Accessible* aAccessible) +{ + MOZ_ASSERT(!aAccessible->IsProxy()); + aAccessible->mInt.mIndexOfEmbeddedChild = mObjects.Length(); + mObjects.AppendElement(aAccessible); +} |