[ATSPI] Introduce SetListenPostRender interface
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-accessible.cpp
index 8545240..db9a2aa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -19,6 +19,8 @@
 #include <dali/internal/accessibility/bridge/bridge-accessible.h>
 
 // EXTERNAL INCLUDES
+#include <dali/public-api/math/math-utils.h>
+
 #include <algorithm>
 #include <iostream>
 
@@ -60,7 +62,7 @@ std::vector<std::vector<Component*>> SplitLines(const std::vector<Component*>& c
   // Find first with non-zero area
   auto first = std::find_if(children.begin(), children.end(), [](Component* child) -> bool {
     auto extents = child->GetExtents(CoordinateType::WINDOW);
-    return extents.height != 0.0f && extents.width != 0.0f;
+    return !Dali::EqualsZero(extents.height) && !Dali::EqualsZero(extents.width);
   });
 
   if(first == children.end())
@@ -78,7 +80,7 @@ std::vector<std::vector<Component*>> SplitLines(const std::vector<Component*>& c
     auto child = *it;
 
     rect = child->GetExtents(CoordinateType::WINDOW);
-    if(rect.height == 0.0f || rect.width == 0.0f)
+    if(Dali::EqualsZero(rect.height) || Dali::EqualsZero(rect.width))
     {
       // Zero area, ignore
       continue;
@@ -156,7 +158,7 @@ static bool IsObjectZeroSize(Component* obj)
     return false;
   }
   auto extents = obj->GetExtents(CoordinateType::WINDOW);
-  return extents.height == 0 || extents.width == 0;
+  return Dali::EqualsZero(extents.height) || Dali::EqualsZero(extents.width);
 }
 
 static bool IsObjectAcceptable(Component* obj)
@@ -266,30 +268,6 @@ static std::string MakeIndent(unsigned int maxRecursionDepth)
   return std::string(GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH - maxRecursionDepth, ' ');
 }
 
-static bool IsDeputy(Accessible* obj)
-{
-  //TODO: add deputy
-  return false;
-}
-
-static Accessible* GetProxyInParent(Accessible* obj)
-{
-  if(!obj)
-  {
-    return nullptr;
-  }
-
-  auto children = obj->GetChildren();
-  for(auto& child : children)
-  {
-    if(child->IsProxy())
-    {
-      return child;
-    }
-  }
-  return nullptr;
-}
-
 static bool IsRoleAcceptableWhenNavigatingNextPrev(Accessible* obj)
 {
   if(!obj)
@@ -355,11 +333,6 @@ static bool CheckChainEndWithAttribute(Accessible* obj, unsigned char forward)
   return false;
 }
 
-static Accessible* GetDeputyOfProxyInParent(Accessible* obj)
-{
-  return nullptr;
-}
-
 static std::vector<Component*> GetScrollableParents(Accessible* accessible)
 {
   std::vector<Component*> scrollableParents;
@@ -420,6 +393,7 @@ void BridgeAccessible::RegisterInterfaces()
   AddFunctionToInterface(desc, "DoGesture", &BridgeAccessible::DoGesture);
   AddFunctionToInterface(desc, "GetReadingMaterial", &BridgeAccessible::GetReadingMaterial);
   AddFunctionToInterface(desc, "GetRelationSet", &BridgeAccessible::GetRelationSet);
+  AddFunctionToInterface(desc, "SetListenPostRender", &BridgeAccessible::SetListenPostRender);
   mDbusServer.addInterface("/", desc, true);
 }
 
