[Tizen] Backport Accessibility API V2 82/316782/1 accepted/tizen/7.0/unified/20240903.174532
authorYoungsun Suh <youngsun.suh@samsung.com>
Wed, 14 Aug 2024 02:23:33 +0000 (11:23 +0900)
committerYoungsun Suh <youngsun.suh@samsung.com>
Wed, 28 Aug 2024 05:02:42 +0000 (14:02 +0900)
Add Accessibility::ActionType

Change-Id: I946b1459467eb62154150e5b6fcb91fff210b0f5

Add support for AccessibilityValue property

Change-Id: I283af7f92c2a7296e4f320ac6b65ba9387f0dc35

Update a11y::GetAttribute to return value text

Change-Id: I811df8091be1b9865c6d479ee6b08c000218a3b2

Add ActionInfo type

Change-Id: If8d3284150bfda5097bafeb41bddab2d809d3c64

Emit StateChanged event only when the value is updated

Change-Id: I3d386365f3cfccfd1d7cdcb7c4e6724ad6ccd3dd

dali/devel-api/adaptor-framework/accessibility.h
dali/devel-api/adaptor-framework/actor-accessible.cpp
dali/devel-api/adaptor-framework/actor-accessible.h
dali/devel-api/adaptor-framework/proxy-accessible.h
dali/devel-api/atspi-interfaces/accessible.h
dali/internal/accessibility/bridge/accessible.cpp
dali/internal/accessibility/bridge/bridge-accessible.cpp
dali/internal/accessibility/bridge/bridge-base.h

index d542e12aa5ff18522010c4f665b95a40f6df2da9..6a091da53cb93afaf385dff5a922a6b692c6c362 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_ATSPI_ACCESSIBILITY_H\r
 #define DALI_ATSPI_ACCESSIBILITY_H\r
 /*\r
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.\r
  *\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -24,6 +24,7 @@
 \r
 // INTERNAL INCLUDES\r
 #include <dali/devel-api/adaptor-framework/accessibility-bitset.h>\r
+#include <dali/public-api/actors/actor.h>\r
 #include <dali/public-api/dali-adaptor-common.h>\r
 \r
 namespace Dali\r
@@ -500,6 +501,16 @@ enum class AtspiEvent
   MAX_COUNT\r
 };\r
 \r
+enum class ActionType\r
+{\r
+  ACTIVATE,\r
+  ESCAPE,\r
+  INCREMENT,\r
+  DECREMENT,\r
+  SCROLL_TO_CHILD,\r
+  MAX_COUNT\r
+};\r
+\r
 using AtspiInterfaces  = EnumBitSet<AtspiInterface, AtspiInterface::MAX_COUNT>;\r
 using AtspiEvents      = EnumBitSet<AtspiEvent, AtspiEvent::MAX_COUNT>;\r
 using ReadingInfoTypes = EnumBitSet<ReadingInfoType, ReadingInfoType::MAX_COUNT>;\r
@@ -736,6 +747,19 @@ struct DALI_ADAPTOR_API Relation
   std::vector<Accessible*> mTargets;\r
 };\r
 \r
+struct DALI_ADAPTOR_API ActionInfo\r
+{\r
+  ActionInfo() = default;\r
+  ActionInfo(ActionType type, Actor target)\r
+  : type{type},\r
+    target{target}\r
+  {\r
+  }\r
+\r
+  ActionType type{ActionType::MAX_COUNT};\r
+  Actor      target{};\r
+};\r
+\r
 } // namespace Accessibility\r
 } // namespace Dali\r
 \r
index 56125f2a598e052276730dbdd4c3e71a067a15c6..8797e22018e0f28ce45f044d70cdac2c2a43a181 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,11 @@ std::string ActorAccessible::GetDescription() const
   return {};
 }
 
+std::string ActorAccessible::GetValue() const
+{
+  return {};
+}
+
 Accessible* ActorAccessible::GetParent()
 {
   if(IsOnRootLevel())
index 777ae9c854bcbc4b3a80a67ee0d996fac40c4ac7..5a23a7e6a14a84354546e3757852d119747331d9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ADAPTOR_ACTOR_ACCESSIBLE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,11 @@ public:
    */
   std::string GetDescription() const override;
 
