Checked if mInputStyle has changed. 59/198259/3
authorJoogab Yun <joogab.yun@samsung.com>
Wed, 23 Jan 2019 03:54:55 +0000 (12:54 +0900)
committerjoogab yun <joogab.yun@samsung.com>
Tue, 12 Mar 2019 00:23:11 +0000 (00:23 +0000)
If InsertText () is called while mEventData-> mInputStyle is not yet set to defaultInputStyle(),
it will behave wrong action.

ex) corner case :
  style.size = 30 but mImpl->mEventData->mInputStyle.size = 0 in InsertText()
  then this code will behave wrong action.
  const bool addFontSizeRun = style.size != mImpl->mEventData->mInputStyle.size;

  Normally, ProcessInputEvents () is called before InsertText(),
  and the value of mImpl-> mEventData-> mInputStyle.size is set to 30.
  So there is usually no problem.

Change-Id: I7ac15fe4b1bdd55c224e43a23c389fcd74a093a3

dali-toolkit/internal/text/text-controller.cpp

index 75a9e66..0088e93 100755 (executable)
@@ -3226,14 +3226,14 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ
     mImpl->mModel->mLogicalModel->RetrieveStyle( styleIndex, style );
 
     // Whether to add a new text color run.
-    const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor );
+    const bool addColorRun = ( style.textColor != mImpl->mEventData->mInputStyle.textColor ) && !mImpl->mEventData->mInputStyle.isDefaultColor;
 
     // Whether to add a new font run.
-    const bool addFontNameRun = style.familyName != mImpl->mEventData->mInputStyle.familyName;
-    const bool addFontWeightRun = style.weight != mImpl->mEventData->mInputStyle.weight;
-    const bool addFontWidthRun = style.width != mImpl->mEventData->mInputStyle.width;
-    const bool addFontSlantRun = style.slant != mImpl->mEventData->mInputStyle.slant;
-    const bool addFontSizeRun = style.size != mImpl->mEventData->mInputStyle.size;
+    const bool addFontNameRun = ( style.familyName != mImpl->mEventData->mInputStyle.familyName ) && mImpl->mEventData->mInputStyle.isFamilyDefined;
+    const bool addFontWeightRun = ( style.weight != mImpl->mEventData->mInputStyle.weight ) && mImpl->mEventData->mInputStyle.isWeightDefined;
+    const bool addFontWidthRun = ( style.width != mImpl->mEventData->mInputStyle.width ) && mImpl->mEventData->mInputStyle.isWidthDefined;
+    const bool addFontSlantRun = ( style.slant != mImpl->mEventData->mInputStyle.slant ) && mImpl->mEventData->mInputStyle.isSlantDefined;
+    const bool addFontSizeRun = ( style.size != mImpl->mEventData->mInputStyle.size ) && mImpl->mEventData->mInputStyle.isSizeDefined ;
 
     // Add style runs.
     if( addColorRun )