fixing some of the comments and changing copy-by-value to by reference in size negoti...
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-impl.cpp
index 3919c6d..01566d6 100644 (file)
  */
 
 // CLASS HEADER
  */
 
 // CLASS HEADER
-#include "text-view-impl.h"
+#include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
 
 // INTERNAL INCLUDES
 
 // INTERNAL INCLUDES
-#include "split-by-new-line-char-policies.h"
-#include "split-by-word-policies.h"
-#include "split-by-char-policies.h"
-#include "text-view-processor.h"
-#include "text-view-word-processor.h"
-#include "relayout-utilities.h"
-#include "text-view-processor-dbg.h"
+#include <dali-toolkit/internal/controls/text-view/split-by-new-line-char-policies.h>
+#include <dali-toolkit/internal/controls/text-view/split-by-word-policies.h>
+#include <dali-toolkit/internal/controls/text-view/split-by-char-policies.h>
+#include <dali-toolkit/internal/controls/text-view/text-processor-bidirectional-info.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
+#include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -122,9 +127,10 @@ bool IsTextViewProcessorNewStyleOperation( const TextView::TextViewProcessorMeta
 
 TextView::TextViewProcessorMetadata::TextViewProcessorMetadata()
 : mType( TextView::TextSet ),
 
 TextView::TextViewProcessorMetadata::TextViewProcessorMetadata()
 : mType( TextView::TextSet ),
-  mPosition( 0 ),
-  mNumberOfCharacters( 0 ),
-  mText()
+  mPosition( 0u ),
+  mNumberOfCharacters( 0u ),
+  mText(),
+  mStyleMask(TextStyle::NONE)
 {
 }
 
 {
 }
 
@@ -194,23 +200,38 @@ void TextView::InsertTextAt( std::size_t position, const std::string& text )
 
 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
 {
 
 void TextView::InsertTextAt( std::size_t position, const MarkupProcessor::StyledTextArray& text )
 {
-  // Creates metadata with the Insert operation.
-  TextViewProcessorMetadata metadata;
-  metadata.mType = TextView::TextInserted;
-  metadata.mPosition = position;
-  metadata.mText = text;
+  std::string textStr;
+  MarkupProcessor::GetPlainString( text, textStr );
 
 
-  // Store metadata.
-  mTextViewProcessorOperations.push_back( metadata );
+  if( TextProcessor::ContainsRightToLeftCharacter( Text( textStr ) ) ||
+      TextProcessor::ContainsRightToLeftCharacter( Text( GetText() ) ) )
+  {
+    // Temporary fix. Creates the whole layout if there is rtl text.
 
 
-  // Updates current styled text.
-  mCurrentStyledText.insert( mCurrentStyledText.begin() + position, text.begin(), text.end() );
+    MarkupProcessor::StyledTextArray textToSet = mCurrentStyledText;
+    textToSet.insert( textToSet.begin() + position, text.begin(), text.end() );
+    SetText( textToSet );
+  }
+  else
+  {
+    // Creates metadata with the Insert operation.
+    TextViewProcessorMetadata metadata;
+    metadata.mType = TextView::TextInserted;
+    metadata.mPosition = position;
+    metadata.mText = text;
 
 
-  // Request to be relaid out
-  RelayoutRequest();
+    // Store metadata.
+    mTextViewProcessorOperations.push_back( metadata );
 
 
-  // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
-  mRelayoutOperations = RELAYOUT_ALL;
+    // Updates current styled text.
+    mCurrentStyledText.insert( mCurrentStyledText.begin() + position, text.begin(), text.end() );
+
+    // Request to be relaid out
+    RelayoutRequest();
+
+    // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
+    mRelayoutOperations = RELAYOUT_ALL;
+  }
 }
 
 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
 }
 
 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
