[Tizen][AT-SPI] Move AccessibilityAttributes to Accessible 00/309100/1
authorArtur Świgoń <a.swigon@samsung.com>
Thu, 28 Mar 2024 12:04:16 +0000 (13:04 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Thu, 4 Apr 2024 15:02:01 +0000 (17:02 +0200)
This patch allows setting arbitrary attributes on the Accessible level.
Previously this was only possible for Control, and thus application-side
customization of the attributes was unavailable for some other classes (most
notably Layer, which stands in for Window in the AT-SPI tree).

Change-Id: I19f34197dbe9a26d842b1e31b1b23d2a822ac639

dali-csharp-binder/src/dali-wrap.cpp
dali-csharp-binder/src/nui-view-accessible.cpp
dali-csharp-binder/src/nui-view-accessible.h

index 4ff70cb65b252c64b58aeb7296a593c13ea2958e..092b146b6eaef3b2b0402593698229060913b184 100644 (file)
@@ -40084,10 +40084,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_Dali_View_Property_ACCESSIBILITY_HIGHLIGHTABLE
   return (int)Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE;
 }
 
-SWIGEXPORT int SWIGSTDCALL CSharp_Dali_View_Property_ACCESSIBILITY_ATTRIBUTES_get() {
-  return (int)Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_ATTRIBUTES;
-}
-
 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_View_Property_ACCESSIBILITY_HIDDEN_get() {
   return (int)Dali::Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN;
 }
index 4ebad2774699fdfda069304b85fb729179045ff5..adcd8b74c4d9a6bb5381a9fbdb8e42c64be43696 100644 (file)
@@ -255,13 +255,26 @@ Accessibility::States NUIViewAccessible::CalculateStates()
   return Accessibility::States{states};
 }
 
-Accessibility::Attributes NUIViewAccessible::GetAttributes() const
+void NUIViewAccessible::UpdateAttributes(Accessibility::Attributes& attributes) const
 {
-  auto attributes = ControlAccessible::GetAttributes();
+  ControlAccessible::UpdateAttributes(attributes);
 
-  CallMethod<Interface::ACCESSIBLE>(mTable->getAttributes, &GetAttributesCallback, &attributes);
+  // Clear attributes previously received from C#. Otherwise we would store all C#
+  // attributes forever, ever if they were removed at the C# end at some point.
+  for(auto& key : mExtraAttributeKeys)
+  {
+    attributes.erase(key);
+  }
+  mExtraAttributeKeys.clear();
+
+  Dali::Accessibility::Attributes extraAttributes;
+  CallMethod<Interface::ACCESSIBLE>(mTable->getAttributes, &GetAttributesCallback, &extraAttributes);
 
-  return attributes;
+  for(auto& extraAttribute : extraAttributes)
+  {
+    attributes.insert_or_assign(extraAttribute.first, extraAttribute.second);
+    mExtraAttributeKeys.emplace(extraAttribute.first);
+  }
 }
 
 Property::Index NUIViewAccessible::GetNamePropertyIndex()
index dd506bbf517bf8f008acaa0fd20820d0d285da5f..77fd1be03e7618ca34cb13f167e21fc7d2ba2df8 100644 (file)
@@ -28,6 +28,7 @@
 #include <dali/devel-api/atspi-interfaces/table-cell.h>
 #include <dali/devel-api/atspi-interfaces/text.h>
 #include <dali/devel-api/atspi-interfaces/value.h>
+#include <set>
 
 class NUIViewAccessible : public Dali::Toolkit::DevelControl::ControlAccessible,
                           public virtual Dali::Accessibility::EditableText, // includes Text
@@ -74,7 +75,7 @@ public:
 
   Dali::Accessibility::States CalculateStates() override;
 
-  Dali::Accessibility::Attributes GetAttributes() const override;
+  void UpdateAttributes(Dali::Accessibility::Attributes& attributes) const override;
 
   Dali::Property::Index GetNamePropertyIndex() override;
 
@@ -251,6 +252,9 @@ private:
   template<Dali::Accessibility::AtspiInterface I, typename R, typename... Args>
   R CallMethod(R (*method)(Dali::RefObject*, Args...), Args... args) const;
 
+  // Set of attribute keys to clean up in UpdateAttributes()
+  mutable std::set<std::string> mExtraAttributeKeys;
+
   // Prevents calling C# methods if the View has been disposed
   bool mIsDetached = false;
 };