summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungsun Suh <youngsun.suh@samsung.com>2024-06-20 03:36:48 +0000
committerGerrit Code Review <gerrit@review>2024-06-20 03:36:48 +0000
commiteda8c1579dcc29673de9b51a09a9a9a9715bc459 (patch)
tree417c83ad9b1530ec4adae5a7d31051b8395a92de
parentb97714d463bcd59c77f2cd5a3ea6080a1eed72a3 (diff)
parent041778a56ac12a9220df7d1b59fbf0d19dbbdf47 (diff)
downloaddali-adaptor-eda8c1579dcc29673de9b51a09a9a9a9715bc459.tar.gz
dali-adaptor-eda8c1579dcc29673de9b51a09a9a9a9715bc459.tar.bz2
dali-adaptor-eda8c1579dcc29673de9b51a09a9a9a9715bc459.zip
Merge "Make sure invalid default label is removed before searching the list" into devel/master
-rw-r--r--dali/devel-api/adaptor-framework/accessibility-bridge.h14
-rw-r--r--dali/devel-api/adaptor-framework/accessibility.cpp30
-rw-r--r--dali/devel-api/atspi-interfaces/accessible.h15
-rw-r--r--dali/internal/accessibility/bridge/bridge-base.cpp39
-rw-r--r--dali/internal/accessibility/bridge/bridge-base.h22
-rw-r--r--dali/internal/accessibility/bridge/dummy/dummy-atspi.h10
6 files changed, 79 insertions, 51 deletions
diff --git a/dali/devel-api/adaptor-framework/accessibility-bridge.h b/dali/devel-api/adaptor-framework/accessibility-bridge.h
index 6d30da6e6..3cac8f50d 100644
--- a/dali/devel-api/adaptor-framework/accessibility-bridge.h
+++ b/dali/devel-api/adaptor-framework/accessibility-bridge.h
@@ -99,7 +99,7 @@ struct DALI_ADAPTOR_API Bridge
*
* @param[in] object The accessible object
*/
- virtual void RegisterDefaultLabel(Accessible* object) = 0;
+ virtual void RegisterDefaultLabel(std::shared_ptr<Accessible> object) = 0;
/**
* @brief Removes object from the stack of "default label" sourcing objects.
@@ -108,7 +108,7 @@ struct DALI_ADAPTOR_API Bridge
*
* @param[in] object The accessible object
*/
- virtual void UnregisterDefaultLabel(Accessible* object) = 0;
+ virtual void UnregisterDefaultLabel(std::shared_ptr<Accessible> object) = 0;
/**
* @brief Gets the top-most object from the stack of "default label" sourcing objects.
@@ -126,7 +126,7 @@ struct DALI_ADAPTOR_API Bridge
* Following strings are valid values for "default_label" attribute: "enabled", "disabled".
* Any other value will be interpreted as "enabled".
*/
- virtual Accessible* GetDefaultLabel(Accessible* root) const = 0;
+ virtual Accessible* GetDefaultLabel(Accessible* root) = 0;
/**
* @brief Sets name of current application which will be visible on accessibility bus.
@@ -302,14 +302,14 @@ struct DALI_ADAPTOR_API Bridge
*
* @param obj Accessible Object
*/
- virtual void EmitScrollStarted(Accessible *obj) = 0;
+ virtual void EmitScrollStarted(Accessible* obj) = 0;
- /**
+ /**
* @brief Emits ScrollFinished event on at-spi bus.
*
* @param obj Accessible Object
*/
- virtual void EmitScrollFinished(Accessible *obj) = 0;
+ virtual void EmitScrollFinished(Accessible* obj) = 0;
/**
* @brief Emits state-changed event on at-spi bus.
@@ -357,7 +357,7 @@ struct DALI_ADAPTOR_API Bridge
* The actual number of events emitted during a given time interval may be smaller
* than the number of calls to this method, but at least one is guaranteed.
*/
- virtual void EmitPostRender(Accessible *obj) = 0;
+ virtual void EmitPostRender(Accessible* obj) = 0;
/**
* @brief Emits key event on at-spi bus.
diff --git a/dali/devel-api/adaptor-framework/accessibility.cpp b/dali/devel-api/adaptor-framework/accessibility.cpp
index f69c96cdc..4b4fe25b0 100644
--- a/dali/devel-api/adaptor-framework/accessibility.cpp
+++ b/dali/devel-api/adaptor-framework/accessibility.cpp
@@ -40,8 +40,8 @@
#include <dali/devel-api/atspi-interfaces/hypertext.h>
#include <dali/devel-api/atspi-interfaces/selection.h>
#include <dali/devel-api/atspi-interfaces/socket.h>
-#include <dali/devel-api/atspi-interfaces/table.h>
#include <dali/devel-api/atspi-interfaces/table-cell.h>
+#include <dali/devel-api/atspi-interfaces/table.h>
#include <dali/devel-api/atspi-interfaces/text.h>
#include <dali/devel-api/atspi-interfaces/value.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
@@ -451,7 +451,7 @@ public:
state[State::VISIBLE] = true;
state[State::ACTIVE] = visible;
}
- else if (GetParent())
+ else if(GetParent())
{
auto parentState = GetParent()->GetStates();
state[State::SHOWING] = parentState[State::SHOWING];
@@ -495,22 +495,22 @@ public:
void SetListenPostRender(bool enabled) override
{
- if (!mRoot)
+ if(!mRoot)
{
return;
}
- auto window = Dali::DevelWindow::Get(Self());
+ auto window = Dali::DevelWindow::Get(Self());
Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
if(!mRenderNotification)
{
mRenderNotification = std::unique_ptr<TriggerEventInterface>(
- TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &AdaptorAccessible::OnPostRender),
- TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
+ TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &AdaptorAccessible::OnPostRender),
+ TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
}
- if (enabled)
+ if(enabled)
{
windowImpl.SetRenderNotification(mRenderNotification.get());
}
@@ -526,7 +526,7 @@ public:
}
}; // AdaptorAccessible
-using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::unique_ptr<AdaptorAccessible> >;
+using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::shared_ptr<AdaptorAccessible>>;
// Save RefObject from an Actor in Accessible::Get()
AdaptorAccessiblesType& GetAdaptorAccessibles()
@@ -535,7 +535,7 @@ AdaptorAccessiblesType& GetAdaptorAccessibles()
return gAdaptorAccessibles;
}
-std::function<Accessible*(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> Accessible* {
+std::function<std::shared_ptr<Accessible>(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> std::shared_ptr<Accessible> {
return nullptr;
};
@@ -550,12 +550,12 @@ void Accessible::SetObjectRegistry(ObjectRegistry registry)
});
}
-void Accessible::RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor)
+void Accessible::RegisterExternalAccessibleGetter(std::function<std::shared_ptr<Accessible>(Dali::Actor)> functor)
{
convertingFunctor = functor;
}
-Accessible* Accessible::Get(Dali::Actor actor)
+std::shared_ptr<Accessible> Accessible::GetOwningPtr(Dali::Actor actor)
{
if(!actor)
{
@@ -576,8 +576,14 @@ Accessible* Accessible::Get(Dali::Actor actor)
}
pair.first->second.reset(new AdaptorAccessible(actor, isRoot));
}
- accessible = pair.first->second.get();
+ accessible = pair.first->second;
}
return accessible;
}
+
+Accessible* Accessible::Get(Dali::Actor actor)
+{
+ auto accessible = Accessible::GetOwningPtr(actor);
+ return accessible ? accessible.get() : nullptr;
+} \ No newline at end of file
diff --git a/dali/devel-api/atspi-interfaces/accessible.h b/dali/devel-api/atspi-interfaces/accessible.h
index f34f9e3a3..3590817ac 100644
--- a/dali/devel-api/atspi-interfaces/accessible.h
+++ b/dali/devel-api/atspi-interfaces/accessible.h
@@ -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.
@@ -459,18 +459,27 @@ public:
* @brief The method registers functor resposible for converting Actor into Accessible.
* @param functor The returning Accessible handle from Actor object
*/
- static void RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor);
+ static void RegisterExternalAccessibleGetter(std::function<std::shared_ptr<Accessible>(Dali::Actor)> functor);
/**
* @brief Acquires Accessible object from Actor object.
*
* @param[in] actor Actor object
*
- * @return The handle to Accessible object
+ * @return The raw pointer to Accessible object
*/
static Accessible* Get(Dali::Actor actor);
/**
+ * @brief Acquires Accessible object from Actor object.
+ *
+ * @param[in] actor Actor object
+ *
+ * @return The owning pointer to Accessible object
+ */
+ static std::shared_ptr<Accessible> GetOwningPtr(Dali::Actor actor);
+
+ /**
* @brief Obtains the DBus interface name for the specified AT-SPI interface.
*
* @param interface AT-SPI interface identifier (e.g. AtspiInterface::ACCESSIBLE)
diff --git a/dali/internal/accessibility/bridge/bridge-base.cpp b/dali/internal/accessibility/bridge/bridge-base.cpp
index 30e6cf4f9..ba4e15452 100644
--- a/dali/internal/accessibility/bridge/bridge-base.cpp
+++ b/dali/internal/accessibility/bridge/bridge-base.cpp
@@ -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.
@@ -88,7 +88,7 @@ bool BridgeBase::TickCoalescableMessages()
if(functor)
{
functor();
- functor = {};
+ functor = {};
countdown = countdownBase;
}
else
@@ -234,24 +234,25 @@ void BridgeBase::CompressDefaultLabels()
{
// Remove entries for objects which no longer exist
mDefaultLabels.remove_if([](const DefaultLabelType& label) {
- return !label.first.GetBaseHandle(); // Check window's weak handle
- // TODO: Once Accessible becomes a handle type, check its weak handle here as well
+ // Check 1) window's weak handle; 2) accessible's ref object
+ return !label.first.GetBaseHandle() || label.second.expired();
});
}
-void BridgeBase::RegisterDefaultLabel(Accessible* object)
+void BridgeBase::RegisterDefaultLabel(std::shared_ptr<Accessible> object)
{
CompressDefaultLabels();
- Dali::WeakHandle<Dali::Window> window = GetWindow(object);
+ Dali::WeakHandle<Dali::Window> window = GetWindow(object.get());
if(!window.GetBaseHandle()) // true also if `object` is null
{
DALI_LOG_ERROR("Cannot register default label: object does not belong to any window");
return;
}
- auto it = std::find_if(mDefaultLabels.begin(), mDefaultLabels.end(), [object](const DefaultLabelType& label) {
- return object == label.second;
+ auto it = std::find_if(mDefaultLabels.begin(), mDefaultLabels.end(), [&object](const DefaultLabelType& label) {
+ auto labelPtr = label.second.lock();
+ return labelPtr && object == labelPtr;
});
if(it == mDefaultLabels.end())
@@ -270,17 +271,20 @@ void BridgeBase::RegisterDefaultLabel(Accessible* object)
}
}
-void BridgeBase::UnregisterDefaultLabel(Accessible* object)
+void BridgeBase::UnregisterDefaultLabel(std::shared_ptr<Accessible> object)
{
CompressDefaultLabels();
- mDefaultLabels.remove_if([object](const DefaultLabelType& label) {
- return object == label.second;
+ mDefaultLabels.remove_if([&object](const DefaultLabelType& label) {
+ auto labelPtr = label.second.lock();
+ return labelPtr && object == labelPtr;
});
}
-Accessible* BridgeBase::GetDefaultLabel(Accessible* root) const
+Accessible* BridgeBase::GetDefaultLabel(Accessible* root)
{
+ CompressDefaultLabels();
+
Dali::WeakHandle<Dali::Window> window = GetWindow(root);
if(!window.GetBaseHandle())
{
@@ -291,7 +295,16 @@ Accessible* BridgeBase::GetDefaultLabel(Accessible* root) const
return window == label.first;
});
- return (it == mDefaultLabels.rend()) ? root : it->second;
+ Accessible* rawPtr = root;
+ if(it != mDefaultLabels.rend())
+ {
+ if(auto labelPtr = it->second.lock())
+ {
+ rawPtr = labelPtr.get();
+ }
+ }
+
+ return rawPtr;
}
std::string BridgeBase::StripPrefix(const std::string& path)
diff --git a/dali/internal/accessibility/bridge/bridge-base.h b/dali/internal/accessibility/bridge/bridge-base.h
index 6c72399f2..2cfcab094 100644
--- a/dali/internal/accessibility/bridge/bridge-base.h
+++ b/dali/internal/accessibility/bridge/bridge-base.h
@@ -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.
@@ -283,12 +283,12 @@ public:
*/
enum class CoalescableMessages
{
- BOUNDS_CHANGED, ///< Bounds changed
- SET_OFFSET, ///< Set offset
- POST_RENDER, ///< Post render
- STATE_CHANGED_BEGIN = 500, ///< State changed (begin of reserved range)
- STATE_CHANGED_END = STATE_CHANGED_BEGIN + 99, ///< State changed (end of reserved range)
- PROPERTY_CHANGED_BEGIN, ///< Property changed (begin of reserved range)
+ BOUNDS_CHANGED, ///< Bounds changed
+ SET_OFFSET, ///< Set offset
+ POST_RENDER, ///< Post render
+ STATE_CHANGED_BEGIN = 500, ///< State changed (begin of reserved range)
+ STATE_CHANGED_END = STATE_CHANGED_BEGIN + 99, ///< State changed (end of reserved range)
+ PROPERTY_CHANGED_BEGIN, ///< Property changed (begin of reserved range)
PROPERTY_CHANGED_END = PROPERTY_CHANGED_BEGIN + 99, ///< Property changed (end of reserved range)
};
@@ -364,17 +364,17 @@ public:
/**
* @copydoc Dali::Accessibility::Bridge::RegisterDefaultLabel()
*/
- void RegisterDefaultLabel(Dali::Accessibility::Accessible* object) override;
+ void RegisterDefaultLabel(std::shared_ptr<Dali::Accessibility::Accessible> object) override;
/**
* @copydoc Dali::Accessibility::Bridge::UnregisterDefaultLabel()
*/
- void UnregisterDefaultLabel(Dali::Accessibility::Accessible* object) override;
+ void UnregisterDefaultLabel(std::shared_ptr<Dali::Accessibility::Accessible> object) override;
/**
* @copydoc Dali::Accessibility::Bridge::GetDefaultLabel()
*/
- Dali::Accessibility::Accessible* GetDefaultLabel(Dali::Accessibility::Accessible* root) const override;
+ Dali::Accessibility::Accessible* GetDefaultLabel(Dali::Accessibility::Accessible* root) override;
/**
* @copydoc Dali::Accessibility::Bridge::GetApplication()
@@ -618,7 +618,7 @@ public:
protected:
// We use a weak handle in order not to keep a window alive forever if someone forgets to UnregisterDefaultLabel()
- using DefaultLabelType = std::pair<Dali::WeakHandle<Dali::Window>, Dali::Accessibility::Accessible*>;
+ using DefaultLabelType = std::pair<Dali::WeakHandle<Dali::Window>, std::weak_ptr<Dali::Accessibility::Accessible>>;
using DefaultLabelsType = std::list<DefaultLabelType>;
mutable ApplicationAccessible mApplication;
diff --git a/dali/internal/accessibility/bridge/dummy/dummy-atspi.h b/dali/internal/accessibility/bridge/dummy/dummy-atspi.h
index a5ed28962..7f1166f36 100644
--- a/dali/internal/accessibility/bridge/dummy/dummy-atspi.h
+++ b/dali/internal/accessibility/bridge/dummy/dummy-atspi.h
@@ -18,8 +18,8 @@
*
*/
-#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/accessibility.h>
namespace Dali::Accessibility
{
@@ -46,15 +46,15 @@ struct DummyBridge : Dali::Accessibility::Bridge
{
}
- void RegisterDefaultLabel(Accessibility::Accessible* object) override
+ void RegisterDefaultLabel(std::shared_ptr<Accessibility::Accessible> object) override
{
}
- void UnregisterDefaultLabel(Accessibility::Accessible* object) override
+ void UnregisterDefaultLabel(std::shared_ptr<Accessibility::Accessible> object) override
{
}
- Dali::Accessibility::Accessible* GetDefaultLabel(Dali::Accessibility::Accessible* root) const override
+ Dali::Accessibility::Accessible* GetDefaultLabel(Dali::Accessibility::Accessible* root) override
{
return nullptr;
}
@@ -170,7 +170,7 @@ struct DummyBridge : Dali::Accessibility::Bridge
{
}
- void EmitPostRender(Accessibility::Accessible *obj) override
+ void EmitPostRender(Accessibility::Accessible* obj) override
{
}