@@ -225,49 +246,84 @@ void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfChar
 
 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
 {
 
 void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const MarkupProcessor::StyledTextArray& text )
 {
-  // Creates metadata with the Insert operation.
-  TextViewProcessorMetadata metadata;
-  metadata.mType = TextView::TextReplaced;
-  metadata.mPosition = position;
-  metadata.mNumberOfCharacters = numberOfCharacters;
-  metadata.mText = text;
+  std::string textStr;
+  MarkupProcessor::GetPlainString( text, textStr );
 
 
-  // Store metadata.
-  mTextViewProcessorOperations.push_back( metadata );
+  if( TextProcessor::ContainsRightToLeftCharacter( Text( textStr ) ) ||
+      TextProcessor::ContainsRightToLeftCharacter( Text( GetText() ) ) )
+  {
+    // Temporary fix. Creates the whole layout if there is rtl text.
 
 
-  // Updates current styled text.
-  MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
-  mCurrentStyledText.erase( it, it + numberOfCharacters );
-  it = mCurrentStyledText.begin() + position;
-  mCurrentStyledText.insert( it, text.begin(), text.end() );
+    // Updates current styled text.
+    MarkupProcessor::StyledTextArray textToSet = mCurrentStyledText;
 
 
-  // Request to be relaid out
-  RelayoutRequest();
+    MarkupProcessor::StyledTextArray::iterator it = textToSet.begin() + position;
+    textToSet.erase( it, it + numberOfCharacters );
+    it = textToSet.begin() + position;
+    textToSet.insert( it, text.begin(), text.end() );
 
 
-  // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
-  mRelayoutOperations = RELAYOUT_ALL;
+    SetText( textToSet );
+  }
+  else
+  {
+    // Creates metadata with the Insert operation.
+    TextViewProcessorMetadata metadata;
+    metadata.mType = TextView::TextReplaced;
+    metadata.mPosition = position;
+    metadata.mNumberOfCharacters = numberOfCharacters;
+    metadata.mText = text;
+
+    // Store metadata.
+    mTextViewProcessorOperations.push_back( metadata );
+
+    // Updates current styled text.
+    MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
+    mCurrentStyledText.erase( it, it + numberOfCharacters );
+    it = mCurrentStyledText.begin() + position;
+    mCurrentStyledText.insert( it, text.begin(), text.end() );
+
+    // Request to be relaid out
+    RelayoutRequest();
+
+    // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
+    mRelayoutOperations = RELAYOUT_ALL;
+  }
 }
 
 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
 {
 }
 
 void TextView::RemoveTextFrom( std::size_t position, std::size_t numberOfCharacters )
 {
-  // Creates metadata with the Remove operation.
-  TextViewProcessorMetadata metadata;
-  metadata.mType = TextView::TextRemoved;
-  metadata.mPosition = position;
-  metadata.mNumberOfCharacters = numberOfCharacters;
+  if( TextProcessor::ContainsRightToLeftCharacter( Text( GetText() ) ) )
+  {
+    // Temporary fix. Creates the whole layout if there is rtl text.
 
 
-  // Store metadata.
-  mTextViewProcessorOperations.push_back( metadata );
+    // Updates current styled text.
+    MarkupProcessor::StyledTextArray textToSet = mCurrentStyledText;
+    MarkupProcessor::StyledTextArray::iterator it = textToSet.begin() + position;
+    textToSet.erase( it, it + numberOfCharacters );
 
 
-  // Updates current styled text.
-  MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
-  mCurrentStyledText.erase( it, it + numberOfCharacters );
+    SetText( textToSet );
+  }
+  else
+  {
+    // Creates metadata with the Remove operation.
+    TextViewProcessorMetadata metadata;
+    metadata.mType = TextView::TextRemoved;
+    metadata.mPosition = position;
+    metadata.mNumberOfCharacters = numberOfCharacters;
 
 
-  // Request to be relaid out
-  RelayoutRequest();
+    // Store metadata.
+    mTextViewProcessorOperations.push_back( metadata );
 
 
-  // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
-  mRelayoutOperations = RELAYOUT_ALL;
+    // Updates current styled text.
+    MarkupProcessor::StyledTextArray::iterator it = mCurrentStyledText.begin() + position;
+    mCurrentStyledText.erase( it, it + numberOfCharacters );
+
+    // Request to be relaid out
+    RelayoutRequest();
+
+    // If a GetTextLayoutInfo() or GetHeightForWidth() arrives, relayout the text synchronously is needed on order to retrieve the right values.
+    mRelayoutOperations = RELAYOUT_ALL;
+  }
 }
 
 std::string TextView::GetText() const
 }
 
 std::string TextView::GetText() const
