[AT-SPI] Require ControlAccessible for Control 17/272317/3
authorArtur Świgoń <a.swigon@samsung.com>
Mon, 14 Mar 2022 12:31:51 +0000 (13:31 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Tue, 15 Mar 2022 10:02:09 +0000 (11:02 +0100)
This change narrows down the type used in GetAccessibilityObject() and
SetAccessibilityConstructor() from Accessible to ControlAccessible. It
has always been the case that a Control is represented by either a
ControlAccessible or a more derived type, and this fact is now
reaffirmed in the API.

Change-Id: Iae5f87845d951ac9affe2eb8589ec4aa3ea274e6

35 files changed:
dali-toolkit/devel-api/controls/control-accessible.cpp
dali-toolkit/devel-api/controls/control-devel.cpp
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/internal/controls/alignment/alignment-impl.cpp
dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp
dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp
dali-toolkit/internal/controls/buttons/push-button-impl.cpp
dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp
dali-toolkit/internal/controls/canvas-view/canvas-view-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/control/control-data-impl.h
dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp
dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp
dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp
dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp
dali-toolkit/internal/controls/navigation-view/navigation-view-impl.cpp
dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp
dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
dali-toolkit/internal/controls/table-view/table-view-impl.cpp
dali-toolkit/internal/controls/text-controls/text-anchor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp
dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control-impl.h

index ae7eff0553772af4dc3a1e07cac7ebbaa31aa3d7..582f73905ea15d7e80b24d1419a0eb20d95c5d82 100644 (file)
@@ -348,10 +348,10 @@ bool ControlAccessible::GrabHighlight()
   // Clear the old highlight.
   if(oldHighlightedActor)
   {
-    auto oldHighlightObject = dynamic_cast<Dali::Accessibility::Component*>(Internal::Control::Impl::GetAccessibilityObject(oldHighlightedActor));
-    if(oldHighlightObject)
+    auto oldHighlightedObject = Dali::Accessibility::Component::DownCast(Accessible::Get(oldHighlightedActor));
+    if(oldHighlightedObject)
     {
-      oldHighlightObject->ClearHighlight();
+      oldHighlightedObject->ClearHighlight();
     }
   }
 
index a98cefeae512de365139fe98b47cdb3c470c9d5a..a15e5a1fde82b0bccfac0c1da193ecbcee5ff9b7 100644 (file)
@@ -224,7 +224,7 @@ void ClearAccessibilityRelations(Toolkit::Control control)
   GetControlImplementation(control).mAccessibilityRelations.clear();
 }
 
-void SetAccessibilityConstructor(Dali::Actor control, std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Dali::Actor)> constructor)
+void SetAccessibilityConstructor(Dali::Actor control, std::function<std::unique_ptr<Toolkit::DevelControl::ControlAccessible>(Dali::Actor)> constructor)
 {
   GetControlImplementation(Toolkit::Control::DownCast(control)).mAccessibilityConstructor = constructor;
 }
@@ -256,28 +256,22 @@ Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType(Toolkit::C
 
 bool ClearAccessibilityHighlight(Toolkit::Control control)
 {
-  auto* accessible = Dali::Accessibility::Component::DownCast(GetControlImplementation(control).GetAccessibilityObject());
-
-  return accessible ? accessible->ClearHighlight() : false;
+  return GetControlImplementation(control).GetAccessibleObject()->ClearHighlight();
 }
 
 bool GrabAccessibilityHighlight(Toolkit::Control control)
 {
-  auto* accessible = Dali::Accessibility::Component::DownCast(GetControlImplementation(control).GetAccessibilityObject());
-
-  return accessible ? accessible->GrabHighlight() : false;
+  return GetControlImplementation(control).GetAccessibleObject()->GrabHighlight();
 }
 
 Dali::Accessibility::States GetAccessibilityStates(Toolkit::Control control)
 {
-  auto* accessible = GetControlImplementation(control).GetAccessibilityObject();
-
-  return accessible->GetStates();
+  return GetControlImplementation(control).GetAccessibleObject()->GetStates();
 }
 
 void NotifyAccessibilityStateChange(Toolkit::Control control, Dali::Accessibility::States states, bool recurse)
 {
-  GetControlImplementation(control).GetAccessibilityObject()->NotifyAccessibilityStateChange(std::move(states), recurse);
+  GetControlImplementation(control).GetAccessibleObject()->NotifyAccessibilityStateChange(std::move(states), recurse);
 }
 
 } // namespace DevelControl
