Merge "Updated shader source to set precision explicitly" into tizen
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-impl.cpp
index 7e9c5fa..3e08d27 100644 (file)
@@ -1,30 +1,36 @@
-//
-// 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 "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
-#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
 {
@@ -49,7 +55,6 @@ namespace Internal
 namespace
 {
 
-
 const char* MULTILINE_POLICY_NAME[] = {"SplitByNewLineChar", "SplitByWord", "SplitByChar"};
 const char* EXCEED_POLICY_NAME[] = {"Original", "Truncate", "Fade", "Split","ShrinkToFit","EllipsizeEnd"};
 const char* LINE_JUSTIFICATION_NAME[] = {"Left","Center","Right","Justified"};
@@ -122,8 +127,8 @@ bool IsTextViewProcessorNewStyleOperation( const TextView::TextViewProcessorMeta
 
 TextView::TextViewProcessorMetadata::TextViewProcessorMetadata()
 : mType( TextView::TextSet ),
-  mPosition( 0 ),
-  mNumberOfCharacters( 0 ),
+  mPosition( 0u ),
+  mNumberOfCharacters( 0u ),
   mText()
 {
 }
@@ -140,8 +145,8 @@ Toolkit::TextView TextView::New()
   // This can only be done after the CustomActor connection has been made...
   textView->Initialize();
 
-  // Enables by default the offscreen rendering.
-  textView->SetSnapshotModeEnabled( false ); /// @note Temporary disabled due to some issues with text quality and glyph loading.
+  // Disables by default the offscreen rendering.
+  textView->SetSnapshotModeEnabled( false );
 
   return handle;
 }
@@ -192,28 +197,43 @@ void TextView::InsertTextAt( std::size_t position, const std::string& text )
   InsertTextAt( position, styledText );
 }
 
-void TextView::InsertTextAt( const 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( const std::size_t position, const std::size_t numberOfCharacters, const std::string& text )
+void TextView::ReplaceTextFromTo( std::size_t position, std::size_t numberOfCharacters, const std::string& text )
 {
   // Creates a styled text with the markup or plain string.
   MarkupProcessor::StyledTextArray styledText;
@@ -223,51 +243,86 @@ void TextView::ReplaceTextFromTo( const std::size_t position, const std::size_t
   ReplaceTextFromTo( position, numberOfCharacters, styledText );
 }
 
-void TextView::ReplaceTextFromTo( const std::size_t position, const 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( const std::size_t position, const 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
@@ -284,7 +339,7 @@ std::string TextView::GetText() const
   return text;
 }
 
-void TextView::SetLineHeightOffset( const PointSize offset )
+void TextView::SetLineHeightOffset( PointSize offset )
 {
   if( fabsf( mLayoutParameters.mLineHeightOffset - offset ) > Math::MACHINE_EPSILON_1000 )
   {
@@ -312,8 +367,7 @@ void TextView::SetLineHeightOffset( const PointSize offset )
                                                                 RELAYOUT_ALIGNMENT |
                                                                 RELAYOUT_VISIBILITY |
                                                                 RELAYOUT_TEXT_ACTOR_UPDATE |
-                                                                RELAYOUT_INSERT_TO_TEXT_VIEW |
-                                                                RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
+                                                                RELAYOUT_INSERT_TO_TEXT_VIEW );
     }
   }
 }
@@ -323,7 +377,7 @@ PointSize TextView::GetLineHeightOffset() const
   return PointSize( mLayoutParameters.mLineHeightOffset );
 }
 
-void TextView::SetStyleToCurrentText( const TextStyle& style, const TextStyle::Mask mask )
+void TextView::SetStyleToCurrentText( const TextStyle& style, TextStyle::Mask mask )
 {
   if( !mCurrentStyledText.empty() )
   {
@@ -379,14 +433,18 @@ void TextView::SetStyleToCurrentText( const TextStyle& style, const TextStyle::M
   }
 
   // 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 +536,7 @@ void TextView::SetHeightExceedPolicy( Toolkit::TextView::ExceedPolicy policy )
                                                                 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 +563,7 @@ void TextView::SetLineJustification( Toolkit::TextView::LineJustification justif
                                                                 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 +591,7 @@ void TextView::SetFadeBoundary( const Toolkit::TextView::FadeBoundary& fadeBound
                                                                 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 +607,35 @@ void TextView::SetEllipsizeText( const std::string& ellipsizeText )
   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 )
 {
-  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();
@@ -572,13 +645,7 @@ void TextView::SetEllipsizeText( const MarkupProcessor::StyledTextArray& ellipsi
 
 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()
@@ -636,9 +703,7 @@ void TextView::GetTextLayoutInfo()
       if( hasGlyphActors )
       {
         mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_VIEW );
-        mRelayoutOperations = static_cast<RelayoutOperationMask>( mRelayoutOperations | RELAYOUT_INSERT_TO_TEXT_ACTOR_LIST );
       }
-
     }
   }
 }
@@ -712,11 +777,13 @@ void TextView::SetSnapshotModeEnabled( bool enable )
 
       mOffscreenImageActor.SetAnchorPoint( ParentOrigin::CENTER );
       mOffscreenImageActor.SetParentOrigin( ParentOrigin::CENTER );
+      mOffscreenImageActor.SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA,
+                                         BlendingFactor::ONE, BlendingFactor::ONE );
 
       Actor self = Self();
       self.Add( mOffscreenRootActor );
       self.Add( mOffscreenImageActor );
-      mOffscreenImageActor.SetScale(Vector3(1.f, -1.f, 1.f));
+      mOffscreenImageActor.SetScale( Vector3( 1.f, -1.f, 1.f ) );
     }
     else
     {
@@ -740,8 +807,7 @@ void TextView::SetSnapshotModeEnabled( bool enable )
       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();
   }
