From: Lukasz Oleksak Date: Wed, 16 Jun 2021 17:55:04 +0000 (+0200) Subject: [ATSPI] missing variables provided in ReadingMaterialType X-Git-Tag: dali_2.0.34~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=496868d8629c3845240805505f2c6cea250fae0f [ATSPI] missing variables provided in ReadingMaterialType Change-Id: I0caa86f8f6fcde6dcc196a1da7004fb71d97eaf5 --- diff --git a/dali/internal/accessibility/bridge/bridge-accessible.cpp b/dali/internal/accessibility/bridge/bridge-accessible.cpp index 309be51..2ba6212 100644 --- a/dali/internal/accessibility/bridge/bridge-accessible.cpp +++ b/dali/internal/accessibility/bridge/bridge-accessible.cpp @@ -213,6 +213,44 @@ static bool AcceptObject(Accessible* obj) return AcceptObject(c); } +static int32_t GetItemCountOfList(Accessible* obj) +{ + int32_t itemCount = 0; + if(obj && obj->GetRole() == Role::LIST) + { + for(auto i = 0u; i < static_cast(obj->GetChildCount()); ++i) + { + auto child = obj->GetChildAtIndex(i); + if(child && child->GetRole() == Role::LIST_ITEM) + { + itemCount++; + } + } + } + return itemCount; +} + +static int32_t GetItemCountOfFirstDescendantList(Accessible* obj) +{ + int32_t itemCount = 0; + itemCount = GetItemCountOfList(obj); + if(itemCount > 0 || !obj) + { + return itemCount; + } + + for(auto i = 0u; i < static_cast(obj->GetChildCount()); ++i) + { + auto child = obj->GetChildAtIndex(i); + itemCount = GetItemCountOfFirstDescendantList(child); + if(itemCount > 0) + { + return itemCount; + } + } + return itemCount; +} + static std::string objDump(Component* obj) { if(!obj) @@ -284,69 +322,100 @@ Component* BridgeAccessible::CalculateNavigableAccessibleAtPoint(Accessible* roo BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial() { - auto self = FindSelf(); - auto attributes = self->GetAttributes(); - auto name = self->GetName(); - std::string labeledByName = ""; - std::string textIfceName = ""; - auto role = static_cast(self->GetRole()); - auto states = self->GetStates(); - auto localizedName = self->GetLocalizedRoleName(); - auto childCount = static_cast(self->GetChildCount()); + auto self = FindSelf(); + auto findObjectByRelationType = [this, &self](RelationType relationType) { + auto relations = self->GetRelationSet(); + auto relation = std::find_if(relations.begin(), + relations.end(), + [relationType](const Dali::Accessibility::Relation& relation) -> bool { + return relation.relationType == relationType; + }); + return relations.end() != relation && !relation->targets.empty() ? Find(relation->targets.back()) : nullptr; + }; + + auto labellingObject = findObjectByRelationType(RelationType::LABELLED_BY); + std::string labeledByName = labellingObject ? labellingObject->GetName() : ""; + + auto describedByObject = findObjectByRelationType(RelationType::DESCRIBED_BY); double currentValue = 0.0; double minimumIncrement = 0.0; double maximumValue = 0.0; double minimumValue = 0.0; - - auto* value = dynamic_cast(self); - if(value) + auto* valueInterface = dynamic_cast(self); + if(valueInterface) { - currentValue = value->GetCurrent(); - minimumIncrement = value->GetMinimumIncrement(); - maximumValue = value->GetMaximum(); - minimumValue = value->GetMinimum(); + currentValue = valueInterface->GetCurrent(); + minimumIncrement = valueInterface->GetMinimumIncrement(); + maximumValue = valueInterface->GetMaximum(); + minimumValue = valueInterface->GetMinimum(); } - auto description = self->GetDescription(); - auto indexInParent = static_cast(self->GetIndexInParent()); - bool isSelectedInParent = false; - bool hasCheckBoxChild = false; int32_t firstSelectedChildIndex = -1; int32_t selectedChildCount = 0; + auto* selfSelectionInterface = dynamic_cast(self); + if(selfSelectionInterface) + { + selectedChildCount = selfSelectionInterface->GetSelectedChildrenCount(); + auto firstSelectedChild = selfSelectionInterface->GetSelectedChild(0); + if(firstSelectedChild) + { + firstSelectedChildIndex = firstSelectedChild->GetIndexInParent(); + } + } + auto childCount = static_cast(self->GetChildCount()); + bool hasCheckBoxChild = false; for(auto i = 0u; i < static_cast(childCount); ++i) { - auto q = self->GetChildAtIndex(i); - auto s = q->GetStates(); - if(s[State::SELECTABLE]) + auto child = self->GetChildAtIndex(i); + if(child->GetRole() == Role::CHECK_BOX) { - if(s[State::SELECTED]) - { - ++selectedChildCount; - if(firstSelectedChildIndex < 0) - firstSelectedChildIndex = static_cast(i); - } - } - if(q->GetRole() == Role::CHECK_BOX) hasCheckBoxChild = true; + break; + } } - int32_t listChildrenCount = 0; - Accessible* parent = self->GetParent(); - auto parentStateSet = parent ? parent->GetStates() : States{}; - auto parentChildCount = parent ? static_cast(parent->GetChildCount()) : 0; - auto parentRole = static_cast(parent ? parent->GetRole() : Role{}); - Accessible* describedByObject = nullptr; + auto role = static_cast(self->GetRole()); + int32_t listChildrenCount = 0; + if(role == static_cast(Role::DIALOG)) + { + listChildrenCount = GetItemCountOfFirstDescendantList(self); + } + + auto* textInterface = dynamic_cast(self); + std::string nameFromTextInterface = ""; + if(textInterface) + { + nameFromTextInterface = textInterface->GetText(0, textInterface->GetCharacterCount()); + } + + auto description = self->GetDescription(); + auto attributes = self->GetAttributes(); + auto states = self->GetStates(); + auto name = self->GetName(); + auto localizedRoleName = self->GetLocalizedRoleName(); + auto indexInParent = static_cast(self->GetIndexInParent()); + + auto parent = self->GetParent(); + auto parentRole = static_cast(parent ? parent->GetRole() : Role{}); + auto parentChildCount = parent ? static_cast(parent->GetChildCount()) : 0; + auto parentStateSet = parent ? parent->GetStates() : States{}; + bool isSelectedInParent = false; + auto* parentSelectionInterface = dynamic_cast(parent); + if(parentSelectionInterface) + { + isSelectedInParent = parentSelectionInterface->IsChildSelected(indexInParent); + } return { attributes, name, labeledByName, - textIfceName, + nameFromTextInterface, role, states, - localizedName, + localizedRoleName, childCount, currentValue, minimumIncrement,