From: Hosang Kim Date: Thu, 30 Nov 2023 11:36:36 +0000 (+0900) Subject: [ATSPI] Introduce GetMatchesInMatches API X-Git-Tag: accepted/tizen/7.0/unified/20240216.161223^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=b1935853ddc6da536c6faf53b1365ce7221ab5e3 [ATSPI] Introduce GetMatchesInMatches API The GetMatchesInMatches API allows users to get a list of Accessible objects that match two different MatchRule parameters. Change-Id: I2ac3dc502561b288a8d491e0392ecea8ef66e790 (cherry picked from commit 0fe284fc3ba14e071b32c69ab4fc7ce6e098e4bc) --- diff --git a/dali/internal/accessibility/bridge/bridge-collection.cpp b/dali/internal/accessibility/bridge/bridge-collection.cpp index d6caa90..2011130 100644 --- a/dali/internal/accessibility/bridge/bridge-collection.cpp +++ b/dali/internal/accessibility/bridge/bridge-collection.cpp @@ -47,6 +47,8 @@ void BridgeCollection::RegisterInterfaces() { DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::COLLECTION)}; AddFunctionToInterface(desc, "GetMatches", &BridgeCollection::GetMatches); + AddFunctionToInterface(desc, "GetMatchesInMatches", &BridgeCollection::GetMatchesInMatches); + mDbusServer.addInterface("/", desc, true); } @@ -449,6 +451,17 @@ struct BridgeCollection::Comparer CompareFunc(mState, obj); } + bool IsShowing(Accessible* obj) + { + if (mState.mMode == Mode::NONE) return true; + mState.Update(obj); + if (mState.IsRequestEmpty() || mState.IsObjectEmpty()) return true; + if (!mState.mRequested[State::SHOWING] ) return true; + if (mState.mObject[State::SHOWING]) return true; + + return false; + } + ComparerInterfaces mInterface; ComparerAttributes mAttribute; ComparerRoles mRole; @@ -473,6 +486,11 @@ void BridgeCollection::VisitNodes(Accessible* obj, std::vector& res } } + if (!comparer.IsShowing(obj)) + { + return; + } + for(auto i = 0u; i < obj->GetChildCount(); ++i) { VisitNodes(obj->GetChildAtIndex(i), result, comparer, maxCount); @@ -508,3 +526,44 @@ DBus::ValueOrError > BridgeCollection::GetMatches(Match return res; } + +DBus::ValueOrError > BridgeCollection::GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse) +{ + std::vector res; + std::vector firstRes; + std::vector secondRes; + auto self = BridgeBase::FindCurrentObject(); + auto firstMatcher = Comparer{&firstRule}; + auto secondMatcher = Comparer{&secondRule}; + VisitNodes(self, firstRes, firstMatcher, firstCount); + + for (auto &obj : firstRes) + { + VisitNodes(obj, secondRes, secondMatcher, secondCount); + + res.insert(res.end(), secondRes.begin(), secondRes.end()); + secondRes.clear(); + } + + switch(static_cast(sortBy)) + { + case SortOrder::CANONICAL: + { + break; + } + + case SortOrder::REVERSE_CANONICAL: + { + std::reverse(res.begin(), res.end()); + break; + } + + default: + { + throw std::domain_error{"unsupported sorting order"}; + } + //TODO: other cases + } + + return res; +} diff --git a/dali/internal/accessibility/bridge/bridge-collection.h b/dali/internal/accessibility/bridge/bridge-collection.h index 88f4d02..32ea9c1 100644 --- a/dali/internal/accessibility/bridge/bridge-collection.h +++ b/dali/internal/accessibility/bridge/bridge-collection.h @@ -112,6 +112,19 @@ public: * @return The matching Accessible objects */ DBus::ValueOrError > GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse); + + /** + * @brief Gets the matching Accessible objects with two MatchRules. + * + * @param[in] firstRule The initial BridgeCollection::MatchRule. + * @param[in] secondRule An secondary BridgeCollection::MatchRule. + * @param[in] sortBy SortOrder::CANONICAL or SortOrder::REVERSE_CANONICAL + * @param[in] firstCount The maximum number of objects to return for the initial match. + * @param[in] secondCount The maximum number of objects to return for the secondary match. + * @param[in] traverse True if it is traverse, otherwise false. + * @return The matching Accessible objects + */ + DBus::ValueOrError > GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse); }; #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H