index 07b504012c9ddc8913f0ce89db707448e9dab5b4..66df21c1fb08f8f3b8939b33a07077541f421e34 100644 (file)
@@ -570,15 +570,14 @@ DALI_TOOLKIT_API void NotifyAccessibilityStateChange(Toolkit::Control control, D
  *
  * Possible usage can be as follows:
  * @code
- *   SetAccessibilityConstructor( []( Dali::Actor actor ) {
-       return std::unique_ptr< Dali::Accessibility::Accessible >(
-       new ControlAccessible( actor, Dali::Accessibility::Role::DIALOG, true ) );
-      } );
+ *   SetAccessibilityConstructor([](Dali::Actor actor) {
+       return std::make_unique<ControlAccessible>(actor, Dali::Accessibility::Role::DIALOG, true));
+      });
   * @endcode
   *
   * param constructor callback creating Accessible object
   */
-DALI_TOOLKIT_API void SetAccessibilityConstructor(Dali::Actor control, std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Dali::Actor)> constructor);
+DALI_TOOLKIT_API void SetAccessibilityConstructor(Dali::Actor control, std::function<std::unique_ptr<Toolkit::DevelControl::ControlAccessible>(Dali::Actor)> constructor);
 
 } // namespace DevelControl
 
index d9b3b4dbcc57d175582ed90479cf361a3b907263..77af58f4c07692d1d5d69aac28f6395c16ca82ea 100644 (file)
@@ -188,8 +188,7 @@ const Toolkit::Alignment::Padding& Alignment::GetPadding() const
 void Alignment::OnInitialize()
 {
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 5ed17c8d64f9fa02a88cd447fbc7db843bdd533a..8b6bf6e24f86018e357dae688d263e8abe726c81 100644 (file)
@@ -218,8 +218,7 @@ void BloomView::OnInitialize()
   SetupProperties();
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::ANIMATION));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::ANIMATION);
   });
 }
 
index 3fcaae26aa0667ef9ef9a350dfcb24d59087ae25..4d63d9297bb1939274c8c29eb8a2c04e555a5fbe 100644 (file)
@@ -96,10 +96,9 @@ Dali::Accessibility::States CheckBoxButton::CheckBoxButtonAccessible::CalculateS
 void CheckBoxButton::OnStateChange(State newState)
 {
   // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
-  if(Dali::Accessibility::IsUp() && (Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self())
-     && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
+  if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
   {
-    Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0);
+    GetAccessibleObject()->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0);
   }
 }
 
index 290624559fa6e716ff9dd0277231914ac8c79edc..bd6cffb61428fdcd30b34db89591ec72eacfa6e0 100644 (file)
@@ -204,14 +204,15 @@ Dali::Accessibility::States PushButton::PushButtonAccessible::CalculateStates()
 void PushButton::OnStateChange(State newState)
 {
   // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
-  if(Dali::Accessibility::IsUp() && (Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self())
-     && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
+  if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
   {
-    Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0);
+    auto* accessible = GetAccessibleObject();
+
+    accessible->EmitStateChanged(Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0);
 
     if(Self().GetProperty<bool>(Toolkit::Button::Property::TOGGLABLE))
     {
-      Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0);
+      accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0);
     }
   }
 }
index ae0d4d7c392870eb7f9af23d4bfad29892e206b6..01be254a9473501f86f91a62ecba6700e8f14730 100644 (file)
@@ -104,10 +104,9 @@ void RadioButton::OnStateChange(State newState)
   }
 
   // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
-  if(Dali::Accessibility::IsUp() && (Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self())
-     && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
+  if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
   {
-    Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0);
+    GetAccessibleObject()->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0);
   }
 }
 