@@ -762,7 +828,7 @@ bool TextView::IsMarkupProcessingEnabled() const
   return mMarkUpEnabled;
 }
 
-void TextView::SetScrollEnabled( const bool enable )
+void TextView::SetScrollEnabled( bool enable )
 {
   if( enable != mVisualParameters.mScrollEnabled )
   {
@@ -866,22 +932,21 @@ TextView::LayoutParameters::LayoutParameters()
   mVerticalAlignment( Toolkit::Alignment::VerticalCenter ),
   mLineJustification( Toolkit::TextView::Left ),
   mLineHeightOffset( 0.f ),
-  mEllipsizeText(),
   mMarkUpEnabled( false )
 {
-  // Sets ellipsize text
-  MarkupProcessor::StyledTextArray styledEllipsize;
-  MarkupProcessor::GetStyledTextArray( std::string( "..." ), mEllipsizeText, false );
 }
 
-TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::MultilinePolicy   multilinePolicy,
-                                              const Toolkit::TextView::ExceedPolicy      widthExceedPolicy,
-                                              const Toolkit::TextView::ExceedPolicy      heightExceedPolicy,
-                                              const Toolkit::Alignment::Type             alignmentType,
-                                              const Toolkit::TextView::LineJustification lineJustification,
-                                              const float                                lineHeightOffset,
-                                              const std::string&                         ellipsizeText,
-                                              const bool                                 markUpEnabled )
+TextView::LayoutParameters::~LayoutParameters()
+{
+}
+
+TextView::LayoutParameters::LayoutParameters( Toolkit::TextView::MultilinePolicy   multilinePolicy,
+                                              Toolkit::TextView::ExceedPolicy      widthExceedPolicy,
+                                              Toolkit::TextView::ExceedPolicy      heightExceedPolicy,
+                                              Toolkit::Alignment::Type             alignmentType,
+                                              Toolkit::TextView::LineJustification lineJustification,
+                                              float                                lineHeightOffset,
+                                              bool                                 markUpEnabled )
 : mMultilinePolicy( multilinePolicy ),
   mWidthExceedPolicy( widthExceedPolicy ),
   mHeightExceedPolicy( heightExceedPolicy ),
@@ -889,7 +954,6 @@ TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::Multiline
   mVerticalAlignment(),
   mLineJustification( lineJustification ),
   mLineHeightOffset( lineHeightOffset ),
-  mEllipsizeText(),
   mMarkUpEnabled( markUpEnabled )
 {
   // Sets alignment
@@ -902,10 +966,6 @@ TextView::LayoutParameters::LayoutParameters( const Toolkit::TextView::Multiline
 
   mHorizontalAlignment = horizontalAlignment;
   mVerticalAlignment = verticalAlignment;
-
-  // Sets ellipsize text
-  MarkupProcessor::StyledTextArray styledEllipsize;
-  MarkupProcessor::GetStyledTextArray( ellipsizeText, mEllipsizeText, mMarkUpEnabled );
 }
 
 TextView::LayoutParameters::LayoutParameters( const TextView::LayoutParameters& layoutParameters )
@@ -916,7 +976,6 @@ TextView::LayoutParameters::LayoutParameters( const TextView::LayoutParameters&
   mVerticalAlignment( layoutParameters.mVerticalAlignment ),
   mLineJustification( layoutParameters.mLineJustification ),
   mLineHeightOffset( layoutParameters.mLineHeightOffset ),
-  mEllipsizeText( layoutParameters.mEllipsizeText ),
   mMarkUpEnabled( layoutParameters.mMarkUpEnabled )
 {
 }
@@ -930,7 +989,6 @@ TextView::LayoutParameters& TextView::LayoutParameters::operator=( const TextVie
   mVerticalAlignment = layoutParameters.mVerticalAlignment;
   mLineJustification = layoutParameters.mLineJustification;
   mLineHeightOffset = layoutParameters.mLineHeightOffset;
-  mEllipsizeText = layoutParameters.mEllipsizeText;
   mMarkUpEnabled = layoutParameters.mMarkUpEnabled;
 
   return *this;
@@ -1010,7 +1068,7 @@ TextView::RelayoutData& TextView::RelayoutData::operator=( const TextView::Relay
 }
 
 TextView::TextView()
-: ControlImpl( false ),  // doesn't require touch events
+: Control( REQUIRES_STYLE_CHANGE_SIGNALS  ),
   mCurrentStyledText(),
   mTextViewProcessorOperations(),
   mLayoutParameters( Toolkit::TextView::SplitByNewLineChar,
@@ -1019,7 +1077,6 @@ TextView::TextView()
                      static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
                      Toolkit::TextView::Left,
                      PointSize( 0.f ),
-                     std::string( "..." ),
                      false ),
   mVisualParameters(),
   mRelayoutData(),
@@ -1035,8 +1092,8 @@ TextView::TextView()
   mPreviousSnapshotModeEnabled( false ),
   mMarkUpEnabled( false )
 {
-  TextViewProcessor::CreateWordTextInfo( mLayoutParameters.mEllipsizeText,
-                                         mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo );
+  // Creates the ellipsis layout info.
+  CreateEllipsizeLayout();
 }
 
 TextView::~TextView()
@@ -1065,7 +1122,6 @@ Vector3 TextView::GetNaturalSize()
       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();
@@ -1126,7 +1182,6 @@ float TextView::GetHeightForWidth( float width )
     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 )
@@ -1150,11 +1205,10 @@ void TextView::OnInitialize()
 }
 
 
-void TextView::OnStyleChange( StyleChange change )
+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 );
 }
