[AT-SPI] Fixed uint underflow risk
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-label-impl.cpp
index 4699878..3ecb376 100755 (executable)
@@ -721,6 +721,9 @@ void TextLabel::OnInitialize()
   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
   self.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
 
+  // Enable highlightability
+  self.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true );
+
   // Enable the text ellipsis.
   mController->SetTextElideEnabled( true );   // If false then text larger than control will overflow
 
@@ -731,6 +734,11 @@ void TextLabel::OnInitialize()
 
   Layout::Engine& engine = mController->GetLayoutEngine();
   engine.SetCursorWidth( 0u ); // Do not layout space for the cursor.
+
+  DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) {
+    return std::unique_ptr< Dali::Accessibility::Accessible >(
+      new AccessibleImpl( actor, Dali::Accessibility::Role::LABEL ) );
+  } );
 }
 
 void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
@@ -969,10 +977,6 @@ TextLabel::TextLabel()
   mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
   mTextUpdateNeeded( false )
 {
-  DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
-    return std::unique_ptr< Dali::Accessibility::Accessible >(
-        new AccessibleImpl( actor, Dali::Accessibility::Role::LABEL ) );
-  } );
 }
 
 TextLabel::~TextLabel()
@@ -985,6 +989,11 @@ std::string TextLabel::AccessibleImpl::GetNameRaw()
   return slf.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get< std::string >();
 }
 
+Property::Index TextLabel::AccessibleImpl::GetNamePropertyIndex()
+{
+  return Toolkit::TextLabel::Property::TEXT;
+}
+
 std::string TextLabel::AccessibleImpl::GetText( size_t startOffset,
                                                 size_t endOffset )
 {
@@ -1068,7 +1077,7 @@ Dali::Accessibility::Range TextLabel::AccessibleImpl::GetTextAtOffset(
             if (boundary == Dali::Accessibility::TextBoundary::LINE)
               counter++;
           }
-          if ((counter - 1) == offset)
+          if ((counter > 0) && ((counter - 1) == offset))
           {
             range.content = txt.substr(start, index - start + 1);
             range.startOffset = start;