+static std::vector<Component*> GetScrollableParents(Accessible *accessible)
+{
+ std::vector<Component*> scrollableParents;
+
+ while(accessible)
+ {
+ accessible = accessible->GetParent();
+ auto component = dynamic_cast<Component*>(accessible);
+ if(component && component->IsScrollable())
+ {
+ scrollableParents.push_back(component);
+ }
+ }
+ return scrollableParents;
+}
+
+static std::vector<Component*> GetNonDuplicatedScrollableParents(Accessible *child, Accessible *start)
+{
+ auto scrollableParentsOfChild = GetScrollableParents(child);
+ auto scrollableParentsOfStart = GetScrollableParents(start);
+
+ // find the first different scrollable parent by comparing from top to bottom.
+ // since it can not be the same after that, there is no need to compare.
+ while(!scrollableParentsOfChild.empty() && !scrollableParentsOfStart.empty() && scrollableParentsOfChild.back() == scrollableParentsOfStart.back())
+ {
+ scrollableParentsOfChild.pop_back();
+ scrollableParentsOfStart.pop_back();
+ }
+
+ return scrollableParentsOfChild;
+}