Fix PlaceholderTextColor update issue
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller-placeholder-handler.cpp
index 793a3e6..d649371 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-controls/placeholder-properties.h>
 #include <dali-toolkit/internal/text/character-set-conversion.h>
 #include <dali-toolkit/internal/text/text-controller-impl.h>
 #include <dali-toolkit/internal/text/text-font-style.h>
+#include <dali-toolkit/public-api/controls/text-controls/placeholder-properties.h>
 
 namespace
 {
-
 #if defined(DEBUG_ENABLED)
 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
 #endif
 
 const std::string EMPTY_STRING("");
 
-const char * const PLACEHOLDER_TEXT = "text";
-const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
-const char * const PLACEHOLDER_COLOR = "color";
-const char * const PLACEHOLDER_FONT_FAMILY = "fontFamily";
-const char * const PLACEHOLDER_FONT_STYLE = "fontStyle";
-const char * const PLACEHOLDER_POINT_SIZE = "pointSize";
-const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
-const char * const PLACEHOLDER_ELLIPSIS = "ellipsis";
+const char* const PLACEHOLDER_TEXT         = "text";
+const char* const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
+const char* const PLACEHOLDER_COLOR        = "color";
+const char* const PLACEHOLDER_FONT_FAMILY  = "fontFamily";
+const char* const PLACEHOLDER_FONT_STYLE   = "fontStyle";
+const char* const PLACEHOLDER_POINT_SIZE   = "pointSize";
+const char* const PLACEHOLDER_PIXEL_SIZE   = "pixelSize";
+const char* const PLACEHOLDER_ELLIPSIS     = "ellipsis";
 
 } // namespace
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Text
 {
-
 void Controller::PlaceholderHandler::SetPlaceholderTextElideEnabled(Controller& controller, bool enabled)
 {
   controller.mImpl->mEventData->mIsPlaceholderElideEnabled = enabled;
-  controller.mImpl->mEventData->mPlaceholderEllipsisFlag = true;
+  controller.mImpl->mEventData->mPlaceholderEllipsisFlag   = true;
 
   // Update placeholder if there is no text
-  if( controller.mImpl->IsShowingPlaceholderText() ||
-      ( 0u == controller.mImpl->mModel->mLogicalModel->mText.Count() ) )
+  if(controller.mImpl->IsShowingPlaceholderText() ||
+     (0u == controller.mImpl->mModel->mLogicalModel->mText.Count()))
   {
     controller.ShowPlaceholderText();
   }
@@ -76,9 +72,9 @@ bool Controller::PlaceholderHandler::IsPlaceholderTextElideEnabled(const Control
 
 void Controller::PlaceholderHandler::SetPlaceholderText(Controller& controller, PlaceholderType type, const std::string& text)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( PLACEHOLDER_TYPE_INACTIVE == type )
+    if(PLACEHOLDER_TYPE_INACTIVE == type)
     {
       controller.mImpl->mEventData->mPlaceholderTextInactive = text;
     }
@@ -88,8 +84,8 @@ void Controller::PlaceholderHandler::SetPlaceholderText(Controller& controller,
     }
 
     // Update placeholder if there is no text
-    if( controller.mImpl->IsShowingPlaceholderText() ||
-        ( 0u == controller.mImpl->mModel->mLogicalModel->mText.Count() ) )
+    if(controller.mImpl->IsShowingPlaceholderText() ||
+       (0u == controller.mImpl->mModel->mLogicalModel->mText.Count()))
     {
       controller.ShowPlaceholderText();
     }
@@ -98,9 +94,9 @@ void Controller::PlaceholderHandler::SetPlaceholderText(Controller& controller,
 
 void Controller::PlaceholderHandler::GetPlaceholderText(const Controller& controller, PlaceholderType type, std::string& text)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( PLACEHOLDER_TYPE_INACTIVE == type )
+    if(PLACEHOLDER_TYPE_INACTIVE == type)
     {
       text = controller.mImpl->mEventData->mPlaceholderTextInactive;
     }
@@ -113,15 +109,13 @@ void Controller::PlaceholderHandler::GetPlaceholderText(const Controller& contro
 
 void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& controller, const std::string& placeholderTextFontFamily)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
-    DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
+    DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
     controller.mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty();
 
     controller.mImpl->RequestRelayout();
@@ -130,7 +124,7 @@ void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& contro
 
 const std::string& Controller::PlaceholderHandler::GetPlaceholderFontFamily(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family;
   }
@@ -140,15 +134,13 @@ const std::string& Controller::PlaceholderHandler::GetPlaceholderFontFamily(cons
 
 void Controller::PlaceholderHandler::SetPlaceholderTextFontWeight(Controller& controller, FontWeight weight)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
-    controller.mImpl->mEventData->mPlaceholderFont->weightDefined = true;
+    controller.mImpl->mEventData->mPlaceholderFont->weightDefined           = true;
 
     controller.mImpl->RequestRelayout();
   }
@@ -156,7 +148,7 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontWeight(Controller& co
 
 bool Controller::PlaceholderHandler::IsPlaceholderTextFontWeightDefined(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->weightDefined;
   }
@@ -165,7 +157,7 @@ bool Controller::PlaceholderHandler::IsPlaceholderTextFontWeightDefined(const Co
 
 FontWeight Controller::PlaceholderHandler::GetPlaceholderTextFontWeight(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight;
   }
@@ -175,15 +167,13 @@ FontWeight Controller::PlaceholderHandler::GetPlaceholderTextFontWeight(const Co
 
 void Controller::PlaceholderHandler::SetPlaceholderTextFontWidth(Controller& controller, FontWidth width)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
-    controller.mImpl->mEventData->mPlaceholderFont->widthDefined = true;
+    controller.mImpl->mEventData->mPlaceholderFont->widthDefined           = true;
 
     controller.mImpl->RequestRelayout();
   }
@@ -191,7 +181,7 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontWidth(Controller& con
 
 bool Controller::PlaceholderHandler::IsPlaceholderTextFontWidthDefined(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->widthDefined;
   }
@@ -200,7 +190,7 @@ bool Controller::PlaceholderHandler::IsPlaceholderTextFontWidthDefined(const Con
 
 FontWidth Controller::PlaceholderHandler::GetPlaceholderTextFontWidth(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width;
   }
@@ -210,15 +200,13 @@ FontWidth Controller::PlaceholderHandler::GetPlaceholderTextFontWidth(const Cont
 
 void Controller::PlaceholderHandler::SetPlaceholderTextFontSlant(Controller& controller, FontSlant slant)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
-    controller.mImpl->mEventData->mPlaceholderFont->slantDefined = true;
+    controller.mImpl->mEventData->mPlaceholderFont->slantDefined           = true;
 
     controller.mImpl->RequestRelayout();
   }
@@ -226,7 +214,7 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontSlant(Controller& con
 
 bool Controller::PlaceholderHandler::IsPlaceholderTextFontSlantDefined(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->slantDefined;
   }
@@ -235,7 +223,7 @@ bool Controller::PlaceholderHandler::IsPlaceholderTextFontSlantDefined(const Con
 
 FontSlant Controller::PlaceholderHandler::GetPlaceholderTextFontSlant(const Controller& controller)
 {
-  if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+  if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
   {
     return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant;
   }
@@ -245,33 +233,31 @@ FontSlant Controller::PlaceholderHandler::GetPlaceholderTextFontSlant(const Cont
 
 void Controller::PlaceholderHandler::SetPlaceholderTextFontSize(Controller& controller, float fontSize, FontSizeType type)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
-    switch( type )
+    switch(type)
     {
       case POINT_SIZE:
       {
         controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize;
-        controller.mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
-        controller.mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag
+        controller.mImpl->mEventData->mPlaceholderFont->sizeDefined       = true;
+        controller.mImpl->mEventData->mIsPlaceholderPixelSize             = false; // Font size flag
         break;
       }
       case PIXEL_SIZE:
       {
         // Point size = Pixel size * 72.f / DPI
-        unsigned int horizontalDpi = 0u;
-        unsigned int verticalDpi = 0u;
-        TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
-        fontClient.GetDpi( horizontalDpi, verticalDpi );
-
-        controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
-        controller.mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
-        controller.mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
+        unsigned int                horizontalDpi = 0u;
+        unsigned int                verticalDpi   = 0u;
+        TextAbstraction::FontClient fontClient    = TextAbstraction::FontClient::Get();
+        fontClient.GetDpi(horizontalDpi, verticalDpi);
+
+        controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = (fontSize * 72.f) / static_cast<float>(horizontalDpi);
+        controller.mImpl->mEventData->mPlaceholderFont->sizeDefined       = true;
+        controller.mImpl->mEventData->mIsPlaceholderPixelSize             = true; // Font size flag
         break;
       }
     }
@@ -280,42 +266,42 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontSize(Controller& cont
   }
 }
 
-float Controller::PlaceholderHandler::GetPlaceholderTextFontSize(const Controller& controller, FontSizeType type )
+float Controller::PlaceholderHandler::GetPlaceholderTextFontSize(const Controller& controller, FontSizeType type)
 {
   float value = 0.0f;
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    switch( type )
+    switch(type)
     {
       case POINT_SIZE:
       {
-        if( NULL != controller.mImpl->mEventData->mPlaceholderFont )
+        if(NULL != controller.mImpl->mEventData->mPlaceholderFont)
         {
           value = controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize;
         }
         else
         {
           // If the placeholder text font size is not set, then return the default font size.
-          value = controller.GetDefaultFontSize( POINT_SIZE );
+          value = controller.GetDefaultFontSize(POINT_SIZE);
         }
         break;
       }
       case PIXEL_SIZE:
       {
-        if( NULL != controller.mImpl->mEventData->mPlaceholderFont )
+        if(NULL != controller.mImpl->mEventData->mPlaceholderFont)
         {
           // Pixel size = Point size * DPI / 72.f
-          unsigned int horizontalDpi = 0u;
-          unsigned int verticalDpi = 0u;
-          TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
-          fontClient.GetDpi( horizontalDpi, verticalDpi );
+          unsigned int                horizontalDpi = 0u;
+          unsigned int                verticalDpi   = 0u;
+          TextAbstraction::FontClient fontClient    = TextAbstraction::FontClient::Get();
+          fontClient.GetDpi(horizontalDpi, verticalDpi);
 
-          value = controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
+          value = controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast<float>(horizontalDpi) / 72.f;
         }
         else
         {
           // If the placeholder text font size is not set, then return the default font size.
-          value = controller.GetDefaultFontSize( PIXEL_SIZE );
+          value = controller.GetDefaultFontSize(PIXEL_SIZE);
         }
         break;
       }
@@ -326,23 +312,25 @@ float Controller::PlaceholderHandler::GetPlaceholderTextFontSize(const Controlle
   return value;
 }
 
-void Controller::PlaceholderHandler::SetPlaceholderTextColor(Controller& controller, const Vector4& textColor )
+void Controller::PlaceholderHandler::SetPlaceholderTextColor(Controller& controller, const Vector4& textColor)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
     controller.mImpl->mEventData->mPlaceholderTextColor = textColor;
   }
 
-  if( controller.mImpl->IsShowingPlaceholderText() )
+  if(controller.mImpl->IsShowingPlaceholderText())
   {
-    controller.mImpl->mModel->mVisualModel->SetTextColor( textColor );
+    controller.mImpl->mModel->mVisualModel->SetTextColor(textColor);
+    controller.mImpl->mModel->mLogicalModel->mColorRuns.Clear();
+    controller.mImpl->mOperationsPending = static_cast<OperationsMask>(controller.mImpl->mOperationsPending | COLOR);
     controller.mImpl->RequestRelayout();
   }
 }
 
 const Vector4& Controller::PlaceholderHandler::GetPlaceholderTextColor(const Controller& controller)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
     return controller.mImpl->mEventData->mPlaceholderTextColor;
   }
@@ -350,69 +338,69 @@ const Vector4& Controller::PlaceholderHandler::GetPlaceholderTextColor(const Con
   return Color::BLACK;
 }
 
-void Controller::PlaceholderHandler::SetPlaceholderProperty(Controller& controller, const Property::Map& map )
+void Controller::PlaceholderHandler::SetPlaceholderProperty(Controller& controller, const Property::Map& map)
 {
   const Property::Map::SizeType count = map.Count();
 
-  for( Property::Map::SizeType position = 0; position < count; ++position )
+  for(Property::Map::SizeType position = 0; position < count; ++position)
   {
-    KeyValuePair keyValue = map.GetKeyValue( position );
-    Property::Key& key = keyValue.first;
-    Property::Value& value = keyValue.second;
+    KeyValuePair     keyValue = map.GetKeyValue(position);
+    Property::Key&   key      = keyValue.first;
+    Property::Value& value    = keyValue.second;
 
-    if( key == Toolkit::Text::PlaceHolder::Property::TEXT  || key == PLACEHOLDER_TEXT )
+    if(key == Toolkit::Text::PlaceHolder::Property::TEXT || key == PLACEHOLDER_TEXT)
     {
       std::string text = "";
-      value.Get( text );
+      value.Get(text);
       SetPlaceholderText(controller, Controller::PLACEHOLDER_TYPE_INACTIVE, text);
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED )
+    else if(key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED)
     {
       std::string text = "";
-      value.Get( text );
+      value.Get(text);
       SetPlaceholderText(controller, Controller::PLACEHOLDER_TYPE_ACTIVE, text);
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR )
+    else if(key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR)
     {
       Vector4 textColor;
-      value.Get( textColor );
-      if( GetPlaceholderTextColor(controller) != textColor )
+      value.Get(textColor);
+      if(GetPlaceholderTextColor(controller) != textColor)
       {
         SetPlaceholderTextColor(controller, textColor);
       }
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY )
+    else if(key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY)
     {
       std::string fontFamily = "";
-      value.Get( fontFamily );
+      value.Get(fontFamily);
       SetPlaceholderFontFamily(controller, fontFamily);
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE )
+    else if(key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE)
     {
-      SetFontStyleProperty( &controller, value, Text::FontStyle::PLACEHOLDER );
+      SetFontStyleProperty(&controller, value, Text::FontStyle::PLACEHOLDER);
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE )
+    else if(key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE)
     {
       float pointSize;
-      value.Get( pointSize );
-      if( !Equals(GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE), pointSize) )
+      value.Get(pointSize);
+      if(!Equals(GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE), pointSize))
       {
         SetPlaceholderTextFontSize(controller, pointSize, Text::Controller::POINT_SIZE);
       }
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE )
+    else if(key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE)
     {
       float pixelSize;
-      value.Get( pixelSize );
-      if( !Equals(GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE), pixelSize) )
+      value.Get(pixelSize);
+      if(!Equals(GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE), pixelSize))
       {
         SetPlaceholderTextFontSize(controller, pixelSize, Text::Controller::PIXEL_SIZE);
       }
     }
-    else if( key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS )
+    else if(key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS)
     {
       bool ellipsis;
-      value.Get( ellipsis );
+      value.Get(ellipsis);
       SetPlaceholderTextElideEnabled(controller, ellipsis);
     }
   }
@@ -420,37 +408,37 @@ void Controller::PlaceholderHandler::SetPlaceholderProperty(Controller& controll
 
 void Controller::PlaceholderHandler::GetPlaceholderProperty(Controller& controller, Property::Map& map)
 {
-  if( NULL != controller.mImpl->mEventData )
+  if(NULL != controller.mImpl->mEventData)
   {
-    if( !controller.mImpl->mEventData->mPlaceholderTextActive.empty() )
+    if(!controller.mImpl->mEventData->mPlaceholderTextActive.empty())
     {
-      map[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = controller.mImpl->mEventData->mPlaceholderTextActive;
+      map[Text::PlaceHolder::Property::TEXT_FOCUSED] = controller.mImpl->mEventData->mPlaceholderTextActive;
     }
-    if( !controller.mImpl->mEventData->mPlaceholderTextInactive.empty() )
+    if(!controller.mImpl->mEventData->mPlaceholderTextInactive.empty())
     {
-      map[ Text::PlaceHolder::Property::TEXT ] = controller.mImpl->mEventData->mPlaceholderTextInactive;
+      map[Text::PlaceHolder::Property::TEXT] = controller.mImpl->mEventData->mPlaceholderTextInactive;
     }
 
-    map[ Text::PlaceHolder::Property::COLOR ] = controller.mImpl->mEventData->mPlaceholderTextColor;
-    map[ Text::PlaceHolder::Property::FONT_FAMILY ] = GetPlaceholderFontFamily(controller);
+    map[Text::PlaceHolder::Property::COLOR]       = controller.mImpl->mEventData->mPlaceholderTextColor;
+    map[Text::PlaceHolder::Property::FONT_FAMILY] = GetPlaceholderFontFamily(controller);
 
     Property::Value fontStyleMapGet;
-    GetFontStyleProperty( &controller, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
-    map[ Text::PlaceHolder::Property::FONT_STYLE ] = fontStyleMapGet;
+    GetFontStyleProperty(&controller, fontStyleMapGet, Text::FontStyle::PLACEHOLDER);
+    map[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleMapGet;
 
     // Choose font size : POINT_SIZE or PIXEL_SIZE
-    if( !controller.mImpl->mEventData->mIsPlaceholderPixelSize )
+    if(!controller.mImpl->mEventData->mIsPlaceholderPixelSize)
     {
-      map[ Text::PlaceHolder::Property::POINT_SIZE ] = GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE);
+      map[Text::PlaceHolder::Property::POINT_SIZE] = GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE);
     }
     else
     {
-      map[ Text::PlaceHolder::Property::PIXEL_SIZE ] = GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE);
+      map[Text::PlaceHolder::Property::PIXEL_SIZE] = GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE);
     }
 
-    if( controller.mImpl->mEventData->mPlaceholderEllipsisFlag )
+    if(controller.mImpl->mEventData->mPlaceholderEllipsisFlag)
     {
-      map[ Text::PlaceHolder::Property::ELLIPSIS ] = IsPlaceholderTextElideEnabled(controller);
+      map[Text::PlaceHolder::Property::ELLIPSIS] = IsPlaceholderTextElideEnabled(controller);
     }
   }
 }
@@ -459,12 +447,12 @@ void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller)
 {
   Controller::Impl& impl = *controller.mImpl;
 
-  if( impl.IsPlaceholderAvailable() )
+  if(impl.IsPlaceholderAvailable())
   {
     EventData*& eventData = impl.mEventData;
-    DALI_ASSERT_DEBUG( eventData && "No placeholder text available" );
+    DALI_ASSERT_DEBUG(eventData && "No placeholder text available");
 
-    if( NULL == eventData )
+    if(NULL == eventData)
     {
       return;
     }
@@ -473,17 +461,17 @@ void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller)
 
     // Disable handles when showing place-holder text
     DecoratorPtr& decorator = eventData->mDecorator;
-    decorator->SetHandleActive( GRAB_HANDLE, false );
-    decorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
-    decorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
+    decorator->SetHandleActive(GRAB_HANDLE, false);
+    decorator->SetHandleActive(LEFT_SELECTION_HANDLE, false);
+    decorator->SetHandleActive(RIGHT_SELECTION_HANDLE, false);
 
-    const char* text( NULL );
-    size_t size( 0 );
+    const char* text(NULL);
+    size_t      size(0);
 
     // TODO - Switch Placeholder text when changing state
     std::string& placeholderTextActive = eventData->mPlaceholderTextActive;
-    if( ( EventData::INACTIVE != eventData->mState ) &&
-        ( 0u != placeholderTextActive.c_str() ) )
+    if((EventData::INACTIVE != eventData->mState) &&
+       (0u != placeholderTextActive.c_str()))
     {
       text = placeholderTextActive.c_str();
       size = placeholderTextActive.size();
@@ -491,31 +479,31 @@ void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller)
     else
     {
       std::string& placeholderTextInactive = eventData->mPlaceholderTextInactive;
-      text = placeholderTextInactive.c_str();
-      size = placeholderTextInactive.size();
+      text                                 = placeholderTextInactive.c_str();
+      size                                 = placeholderTextInactive.size();
     }
 
-    TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
-    textUpdateInfo.mCharacterIndex = 0u;
+    TextUpdateInfo& textUpdateInfo             = impl.mTextUpdateInfo;
+    textUpdateInfo.mCharacterIndex             = 0u;
     textUpdateInfo.mNumberOfCharactersToRemove = textUpdateInfo.mPreviousNumberOfCharacters;
 
     // Reset model for showing placeholder.
-    ModelPtr& model = impl.mModel;
+    ModelPtr&        model        = impl.mModel;
     LogicalModelPtr& logicalModel = model->mLogicalModel;
     logicalModel->mText.Clear();
-    model->mVisualModel->SetTextColor( eventData->mPlaceholderTextColor );
+    model->mVisualModel->SetTextColor(eventData->mPlaceholderTextColor);
 
     // Convert text into UTF-32
     Vector<Character>& utf32Characters = logicalModel->mText;
-    utf32Characters.Resize( size );
+    utf32Characters.Resize(size);
 
     // This is a bit horrible but std::string returns a (signed) char*
-    const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text );
+    const uint8_t* utf8 = reinterpret_cast<const uint8_t*>(text);
 
     // Transform a text array encoded in utf8 into an array encoded in utf32.
     // It returns the actual number of characters.
-    const Length characterCount = Utf8ToUtf32( utf8, size, utf32Characters.Begin() );
-    utf32Characters.Resize( characterCount );
+    const Length characterCount = Utf8ToUtf32(utf8, size, utf32Characters.Begin());
+    utf32Characters.Resize(characterCount);
 
     // The characters to be added.
     textUpdateInfo.mNumberOfCharactersToAdd = characterCount;
@@ -533,10 +521,17 @@ void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller)
     impl.mOperationsPending = ALL_OPERATIONS;
 
     // Update the rest of the model during size negotiation
-    impl.QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
+    impl.QueueModifyEvent(ModifyEvent::TEXT_REPLACED);
   }
 }
 
+void Controller::PlaceholderHandler::CreatePlaceholderFont(Controller& controller)
+{
+  if(nullptr == controller.mImpl->mEventData->mPlaceholderFont)
+  {
+    controller.mImpl->mEventData->mPlaceholderFont = std::unique_ptr<FontDefaults>(new FontDefaults());
+  }
+}
 
 } // namespace Text