(toolkit) fix klocwork issues
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-decorator-impl.cpp
index 1e034a3..9f83898 100644 (file)
@@ -1,24 +1,31 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2014 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.
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h>
 
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/clipboard.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/events/pan-gesture.h>
+#include <dali/public-api/object/property-notification.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h>
-
 #include <dali-toolkit/internal/controls/text-input/text-input-handles-impl.h>
 
 using namespace Dali;
 #include <dali-toolkit/internal/controls/text-input/text-input-handles-impl.h>
 
 using namespace Dali;
@@ -29,38 +36,39 @@ namespace
   Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_INPUT_DECORATOR");
 #endif
 
   Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_INPUT_DECORATOR");
 #endif
 
-  const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f );
-  const float TOP_HANDLE_TOP_OFFSET(-1.5f);                                   // Offset between top handle and cutCopyPaste pop-up
-  const float BOTTOM_HANDLE_BOTTOM_OFFSET(1.5f);                              // Offset between bottom handle and cutCopyPaste pop-up
-  const float UI_Z_OFFSET( 0.2f );                                            // Text Selection Handles/Cursor z-offset.
-  const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET);                           // Text Selection Handles/Cursor offset.
-  const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" );
-  const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f );
-  const std::size_t CURSOR_BLINK_INTERVAL = 500;                              // Cursor blink interval
-  const float CURSOR_THICKNESS(6.0f);
-  const Degree CURSOR_ANGLE_OFFSET(2.0f);                                     // Offset from the angle
-
-  const unsigned int SCROLL_TICK_INTERVAL = 50u;
-  const float SCROLL_THRESHOLD = 10.f;
-  const float SCROLL_SPEED = 15.f;
-
-  /**
-   * Whether the given position plus the cursor size offset is inside the given boundary.
-   *
-   * @param[in] position The given position.
-   * @param[in] cursorSize The cursor size.
-   * @param[in] controlSize The given boundary.
-   * @param[in] threshold imaginary indent around boundary that will trigger the position to be outside of control.
-   *
-   * @return whether the given position is inside the given boundary.
-   */
-  bool IsPositionWithinControl( const Vector3& position, const Size& cursorSize, const Vector3& controlSize, const Vector2 threshold = Vector2::ZERO )
-  {
-    return ( position.x >= -Math::MACHINE_EPSILON_1000 + threshold.x ) &&
-           ( position.x <= controlSize.width - threshold.x + Math::MACHINE_EPSILON_1000 ) &&
-           ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 + threshold.y ) &&
-           ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 - threshold.y);
-  }
+const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f );
+const float TOP_HANDLE_TOP_OFFSET(-1.5f);                                   // Offset between top handle and cutCopyPaste pop-up
+const float BOTTOM_HANDLE_BOTTOM_OFFSET(1.5f);                              // Offset between bottom handle and cutCopyPaste pop-up
+const float UI_Z_OFFSET( 0.2f );                                            // Text Selection Handles/Cursor z-offset.
+const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET);                           // Text Selection Handles/Cursor offset.
+const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" );
+const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f );
+const std::size_t CURSOR_BLINK_INTERVAL = 500;                              // Cursor blink interval
+const float CURSOR_THICKNESS(6.0f);
+const Degree CURSOR_ANGLE_OFFSET(2.0f);                                     // Offset from the angle
+
+const unsigned int SCROLL_TICK_INTERVAL = 50u;
+const float SCROLL_THRESHOLD = 10.f;
+const float SCROLL_SPEED = 15.f;
+
+/**
+ * Whether the given position plus the cursor size offset is inside the given boundary.
+ *
+ * @param[in] position The given position.
+ * @param[in] cursorSize The cursor size.
+ * @param[in] controlSize The given boundary.
+ * @param[in] threshold imaginary indent around boundary that will trigger the position to be outside of control.
+ *
+ * @return whether the given position is inside the given boundary.
+ */
+bool IsPositionWithinControl( const Vector3& position, const Size& cursorSize, const Vector3& controlSize, const Vector2 threshold = Vector2::ZERO )
+{
+  return ( position.x >= -Math::MACHINE_EPSILON_1000 + threshold.x ) &&
+         ( position.x <= controlSize.width - threshold.x + Math::MACHINE_EPSILON_1000 ) &&
+         ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 + threshold.y ) &&
+         ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 - threshold.y);
+}
+
 }
 
 namespace Dali
 }
 
 namespace Dali
