libaurum: use dumpTree for reducing dbus message calls. 35/320835/9
authorHosang Kim <hosang12.kim@samsung.com>
Mon, 10 Mar 2025 04:17:42 +0000 (13:17 +0900)
committerHosang Kim <hosang12.kim@samsung.com>
Thu, 20 Mar 2025 06:04:03 +0000 (15:04 +0900)
Change-Id: I3ac096d2669b487db58630c981444e936be2ad04

libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc

index f1d4e89c20ae7416c30c02257c90f71263317524..f1381a7df942d7e54da0234ccb48e2cc694db824 100644 (file)
@@ -537,6 +537,24 @@ public:
      */
     virtual void refresh(bool updateAll = true) = 0;
 
+    /**
+     * @brief refresh method for updating properties of accessible node. This method is called when the node is created.
+     *
+     * @param text
+     * @param role
+     * @param type
+     * @param automationId
+     * @param description
+     * @param value
+     * @param minValue
+     * @param maxValue
+     * @param increment
+     * @param extents
+     */
+    virtual void refresh(const std::string &text, const std::string &role, const std::string &type,
+                         const std::string &automationId, const std::string &description, const std::string &imgSrc,
+                         double value, double minValue, double maxValue, double increment, const Rect<int> &extents) = 0;
+
     /**
      * @brief Gets available atspi action name.
      *
index 149980de70f300f0f16465548793ebda529036e8..cca75d097dc0e3078e7b1055ea4e2404ca0fe67a 100644 (file)
@@ -201,6 +201,13 @@ public:
      */
     void refresh(bool updateAll = true) override;
 
+    /**
+     * @copydoc AccessibleNode::refresh()
+     */
+    void refresh(const std::string &text, const std::string &role, const std::string &type,
+                 const std::string &automationId, const std::string &description, const std::string &imgSrc,
+                 double value, double minValue, double maxValue, double increment, const Rect<int> &extents) override;
+
     /**
      * @copydoc AccessibleNode::getActions()
      */
index f0bc7f0d8fea065f76a91e41829fbc9fa9230027..a2db6ad77ae75f9408281df70e26686c69ab0fe6 100644 (file)
@@ -211,6 +211,13 @@ public:
      */
     void refresh(bool updateAll = true) override;
 
+    /**
+     * @brief TBD
+     */
+    void refresh(const std::string &text, const std::string &role, const std::string &type,
+                 const std::string &automationId, const std::string &description, const std::string &imgSrc,
+                 double value, double minValue, double maxValue, double increment, const Rect<int> &extents) override;
+
     /**
      * @brief TBD
      * @since_tizen 6.5
index cf6865efc4fde89fa0c97edb62654575f71b0ef8..fa24c77480793b8e786242b75ecc6f52393f46a3 100644 (file)
 #include "UiSelector.h"
 #include "Waiter.h"
 
+#include "rapidjson/document.h"
+
 #include <memory>
 #include <vector>
 
+using namespace rapidjson;
+
 namespace Aurum {
 
 class UiDevice;
@@ -791,6 +795,9 @@ public:
      */
     bool getIncludeHidden() const;
 
+private:
+    std::shared_ptr<Node> parseTreeFromJson(Value &doc);
+
 private:
     std::shared_ptr<UiDevice> mDevice;
     std::shared_ptr<UiSelector>  mSelector;
index 316cd5e55dc09afbcab2bc1a8336a2e7df0ea7bf..87bf87882a9b0481623ae46bf6d144996d20b425 100644 (file)
@@ -456,6 +456,23 @@ void AtspiAccessibleNode::refresh(bool updateAll)
     }
 }
 
+void AtspiAccessibleNode::refresh(const std::string &text, const std::string &role, const std::string &type,
+                                  const std::string &automationId, const std::string &description, const std::string &imgSrc,
+                                  double value, double minValue, double maxValue, double increment, const Rect<int> &extents)
+{
+    mText = text;
+    mRole = role;
+    mType = type;
+    mAutomationId = automationId;
+    mDescription = description;
+    mImgSrc = imgSrc;
+    mValue = value;
+    mMinValue = minValue;
+    mMaxValue = maxValue;
+    mIncrement = increment;
+    mScreenBoundingBox = extents;
+}
+
 std::vector<std::string> AtspiAccessibleNode::getActions() const
 {
     std::vector<std::string> result{};
index 5501b92fa4682dcbe2e8c32c9cb0fe1e9b68344c..4cd6a65e0493a942cc544a9b24d1eb70960c911a 100644 (file)
@@ -225,6 +225,12 @@ void MockAccessibleNode::refresh(bool updateAll)
     mFeatureProperty = (int)NodeFeatureProperties::SELECTABLE | (int)NodeFeatureProperties::SELECTED;
 }
 