index 490085a06424eaceeec72e3e5580e03251581846..a69f7ec42b2bf3a8b6ae40a2c98b4354e1756950 100644 (file)
@@ -399,11 +399,12 @@ Property::Index ToggleButton::ToggleButtonAccessible::GetDescriptionPropertyInde
 void ToggleButton::OnStateChange(State newState)
 {
   // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
-  if(Dali::Accessibility::IsUp() && (Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
-     && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
+  if((Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
   {
-    Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::CHECKED, mCurrentToggleIndex ? 1 : 0, 0);
-    Dali::Accessibility::Accessible::Get(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION);
+    auto* accessible = GetAccessibleObject();
+
+    accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, mCurrentToggleIndex ? 1 : 0, 0);
+    accessible->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION);
   }
 }
 
index 6ec6fc996e0e67c910bf5622b63b631ba1a28492..7d4c14b8af86700a9a9fb4ead5f046a152b266f8 100644 (file)
@@ -98,8 +98,7 @@ void CanvasView::OnInitialize()
   Dali::Toolkit::Control handle(GetOwner());
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::IMAGE));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::IMAGE);
   });
 
   Adaptor::Get().RegisterProcessor(*this, true);
index 3d71f4d24924e9b5d517a3e967b5d5b62ff01202..2c5a279156e28c0c695ae96e96cad7e6137da7ad 100644 (file)
@@ -445,6 +445,19 @@ static bool IsShowingGeometryOnScreen(Dali::Rect<> rect)
   return rect.width > 0 && rect.height > 0;
 }
 
+Dali::Accessibility::Accessible* ExternalAccessibleGetter(Dali::Actor actor)
+{
+  auto control = Toolkit::Control::DownCast(actor);
+  if (!control)
+  {
+    return nullptr;
+  }
+
+  auto& controlImpl = Toolkit::Internal::GetImplementation(control);
+
+  return controlImpl.GetAccessibleObject();
+}
+
 } // unnamed namespace
 
 // clang-format off
@@ -508,13 +521,10 @@ Control::Impl::Impl(Control& controlImpl)
   mNeedToEmitResourceReady(false),
   mDispatchKeyEvents(true)
 {
-  Dali::Accessibility::Accessible::RegisterExternalAccessibleGetter(
-    [](Dali::Actor actor) -> Dali::Accessibility::Accessible* {
-      return Control::Impl::GetAccessibilityObject(actor);
-    });
+  Dali::Accessibility::Accessible::RegisterExternalAccessibleGetter(&ExternalAccessibleGetter);
 
-  mAccessibilityConstructor = [](Dali::Actor actor) -> std::unique_ptr<Dali::Accessibility::Accessible> {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::UNKNOWN));
+  mAccessibilityConstructor = [](Dali::Actor actor) {
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::UNKNOWN);
   };
 }
 