@@ -75,10 +83,17 @@ namespace Internal
 Decorator::Decorator( TextViewCharacterPositioning& textViewManager, TextInputTextStyle& textStyle ):
   mTextViewCharacterPositioning( textViewManager ),
   mTextStyle( textStyle ),
 Decorator::Decorator( TextViewCharacterPositioning& textViewManager, TextInputTextStyle& textStyle ):
   mTextViewCharacterPositioning( textViewManager ),
   mTextStyle( textStyle ),
+  mSelectionHandleOnePosition(0),
+  mSelectionHandleTwoPosition(0),
+  mGrabHandlePosition(0),
   mCursorPosition( 0 ),
   mTextHighlight( textViewManager ),
   mCursorBlinkStatus( true ),
   mCursorVisibility( true ),
   mCursorPosition( 0 ),
   mTextHighlight( textViewManager ),
   mCursorBlinkStatus( true ),
   mCursorVisibility( true ),
+  mCursorRTLEnabled( false ),
+  mIsGrabHandleInScrollArea( false ),
+  mIsCursorInScrollArea( false ),
+  mGrabHandleVisibility( false ),
   mGrabHandleEnabled( true )
 {
 }
   mGrabHandleEnabled( true )
 {
 }
@@ -114,7 +129,7 @@ Vector4 Decorator::GetBoundingBox() const
 /**
  * Selection Handles
  */
 /**
  * Selection Handles
  */
-void Decorator::OnHandlePan(Actor actor, PanGesture gesture)
+void Decorator::OnHandlePan(Actor actor, const PanGesture& gesture)
 {
   Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
   Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
 {
   Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
   Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
@@ -150,22 +165,19 @@ void Decorator::OnHandlePan(Actor actor, PanGesture gesture)
       // Revert back to non-pressed selection handle images
       if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() )
       {
       // Revert back to non-pressed selection handle images
       if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() )
       {
-        mSelectionHandleOneActualPosition = MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement );
+         mSelectionHandleOneActualPosition = MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement );
         ShowPopupCutCopyPaste();
         ShowPopupCutCopyPaste();
-        ShowPopUp();
       }
       else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() )
       {
         mSelectionHandleTwoActualPosition = MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement );
         ShowPopupCutCopyPaste();
       }
       else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() )
       {
         mSelectionHandleTwoActualPosition = MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement );
         ShowPopupCutCopyPaste();
-        ShowPopUp();
       }
       else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() )
       {
         MoveGrabHandle( gesture.displacement );
         SetCursorVisibility( true );
         ShowPopupCutCopyPaste();
       }
       else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() )
       {
         MoveGrabHandle( gesture.displacement );
         SetCursorVisibility( true );
         ShowPopupCutCopyPaste();
-        ShowPopUp();
       }
     }
     break;
       }
     }
     break;
@@ -233,17 +245,6 @@ Vector3 Decorator::PositionSelectionHandle( Actor selectionHandle, Vector3& actu
 
   selectionHandle.SetPosition( actualPosition += DEFAULT_HANDLE_OFFSET );
 
 
   selectionHandle.SetPosition( actualPosition += DEFAULT_HANDLE_OFFSET );
 
-  if( mTextViewCharacterPositioning.IsScrollEnabled() )
-  {
-    const Vector3 controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize();
-    const Size cursorSize( GetCursorSizeAt( position ) );
-    bool handleVisible = IsPositionWithinControl( actualPosition, Vector2(DEFAULT_HANDLE_OFFSET.width, DEFAULT_HANDLE_OFFSET.height), controlSize );
-
-    DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::PositionSelectionHandle controlSize[%f,%f] cursorSize[%f,%f] actualPos[%f,%f] visible[%s] \n",
-              controlSize.x, controlSize.y, cursorSize.x, cursorSize.y, actualPosition.x, actualPosition.y, ( handleVisible )?"true":"false" );
-
-    selectionHandle.SetVisible( handleVisible );
-  }
   return actualPosition;
 }
 
   return actualPosition;
 }
 
@@ -253,12 +254,6 @@ void Decorator::SetSelectionHandlesVisibility(bool visible )
   mTextInputHandles.SetSelectionHandleTwoVisibility( visible );
 }
 
   mTextInputHandles.SetSelectionHandleTwoVisibility( visible );
 }
 
