From: Hosang Kim Date: Wed, 8 Feb 2023 06:11:34 +0000 (+0900) Subject: AurumXML: apply method of creating node partially. X-Git-Tag: accepted/tizen/unified/20230215.100725^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d1609260dbeb1bb973dec48d5da480f7e37137b;p=platform%2Fcore%2Fuifw%2Faurum.git AurumXML: apply method of creating node partially. Change-Id: I5c1d7658cb03b3d427546616268324c79ad3994e --- diff --git a/libaurum/inc/AurumXML.h b/libaurum/inc/AurumXML.h index f8a86b1..6574b49 100644 --- a/libaurum/inc/AurumXML.h +++ b/libaurum/inc/AurumXML.h @@ -66,13 +66,13 @@ public: /** * @brief Gets a XPath from specific id. * - * @param id + * @param node AccessibleNode * * @return XPath * * @since_tizen 7.0 */ - std::string getXPath(std::string id); + std::string getXPath(std::shared_ptr node); /** * @brief Finds that objects that satisfied with the xpath in the object tree. @@ -119,13 +119,26 @@ private: * * @brief Check xml_node exists or not * - * @param string id + * @param node AccessibleNode * * @return xml_node * * @since_tizen 7.0 */ - xml_node checkNode(std::string id); + xml_node checkNode(std::shared_ptr node); + + /** + * @internal + * + * @brief Check parent's xml_node exists or not + * + * @param node AccessibleNode + * + * @return AccessibleNode + * + * @since_tizen 7.5 + */ + std::shared_ptr checkParentNode(std::shared_ptr node); private: xml_document *mDoc; diff --git a/libaurum/src/AurumXML.cc b/libaurum/src/AurumXML.cc index 9a8c8a8..7ca1303 100644 --- a/libaurum/src/AurumXML.cc +++ b/libaurum/src/AurumXML.cc @@ -174,29 +174,58 @@ std::string makeQuery(std::string id) return query; } -xml_node AurumXML::checkNode(std::string id) +std::shared_ptr AurumXML::checkParentNode(std::shared_ptr node) { - xml_node node; + auto parent = node->getParent(); + if (!parent) return nullptr; + + std::string query = makeQuery(node->getId()); + xml_node xmlNode = mDoc->select_node(query.c_str()).node(); + + if (xmlNode) { + int childCnt = parent->getChildCount(); + for (int i = 0; i < childCnt; i++) { + std::shared_ptr childNode = parent->getChildAt(i); + if (childNode->getRawHandler() == nullptr) continue; + + xml_node childElement = xmlNode.append_child(""); + traverse(childElement, childNode); + } + return parent; + } + + return checkParentNode(parent); +} + +xml_node AurumXML::checkNode(std::shared_ptr node) +{ + xml_node xmlNode; + try { - std::string query = makeQuery(id); - node = mDoc->select_node(query.c_str()).node(); + std::string query = makeQuery(node->getId()); + xmlNode = mDoc->select_node(query.c_str()).node(); + + if (!xmlNode) { + // 1. find parent and check node again + auto parent = checkParentNode(node); + + // 2. clear tree and create tree again + if (!parent) createXMLtree(); - if (!node) { - createXMLtree(); - node = mDoc->select_node(query.c_str()).node(); + xmlNode = mDoc->select_node(query.c_str()).node(); } } catch (const xpath_exception &e) { LOGI("getXPath Error: %s", e.what()); } - return node; + return xmlNode; } -std::string AurumXML::getXPath(std::string id) +std::string AurumXML::getXPath(std::shared_ptr node) { - xml_node node = checkNode(id); + xml_node xmlNode = checkNode(node); - if (node) { - std::string xpath = getOptimalXPath(mDoc, node); + if (xmlNode) { + std::string xpath = getOptimalXPath(mDoc, xmlNode); return xpath; } diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index 2fc415f..ead1399 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -250,7 +250,7 @@ void AtspiAccessibleNode::updateXPath() auto XMLDoc = XMLDocMap[mPkg]; - mXPath = XMLDoc->getXPath(mId); + mXPath = XMLDoc->getXPath(shared_from_this()); } void AtspiAccessibleNode::updateValue()