@@ -312,8 +368,7 @@ void TextView::SetLineHeightOffset( PointSize offset )
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
     }
   }
 }
     }
   }
 }
@@ -379,14 +434,18 @@ void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask ma
   }
 
   // Sets the new style to the ellipsize text
   }
 
   // Sets the new style to the ellipsize text
-  if( !mLayoutParameters.mEllipsizeText.empty() )
+  // TODO: fix this as a call to SetEllipsizeText will trigger the creation of new text actors.
+  if( 0u < mRelayoutData.mTextLayoutInfo.mEllipsisTextStyles.Count() )
   {
   {
-    for( MarkupProcessor::StyledTextArray::iterator it = mLayoutParameters.mEllipsizeText.begin(), endIt = mLayoutParameters.mEllipsizeText.end(); it != endIt; ++it )
+    for( Vector<TextStyle*>::Iterator it = mRelayoutData.mTextLayoutInfo.mEllipsisTextStyles.Begin(),
+           endIt = mRelayoutData.mTextLayoutInfo.mEllipsisTextStyles.End();
+         it != endIt;
+         ++it )
     {
     {
-      (*it).mStyle.Copy( style, mask );
+      (*it)->Copy( style, mask );
     }
 
     }
 
-    SetEllipsizeText( mLayoutParameters.mEllipsizeText );
+    SetEllipsizeText( mRelayoutData.mTextLayoutInfo.mEllipsisText, mRelayoutData.mTextLayoutInfo.mEllipsisTextStyles );
   }
 }
 
   }
 }
 
@@ -478,8 +537,7 @@ void TextView::SetHeightExceedPolicy( Toolkit::TextView::ExceedPolicy policy )
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
     }
   }
 }
     }
   }
 }
@@ -506,8 +564,7 @@ void TextView::SetLineJustification( Toolkit::TextView::LineJustification justif
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
     }
   }
 }
     }
   }
 }
@@ -535,8 +592,7 @@ void TextView::SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBound
                                                                 RELAYOUT_REMOVE_TEXT_ACTORS |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
                                                                 RELAYOUT_REMOVE_TEXT_ACTORS |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
     }
   }
 }
     }
   }
 }
@@ -552,17 +608,35 @@ void TextView::SetEllipsizeText( const std::string& ellipsizeText )
   MarkupProcessor::StyledTextArray styledText;
   MarkupProcessor::GetStyledTextArray( ellipsizeText, styledText, IsMarkupProcessingEnabled() );
 
   MarkupProcessor::StyledTextArray styledText;
   MarkupProcessor::GetStyledTextArray( ellipsizeText, styledText, IsMarkupProcessingEnabled() );
 
