Merge "[AT-SPI] Use WeakHandle<Actor> in Accessible objects" into devel/master
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Wed, 7 Apr 2021 10:27:01 +0000 (10:27 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 7 Apr 2021 10:27:01 +0000 (10:27 +0000)
1  2 
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-label-impl.cpp

@@@ -151,7 -151,6 +151,7 @@@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolki
  DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged",        SIGNAL_TEXT_CHANGED       )
  DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged",  SIGNAL_INPUT_STYLE_CHANGED)
  DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "maxLengthReached",   SIGNAL_MAX_LENGTH_REACHED )
 +DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "anchorClicked",      SIGNAL_ANCHOR_CLICKED     )
  
  DALI_TYPE_REGISTRATION_END()
  // clang-format on
@@@ -1205,11 -1204,6 +1205,11 @@@ DevelTextEditor::MaxLengthReachedSignal
    return mMaxLengthReachedSignal;
  }
  
 +DevelTextEditor::AnchorClickedSignalType& TextEditor::AnchorClickedSignal()
 +{
 +  return mAnchorClickedSignal;
 +}
 +
  Text::ControllerPtr TextEditor::getController()
  {
    return mController;
@@@ -1238,14 -1232,6 +1238,14 @@@ bool TextEditor::DoConnectSignal(BaseOb
        editorImpl.MaxLengthReachedSignal().Connect(tracker, functor);
      }
    }
 +  else if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
 +  {
 +    if(editor)
 +    {
 +      Internal::TextEditor& editorImpl(GetImpl(editor));
 +      editorImpl.AnchorClickedSignal().Connect(tracker, functor);
 +    }
 +  }
    else
    {
      // signalName does not match any signal
@@@ -1274,7 -1260,7 +1274,7 @@@ void TextEditor::OnInitialize(
  {
    Actor self = Self();
  
 -  mController = Text::Controller::New(this, this, this);
 +  mController = Text::Controller::New(this, this, this, this);
  
    mDecorator = Text::Decorator::New(*mController,
                                      *mController);
@@@ -1624,7 -1610,6 +1624,7 @@@ void TextEditor::OnTap(const TapGesture
    padding                   = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
    const Vector2& localPoint = gesture.GetLocalPoint();
    mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top);
 +  mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
  
    SetKeyInputFocus();
  }
@@@ -1774,12 -1759,6 +1774,12 @@@ void TextEditor::InputStyleChanged(Text
    mInputStyleChangedSignal.Emit(handle, editorInputStyleMask);
  }
  
 +void TextEditor::AnchorClicked(const std::string& href)
 +{
 +  Dali::Toolkit::TextEditor handle(GetOwner());
 +  mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
 +}
 +
  void TextEditor::AddDecoration(Actor& actor, bool needsClipping)
  {
    if(actor)
@@@ -2057,7 -2036,7 +2057,7 @@@ TextEditor::~TextEditor(
  
  std::string TextEditor::AccessibleImpl::GetName()
  {
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    return slf.GetProperty(Toolkit::TextEditor::Property::TEXT)
      .Get<std::string>();
  }
@@@ -2068,7 -2047,7 +2068,7 @@@ std::string TextEditor::AccessibleImpl:
    if(endOffset <= startOffset)
      return {};
  
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    auto txt =
      slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
  
  
  size_t TextEditor::AccessibleImpl::GetCharacterCount()
  {
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    auto txt =
      slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
  
  
  size_t TextEditor::AccessibleImpl::GetCaretOffset()
  {
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    return Dali::Toolkit::GetImpl(slf).getController()->GetCursorPosition();
  }
  
  bool TextEditor::AccessibleImpl::SetCaretOffset(size_t offset)
  {
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
    if(offset > txt.size())
      return false;
  Dali::Accessibility::Range TextEditor::AccessibleImpl::GetTextAtOffset(
    size_t offset, Dali::Accessibility::TextBoundary boundary)
  {
-   auto slf      = Toolkit::TextEditor::DownCast(self);
+   auto slf      = Toolkit::TextEditor::DownCast(Self());
    auto txt      = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
    auto txt_size = txt.size();
  
@@@ -2189,7 -2168,7 +2189,7 @@@ TextEditor::AccessibleImpl::GetSelectio
    if(selectionNum > 0)
      return {};
  
-   auto        slf  = Toolkit::TextEditor::DownCast(self);
+   auto        slf  = Toolkit::TextEditor::DownCast(Self());
    auto        ctrl = Dali::Toolkit::GetImpl(slf).getController();
    std::string ret;
    ctrl->RetrieveSelection(ret);
@@@ -2204,7 -2183,7 +2204,7 @@@ bool TextEditor::AccessibleImpl::Remove
    if(selectionNum > 0)
      return false;
  
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    Dali::Toolkit::GetImpl(slf).getController()->SetSelection(0, 0);
    return true;
  }
@@@ -2217,7 -2196,7 +2217,7 @@@ bool TextEditor::AccessibleImpl::SetSel
    if(selectionNum > 0)
      return false;
  
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    Dali::Toolkit::GetImpl(slf).getController()->SetSelection(startOffset,
                                                              endOffset);
    return true;
@@@ -2229,7 -2208,7 +2229,7 @@@ bool TextEditor::AccessibleImpl::CopyTe
    if(endPosition <= startPosition)
      return false;
  
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
    Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
  
@@@ -2242,7 -2221,7 +2242,7 @@@ bool TextEditor::AccessibleImpl::CutTex
    if(endPosition <= startPosition)
      return false;
  
-   auto slf = Toolkit::TextEditor::DownCast(self);
+   auto slf = Toolkit::TextEditor::DownCast(Self());
    auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
    Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
  
@@@ -142,7 -142,6 +142,7 @@@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolki
  DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged",       SIGNAL_TEXT_CHANGED       )
  DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached",  SIGNAL_MAX_LENGTH_REACHED )
  DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED)
 +DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "anchorClicked",     SIGNAL_ANCHOR_CLICKED     )
  
  DALI_TYPE_REGISTRATION_END()
  // clang-format on
@@@ -1196,14 -1195,6 +1196,14 @@@ bool TextField::DoConnectSignal(BaseObj
    {
      field.InputStyleChangedSignal().Connect(tracker, functor);
    }
 +  else if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
 +  {
 +    if(field)
 +    {
 +      Internal::TextField& fieldImpl(GetImpl(field));
 +      fieldImpl.AnchorClickedSignal().Connect(tracker, functor);
 +    }
 +  }
    else
    {
      // signalName does not match any signal
@@@ -1228,16 -1219,11 +1228,16 @@@ Toolkit::TextField::InputStyleChangedSi
    return mInputStyleChangedSignal;
  }
  
 +DevelTextField::AnchorClickedSignalType& TextField::AnchorClickedSignal()
 +{
 +  return mAnchorClickedSignal;
 +}
 +
  void TextField::OnInitialize()
  {
    Actor self = Self();
  
 -  mController = Text::Controller::New(this, this, this);
 +  mController = Text::Controller::New(this, this, this, this);
  
    // When using the vector-based rendering, the size of the GLyphs are different
    TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
@@@ -1633,7 -1619,6 +1633,7 @@@ void TextField::OnTap(const TapGesture
    padding                   = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
    const Vector2& localPoint = gesture.GetLocalPoint();
    mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top);
 +  mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
  
    SetKeyInputFocus();
  }
@@@ -1798,12 -1783,6 +1798,12 @@@ void TextField::InputStyleChanged(Text:
    mInputStyleChangedSignal.Emit(handle, fieldInputStyleMask);
  }
  
 +void TextField::AnchorClicked(const std::string& href)
 +{
 +  Dali::Toolkit::TextField handle(GetOwner());
 +  mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
 +}
 +
  void TextField::AddDecoration(Actor& actor, bool needsClipping)
  {
    if(actor)
@@@ -1939,7 -1918,7 +1939,7 @@@ TextField::~TextField(
  
  std::string TextField::AccessibleImpl::GetName()
  {
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    return slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
  }
  
@@@ -1949,7 -1928,7 +1949,7 @@@ std::string TextField::AccessibleImpl::
    if(endOffset <= startOffset)
      return {};
  
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    auto txt =
      slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
  
  
  size_t TextField::AccessibleImpl::GetCharacterCount()
  {
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    auto txt =
      slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
  
  
  size_t TextField::AccessibleImpl::GetCaretOffset()
  {
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    return Dali::Toolkit::GetImpl(slf).getController()->GetCursorPosition();
  }
  
  bool TextField::AccessibleImpl::SetCaretOffset(size_t offset)
  {
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
    if(offset > txt.size())
      return false;
  Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset(
    size_t offset, Dali::Accessibility::TextBoundary boundary)
  {
-   auto slf      = Toolkit::TextField::DownCast(self);
+   auto slf      = Toolkit::TextField::DownCast(Self());
    auto txt      = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
    auto txt_size = txt.size();
  
@@@ -2070,7 -2049,7 +2070,7 @@@ TextField::AccessibleImpl::GetSelection
    if(selectionNum > 0)
      return {};
  
-   auto        slf  = Toolkit::TextField::DownCast(self);
+   auto        slf  = Toolkit::TextField::DownCast(Self());
    auto        ctrl = Dali::Toolkit::GetImpl(slf).getController();
    std::string ret;
    ctrl->RetrieveSelection(ret);
@@@ -2085,7 -2064,7 +2085,7 @@@ bool TextField::AccessibleImpl::RemoveS
    if(selectionNum > 0)
      return false;
  
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    Dali::Toolkit::GetImpl(slf).getController()->SetSelection(0, 0);
    return true;
  }
@@@ -2098,7 -2077,7 +2098,7 @@@ bool TextField::AccessibleImpl::SetSele
    if(selectionNum > 0)
      return false;
  
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    Dali::Toolkit::GetImpl(slf).getController()->SetSelection(startOffset,
                                                              endOffset);
    return true;
@@@ -2110,7 -2089,7 +2110,7 @@@ bool TextField::AccessibleImpl::CopyTex
    if(endPosition <= startPosition)
      return false;
  
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
    Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
  
@@@ -2123,7 -2102,7 +2123,7 @@@ bool TextField::AccessibleImpl::CutText
    if(endPosition <= startPosition)
      return false;
  
-   auto slf = Toolkit::TextField::DownCast(self);
+   auto slf = Toolkit::TextField::DownCast(Self());
    auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
    Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
  
@@@ -139,9 -139,6 +139,9 @@@ DALI_ANIMATABLE_PROPERTY_COMPONENT_REGI
  DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit,    TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR, 1)
  DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit,    TextLabel, "textColorBlue",  TEXT_COLOR_BLUE,  TEXT_COLOR, 2)
  DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit,    TextLabel, "textColorAlpha", TEXT_COLOR_ALPHA, TEXT_COLOR, 3)
 +
 +DALI_SIGNAL_REGISTRATION(Toolkit, TextLabel, "anchorClicked", SIGNAL_ANCHOR_CLICKED)
 +
  DALI_TYPE_REGISTRATION_END()
  // clang-format on
  
@@@ -723,35 -720,6 +723,35 @@@ Property::Value TextLabel::GetProperty(
    return value;
  }
  
 +bool TextLabel::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
 +{
 +  Dali::BaseHandle handle(object);
 +
 +  bool               connected(true);
 +  Toolkit::TextLabel label = Toolkit::TextLabel::DownCast(handle);
 +
 +  if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
 +  {
 +    if(label)
 +    {
 +      Internal::TextLabel& labelImpl(GetImpl(label));
 +      labelImpl.AnchorClickedSignal().Connect(tracker, functor);
 +    }
 +  }
 +  else
 +  {
 +    // signalName does not match any signal
 +    connected = false;
 +  }
 +
 +  return connected;
 +}
 +
 +DevelTextLabel::AnchorClickedSignalType& TextLabel::AnchorClickedSignal()
 +{
 +  return mAnchorClickedSignal;
 +}
 +
  void TextLabel::OnInitialize()
  {
    Actor self = Self();
    DALI_ASSERT_DEBUG(mController && "Invalid Text Controller")
  
    mController->SetControlInterface(this);
 +  mController->SetAnchorControlInterface(this);
  
    // Use height-for-width negotiation by default
    self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
    Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
    mController->SetLayoutDirection(layoutDirection);
  
 +  // Forward input events to controller
 +  EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP));
 +  GetTapGestureDetector().SetMaximumTapsRequired(1);
 +
    Layout::Engine& engine = mController->GetLayoutEngine();
    engine.SetCursorWidth(0u); // Do not layout space for the cursor.
  
@@@ -830,23 -793,6 +830,23 @@@ void TextLabel::OnStyleChange(Toolkit::
    Control::OnStyleChange(styleManager, change);
  }
  
 +void TextLabel::OnTap(const TapGesture& gesture)
 +{
 +  DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextLabel::OnTap %p\n", mController.Get());
 +
 +  // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
 +  Extents padding;
 +  padding                   = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
 +  const Vector2& localPoint = gesture.GetLocalPoint();
 +  mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
 +}
 +
 +void TextLabel::AnchorClicked(const std::string& href)
 +{
 +  Dali::Toolkit::TextLabel handle(GetOwner());
 +  mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
 +}
 +
  Vector3 TextLabel::GetNaturalSize()
  {
    Extents padding;
@@@ -1057,7 -1003,7 +1057,7 @@@ TextLabel::~TextLabel(
  
  std::string TextLabel::AccessibleImpl::GetNameRaw()
  {
-   auto slf = Toolkit::TextLabel::DownCast(self);
+   auto slf = Toolkit::TextLabel::DownCast(Self());
    return slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
  }
  
@@@ -1072,7 -1018,7 +1072,7 @@@ std::string TextLabel::AccessibleImpl::
    if(endOffset <= startOffset)
      return {};
  
-   auto slf = Toolkit::TextLabel::DownCast(self);
+   auto slf = Toolkit::TextLabel::DownCast(Self());
    auto txt =
      slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
  
  
  size_t TextLabel::AccessibleImpl::GetCharacterCount()
  {
-   auto slf = Toolkit::TextLabel::DownCast(self);
+   auto slf = Toolkit::TextLabel::DownCast(Self());
    auto txt =
      slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
  
@@@ -1104,7 -1050,7 +1104,7 @@@ bool TextLabel::AccessibleImpl::SetCare
  Dali::Accessibility::Range TextLabel::AccessibleImpl::GetTextAtOffset(
    size_t offset, Dali::Accessibility::TextBoundary boundary)
  {
-   auto slf      = Toolkit::TextLabel::DownCast(self);
+   auto slf      = Toolkit::TextLabel::DownCast(Self());
    auto txt      = slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
    auto txt_size = txt.size();
  
@@@ -1184,7 -1130,7 +1184,7 @@@ TextLabel::AccessibleImpl::GetSelection
    if(selectionNum > 0)
      return {};
  
-   auto        slf  = Toolkit::TextLabel::DownCast(self);
+   auto        slf  = Toolkit::TextLabel::DownCast(Self());
    auto        ctrl = Dali::Toolkit::GetImpl(slf).getController();
    std::string ret;
    ctrl->RetrieveSelection(ret);
@@@ -1199,7 -1145,7 +1199,7 @@@ bool TextLabel::AccessibleImpl::RemoveS
    if(selectionNum > 0)
      return false;
  
-   auto slf = Toolkit::TextLabel::DownCast(self);
+   auto slf = Toolkit::TextLabel::DownCast(Self());
    Dali::Toolkit::GetImpl(slf).getController()->SetSelection(0, 0);
    return true;
  }
@@@ -1212,7 -1158,7 +1212,7 @@@ bool TextLabel::AccessibleImpl::SetSele
    if(selectionNum > 0)
      return false;
  
-   auto slf = Toolkit::TextLabel::DownCast(self);
+   auto slf = Toolkit::TextLabel::DownCast(Self());
    Dali::Toolkit::GetImpl(slf).getController()->SetSelection(startOffset,
                                                              endOffset);
    return true;