+  /**
+   * @copydoc Dali::Accessibility::Accessible::GetValue()
+   */
+  std::string GetValue() const override;
+
   /**
    * @copydoc Dali::Accessibility::Accessible::GetParent()
    */
index 7d4ff21f5ce82e2a7414549cf7c6614fae140141..d7b5e73a45ba304ddd58170bebf5956dad9f10a4 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ADAPTOR_PROXY_ACCESSIBLE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -64,6 +64,11 @@ public:
     return "";
   }
 
+  std::string GetValue() const override
+  {
+    return "";
+  }
+
   Accessible* GetParent() override
   {
     return mParent;
index 2ba479155c2fabb9b37acc9011a86ca401125e8b..d9590a96546c9cea5d307434ce3311e896f25ad0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ADAPTOR_ATSPI_ACCESSIBLE_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/object/object-registry.h>
 #include <cstdint>
+#include <map>
 #include <string>
 #include <vector>
 
@@ -167,6 +168,13 @@ public:
    */
   virtual std::string GetDescription() const = 0;
 
+  /**
+   * @brief Gets accessibility value.
+   *
+   * @return The value text
+   */
+  virtual std::string GetValue() const = 0;
+
   /**
    * @brief Gets parent.
    *
@@ -567,6 +575,8 @@ private:
   ReadingInfoTypes                    mReadingInfoTypes = ~ReadingInfoTypes(); // all set
   AtspiEvents                         mSuppressedEvents;
   bool                                mIsOnRootLevel = false;
+  std::map<State, int>                mLastEmittedState;
+
 }; // Accessible class
 
 namespace Internal
index bc3557b0a6079dee1530b5a4bcb47014263add2a..79c7594a6967d84776840ec724c0c7ba209d7004 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 using namespace Dali::Accessibility;
 
+namespace
+{
+bool UpdateLastEmitted(std::map<State, int>& lastEmitted, State state, int newValue)
+{
+  bool updated                = false;
+  const auto [iter, inserted] = lastEmitted.emplace(state, newValue);
+  if(!inserted && iter->second != newValue)
+  {
+    iter->second = newValue;
+    updated      = true;
+  }
+
+  return inserted || updated;
+}
+
+} // namespace
+
 Accessible::Accessible()
 {
 }
@@ -50,41 +67,33 @@ void Accessible::EmitStateChanged(State state, int newValue, int reserved)
 {
   if(auto bridgeData = GetBridgeData())
   {
-    bridgeData->mBridge->EmitStateChanged(this, state, newValue, reserved);
+    if(UpdateLastEmitted(mLastEmittedState, state, newValue))
+    {
+      bridgeData->mBridge->EmitStateChanged(this, state, newValue, reserved);
+    }
   }
 }
 
 void Accessible::EmitShowing(bool isShowing)
 {
-  if(auto bridgeData = GetBridgeData())
-  {
-    bridgeData->mBridge->EmitStateChanged(this, State::SHOWING, isShowing ? 1 : 0, 0);
-  }
+  EmitStateChanged(State::SHOWING, isShowing ? 1 : 0);
 }
 
 void Accessible::EmitVisible(bool isVisible)
 {
-  if(auto bridgeData = GetBridgeData())
-  {
-    bridgeData->mBridge->EmitStateChanged(this, State::VISIBLE, isVisible ? 1 : 0, 0);
-  }
+  EmitStateChanged(State::VISIBLE, isVisible ? 1 : 0);
 }
 
 void Accessible::EmitHighlighted(bool isHighlighted)
 {
-  if(auto bridgeData = GetBridgeData())
-  {
-    bridgeData->mBridge->EmitStateChanged(this, State::HIGHLIGHTED, isHighlighted ? 1 : 0, 0);
-  }
+  EmitStateChanged(State::HIGHLIGHTED, isHighlighted ? 1 : 0);
 }
 
 void Accessible::EmitFocused(bool isFocused)
 {
-  if(auto bridgeData = GetBridgeData())
-  {
-    bridgeData->mBridge->EmitStateChanged(this, State::FOCUSED, isFocused ? 1 : 0, 0);
-  }
+  EmitStateChanged(State::FOCUSED, isFocused ? 1 : 0);
 }
+
 void Accessible::EmitTextInserted(unsigned int position, unsigned int length, const std::string& content)
 {
   if(auto bridgeData = GetBridgeData())
@@ -202,14 +211,15 @@ bool Accessible::IsProxy() const
 
 void Accessible::NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive)
 {
-  if(auto data = GetBridgeData())
+  if(Accessibility::IsUp())
   {
+    const auto newStates = GetStates();
     for(auto i = 0u; i < static_cast<unsigned int>(Dali::Accessibility::State::MAX_COUNT); i++)
     {
-      auto index = static_cast<Dali::Accessibility::State>(i);
+      const auto index = static_cast<Dali::Accessibility::State>(i);
       if(states[index])
       {
-        data->mBridge->EmitStateChanged(this, index, GetStates()[index], 0);
+        EmitStateChanged(index, newStates[index]);
       }
     }
 
index 73dbdb786d353419a2a9df1b9809231bede84a63..afc6ddf950810b91dc9c658751f217b7f855bb78 100644 (file)
@@ -1,5 +1,5 @@
 /*
* Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,6 +42,8 @@ using namespace Dali::Accessibility;
 namespace
 {
 constexpr const char* FORCE_CHILD_SEARCH_ATTR{"forceChildSearch"};
+constexpr const char* VALUE_FORMAT_KEY      = "value_format";
+constexpr const char* VALUE_FORMAT_TEXT_VAL = "text";
 
 bool SortVertically(Component* lhs, Component* rhs)
 {
@@ -526,6 +528,7 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
   std::string labeledByName   = labellingObject ? labellingObject->GetName() : "";
 
   auto describedByObject = findObjectByRelationType(RelationType::DESCRIBED_BY);
+  auto attributes        = self->GetAttributes();
 
   double      currentValue = 0.0;
   std::string currentValueText;
@@ -541,6 +544,15 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
     maximumValue     = valueInterface->GetMaximum();
     minimumValue     = valueInterface->GetMinimum();
   }
+  else
+  {
+    // value text support outside of IAtspiValue interface
+    currentValueText = self->GetValue();
+    if(!currentValueText.empty())
+    {
+      attributes.insert({VALUE_FORMAT_KEY, VALUE_FORMAT_TEXT_VAL});
+    }
+  }
 
   int32_t firstSelectedChildIndex = -1;
   int32_t selectedChildCount      = 0;
@@ -567,7 +579,6 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
     }
   }
 
-  auto    attributes        = self->GetAttributes();
   auto    itemCount         = attributes.find("item_count");
   auto    atspiRole         = self->GetRole();
   int32_t listChildrenCount = 0;
@@ -1061,13 +1072,20 @@ DBus::ValueOrError<std::array<uint32_t, 2>> BridgeAccessible::GetStates()
 
 DBus::ValueOrError<std::map<std::string, std::string>> BridgeAccessible::GetAttributes()
 {
-  std::map<std::string, std::string> attributes = FindSelf()->GetAttributes();
+  auto                               self       = FindSelf();
+  std::map<std::string, std::string> attributes = self->GetAttributes();
 
   if(mIsScreenReaderSuppressed)
   {
     attributes.insert({"suppress-screen-reader", "true"});
   }
 
+  auto* valueInterface = Value::DownCast(self);
+  if(!valueInterface && !self->GetValue().empty())
+  {
+    attributes.insert({VALUE_FORMAT_KEY, VALUE_FORMAT_TEXT_VAL});
+  }
+
   return attributes;
 }
 
index 5abe6d53e6880812472b497d2cc3993fdb361e71..fd2a53ce8ac9d1459dd2ad6500ec39c1559258d0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_BASE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,12 @@ public:
 
   std::string GetDescription() const override
   {
-    return "";
+    return {};
+  }
+
+  std::string GetValue() const override
+  {
+    return {};
   }
 
   Dali::Accessibility::Accessible* GetParent() override
@@ -279,7 +284,7 @@ public:
 enum class CoalescableMessages
 {
   BOUNDS_CHANGED, ///< Bounds changed
-  SET_OFFSET, ///< Set offset
+  SET_OFFSET,     ///< Set offset
 };
 
 // Custom specialization of std::hash