@@ -1190,8 +1244,18 @@ void TextView::OnRelaidOut( Vector2 size, ActorSizeContainer& container )
                                                                 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;
     }
   }
 
@@ -1299,9 +1363,9 @@ void TextView::OptimizeTextViewProcessorOperations()
       {
         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 )
@@ -1336,7 +1400,7 @@ void TextView::OptimizeTextViewProcessorOperations()
   mTextViewProcessorOperations = textViewProcessorOperations;
 }
 
-void TextView::DoRelayOut( const Size& textViewSize, const RelayoutOperationMask relayoutOperationMask )
+void TextView::DoRelayOut( const Size& textViewSize, RelayoutOperationMask relayoutOperationMask )
 {
   // Traverse the relayout operation vector. It fills the natural size, layout and glyph-actor data structures.
   if( !mTextViewProcessorOperations.empty() )
@@ -1779,6 +1843,11 @@ void TextView::CombineExceedPolicies()
           mLayoutParameters.mExceedPolicy = SplitShrink;
           break;
         }
+        case Toolkit::TextView::EllipsizeEnd:
+        {
+          mLayoutParameters.mExceedPolicy = SplitEllipsizeEnd;
+          break;
+        }
         default:
         {
           DALI_ASSERT_ALWAYS( !"TextView::CombineExceedPolicies() Invalid width and height exceed policies combination" );
@@ -1879,6 +1948,16 @@ Actor TextView::GetRootActor() const
   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>() );
@@ -1925,10 +2004,6 @@ void TextView::OnWidthExceedPolicyPropertySet( Property::Value propertyValue )
   {
     SetWidthExceedPolicy(Toolkit::TextView::Original);
   }
-  else if(policyName == "Truncate")
-  {
-    SetWidthExceedPolicy(Toolkit::TextView::Truncate);
-  }
   else if(policyName == "Fade")
   {
     SetWidthExceedPolicy(Toolkit::TextView::Fade);
@@ -1958,10 +2033,6 @@ void TextView::OnHeightExceedPolicyPropertySet( Property::Value propertyValue )
   {
     SetHeightExceedPolicy(Toolkit::TextView::Original);
   }
-  else if(policyName == "Truncate")
-  {
-    SetHeightExceedPolicy(Toolkit::TextView::Truncate);
-  }
   else if(policyName == "Fade")
   {
     SetHeightExceedPolicy(Toolkit::TextView::Fade);
@@ -2008,7 +2079,7 @@ void TextView::OnLineJustificationPropertySet( Property::Value propertyValue )
 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 ) ),