From 0dc5af6a77547e78ac641101825bf7fe7b47666c Mon Sep 17 00:00:00 2001 From: Chihun Jeong Date: Wed, 24 Aug 2022 16:20:26 +0900 Subject: [PATCH] Introduce getTextMinBoundingRect command Change-Id: I3a7679b6dddd2126e8cfefdad4428700a5f8f5d5 --- libaurum/inc/Accessibility/AccessibleNode.h | 14 +++++- .../inc/Impl/Accessibility/AtspiAccessibleNode.h | 7 ++- libaurum/inc/Impl/Accessibility/AtspiWrapper.h | 1 + .../inc/Impl/Accessibility/MockAccessibleNode.h | 8 +++- libaurum/inc/UiObject.h | 21 ++++++++- libaurum/src/Accessibility/AccessibleNode.cc | 7 ++- .../src/Impl/Accessibility/AtspiAccessibleNode.cc | 23 +++++++++- libaurum/src/Impl/Accessibility/AtspiWrapper.cc | 7 +++ .../src/Impl/Accessibility/MockAccessibleNode.cc | 4 ++ libaurum/src/UiObject.cc | 12 +++++- org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h | 6 ++- org.tizen.aurum-bootstrap/inc/Commands/Commands.h | 4 +- .../inc/Commands/GetTextMinBoundingRectCommand.h | 34 +++++++++++++++ org.tizen.aurum-bootstrap/meson.build | 1 + org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc | 10 ++++- .../src/Commands/GetTextMinBoundingRectCommand.cc | 50 ++++++++++++++++++++++ protocol/aurum.proto | 10 +++++ 17 files changed, 209 insertions(+), 10 deletions(-) create mode 100644 org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h create mode 100644 org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc diff --git a/libaurum/inc/Accessibility/AccessibleNode.h b/libaurum/inc/Accessibility/AccessibleNode.h index 2fa3a41..be58257 100644 --- a/libaurum/inc/Accessibility/AccessibleNode.h +++ b/libaurum/inc/Accessibility/AccessibleNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -277,6 +277,12 @@ public: double getIncrement() const; /** + * @copydoc UiObject::getTextMinBoundingRect() + * + */ + Rect getTextMinBoundingRect() const; + + /** * @copydoc UiObject::isCheckable() */ bool isCheckable() const; @@ -406,6 +412,11 @@ public: virtual bool setFocus() = 0; /** + * @copydoc UIObject::updateTextMinBoundingRect() + */ + virtual void updateTextMinBoundingRect() = 0; + + /** * @brief Updates Node information from atspi server. * * @since_tizen 6.5 @@ -516,6 +527,7 @@ protected: std::string mToolkitName; Rect mScreenBoundingBox; Rect mWindowBoundingBox; + Rect mTextMinBoundingRect; int mSupportingIfaces; int mFeatureProperty; int mPid; diff --git a/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h b/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h index ffd1816..6fa1ce3 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h +++ b/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,6 +137,11 @@ public: void updatePid() override; /** + * @copydoc UiObject::updateTextMinBoundingRect() + */ + void updateTextMinBoundingRect() override; + + /** * @copydoc UiObject::setFocus() */ bool setFocus() override; diff --git a/libaurum/inc/Impl/Accessibility/AtspiWrapper.h b/libaurum/inc/Impl/Accessibility/AtspiWrapper.h index d34ceba..0389c30 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiWrapper.h +++ b/libaurum/inc/Impl/Accessibility/AtspiWrapper.h @@ -68,6 +68,7 @@ public: static gdouble Atspi_value_get_minimum_increment(AtspiValue *iface, GError **error); static guint Atspi_accessible_get_process_id(AtspiAccessible *node, GError **error); static gchar *Atspi_accessible_get_toolkit_name(AtspiAccessible *node, GError **error); + static AtspiRect *Atspi_text_get_minimum_bounding_rectangles(AtspiText* obj, gint start_offset, gint end_offset, AtspiCoordType type, GError** error); private: static std::recursive_mutex mMutex; diff --git a/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h b/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h index 2a8afa6..abb23c4 100644 --- a/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h +++ b/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -147,6 +147,12 @@ public: */ bool setFocus() override; + /** + * @brief TBD + * @since_tizen 7.0 + */ + void updateTextMinBoundingRect() override; + /** * @brief TBD * @since_tizen 6.5 diff --git a/libaurum/inc/UiObject.h b/libaurum/inc/UiObject.h index 1863560..bb50d19 100644 --- a/libaurum/inc/UiObject.h +++ b/libaurum/inc/UiObject.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -422,6 +422,16 @@ public: const double getIncrement() const; /** + * @brief Gets text object's minimum bounding rectangle(MBR). + * It works only for NUI Text Object. + * + * @return Rect + * + * @since_tizen 7.0 + */ + const Rect getTextMinBoundingRect() const; + + /** * @brief Sets object's value. * * @param[in] double value @@ -601,6 +611,15 @@ public: * @since_tizen 7.0 */ void updateToolkitName() const; + + /* + * @brief Updates text object's minimum bounding rectangle(MBR). + * It works only for NUI Text Object. + * + * @since_tizen 7.0 + */ + void updateTextMinBoundingRect() const; + /** * @brief Sets focus to object. * diff --git a/libaurum/src/Accessibility/AccessibleNode.cc b/libaurum/src/Accessibility/AccessibleNode.cc index e7bdbd1..92e9cb6 100644 --- a/libaurum/src/Accessibility/AccessibleNode.cc +++ b/libaurum/src/Accessibility/AccessibleNode.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -270,3 +270,8 @@ int AccessibleNode::getPid() const { return mPid; } + +Rect AccessibleNode::getTextMinBoundingRect() const +{ + return mTextMinBoundingRect; +} \ No newline at end of file diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index 4130cd4..00e5f7f 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -272,6 +272,27 @@ void AtspiAccessibleNode::updatePid() mPid = AtspiWrapper::Atspi_accessible_get_process_id(mNode, NULL); } +void AtspiAccessibleNode::updateTextMinBoundingRect() +{ + AtspiWrapper::Atspi_accessible_clear_cache(mNode); + + AtspiText *text = atspi_accessible_get_text_iface(mNode); + if (text) + { + gint cc = atspi_text_get_character_count(text, NULL); + AtspiRect *textMinBoundingRectExtent = AtspiWrapper::Atspi_text_get_minimum_bounding_rectangles(text, 0, cc, ATSPI_COORD_TYPE_WINDOW, NULL); + + if (textMinBoundingRectExtent) { + mTextMinBoundingRect = + Rect{textMinBoundingRectExtent->x, textMinBoundingRectExtent->y, textMinBoundingRectExtent->x + textMinBoundingRectExtent->width, + textMinBoundingRectExtent->y + textMinBoundingRectExtent->height}; + g_free(textMinBoundingRectExtent); + } + + g_object_unref(text); + } +} + bool AtspiAccessibleNode::setFocus() { AtspiComponent *component = AtspiWrapper::Atspi_accessible_get_component_iface(mNode); diff --git a/libaurum/src/Impl/Accessibility/AtspiWrapper.cc b/libaurum/src/Impl/Accessibility/AtspiWrapper.cc index ceef6cf..b923969 100644 --- a/libaurum/src/Impl/Accessibility/AtspiWrapper.cc +++ b/libaurum/src/Impl/Accessibility/AtspiWrapper.cc @@ -218,3 +218,10 @@ gchar *AtspiWrapper::Atspi_accessible_get_toolkit_name(AtspiAccessible *node, GE std::unique_lock lock(mMutex); return atspi_accessible_get_toolkit_name(node, error); } + +AtspiRect *AtspiWrapper::Atspi_text_get_minimum_bounding_rectangles(AtspiText* obj, gint start_offset, gint end_offset, AtspiCoordType type, GError** error) +{ + std::unique_lock lock(mMutex); + return atspi_text_get_range_extents(obj, start_offset, end_offset, type, error); +} + diff --git a/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc b/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc index 1650e10..a397f37 100644 --- a/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc @@ -130,6 +130,10 @@ bool MockAccessibleNode::setFocus() return false; } +void MockAccessibleNode::updateTextMinBoundingRect() +{ +} + void MockAccessibleNode::refresh(bool updateAll) { } diff --git a/libaurum/src/UiObject.cc b/libaurum/src/UiObject.cc index c975859..577ef65 100644 --- a/libaurum/src/UiObject.cc +++ b/libaurum/src/UiObject.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -219,6 +219,11 @@ const double UiObject::getIncrement() const return getAccessibleNode()->getIncrement(); } +const Rect UiObject::getTextMinBoundingRect() const +{ + return getAccessibleNode()->getTextMinBoundingRect(); +} + bool UiObject::setValue(double value) { return getAccessibleNode()->setValue(value); @@ -370,6 +375,11 @@ void UiObject::updateToolkitName() const mNode->updateToolkitName(); } +void UiObject::updateTextMinBoundingRect() const +{ + mNode->updateTextMinBoundingRect(); +} + bool UiObject::setFocus() const { return mNode->setFocus(); diff --git a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h index deb020b..5857444 100644 --- a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h +++ b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,6 +126,10 @@ public: ::grpc::Status enableScreenAnalyzer(::grpc::ServerContext *context, const ::aurum::ReqEnableScreenAnalyzer *request, ::aurum::RspEnableScreenAnalyzer *response) override; + ::grpc::Status getTextMinBoundingRect(::grpc::ServerContext *context, + const ::aurum::ReqGetTextMinBoundingRect *request, + ::aurum::RspGetTextMinBoundingRect *response) override; }; #endif + diff --git a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h index 6445640..650b31b 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,3 +51,5 @@ #include "Commands/SetFocusCommand.h" #include "Commands/GetActiveAppToolkitNameCommand.h" #include "Commands/EnableScreenAnalyzerCommand.h" + +#include "Commands/GetTextMinBoundingRectCommand.h" diff --git a/org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h new file mode 100644 index 0000000..bc04262 --- /dev/null +++ b/org.tizen.aurum-bootstrap/inc/Commands/GetTextMinBoundingRectCommand.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include "Commands/Command.h" +#include "ObjectMapper.h" +#include +#include "config.h" + +class GetTextMinBoundingRectCommand : public Command { +private: + const ::aurum::ReqGetTextMinBoundingRect *mRequest; + ::aurum::RspGetTextMinBoundingRect *mResponse; + +public: + GetTextMinBoundingRectCommand(const ::aurum::ReqGetTextMinBoundingRect *request, + ::aurum::RspGetTextMinBoundingRect *response); + ::grpc::Status execute() override; +}; \ No newline at end of file diff --git a/org.tizen.aurum-bootstrap/meson.build b/org.tizen.aurum-bootstrap/meson.build index fb99f18..3f20d19 100644 --- a/org.tizen.aurum-bootstrap/meson.build +++ b/org.tizen.aurum-bootstrap/meson.build @@ -47,6 +47,7 @@ bootstrap_svr_src += [ files('src/Commands/SetFocusCommand.cc'), files('src/Commands/GetActiveAppToolkitNameCommand.cc'), files('src/Commands/EnableScreenAnalyzerCommand.cc'), + files('src/Commands/GetTextMinBoundingRectCommand.cc'), ] bootstrap_svr_dep = [ diff --git a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc index 00abf4e..477ab5e 100644 --- a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc +++ b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,3 +281,11 @@ aurumServiceImpl::~aurumServiceImpl() return execute(cmd.get(), true); } +::grpc::Status aurumServiceImpl::getTextMinBoundingRect(::grpc::ServerContext *context, + const ::aurum::ReqGetTextMinBoundingRect *request, + ::aurum::RspGetTextMinBoundingRect *response) +{ + std::unique_ptr cmd = std::make_unique(request, response); + return execute(cmd.get(), true); +} + diff --git a/org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc new file mode 100644 index 0000000..c512ae5 --- /dev/null +++ b/org.tizen.aurum-bootstrap/src/Commands/GetTextMinBoundingRectCommand.cc @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "bootstrap.h" +#include "GetTextMinBoundingRectCommand.h" +#include "UiObject.h" + +GetTextMinBoundingRectCommand::GetTextMinBoundingRectCommand(const ::aurum::ReqGetTextMinBoundingRect *request, + ::aurum::RspGetTextMinBoundingRect *response) + : mRequest{request}, mResponse{response} +{ +} + +::grpc::Status GetTextMinBoundingRectCommand::execute() +{ + LOGI("GetTextMinBoundingRect --------------- "); + + ObjectMapper *mObjMap = ObjectMapper::getInstance(); + std::shared_ptr obj = mObjMap->getElement(mRequest->elementid()); + if (obj) { + obj->updateTextMinBoundingRect(); + ::aurum::Rect *rect = mResponse->mutable_size(); + const Rect &size = obj->getTextMinBoundingRect(); + + rect->set_x(size.mTopLeft.x); + rect->set_y(size.mTopLeft.y); + rect->set_width(size.width()); + rect->set_height(size.height()); + + mResponse->set_status(::aurum::RspStatus::OK); + } + else + mResponse->set_status(::aurum::RspStatus::ERROR); + + return grpc::Status::OK; +} \ No newline at end of file diff --git a/protocol/aurum.proto b/protocol/aurum.proto index 51600f5..0e076f9 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -35,6 +35,7 @@ service Bootstrap { rpc findElements(ReqFindElements) returns (RspFindElements) {} rpc getActiveAppToolkitName(ReqGetActiveAppToolkitName) returns (RspGetActiveAppToolkitName) {} rpc enableScreenAnalyzer(ReqEnableScreenAnalyzer) returns (RspEnableScreenAnalyzer) {} + rpc getTextMinBoundingRect(ReqGetTextMinBoundingRect) returns (RspGetTextMinBoundingRect) {} } // ------------------------------------ // @@ -593,3 +594,12 @@ message RspEnableScreenAnalyzer { RspStatus status = 1; } +message ReqGetTextMinBoundingRect { + string elementId = 1; +} + +message RspGetTextMinBoundingRect { + RspStatus status = 1; + Rect size = 2; +} + -- 2.7.4