[dali_2.0.3] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / markup-processor.cpp
index 5bbe5ad..8e0b85b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 // EXTERNAL INCLUDES
 #include <climits>  // for ULONG_MAX
+#include <functional>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/character-set-conversion.h>
 #include <dali-toolkit/internal/text/markup-processor-color.h>
+#include <dali-toolkit/internal/text/markup-processor-embedded-item.h>
 #include <dali-toolkit/internal/text/markup-processor-font.h>
 #include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
 #include <dali-toolkit/internal/text/xhtml-entities.h>
 
-
-
 namespace Dali
 {
 
@@ -53,6 +53,7 @@ const std::string XHTML_U_TAG("u");
 const std::string XHTML_SHADOW_TAG("shadow");
 const std::string XHTML_GLOW_TAG("glow");
 const std::string XHTML_OUTLINE_TAG("outline");
+const std::string XHTML_ITEM_TAG("item");
 
 const char LESS_THAN      = '<';
 const char GREATER_THAN   = '>';
@@ -66,7 +67,7 @@ const char SEMI_COLON     = ';';
 const char CHAR_ARRAY_END = '\0';
 const char HEX_CODE       = 'x';
 
-const char WHITE_SPACE    = 0x20; // ASCII value of the white space.
+const char WHITE_SPACE    = 0x20;        // ASCII value of the white space.
 
 // Range 1 0x0u < XHTML_DECIMAL_ENTITY_RANGE <= 0xD7FFu
 // Range 2 0xE000u < XHTML_DECIMAL_ENTITY_RANGE <= 0xFFFDu
@@ -145,6 +146,17 @@ void Initialize( FontDescriptionRun& fontRun )
 }
 
 /**
+ * @brief Initializes a color run description to its defaults.
+ *
+ * @param[in,out] colorRun The font description run to initialize.
+ */
+void Initialize( ColorRun& colorRun )
+{
+  colorRun.characterRun.characterIndex = 0u;
+  colorRun.characterRun.numberOfCharacters = 0u;
+}
+
+/**
  * @brief Splits the tag string into the tag name and its attributes.
  *
  * The attributes are stored in a vector in the tag.
@@ -153,6 +165,11 @@ void Initialize( FontDescriptionRun& fontRun )
  */
 void ParseAttributes( Tag& tag )
 {
+  if( tag.buffer == NULL )
+  {
+    return;
+  }
+
   tag.attributes.Resize( MAX_NUM_OF_ATTRIBUTES );
 
   // Find first the tag name.
@@ -305,12 +322,15 @@ bool IsTag( const char*& markupStringBuffer,
   bool isQuotationOpen = false;
   bool attributesFound = false;
   tag.isEndTag = false;
+  bool isPreviousLessThan = false;
+  bool isPreviousSlash = false;
 
   const char character = *markupStringBuffer;
   if( LESS_THAN == character ) // '<'
   {
     tag.buffer = NULL;
     tag.length = 0u;
+    isPreviousLessThan = true;
 
     // if the iterator is pointing to a '<' character, then check if it's a mark-up tag is needed.
     ++markupStringBuffer;
@@ -322,12 +342,20 @@ bool IsTag( const char*& markupStringBuffer,
       {
         const char character = *markupStringBuffer;
 
-        if( SLASH == character ) // '/'
+        if( !isQuotationOpen && ( SLASH == character ) ) // '/'
         {
-          // if the tag has a '/' then it's an end or empty tag.
-          tag.isEndTag = true;
+          if (isPreviousLessThan)
+          {
+            tag.isEndTag = true;
+          }
+          else
+          {
+            // if the tag has a '/' it may be an end tag.
+            isPreviousSlash = true;
+          }
 
-          if( ( markupStringBuffer + 1u < markupStringEndBuffer ) && ( WHITE_SPACE >= *( markupStringBuffer + 1u ) ) && ( !isQuotationOpen ) )
+          isPreviousLessThan = false;
+          if( ( markupStringBuffer + 1u < markupStringEndBuffer ) && ( WHITE_SPACE >= *( markupStringBuffer + 1u ) ) )
           {
             ++markupStringBuffer;
             SkipWhiteSpace( markupStringBuffer, markupStringEndBuffer );
@@ -337,11 +365,21 @@ bool IsTag( const char*& markupStringBuffer,
         else if( GREATER_THAN == character ) // '>'
         {
           isTag = true;
+          if (isPreviousSlash)
+          {
+            tag.isEndTag = true;
+          }
+
+          isPreviousSlash = false;
+          isPreviousLessThan = false;
         }
         else if( QUOTATION_MARK == character )
         {
           isQuotationOpen = !isQuotationOpen;
           ++tag.length;
+
+          isPreviousSlash = false;
+          isPreviousLessThan = false;
         }
         else if( WHITE_SPACE >= character ) // ' '
         {
@@ -361,6 +399,9 @@ bool IsTag( const char*& markupStringBuffer,
 
           // If it's not any of the 'special' characters then just add it to the tag string.
           ++tag.length;
+
+          isPreviousSlash = false;
+          isPreviousLessThan = false;
         }
       }
     }
@@ -457,10 +498,209 @@ bool XHTMLNumericEntityToUtf8 ( const char* markupText, char* utf8 )
   return result;
 }
 
+/**
+ * @brief Processes a particular tag for the required run (color-run or font-run).
+ *
+ * @tparam RunType Whether ColorRun or FontDescriptionRun
+ *
+ * @param[in/out] runsContainer The container containing all the runs
+ * @param[in/out] styleStack The style stack
+ * @param[in] tag The tag we are currently processing
+ * @param[in] characterIndex The current character index
+ * @param[in/out] runIndex The run index
+ * @param[in/out] tagReference The tagReference we should increment/decrement
+ * @param[in] parameterSettingFunction This function will be called to set run specific parameters
+ */
+template <typename RunType>
+void ProcessTagForRun(
+    Vector<RunType>& runsContainer,
+    StyleStack& styleStack,
+    const Tag& tag,
+    const CharacterIndex characterIndex,
+    StyleStack::RunIndex& runIndex,
+    int& tagReference,
+    std::function<void (const Tag&, RunType&)> parameterSettingFunction)
+{
+  if( !tag.isEndTag )
+  {
+    // Create a new run.
+    RunType run;
+    Initialize(run);
+
+    // Fill the run with the parameters.
+    run.characterRun.characterIndex = characterIndex;
+    parameterSettingFunction(tag, run);
+
+    // Push the run in the logical model.
+    runsContainer.PushBack(run);
+
+    // Push the index of the run into the stack.
+    styleStack.Push(runIndex);
+
+    // Point the next free run.
+    ++runIndex;
+
+    // Increase reference
+    ++tagReference;
+  }
+  else
+  {
+    if( tagReference > 0 )
+    {
+      // Pop the top of the stack and set the number of characters of the run.
+      RunType& run = *( runsContainer.Begin() + styleStack.Pop() );
+      run.characterRun.numberOfCharacters = characterIndex - run.characterRun.characterIndex;
+      --tagReference;
+    }
+  }
+}
+
+/**
+ * @brief Processes the item tag
+ *
+ * @param[in/out] markupProcessData The markup process data
+ * @param[in] tag The current tag
+ * @param[in/out] characterIndex The current character index
+ */
+void ProcessItemTag(
+    MarkupProcessData& markupProcessData,
+    const Tag tag,
+    CharacterIndex& characterIndex)
+{
+  if (tag.isEndTag)
+  {
+    // Create an embedded item instance.
+    EmbeddedItem item;
+    item.characterIndex = characterIndex;
+    ProcessEmbeddedItem(tag, item);
+
+    markupProcessData.items.PushBack(item);
+
+    // Insert white space character that will be replaced by the item.
+    markupProcessData.markupProcessedText.append( 1u, WHITE_SPACE );
+    ++characterIndex;
+  }
+}
+
+/**
+ * @brief Resizes the model's vectors
+ *
+ * @param[in/out] markupProcessData The markup process data
+ * @param[in] fontRunIndex The font run index
+ * @param[in] colorRunIndex The color run index
+ */
+void ResizeModelVectors(MarkupProcessData& markupProcessData, const StyleStack::RunIndex fontRunIndex, const StyleStack::RunIndex colorRunIndex)
+{
+  markupProcessData.fontRuns.Resize( fontRunIndex );
+  markupProcessData.colorRuns.Resize( colorRunIndex );
+
+#ifdef DEBUG_ENABLED
+  for( unsigned int i=0; i<colorRunIndex; ++i )
+  {
+    ColorRun& run = markupProcessData.colorRuns[i];
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "run[%d] index: %d, length: %d, color %f,%f,%f,%f\n", i, run.characterRun.characterIndex, run.characterRun.numberOfCharacters, run.color.r, run.color.g, run.color.b, run.color.a );
+  }
+#endif
+}
+
+/**
+ * @brief Processes the markup string buffer
+ *
+ * @param[in/out] markupProcessData The markup process data
+ * @param[in/out] markupStringBuffer The markup string buffer pointer
+ * @param[in] markupStringEndBuffer The markup string end buffer pointer
+ * @param[in/out] characterIndex The current character index
+ */
+void ProcessMarkupStringBuffer(
+    MarkupProcessData& markupProcessData,
+    const char*& markupStringBuffer,
+    const char* const markupStringEndBuffer,
+    CharacterIndex& characterIndex)
+{
+  unsigned char character = *markupStringBuffer;
+  const char* markupBuffer = markupStringBuffer;
+  unsigned char count = GetUtf8Length( character );
+  char utf8[8];
+
+  if( ( BACK_SLASH == character ) && ( markupStringBuffer + 1u < markupStringEndBuffer ) )
+  {
+    // Adding < , >  or & special character.
+    const unsigned char nextCharacter = *( markupStringBuffer + 1u );
+    if( ( LESS_THAN == nextCharacter ) || ( GREATER_THAN == nextCharacter ) || ( AMPERSAND == nextCharacter ) )
+    {
+      character = nextCharacter;
+      ++markupStringBuffer;
+
+      count = GetUtf8Length( character );
+      markupBuffer = markupStringBuffer;
+    }
+  }
+  else   // checking if contains XHTML entity or not
+  {
+    const unsigned int len =  GetXHTMLEntityLength( markupStringBuffer, markupStringEndBuffer);
+
+    // Parse markupStringTxt if it contains XHTML Entity between '&' and ';'
+    if( len > 0 )
+    {
+      char* entityCode = NULL;
+      bool result = false;
+      count = 0;
+
+      // Checking if XHTML Numeric Entity
+      if( HASH == *( markupBuffer + 1u ) )
+      {
+        entityCode = &utf8[0];
+        // markupBuffer is currently pointing to '&'. By adding 2u to markupBuffer it will point to numeric string by skipping "&#'
+        result = XHTMLNumericEntityToUtf8( ( markupBuffer + 2u ), entityCode );
+      }
+      else    // Checking if XHTML Named Entity
+      {
+        entityCode = const_cast<char*> ( NamedEntityToUtf8( markupBuffer, len ) );
+        result = ( entityCode != NULL );
+      }
+      if ( result )
+      {
+        markupBuffer = entityCode; //utf8 text assigned to markupBuffer
+        character = markupBuffer[0];
+      }
+      else
+      {
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Not valid XHTML entity : (%.*s) \n", len, markupBuffer );
+        markupBuffer = NULL;
+      }
+    }
+    else    // in case string conatins Start of XHTML Entity('&') but not its end character(';')
+    {
+      if( character == AMPERSAND )
+      {
+        markupBuffer = NULL;
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Not Well formed XHTML content \n" );
+      }
+    }
+  }
+
+  if( markupBuffer != NULL )
+  {
+    const unsigned char numberOfBytes = GetUtf8Length( character );
+    markupProcessData.markupProcessedText.push_back( character );
+
+    for( unsigned char i = 1u; i < numberOfBytes; ++i )
+    {
+      ++markupBuffer;
+      markupProcessData.markupProcessedText.push_back( *markupBuffer );
+    }
+
+    ++characterIndex;
+    markupStringBuffer += count;
+  }
+}
+
 } // namespace
 
 void ProcessMarkupString( const std::string& markupString, MarkupProcessData& markupProcessData )
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "markupString: %s\n", markupString.c_str() );
+
   // Reserve space for the plain text.
   const Length markupStringSize = markupString.size();
   markupProcessData.markupProcessedText.reserve( markupStringSize );
@@ -472,6 +712,12 @@ void ProcessMarkupString( const std::string& markupString, MarkupProcessData& ma
   StyleStack::RunIndex colorRunIndex = 0u;
   StyleStack::RunIndex fontRunIndex = 0u;
 
+  // check tag reference
+  int colorTagReference = 0u;
+  int fontTagReference = 0u;
+  int iTagReference = 0u;
+  int bTagReference = 0u;
+
   // Give an initial default value to the model's vectors.
   markupProcessData.colorRuns.Reserve( DEFAULT_VECTOR_SIZE );
   markupProcessData.fontRuns.Reserve( DEFAULT_VECTOR_SIZE );
@@ -484,271 +730,76 @@ void ProcessMarkupString( const std::string& markupString, MarkupProcessData& ma
   CharacterIndex characterIndex = 0u;
   for( ; markupStringBuffer < markupStringEndBuffer; )
   {
+    tag.attributes.Clear();
     if( IsTag( markupStringBuffer,
                markupStringEndBuffer,
                tag ) )
     {
       if( TokenComparison( XHTML_COLOR_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new color run.
-          ColorRun colorRun;
-          colorRun.characterRun.numberOfCharacters = 0u;
-
-          // Set the start character index.
-          colorRun.characterRun.characterIndex = characterIndex;
-
-          // Fill the run with the attributes.
-          ProcessColorTag( tag, colorRun );
-
-          // Push the color run in the logical model.
-          markupProcessData.colorRuns.PushBack( colorRun );
-
-          // Push the index of the run into the stack.
-          styleStack.Push( colorRunIndex );
-
-          // Point the next color run.
-          ++colorRunIndex;
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-          ColorRun& colorRun = *( markupProcessData.colorRuns.Begin() + styleStack.Pop() );
-          colorRun.characterRun.numberOfCharacters = characterIndex - colorRun.characterRun.characterIndex;
-        }
+        ProcessTagForRun<ColorRun>(
+            markupProcessData.colorRuns, styleStack, tag, characterIndex, colorRunIndex, colorTagReference,
+            [] (const Tag& tag, ColorRun& run) { ProcessColorTag( tag, run ); });
       } // <color></color>
       else if( TokenComparison( XHTML_I_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new font run.
-          FontDescriptionRun fontRun;
-          Initialize( fontRun );
-
-          // Fill the run with the parameters.
-          fontRun.characterRun.characterIndex = characterIndex;
-          fontRun.slant = TextAbstraction::FontSlant::ITALIC;
-          fontRun.slantDefined = true;
-
-          // Push the font run in the logical model.
-          markupProcessData.fontRuns.PushBack( fontRun );
-
-          // Push the index of the run into the stack.
-          styleStack.Push( fontRunIndex );
-
-          // Point the next free font run.
-          ++fontRunIndex;
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-          FontDescriptionRun& fontRun = *( markupProcessData.fontRuns.Begin() + styleStack.Pop() );
-          fontRun.characterRun.numberOfCharacters = characterIndex - fontRun.characterRun.characterIndex;
-        }
+        ProcessTagForRun<FontDescriptionRun>(
+            markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, iTagReference,
+            [] (const Tag&, FontDescriptionRun& fontRun)
+            {
+              fontRun.slant = TextAbstraction::FontSlant::ITALIC;
+              fontRun.slantDefined = true;
+            });
       } // <i></i>
       else if( TokenComparison( XHTML_U_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new underline run.
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-        }
+        // TODO: If !tag.isEndTag, then create a new underline run.
+        //       else Pop the top of the stack and set the number of characters of the run.
       } // <u></u>
       else if( TokenComparison( XHTML_B_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new font run.
-          FontDescriptionRun fontRun;
-          Initialize( fontRun );
-
-          // Fill the run with the parameters.
-          fontRun.characterRun.characterIndex = characterIndex;
-          fontRun.weight = TextAbstraction::FontWeight::BOLD;
-          fontRun.weightDefined = true;
-
-          // Push the font run in the logical model.
-          markupProcessData.fontRuns.PushBack( fontRun );
-
-          // Push the index of the run into the stack.
-          styleStack.Push( fontRunIndex );
-
-          // Point the next free font run.
-          ++fontRunIndex;
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-          FontDescriptionRun& fontRun = *( markupProcessData.fontRuns.Begin() + styleStack.Pop() );
-          fontRun.characterRun.numberOfCharacters = characterIndex - fontRun.characterRun.characterIndex;
-        }
+        ProcessTagForRun<FontDescriptionRun>(
+            markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, bTagReference,
+            [] (const Tag&, FontDescriptionRun& fontRun)
+            {
+              fontRun.weight = TextAbstraction::FontWeight::BOLD;
+              fontRun.weightDefined = true;
+            });
       } // <b></b>
       else if( TokenComparison( XHTML_FONT_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new font run.
-          FontDescriptionRun fontRun;
-          Initialize( fontRun );
-
-          // Fill the run with the parameters.
-          fontRun.characterRun.characterIndex = characterIndex;
-
-          ProcessFontTag( tag, fontRun );
-
-          // Push the font run in the logical model.
-          markupProcessData.fontRuns.PushBack( fontRun );
-
-          // Push the index of the run into the stack.
-          styleStack.Push( fontRunIndex );
-
-          // Point the next free font run.
-          ++fontRunIndex;
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-          FontDescriptionRun& fontRun = *( markupProcessData.fontRuns.Begin() + styleStack.Pop() );
-          fontRun.characterRun.numberOfCharacters = characterIndex - fontRun.characterRun.characterIndex;
-        }
+        ProcessTagForRun<FontDescriptionRun>(
+            markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, fontTagReference,
+            [] (const Tag& tag, FontDescriptionRun& fontRun) { ProcessFontTag( tag, fontRun ); });
       } // <font></font>
       else if( TokenComparison( XHTML_SHADOW_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new shadow run.
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-        }
+        // TODO: If !tag.isEndTag, then create a new shadow run.
+        //       else Pop the top of the stack and set the number of characters of the run.
       } // <shadow></shadow>
       else if( TokenComparison( XHTML_GLOW_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new glow run.
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-        }
+        // TODO: If !tag.isEndTag, then create a new glow run.
+        //       else Pop the top of the stack and set the number of characters of the run.
       } // <glow></glow>
       else if( TokenComparison( XHTML_OUTLINE_TAG, tag.buffer, tag.length ) )
       {
-        if( !tag.isEndTag )
-        {
-          // Create a new outline run.
-        }
-        else
-        {
-          // Pop the top of the stack and set the number of characters of the run.
-        }
+        // TODO: If !tag.isEndTag, then create a new outline run.
+        //       else Pop the top of the stack and set the number of characters of the run.
       } // <outline></outline>
+      else if (TokenComparison(XHTML_ITEM_TAG, tag.buffer, tag.length))
+      {
+        ProcessItemTag(markupProcessData, tag, characterIndex);
+      }
     }  // end if( IsTag() )
     else if( markupStringBuffer < markupStringEndBuffer )
     {
-      unsigned char character = *markupStringBuffer;
-      const char* markupBuffer = markupStringBuffer;
-      unsigned char count = GetUtf8Length( character );
-      char utf8[8];
-
-      if( ( BACK_SLASH == character ) && ( markupStringBuffer + 1u < markupStringEndBuffer ) )
-      {
-        // Adding < , >  or & special character.
-        const unsigned char nextCharacter = *( markupStringBuffer + 1u );
-        if( ( LESS_THAN == nextCharacter ) || ( GREATER_THAN == nextCharacter ) || ( AMPERSAND == nextCharacter ) )
-        {
-          character = nextCharacter;
-          ++markupStringBuffer;
-
-          count = GetUtf8Length( character );
-          markupBuffer = markupStringBuffer;
-        }
-      }
-      else   // checking if conatins XHTML entity or not
-      {
-        const unsigned int len =  GetXHTMLEntityLength( markupStringBuffer, markupStringEndBuffer);
-
-        // Parse markupStringTxt if it contains XHTML Entity between '&' and ';'
-        if( len > 0 )
-        {
-          char* entityCode = NULL;
-          bool result = false;
-          count = 0;
-
-          // Checking if XHTML Numeric Entity
-          if( HASH == *( markupBuffer + 1u ) )
-          {
-            entityCode = &utf8[0];
-            // markupBuffer is currently pointing to '&'. By adding 2u to markupBuffer it will point to numeric string by skipping "&#'
-            result = XHTMLNumericEntityToUtf8( ( markupBuffer + 2u ), entityCode );
-          }
-          else    // Checking if XHTML Named Entity
-          {
-            entityCode = const_cast<char*> ( NamedEntityToUtf8( markupBuffer, len ) );
-            result = ( entityCode != NULL );
-          }
-          if ( result )
-          {
-            markupBuffer = entityCode; //utf8 text assigned to markupBuffer
-            character = markupBuffer[0];
-          }
-          else
-          {
-            DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Not valid XHTML entity : (%.*s) \n", len, markupBuffer );
-            markupBuffer = NULL;
-          }
-        }
-        else    // in case string conatins Start of XHTML Entity('&') but not its end character(';')
-        {
-          if( character == AMPERSAND )
-          {
-            markupBuffer = NULL;
-            DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Not Well formed XHTML content \n" );
-          }
-        }
-      }
-
-      if( markupBuffer != NULL )
-      {
-        const unsigned char numberOfBytes = GetUtf8Length( character );
-        markupProcessData.markupProcessedText.push_back( character );
-
-        for( unsigned char i = 1u; i < numberOfBytes; ++i )
-        {
-          ++markupBuffer;
-          markupProcessData.markupProcessedText.push_back( *markupBuffer );
-        }
-
-        ++characterIndex;
-        markupStringBuffer += count;
-      }
+      ProcessMarkupStringBuffer(markupProcessData, markupStringBuffer, markupStringEndBuffer, characterIndex);
     }
   }
 
   // Resize the model's vectors.
-  if( 0u == fontRunIndex )
-  {
-    markupProcessData.fontRuns.Clear();
-  }
-  else
-  {
-    markupProcessData.fontRuns.Resize( fontRunIndex );
-  }
-
-  if( 0u == colorRunIndex )
-  {
-    markupProcessData.colorRuns.Clear();
-  }
-  else
-  {
-    markupProcessData.colorRuns.Resize( colorRunIndex );
-  }
+  ResizeModelVectors(markupProcessData, fontRunIndex, colorRunIndex);
 }
 
 } // namespace Text