+  // Creates the ellipsis layout info and sets the text and styles.
   SetEllipsizeText( styledText );
 }
 
 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
 {
   SetEllipsizeText( styledText );
 }
 
 void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsizeText )
 {
-  mLayoutParameters.mEllipsizeText = ellipsizeText;
+  // Converts the styled text array into a Text and a vector of TextStyles.
+  Text text;
+  Vector<TextStyle*> styles;
+  for( MarkupProcessor::StyledTextArray::const_iterator it = ellipsizeText.begin(), endIt = ellipsizeText.end(); it != endIt; ++it )
+  {
+    const MarkupProcessor::StyledText& styledText( *it );
 
 
-  mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo = TextViewProcessor::WordLayoutInfo();
+    text.Append( styledText.mText );
+    styles.PushBack( new TextStyle( styledText.mStyle ) );
+  }
 
 
-  TextViewProcessor::CreateWordTextInfo( mLayoutParameters.mEllipsizeText,
-                                         mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo );
+  // Creates the ellipsis layout info and sets the text and styles.
+  SetEllipsizeText( text, styles );
+}
+
+void TextView::SetEllipsizeText( const Text& ellipsizeText, const Vector<TextStyle*>& ellipsizeStyles )
+{
+  // Sets the text and styles for the ellipsis text.
+  mRelayoutData.mTextLayoutInfo.mEllipsisText = ellipsizeText;
+  mRelayoutData.mTextLayoutInfo.mEllipsisTextStyles = ellipsizeStyles;
+
+  // Creates the ellipsis layout info.
+  CreateEllipsizeLayout();
 
   // Request to be relaid out
   RelayoutRequest();
 
   // Request to be relaid out
   RelayoutRequest();
@@ -572,13 +646,7 @@ void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsi
 
 std::string TextView::GetEllipsizeText() const
 {
 
 std::string TextView::GetEllipsizeText() const
 {
-  std::string text;
-  for( MarkupProcessor::StyledTextArray::const_iterator it = mLayoutParameters.mEllipsizeText.begin(), endIt = mLayoutParameters.mEllipsizeText.end(); it != endIt; ++it )
-  {
-    text.append( (*it).mText.GetText() );
-  }
-
-  return text;
+  return mRelayoutData.mTextLayoutInfo.mEllipsisText.GetText();
 }
 
 void TextView::GetTextLayoutInfo()
 }
 
 void TextView::GetTextLayoutInfo()
@@ -636,9 +704,7 @@ void TextView::GetTextLayoutInfo()
       if( hasGlyphActors )
       {
         mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
       if( hasGlyphActors )
       {
         mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
-        mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
       }
       }
-
     }
   }
 }
     }
   }
 }
@@ -742,8 +808,7 @@ void TextView::SetSnapshotModeEnabled( bool enable )
       mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations |
                                                                 RELAYOUT_REMOVE_TEXT_ACTORS |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
       mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations |
                                                                 RELAYOUT_REMOVE_TEXT_ACTORS |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
     }
     RelayoutRequest();
   }
     }
     RelayoutRequest();
   }
@@ -835,9 +900,9 @@ bool TextView::IsScrollPositionTrimmed() const
   return mVisualParameters.mScrollPositionTrimmed;
 }
 
   return mVisualParameters.mScrollPositionTrimmed;
 }
 
-Toolkit::TextView::ScrolledSignalV2& TextView::ScrolledSignal()
+Toolkit::TextView::ScrolledSignalType& TextView::ScrolledSignal()
 {
 {
-  return mScrolledSignalV2;
+  return mScrolledSignal;
 }
 
 bool TextView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 }
 
 bool TextView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
@@ -862,18 +927,19 @@ bool TextView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface*
 
 TextView::LayoutParameters::LayoutParameters()
 : mMultilinePolicy( Toolkit::TextView::SplitByNewLineChar ),
 
 TextView::LayoutParameters::LayoutParameters()
 : mMultilinePolicy( Toolkit::TextView::SplitByNewLineChar ),
+  mExceedPolicy( TextView::Original ),
   mWidthExceedPolicy( Toolkit::TextView::Original ),
   mHeightExceedPolicy( Toolkit::TextView::Original ),
   mHorizontalAlignment( Toolkit::Alignment::HorizontalCenter ),
   mVerticalAlignment( Toolkit::Alignment::VerticalCenter ),
   mLineJustification( Toolkit::TextView::Left ),
   mLineHeightOffset( 0.f ),
   mWidthExceedPolicy( Toolkit::TextView::Original ),
   mHeightExceedPolicy( Toolkit::TextView::Original ),
   mHorizontalAlignment( Toolkit::Alignment::HorizontalCenter ),
   mVerticalAlignment( Toolkit::Alignment::VerticalCenter ),
   mLineJustification( Toolkit::TextView::Left ),
   mLineHeightOffset( 0.f ),