-bool Decorator::OnHandleReleased()
-{
-  ShowPopUp();
-  return false;
-}
-
 void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end )
 {
   mSelectionHandleOnePosition = start;
 void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end )
 {
   mSelectionHandleOnePosition = start;
@@ -268,8 +263,6 @@ void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end )
 
   mSelectionHandleOneActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleOne(), mSelectionHandleOnePosition );
   mSelectionHandleTwoActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleTwo(), mSelectionHandleTwoPosition );
 
   mSelectionHandleOneActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleOne(), mSelectionHandleOnePosition );
   mSelectionHandleTwoActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleTwo(), mSelectionHandleTwoPosition );
-
-  mTextInputHandles.ReleasedSignal().Connect( this, &Decorator::OnHandleReleased );
 }
 
 Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle,
 }
 
 Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle,
@@ -279,7 +272,7 @@ Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle,
 {
   Vector3 actualHandlePosition;
   actualSelectionHandlePosition.x += displacement.x * selectionHandle.GetCurrentScale().x;
 {
   Vector3 actualHandlePosition;
   actualSelectionHandlePosition.x += displacement.x * selectionHandle.GetCurrentScale().x;
-  actualSelectionHandlePosition.y += displacement.y * selectionHandle.GetCurrentScale().y;;
+  actualSelectionHandlePosition.y += displacement.y * selectionHandle.GetCurrentScale().y;
 
   // Selection handles should jump to the nearest character
   std::size_t newHandlePosition = 0;
 
   // Selection handles should jump to the nearest character
   std::size_t newHandlePosition = 0;
@@ -292,47 +285,6 @@ Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle,
 
   bool handleVisible = true;
 
 
   bool handleVisible = true;
 
-  Vector2 min, max;
-  if( mTextViewCharacterPositioning.IsScrollEnabled() )
-  {
-    const Vector3 controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize();
-    const Size cursorSize( GetCursorSizeAt( newHandlePosition ) );
-
-    handleVisible = IsPositionWithinControl( actualHandlePosition,
-                                             cursorSize,
-                                             controlSize );
-
-    if( handleVisible )
-    {
-      StopScrollTimer();
-      mCurrentHandlePosition = actualHandlePosition;
-      mScrollDisplacement = Vector2::ZERO;
-    }
-    else
-    {
-
-      if( ( actualHandlePosition.x < SCROLL_THRESHOLD ) && ( displacement.x <= 0.f ) )
-      {
-        mScrollDisplacement.x = -SCROLL_SPEED;
-      }
-      else if( ( actualHandlePosition.x > controlSize.width - SCROLL_THRESHOLD ) && ( displacement.x >= 0.f ) )
-      {
-        mScrollDisplacement.x = SCROLL_SPEED;
-      }
-      if( ( actualHandlePosition.y < SCROLL_THRESHOLD ) && ( displacement.y <= 0.f ) )
-      {
-        mScrollDisplacement.y = -SCROLL_SPEED;
-      }
-      else if( ( actualHandlePosition.y > controlSize.height - SCROLL_THRESHOLD ) && ( displacement.y >= 0.f ) )
-      {
-        mScrollDisplacement.y = SCROLL_SPEED;
-      }
-      DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::MoveSelectionHandle Handle not visible scroll displacement [%f]\n", mScrollDisplacement.x);
-
-      StartScrollTimer();
-   }
-  }
-
   if ( handleVisible &&                                          // Ensure the handle is visible.
      ( newHandlePosition != currentSelectionHandlePosition ) &&  // Ensure the handle has moved.
      ( newHandlePosition != mSelectionHandleTwoPosition ) &&     // Ensure new handle position not the same position as an existing handle.
   if ( handleVisible &&                                          // Ensure the handle is visible.
      ( newHandlePosition != currentSelectionHandlePosition ) &&  // Ensure the handle has moved.
      ( newHandlePosition != mSelectionHandleTwoPosition ) &&     // Ensure new handle position not the same position as an existing handle.
@@ -384,46 +336,7 @@ void Decorator::MoveGrabHandle( const Vector2& displacement /*, std::size_t curr
 
   bool handleVisible = true;
 
 
   bool handleVisible = true;
 
-  if( mTextViewCharacterPositioning.IsScrollEnabled() )
-  {
-    const Vector3 controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize();
-    const Size cursorSize( GetCursorSizeAt( newHandlePosition ) );
-    // Scrolls the text if the handle is not in a visible position
-    handleVisible = IsPositionWithinControl( actualHandlePosition,
-                                                cursorSize,
-                                                controlSize );
-
-    DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::MoveGrabHandle handleVisible[%s]\n", ( handleVisible )?"true":"false");
-
-    if( handleVisible )
-    {
-      StopScrollTimer();
-      mCurrentHandlePosition = actualHandlePosition;
-      mScrollDisplacement = Vector2::ZERO;
-    }
-    else
-    {
-      if( ( actualHandlePosition.x < SCROLL_THRESHOLD ) && ( displacement.x <= 0.f ) )
-      {
-        mScrollDisplacement.x = -SCROLL_SPEED;
-      }
-      else if( ( actualHandlePosition.x > controlSize.width - SCROLL_THRESHOLD ) && ( displacement.x >= 0.f ) )
-      {
-        mScrollDisplacement.x = SCROLL_SPEED;
-      }
-      if( ( actualHandlePosition.y < SCROLL_THRESHOLD ) && ( displacement.y <= 0.f ) )
-      {
-        mScrollDisplacement.y = -SCROLL_SPEED;
-      }
-      else if( ( actualHandlePosition.y > controlSize.height - SCROLL_THRESHOLD ) && ( displacement.y >= 0.f ) )
-      {
-        mScrollDisplacement.y = SCROLL_SPEED;
-      }
-      StartScrollTimer();
-    }
-  }
-
-    if( ( newHandlePosition != mGrabHandlePosition ) &&                           // Only redraw cursor and do updates if position changed
+  if( ( newHandlePosition != mGrabHandlePosition ) &&                           // Only redraw cursor and do updates if position changed
         ( handleVisible ) )// and the new position is visible (if scroll is not enabled, it's always true).
     {
       mActualGrabHandlePosition = actualHandlePosition;
         ( handleVisible ) )// and the new position is visible (if scroll is not enabled, it's always true).
     {
       mActualGrabHandlePosition = actualHandlePosition;
@@ -443,8 +356,6 @@ void Decorator::MoveGrabHandle( const Vector2& displacement /*, std::size_t curr
       if ( !mTextViewCharacterPositioning.IsStyledTextEmpty()  && ( cursorPosition > 0 ) )
       {
         DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
       if ( !mTextViewCharacterPositioning.IsStyledTextEmpty()  && ( cursorPosition > 0 ) )
       {
         DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
-        const TextStyle inputStyle = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 );
-        mTextStyle.SetInputStyle( inputStyle );
       }
     }
 }
       }
     }
 }
@@ -516,16 +427,9 @@ void Decorator::DrawCursor(const std::size_t nthChar)
 
   // Get height of cursor and set its size
   Size size( CURSOR_THICKNESS, 0.0f );
 
   // Get height of cursor and set its size
   Size size( CURSOR_THICKNESS, 0.0f );
-  if ( !mTextViewCharacterPositioning.IsTextEmpty() )
-  {
-    Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition
-    size.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max  ).height;
-  }
-  else
-  {
-    // Measure Font so know how big text will be if no initial text to measure.
-    size.height = mTextViewCharacterPositioning.GetLineHeight( nthChar );
-  }
+
+  Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition
+  size.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max  ).height;
 
   mCursor.SetSize(size);
 
 
   mCursor.SetSize(size);
 
@@ -534,7 +438,7 @@ void Decorator::DrawCursor(const std::size_t nthChar)
   {
     DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
     const TextStyle styleAtCursor = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 );
   {
     DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
     const TextStyle styleAtCursor = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 );
-    mCursor.SetRotation( styleAtCursor.GetItalics() ? Degree( styleAtCursor.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS );
+    mCursor.SetRotation( styleAtCursor.IsItalicsEnabled() ? Degree( styleAtCursor.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS );
   }
 
   DALI_ASSERT_DEBUG( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() );
   }
 
   DALI_ASSERT_DEBUG( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() );
@@ -547,28 +451,7 @@ void Decorator::DrawCursor(const std::size_t nthChar)
 
     SetAltCursorEnabled( altPositionValid );
 
 
     SetAltCursorEnabled( altPositionValid );
 
-    if(!altPositionValid)
-    {
-      mCursor.SetPosition( position + UI_OFFSET );
-    }
-    else
-    {
-      size.height *= 0.5f;
-      mCursor.SetSize(size);
-      mCursor.SetPosition( position + UI_OFFSET - Vector3(0.0f, directionRTL ? 0.0f : size.height, 0.0f) );
-      Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition
-      Size rowSize = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max );
-      size.height = rowSize.height * 0.5f;
-      mCursorRTL.SetSize(size);
-      mCursorRTL.SetPosition( altPosition + UI_OFFSET - Vector3(0.0f, directionRTL ? size.height : 0.0f, 0.0f) );
-    }
-
-    if( mTextViewCharacterPositioning.IsScrollEnabled() )
-    {
-      // Whether cursor and grab handle are inside the boundaries of the text-input when text scroll is enabled.
-      const Vector3& controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize();
-      mIsCursorInScrollArea = mIsGrabHandleInScrollArea = IsPositionWithinControl( position, size, controlSize );
-    }
+    mCursor.SetPosition( position + UI_OFFSET );
   }
 }
 
   }
 }
 
@@ -700,7 +583,6 @@ void Decorator::CreateHighlight( Actor parent )
   {
     mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() );
     mHighlightMeshActor.SetName( "HighlightMeshActor" );
   {
     mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() );
     mHighlightMeshActor.SetName( "HighlightMeshActor" );
-    mHighlightMeshActor.SetInheritShaderEffect( false );
     mHighlightMeshActor.SetAffectedByLighting(false);
     parent.Add( mHighlightMeshActor );
   }
     mHighlightMeshActor.SetAffectedByLighting(false);
     parent.Add( mHighlightMeshActor );
   }
@@ -837,7 +719,7 @@ Vector3 Decorator::PositionOfPopUpRelativeToSelectionHandles()
   // When text is selected, show popup above top handle (and text), or below bottom handle.
 
   // topHandle: referring to the top most point of the handle or the top line of selection.
   // When text is selected, show popup above top handle (and text), or below bottom handle.
 
   // topHandle: referring to the top most point of the handle or the top line of selection.
-  if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y )
+  if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y ) // Handle may switch positions so calculate which is top.
   {
     topHandle = mSelectionHandleOneActualPosition;
     rowSize= mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleOnePosition, min, max );
   {
     topHandle = mSelectionHandleOneActualPosition;
     rowSize= mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleOnePosition, min, max );
@@ -947,10 +829,6 @@ void Decorator::ShowPopupCutCopyPaste()
 
 void Decorator::HidePopUp( bool animate, bool signalFinished )
 {
 
 void Decorator::HidePopUp( bool animate, bool signalFinished )
 {
-  if ( ( mPopUpPanel.GetState() == TextInputPopupNew::StateShowing ) || ( mPopUpPanel.GetState() == TextInputPopupNew::StateShown )  )
-  {
-    mPopUpPanel.Hide( animate );
-  }
 }
 
 void Decorator::AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption)
 }
 
 void Decorator::AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption)
@@ -1118,12 +996,6 @@ bool Decorator::OnScrollTimerTick()
       scrollPosition += scrollDelta;
       mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
 
       scrollPosition += scrollDelta;
       mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
 
-      // If scroll position goes too far TextView will trim it to fit.
-      if ( mTextViewCharacterPositioning.IsScrollPositionTrimmed() )
-      {
-        StopScrollTimer();
-      }
-
       mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newGrabHandlePosition ).GetVectorXY();
     }
   }
       mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newGrabHandlePosition ).GetVectorXY();
     }
   }
@@ -1147,11 +1019,6 @@ bool Decorator::OnScrollTimerTick()
       scrollPosition += scrollDelta;
       mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
 
       scrollPosition += scrollDelta;
       mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
 
-      if( mTextViewCharacterPositioning.IsScrollPositionTrimmed() )
-      {
-        StopScrollTimer();
-      }
-
       mSelectionHandleOnePosition = newHandleOnePosition;
       mSelectionHandleOneActualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition ).GetVectorXY();
     }
       mSelectionHandleOnePosition = newHandleOnePosition;
       mSelectionHandleOneActualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition ).GetVectorXY();
     }
@@ -1173,11 +1040,6 @@ bool Decorator::OnScrollTimerTick()
       scrollPosition += scrollDelta;
       mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
 
       scrollPosition += scrollDelta;
       mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
 
-      if( mTextViewCharacterPositioning.IsScrollPositionTrimmed() )
-      {
-        StopScrollTimer();
-      }
-
       mSelectionHandleTwoPosition = newHandleTwoPosition;
       mCurrentHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition ).GetVectorXY();
 
       mSelectionHandleTwoPosition = newHandleTwoPosition;
       mCurrentHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition ).GetVectorXY();