+void MockAccessibleNode::refresh(const std::string &text, const std::string &role, const std::string &type,
+                                 const std::string &automationId, const std::string &description, const std::string &imgSrc,
+                                 double value, double minValue, double maxValue, double increment, const Rect<int> &extents)
+{
+}
+
 std::vector<std::string> MockAccessibleNode::getActions() const
 {
     std::vector<std::string> ret{};
index bec1d6db2b16173570ab180e876075d874f9a7c9..e5d29344914480197c97c4c6ab5bf09f00ff3bda 100644 (file)
@@ -180,12 +180,61 @@ std::vector<std::shared_ptr<UiObject>> UiObject::getChildren() const
     return ret;
 }
 
+std::shared_ptr<Node> UiObject::parseTreeFromJson(Value &value)
+{
+    std::vector<std::shared_ptr<Node>> nodeChildren{};
+
+    if ((value.HasMember("appname") && value["appname"].IsString()) &&
+        (value.HasMember("path") && value["path"].IsString())) {
+        auto appName = value["appname"].GetString();
+        auto path = value["path"].GetString();
+        auto node = mNode->refAccessibleNode(appName, path);
+        if (node) {
+            auto text = value.HasMember("text") && value["text"].IsString()? value["text"].GetString() : "";
+            auto role = value.HasMember("role") && value["role"].IsString()? value["role"].GetString() : "";
+            auto type = value.HasMember("type") && value["type"].IsString()? value["type"].GetString() : "";
+            auto automationId = value.HasMember("automationId") && value["automationId"].IsString()? value["automationId"].GetString() : "";
+            auto description = value.HasMember("description") && value["description"].IsString()? value["description"].GetString() : "";
+            auto current = value.HasMember("value") && value["value"].HasMember("current") && value["value"]["current"].IsDouble()? value["value"]["current"].GetDouble() : 0.0f;
+            auto minValue = value.HasMember("value") && value["value"].HasMember("min") && value["value"]["min"].IsDouble()? value["value"]["min"].GetDouble() : 0.0f;
+            auto maxValue = value.HasMember("value") && value["value"].HasMember("max") && value["value"]["max"].IsDouble()? value["value"]["mimaxn"].GetDouble() : 0.0f;
+            auto increment = value.HasMember("value") && value["value"].HasMember("increment") && value["value"]["increment"].IsDouble()? value["value"]["increment"].GetDouble() : 0.0f;
+            auto x = value.HasMember("x") ? (value["x"].IsInt() ? value["x"].GetInt() : value["x"].GetDouble()) : 0;
+            auto y = value.HasMember("y") ? (value["y"].IsInt() ? value["y"].GetInt() : value["y"].GetDouble()) : 0;
+            auto w = value.HasMember("w") ? (value["w"].IsInt() ? value["w"].GetInt() : value["w"].GetDouble()) : 0;
+            auto h = value.HasMember("h") ? (value["h"].IsInt() ? value["h"].GetInt() : value["h"].GetDouble()) : 0;
+            auto extents = Rect<int>{x, y, x + w, y + h};
+            auto imgSrc = value.HasMember("attributes") && value["attributes"].HasMember("imgSrc") && value["attributes"]["imgSrc"].IsString() ? value["attributes"]["imgSrc"].GetString() : "";
+            node->refresh(text, role, type, automationId, description, imgSrc, current, minValue, maxValue, increment, extents);
+
+            if (value.HasMember("children") && value["children"].IsArray()) {
+                for (auto &child : value["children"].GetArray()) {
+                    nodeChildren.push_back(parseTreeFromJson(child));
+                }
+            }
+
+            auto obj = std::make_shared<UiObject>(mDevice, mSelector, node);
+            return std::make_shared<Node>(obj, nodeChildren);
+        }
+    }
+    return std::make_shared<Node>(nullptr, nodeChildren);
+}
+
 std::shared_ptr<Node> UiObject::getDescendant()
 {
+    Document document;
     std::vector<std::shared_ptr<Node>> nodeChildren{};
 
+    auto json = mNode->dumpTree();
+    document.Parse(json.c_str());
+    if (!document.HasParseError()) {
+        auto node = parseTreeFromJson(document);
+        if (node->mNode) return node;
+    }
+
     auto children = getChildren();
     for (auto &&child : children) {
+        child->refresh();
         nodeChildren.push_back(child->getDescendant());
     }
     return std::make_shared<Node>(shared_from_this(), nodeChildren);
@@ -543,4 +592,4 @@ void UiObject::setIncludeHidden(bool enabled) const {
 
 bool UiObject::getIncludeHidden() const {
     return mNode->getIncludeHidden();
-}
\ No newline at end of file
+}
index 8faacbd0dbcd3cb9fe23da79ee3630b06b7b96ab..a98bfe4e9e0123f59c7e94319517f04e777c7c95 100644 (file)
@@ -35,7 +35,6 @@ void DumpObjectTreeCommand::traverse(::aurum::Element *root, std::shared_ptr<Nod
     if (!node->mNode) return;
     std::shared_ptr<UiObject> obj = node->mNode;
 
-    obj->refresh();
     if (mObjMap->getElement(obj->getId()) == nullptr)
         mObjMap->addElement(obj);