-  mEllipsizeText(),
   mMarkUpEnabled( false )
 {
   mMarkUpEnabled( false )
 {
-  // Sets ellipsize text
-  MarkupProcessor::StyledTextArray styledEllipsize;
-  MarkupProcessor::GetStyledTextArray( std::string( "..." ), mEllipsizeText, false );
+}
+
+TextView::LayoutParameters::~LayoutParameters()
+{
 }
 
 TextView::LayoutParameters::LayoutParameters( Toolkit::TextView::MultilinePolicy   multilinePolicy,
 }
 
 TextView::LayoutParameters::LayoutParameters( Toolkit::TextView::MultilinePolicy   multilinePolicy,
@@ -882,16 +948,15 @@ TextView::LayoutParameters::LayoutParameters( Toolkit::TextView::MultilinePolicy
                                               Toolkit::Alignment::Type             alignmentType,
                                               Toolkit::TextView::LineJustification lineJustification,
                                               float                                lineHeightOffset,
                                               Toolkit::Alignment::Type             alignmentType,
                                               Toolkit::TextView::LineJustification lineJustification,
                                               float                                lineHeightOffset,
-                                              const std::string&                   ellipsizeText,
                                               bool                                 markUpEnabled )
 : mMultilinePolicy( multilinePolicy ),
                                               bool                                 markUpEnabled )
 : mMultilinePolicy( multilinePolicy ),
+  mExceedPolicy( TextView::Original ),
   mWidthExceedPolicy( widthExceedPolicy ),
   mHeightExceedPolicy( heightExceedPolicy ),
   mHorizontalAlignment(),
   mVerticalAlignment(),
   mLineJustification( lineJustification ),
   mLineHeightOffset( lineHeightOffset ),
   mWidthExceedPolicy( widthExceedPolicy ),
   mHeightExceedPolicy( heightExceedPolicy ),
   mHorizontalAlignment(),
   mVerticalAlignment(),
   mLineJustification( lineJustification ),
   mLineHeightOffset( lineHeightOffset ),
-  mEllipsizeText(),
   mMarkUpEnabled( markUpEnabled )
 {
   // Sets alignment
   mMarkUpEnabled( markUpEnabled )
 {
   // Sets alignment
@@ -904,21 +969,17 @@ TextView::LayoutParameters::LayoutParameters( Toolkit::TextView::MultilinePolicy
 
   mHorizontalAlignment = horizontalAlignment;
   mVerticalAlignment = verticalAlignment;
 
   mHorizontalAlignment = horizontalAlignment;
   mVerticalAlignment = verticalAlignment;
-
-  // Sets ellipsize text
-  MarkupProcessor::StyledTextArray styledEllipsize;
-  MarkupProcessor::GetStyledTextArray( ellipsizeText, mEllipsizeText, mMarkUpEnabled );
 }
 
 TextView::LayoutParameters::LayoutParameters( const TextView::LayoutParameters& layoutParameters )
 : mMultilinePolicy( layoutParameters.mMultilinePolicy ),
 }
 
 TextView::LayoutParameters::LayoutParameters( const TextView::LayoutParameters& layoutParameters )
 : mMultilinePolicy( layoutParameters.mMultilinePolicy ),
+  mExceedPolicy( TextView::Original ),
   mWidthExceedPolicy( layoutParameters.mWidthExceedPolicy ),
   mHeightExceedPolicy( layoutParameters.mHeightExceedPolicy ),
   mHorizontalAlignment( layoutParameters.mHorizontalAlignment ),
   mVerticalAlignment( layoutParameters.mVerticalAlignment ),
   mLineJustification( layoutParameters.mLineJustification ),
   mLineHeightOffset( layoutParameters.mLineHeightOffset ),
   mWidthExceedPolicy( layoutParameters.mWidthExceedPolicy ),
   mHeightExceedPolicy( layoutParameters.mHeightExceedPolicy ),
   mHorizontalAlignment( layoutParameters.mHorizontalAlignment ),
   mVerticalAlignment( layoutParameters.mVerticalAlignment ),
   mLineJustification( layoutParameters.mLineJustification ),
   mLineHeightOffset( layoutParameters.mLineHeightOffset ),
-  mEllipsizeText( layoutParameters.mEllipsizeText ),
   mMarkUpEnabled( layoutParameters.mMarkUpEnabled )
 {
 }
   mMarkUpEnabled( layoutParameters.mMarkUpEnabled )
 {
 }
@@ -932,7 +993,6 @@ TextView::LayoutParameters& TextView::LayoutParameters::operator=( const TextVie
   mVerticalAlignment = layoutParameters.mVerticalAlignment;
   mLineJustification = layoutParameters.mLineJustification;
   mLineHeightOffset = layoutParameters.mLineHeightOffset;
   mVerticalAlignment = layoutParameters.mVerticalAlignment;
   mLineJustification = layoutParameters.mLineJustification;
   mLineHeightOffset = layoutParameters.mLineHeightOffset;
-  mEllipsizeText = layoutParameters.mEllipsizeText;
   mMarkUpEnabled = layoutParameters.mMarkUpEnabled;
 
   return *this;
   mMarkUpEnabled = layoutParameters.mMarkUpEnabled;
 
   return *this;
@@ -1021,7 +1081,6 @@ TextView::TextView()
                      static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
                      Toolkit::TextView::Left,
                      PointSize( 0.f ),
                      static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
                      Toolkit::TextView::Left,
                      PointSize( 0.f ),
-                     std::string( "..." ),
                      false ),
   mVisualParameters(),
   mRelayoutData(),
                      false ),
   mVisualParameters(),
   mRelayoutData(),
@@ -1037,8 +1096,8 @@ TextView::TextView()
   mPreviousSnapshotModeEnabled( false ),
   mMarkUpEnabled( false )
 {
   mPreviousSnapshotModeEnabled( false ),
   mMarkUpEnabled( false )
 {
-  TextViewProcessor::CreateWordTextInfo( mLayoutParameters.mEllipsizeText,
-                                         mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo );
+  // Creates the ellipsis layout info.
+  CreateEllipsizeLayout();
 }
 
 TextView::~TextView()
 }
 
 TextView::~TextView()
@@ -1067,7 +1126,6 @@ Vector3 TextView::GetNaturalSize()
       mRelayoutData.mGlyphActors.clear();
 
       mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
       mRelayoutData.mGlyphActors.clear();
 
       mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
-      mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
     }
 
     PerformTextViewProcessorOperations();
     }
 
     PerformTextViewProcessorOperations();