@@ -552,13 +562,7 @@ const Control::Impl& Control::Impl::Get(const Internal::Control& internalControl
 
 void Control::Impl::CheckHighlightedObjectGeometry()
 {
-  auto accessible = dynamic_cast<Dali::Toolkit::DevelControl::ControlAccessible*>(mAccessibilityObject.get());
-  if(!accessible)
-  {
-    DALI_LOG_ERROR("accessible is not a pointer to a DevelControl::ControlAccessible type");
-    return;
-  }
-
+  auto accessible     = GetAccessibleObject();
   auto lastPosition   = accessible->GetLastPosition();
   auto accessibleRect = accessible->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
   auto rect = GetShowingGeometry(accessibleRect, accessible);
@@ -586,7 +590,7 @@ void Control::Impl::CheckHighlightedObjectGeometry()
       // notify AT-clients on outgoing moves only
       if(mAccessibilityLastScreenRelativeMoveType != Dali::Accessibility::ScreenRelativeMoveType::INSIDE)
       {
-        mAccessibilityObject.get()->EmitMovedOutOfScreen(mAccessibilityLastScreenRelativeMoveType);
+        accessible->EmitMovedOutOfScreen(mAccessibilityLastScreenRelativeMoveType);
       }
       break;
     }
@@ -1358,7 +1362,7 @@ void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const
         {
           controlImpl.mImpl->mAccessibilityHidden = hidden;
 
-          auto* accessible = controlImpl.mImpl->GetAccessibilityObject();
+          auto* accessible = controlImpl.GetAccessibleObject();
           auto* parent     = dynamic_cast<Dali::Accessibility::ActorAccessible*>(accessible->GetParent());
           if (parent)
           {
@@ -2051,27 +2055,14 @@ void Control::Impl::OnIdleCallback()
   mIdleCallback = nullptr;
 }
 
-Dali::Accessibility::Accessible* Control::Impl::GetAccessibilityObject()
+Toolkit::DevelControl::ControlAccessible* Control::Impl::GetAccessibleObject()
 {
-  if(!mAccessibilityObject)
+  if(!mAccessibleObject)
   {
-    mAccessibilityObject = mAccessibilityConstructor(mControlImpl.Self());
+    mAccessibleObject = mAccessibilityConstructor(mControlImpl.Self());
   }
-  return mAccessibilityObject.get();
-}
 
-Dali::Accessibility::Accessible* Control::Impl::GetAccessibilityObject(Dali::Actor actor)
-{
-  if(actor)
-  {
-    auto control = Dali::Toolkit::Control::DownCast(actor);
-    if(control)
-    {
-      auto controlImpl = static_cast<Internal::Control*>(&control.GetImplementation());
-      return controlImpl->mImpl->GetAccessibilityObject();
-    }
-  }
-  return nullptr;
+  return mAccessibleObject.get();
 }
 
 } // namespace Internal
index 1321a1002a12a9b5e40947f67e80f4a4ce80d119..4fe9c44c0e8ef437118c314bffea581d6d15b458 100644 (file)
@@ -423,20 +423,9 @@ public:
   void UpdateVisualProperties(const std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& properties);
 
   /**
-   * @brief Gets the current control's accessible object.
-   *
-   * @return The handle to Accessible object
-   */
-  Dali::Accessibility::Accessible* GetAccessibilityObject();
-
-  /**
-   * @brief Gets Accessible object handle.
-   *
-   * The method acquires Accessible handle from Actor object
-   * @param  actor Actor object
-   * @return The handle to Accessible object
+   * @copydoc Dali::Toolkit::Internal::Control::GetAccessibleObject()
    */
-  static Dali::Accessibility::Accessible* GetAccessibilityObject(Dali::Actor actor);
+  Toolkit::DevelControl::ControlAccessible* GetAccessibleObject();
 
 private:
   /**
@@ -546,8 +535,8 @@ public:
   Dali::Accessibility::Role mAccessibilityRole = Dali::Accessibility::Role::UNKNOWN;
 
   std::map<Dali::Accessibility::RelationType, std::set<Accessibility::Accessible*>> mAccessibilityRelations;
-  std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Actor)>            mAccessibilityConstructor;
-  std::unique_ptr<Dali::Accessibility::Accessible>                                  mAccessibilityObject;
+  std::function<std::unique_ptr<Toolkit::DevelControl::ControlAccessible>(Actor)>   mAccessibilityConstructor;
+  std::unique_ptr<Toolkit::DevelControl::ControlAccessible>                         mAccessibleObject;
 
   // Gesture Detection
   PinchGestureDetector     mPinchGestureDetector;
index 0f3e141cf4237ad924c0cf4308dc4aa77aa92cd9..937a9c9971810627bc626c7452d0c26a645392b6 100644 (file)
@@ -235,8 +235,7 @@ void EffectsView::OnInitialize()
   self.Add(mChildrenRoot);
 
   DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 964afe214fb6b28d943077511976189e27342ac8..ae7f1aa7170e9aa9459913aac778cb04bffbfd16 100644 (file)
@@ -836,8 +836,7 @@ void FlexContainer::OnInitialize()
   SetAsKeyboardFocusGroup(true);
 
   DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 64d5ecb5167caa8c720163822136069dbe28e374..a471455df50b1322375b840c489234c2a977952d 100644 (file)
@@ -296,8 +296,7 @@ void GaussianBlurView::OnInitialize()
   mInternalRoot.Add(mRenderDownsampledCamera);
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 46c9e11c299d7b7a4a0663dbb19bc964bd55af1c..a13e43881666be6563fa9d61aea02f48f5089e59 100644 (file)
@@ -95,8 +95,7 @@ void ImageView::OnInitialize()
   handle.ResourceReadySignal().Connect(this, &ImageView::OnResourceReady);
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::IMAGE));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::IMAGE);
   });
 }
 
index 6da7915048d68fae9aa9014279b1fb8ec545a632..0f8516e35d0fa5154c674dac0665703fabd5f642 100644 (file)
@@ -219,8 +219,7 @@ void Magnifier::Initialize()
   constraint.Apply();
 
   DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index b9ee8734f91cf714e9e73c61f20683b9370db7ca..44c2b9165845dfbad35fcc1e3ec39e5360261965 100644 (file)
@@ -281,8 +281,7 @@ void Model3dView::OnInitialize()
   mRenderer       = Renderer::New(mesh, shader);
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::IMAGE));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::IMAGE);
   });
 }
 
index 9eab2906bea941c83706e2ceccb55cb6df0a111b..f511fe832ac0e50701320467341543db13e73e39 100644 (file)
@@ -71,8 +71,7 @@ Toolkit::NavigationView NavigationView::New()
 void NavigationView::OnInitialize()
 {
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 69369de7b86701d79e6d17443060688d8ae65b6e..df54bd6aac158c16b91e7f7ddb1a6195cf083251 100644 (file)
@@ -415,8 +415,7 @@ void PageTurnView::OnInitialize()
   EnableGestureDetection(GestureType::Value(GestureType::PAN));
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::PAGE_TAB_LIST));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::PAGE_TAB_LIST);
   });
 }
 
index 42d2189e0761f8f025fc3330448043fb6e2e01a1..0787b56f4c9e2f4292210624e1aad9874c37a969 100644 (file)
@@ -270,7 +270,7 @@ void ProgressBar::SetProgressValue(float value)
     mValueChangedSignal.Emit(self, mProgressValue, mSecondaryProgressValue);
     if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
     {
-      Control::Impl::GetAccessibilityObject(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
+      GetAccessibleObject()->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
     }
     RelayoutRequest();
   }
index 93773e9ed9269d4afa83e123b299fb92ec0ea647..a89b9f502412b30db980594955d9b4470ad715dd 100644 (file)
@@ -359,7 +359,7 @@ void ScrollBar::OnScrollPositionIntervalReached(PropertyNotification& source)
     mScrollPositionIntervalReachedSignal.Emit(scrollableHandle.GetCurrentProperty<float>(mPropertyScrollPosition));
     if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
     {
-      Control::Impl::GetAccessibilityObject(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
+      GetAccessibleObject()->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
     }
   }
 }
index 1197a464a46c8cd65cf7efcf85a3325d836fef12..98025ecbb3874f6347a95a65c1a6fcc529bdbab9 100644 (file)
@@ -257,8 +257,7 @@ void ShadowView::OnInitialize()
   blurStrengthConstraint.Apply();
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 49bb8cb519652b398853ebf2085dd200a33572c2..7f47940f8f772e9e1c9dbd5047b25902e18058bd 100644 (file)
@@ -949,7 +949,7 @@ void Slider::SetValue(float value)
   DisplayValue(mValue, true);
   if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
   {
-    Control::Impl::GetAccessibilityObject(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
+    GetAccessibleObject()->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE);
   }
 }
 
index ad90105187feeb8d87b3ecac4580c7050826a6a2..31fee226a9a2ac6243adc39ab746eabc09109cad 100644 (file)
@@ -150,8 +150,7 @@ void SuperBlurView::OnInitialize()
   mBlurStrengthPropertyIndex = self.RegisterUniqueProperty("blurStrength", 0.f);
 
   DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::FILLER));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::FILLER);
   });
 }
 
index 24267756f789e9ab7840f0b397acdbdf50409cfc..7a42643f9b331c3962ce2518abc65d5034e1c512 100644 (file)
@@ -1120,8 +1120,7 @@ void TableView::OnInitialize()
   SetAsKeyboardFocusGroup(true);
 
   DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::TABLE));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::TABLE);
   });
 }
 
index 88fa3d373ca6b613343a80458235129fc1360f58..a712d68a5c4662d3513b3340aa006b868bfa585d 100644 (file)
@@ -184,7 +184,7 @@ int32_t TextAnchor::TextAnchorAccessible::GetAnchorCount() const
 
 Dali::Accessibility::Accessible* TextAnchor::TextAnchorAccessible::GetAnchorAccessible(int32_t anchorIndex) const
 {
-  return Control::Impl::GetAccessibilityObject(Self());
+  return const_cast<TextAnchorAccessible*>(this);
 }
 
 std::string TextAnchor::TextAnchorAccessible::GetAnchorUri(int32_t anchorIndex) const
index d9314015954637dedacc4ac57e1ebc48c73c199c..4e6fc1f1f7b5ec09f2e91a9ddfd210cc202520d4 100644 (file)
@@ -907,26 +907,17 @@ void TextEditor::RequestTextRelayout()
 
 void TextEditor::TextInserted(unsigned int position, unsigned int length, const std::string& content)
 {
-  if(Accessibility::IsUp())
-  {
-    Control::Impl::GetAccessibilityObject(Self())->EmitTextInserted(position, length, content);
-  }
+  GetAccessibleObject()->EmitTextInserted(position, length, content);
 }
 
 void TextEditor::TextDeleted(unsigned int position, unsigned int length, const std::string& content)
 {
-  if(Accessibility::IsUp())
-  {
-    Control::Impl::GetAccessibilityObject(Self())->EmitTextDeleted(position, length, content);
-  }
+  GetAccessibleObject()->EmitTextDeleted(position, length, content);
 }
 
 void TextEditor::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition)
 {
-  if(Accessibility::IsUp())
-  {
-    Control::Impl::GetAccessibilityObject(Self())->EmitTextCursorMoved(newPosition);
-  }
+  GetAccessibleObject()->EmitTextCursorMoved(newPosition);
 
   if((oldPosition != newPosition) && !mCursorPositionChanged)
   {
index 8effb28e8b7c42dc47a7a1ccd58333cc2224e15d..22738f6079271ec98ade573fa189e037cdb80c46 100644 (file)
@@ -860,26 +860,17 @@ void TextField::SetEditable(bool editable)
 
 void TextField::TextInserted(unsigned int position, unsigned int length, const std::string& content)
 {
-  if(Accessibility::IsUp())
-  {
-    Control::Impl::GetAccessibilityObject(Self())->EmitTextInserted(position, length, content);
-  }
+  GetAccessibleObject()->EmitTextInserted(position, length, content);
 }
 
 void TextField::TextDeleted(unsigned int position, unsigned int length, const std::string& content)
 {
-  if(Accessibility::IsUp())
-  {
-    Control::Impl::GetAccessibilityObject(Self())->EmitTextDeleted(position, length, content);
-  }
+  GetAccessibleObject()->EmitTextDeleted(position, length, content);
 }
 
 void TextField::CursorPositionChanged(unsigned int oldPosition, unsigned int newPosition)
 {
-  if(Accessibility::IsUp())
-  {
-    Control::Impl::GetAccessibilityObject(Self())->EmitTextCursorMoved(newPosition);
-  }
+  GetAccessibleObject()->EmitTextCursorMoved(newPosition);
 
   if((oldPosition != newPosition) && !mCursorPositionChanged)
   {
index 2ff1bd413e6ac2346ec01055587a9b693a277c7d..96838ba317919227ba9ec40c12faf90fa49f932c 100644 (file)
@@ -398,8 +398,7 @@ void TextSelectionPopup::OnInitialize()
   self.SetProperty(Actor::Property::COLOR_ALPHA, 0.0f);
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::DIALOG, true));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::DIALOG, true);
   });
 
   //Enable highightability
index 32203289034d5ec8e44f5ecca5f64b3d04e5c68b..3283e42b8c70fcf4c6e70ab2d30ce966f20f6820 100644 (file)
@@ -165,8 +165,7 @@ void TextSelectionToolbar::OnInitialize()
   SetUp();
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::TOOL_BAR));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::TOOL_BAR);
   });
 }
 
index 0e894df0de354f1e0c951097f4fae333a1c0a797..e7c29b4e0e2e2634fc01602242dc8e10dee1a85c 100644 (file)
@@ -312,8 +312,7 @@ void ToolBar::OnInitialize()
   mLayout.SetRelativeWidth(1, mRightRelativeSpace);
 
   DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::TOOL_BAR));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::TOOL_BAR);
   });
 }
 
index c08625fae0463c936d9f2695762ae4e950ea68ff..eefdb2e8cd308d00681f82b86b169db4beb4353c 100644 (file)
@@ -119,8 +119,7 @@ void VideoView::OnInitialize()
   mVideoPlayer.FinishedSignal().Connect(this, &VideoView::EmitSignalFinish);
 
   DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
-    return std::unique_ptr<Dali::Accessibility::Accessible>(
-      new DevelControl::ControlAccessible(actor, Dali::Accessibility::Role::VIDEO));
+    return std::make_unique<DevelControl::ControlAccessible>(actor, Dali::Accessibility::Role::VIDEO);
   });
 
   //Enable highightability
index afb2bf91b9922774b8ae21420b8d248555eab79f..14075780ccf012e8f30b06dbb8ed97fdf178ec61 100644 (file)
@@ -167,6 +167,11 @@ void Control::ClearBackground()
   RelayoutRequest();
 }
 
+Toolkit::DevelControl::ControlAccessible* Control::GetAccessibleObject()
+{
+  return mImpl->GetAccessibleObject();
+}
+
 void Control::EnableGestureDetection(GestureType::Value type)
 {
   if((type & GestureType::PINCH) && !mImpl->mPinchGestureDetector)
@@ -484,7 +489,7 @@ void Control::EmitKeyInputFocusSignal(bool focusGained)
 
   if(Accessibility::IsUp())
   {
-    auto self = mImpl->GetAccessibilityObject(Self());
+    auto self = GetAccessibleObject();
     self->EmitFocused(focusGained);
     auto parent = self->GetParent();
     if(parent && !self->GetStates()[Dali::Accessibility::State::MANAGES_DESCENDANTS])
@@ -571,10 +576,7 @@ void Control::OnPropertySet(Property::Index index, const Property::Value& proper
     }
     case Actor::Property::VISIBLE:
     {
-      if(Dali::Accessibility::IsUp() && !Self().GetProperty<bool>(Toolkit::DevelControl::Property::ACCESSIBILITY_HIDDEN))
-      {
-        Dali::Accessibility::Accessible::Get(Self())->EmitVisible(Self().GetProperty(Actor::Property::VISIBLE).Get<bool>());
-      }
+      GetAccessibleObject()->EmitVisible(Self().GetProperty<bool>(Actor::Property::VISIBLE));
       break;
     }
   }
index e2d1ca43fe8a0129e1da872b707945a913c2ab11..0a3584e17eaaba0ba4f982f88b294f1ab1d752e0 100644 (file)
@@ -43,6 +43,12 @@ namespace Toolkit
 
 class StyleManager;
 
+namespace DevelControl
+{
+class ControlAccessible;
+
+} // namespace DevelControl
+
 namespace Internal
 {
 
@@ -109,6 +115,17 @@ public:
    */
   void ClearBackground();
 
+  // Accessibility
+
+  /**
+   * @brief Gets the Accessible object that represents this control.
+   *
+   * This method creates the Accessible object if necessary, so a non-null return is expected.
+   *
+   * @return The Accessible object
+   */
+  Toolkit::DevelControl::ControlAccessible* GetAccessibleObject();
+
   // Gesture Detection
 
   /**