@@ -746,6 +720,10 @@ Accessible* BridgeAccessible::GetNextNonDefunctSibling(Accessible* obj, Accessib
   {
     return nullptr;
   }
+  else if(parent->IsProxy())
+  {
+    return parent;
+  }
 
   auto children = GetValidChildren(parent->GetChildren(), start);
   SortChildrenFromTopLeft(children);
@@ -817,9 +795,7 @@ Accessible* BridgeAccessible::CalculateNeighbor(Accessible* root, Accessible* st
 
   if(searchMode == BridgeAccessible::NeighborSearchMode::RECURSE_TO_OUTSIDE)
   {
-    // This only works if we navigate backward, and it is not possible to
-    // find in embedded process. In this case the deputy should be used */
-    return GetDeputyOfProxyInParent(start);
+    searchMode = BridgeAccessible::NeighborSearchMode::CONTINUE_AFTER_FAILED_RECURSION;
   }
 
   Accessible* node = start ? start : root;
@@ -880,17 +856,6 @@ Accessible* BridgeAccessible::CalculateNeighbor(Accessible* root, Accessible* st
     }
 
     Accessible* nextRelatedInDirection = !forceNext ? GetObjectInRelation(node, forward ? RelationType::FLOWS_TO : RelationType::FLOWS_FROM) : nullptr;
-    // forceNext means that the searchMode is NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING
-    // in this case the node is elm_layout which is parent of proxy object.
-    // There is an access object working for the proxy object, and the access
-    // object could have relation information. This relation information should
-    // be checked first before using the elm_layout as a node.
-    if(forceNext && forward)
-    {
-      auto deputy            = GetDeputyOfProxyInParent(node);
-      nextRelatedInDirection = GetObjectInRelation(deputy, RelationType::FLOWS_TO);
-    }
-
     if(nextRelatedInDirection && start && start->GetStates()[State::DEFUNCT])
     {
       nextRelatedInDirection = NULL;
@@ -899,27 +864,6 @@ Accessible* BridgeAccessible::CalculateNeighbor(Accessible* root, Accessible* st
     unsigned char wantCycleDetection = 0;
     if(nextRelatedInDirection)
     {
-      // Check whether nextRelatedInDirection is deputy object or not
-      Accessible* parent;
-      if(!forward)
-      {
-        // If the prev object is deputy, then go to inside of its proxy first
-        if(IsDeputy(nextRelatedInDirection))
-        {
-          parent                 = nextRelatedInDirection->GetParent();
-          nextRelatedInDirection = GetProxyInParent(parent);
-        }
-      }
-      else
-      {
-        // If current object is deputy, and it has relation next object,
-        // then do not use the relation next object, and use proxy first
-        if(IsDeputy(node))
-        {
-          parent                 = node->GetParent();
-          nextRelatedInDirection = GetProxyInParent(parent);
-        }
-      }
       node               = nextRelatedInDirection;
       wantCycleDetection = 1;
     }
@@ -953,9 +897,8 @@ Accessible* BridgeAccessible::CalculateNeighbor(Accessible* root, Accessible* st
 
 DBus::ValueOrError<Accessible*, uint8_t> BridgeAccessible::GetNeighbor(std::string rootPath, int32_t direction, int32_t searchMode)
 {
-  auto start               = FindSelf();
-  rootPath                 = StripPrefix(rootPath);
-  auto          root       = !rootPath.empty() ? Find(rootPath) : nullptr;
+  auto          start      = FindSelf();
+  auto          root       = !rootPath.empty() ? Find(StripPrefix(rootPath)) : nullptr;
   auto          accessible = CalculateNeighbor(root, start, direction == 1, static_cast<NeighborSearchMode>(searchMode));
   unsigned char recurse    = 0;
   if(accessible)
@@ -1049,11 +992,9 @@ std::string BridgeAccessible::GetName()
 
 DBus::ValueOrError<Accessible*, uint32_t, std::unordered_map<std::string, std::string>> BridgeAccessible::GetDefaultLabelInfo()
 {
-  auto defaultLabel = GetDefaultLabel();
-  if(defaultLabel == nullptr)
-  {
-    defaultLabel = FindSelf();
-  }
+  auto* defaultLabel = GetDefaultLabel(FindSelf());
+  DALI_ASSERT_DEBUG(defaultLabel);
+
   // By default, the text is taken from navigation context root's accessibility properties name and description.
   return {defaultLabel, static_cast<uint32_t>(defaultLabel->GetRole()), defaultLabel->GetAttributes()};
 }
@@ -1070,3 +1011,9 @@ DBus::ValueOrError<std::vector<BridgeAccessible::Relation>> BridgeAccessible::Ge
 
   return ret;
 }
+
+DBus::ValueOrError<void> BridgeAccessible::SetListenPostRender(bool enabled)
+{
+  FindSelf()->SetListenPostRender(enabled);
+  return {};
+}