@@ -1128,7 +1186,6 @@ float TextView::GetHeightForWidth( float width )
     if( hasGlyphActors )
     {
       mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
     if( hasGlyphActors )
     {
       mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
-      mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
     }
 
     if( differentWidth || hasGlyphActors )
     }
 
     if( differentWidth || hasGlyphActors )
@@ -1154,9 +1211,8 @@ void TextView::OnInitialize()
 
 void TextView::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
 {
 
 void TextView::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
 {
-  mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo = TextViewProcessor::WordLayoutInfo();
-  TextViewProcessor::CreateWordTextInfo( mLayoutParameters.mEllipsizeText,
-                                         mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo );
+  // Creates the ellipsis layout info.
+  CreateEllipsizeLayout();
 
   SetText( mCurrentStyledText );
 }
 
   SetText( mCurrentStyledText );
 }
@@ -1173,7 +1229,7 @@ void TextView::OnControlSizeSet( const Vector3& size )
   }
 }
 
   }
 }
 
-void TextView::OnRelaidOut( Vector2 size, ActorSizeContainer& container )
+void TextView::OnRelayout( const Vector2& size, ActorSizeContainer& container )
 {
   if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
   {
 {
   if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
   {
@@ -1192,8 +1248,18 @@ void TextView::OnRelaidOut( Vector2 size, ActorSizeContainer& container )
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
+    }
+  }
+
+  if( ( Toolkit::TextView::Fade == mLayoutParameters.mWidthExceedPolicy ) ||
+      ( Toolkit::TextView::Fade == mLayoutParameters.mHeightExceedPolicy ) )
+  {
+    if( mRelayoutOperations & RELAYOUT_ALIGNMENT )
+    {
+      // If the text of the alignment changes and a fade exceed policy is set,
+      // some characters may need new TextActor.
+      mRelayoutOperations = RELAYOUT_ALL;
     }
   }
 
     }
   }
 
@@ -1301,9 +1367,9 @@ void TextView::OptimizeTextViewProcessorOperations()
       {
         bool optimizationDone = false;
 
       {
         bool optimizationDone = false;
 
-        if( it + 1 != endIt )
+        if( it + 1u != endIt )
         {
         {
-          const TextViewProcessorMetadata& nextRelayoutMetadata( *( it + 1 ) );
+          const TextViewProcessorMetadata& nextRelayoutMetadata( *( it + 1u ) );
           if( TextView::TextInserted == nextRelayoutMetadata.mType )
           {
             if( relayoutMetadata.mPosition == nextRelayoutMetadata.mPosition )
           if( TextView::TextInserted == nextRelayoutMetadata.mType )
           {
             if( relayoutMetadata.mPosition == nextRelayoutMetadata.mPosition )
@@ -1609,7 +1675,7 @@ void TextView::DestroyOffscreenRenderingResources()
   }
 }
 
   }
 }
 
-void TextView::OnTextPan( Actor actor, PanGesture gesture )
+void TextView::OnTextPan( Actor actor, const PanGesture& gesture )
 {
   if( 1u == gesture.numberOfTouches )
   {
 {
   if( 1u == gesture.numberOfTouches )
   {
@@ -1727,7 +1793,7 @@ void TextView::DoSetScrollPosition( const Vector2& position )
 
   // Emit the signal.
   Toolkit::TextView handle( GetOwner() );
 
   // Emit the signal.
   Toolkit::TextView handle( GetOwner() );
-  mScrolledSignalV2.Emit( handle, delta );
+  mScrolledSignal.Emit( handle, delta );
 }
 
 void TextView::CombineExceedPolicies()
 }
 
 void TextView::CombineExceedPolicies()
@@ -1886,6 +1952,16 @@ Actor TextView::GetRootActor() const
   return rootActor;
 }
 
   return rootActor;
 }
 
+void TextView::CreateEllipsizeLayout()
+{
+  // Creates the ellipsis layout info for the ellipsis text and styles.
+  mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo = TextViewProcessor::WordLayoutInfo();
+  mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo.mCharactersLayoutInfo.resize( mRelayoutData.mTextLayoutInfo.mEllipsisText.GetLength(), TextViewProcessor::CharacterLayoutInfo() );
+  TextViewProcessor::CreateWordTextInfo( mRelayoutData.mTextLayoutInfo.mEllipsisText,
+                                         mRelayoutData.mTextLayoutInfo.mEllipsisTextStyles,
+                                         mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo );
+}
+
 void TextView::OnMarkupEnabledPeopertySet( Property::Value propertyValue )
 {
   bool newValue( propertyValue.Get<bool>() );
 void TextView::OnMarkupEnabledPeopertySet( Property::Value propertyValue )
 {
   bool newValue( propertyValue.Get<bool>() );
@@ -2007,7 +2083,7 @@ void TextView::OnLineJustificationPropertySet( Property::Value propertyValue )
 void TextView::OnFadeBoundaryPropertySet( Property::Value propertyValue )
 {
   Vector4 value( propertyValue.Get<Vector4>() );
 void TextView::OnFadeBoundaryPropertySet( Property::Value propertyValue )
 {
   Vector4 value( propertyValue.Get<Vector4>() );
-  DALI_ASSERT_ALWAYS( value.x >= 0 && value.y >= 0 && value.z >= 0 && value.w >= 0
+  DALI_ASSERT_ALWAYS( ( value.x >= 0.f ) && ( value.y >= 0.f ) && ( value.z >= 0.f ) && ( value.w >= 0.f )
                       && "TextView::OnFadeBoundaryPropertySet(). Negative value is invalid. "  );
 
   Toolkit::TextView::FadeBoundary fadeBoundary( PixelSize( static_cast<unsigned int>( value.x ) ),
                       && "TextView::OnFadeBoundaryPropertySet(). Negative value is invalid. "  );
 
   Toolkit::TextView::FadeBoundary fadeBoundary( PixelSize( static_cast<unsigned int>( value.x ) ),