X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmarkup-processor.cpp;h=344cde15b5757073d124ea6b0434f752d6fcbc97;hp=6fef0921a39f648026e5422bd9582f0d262582b8;hb=c93f6281a8bafc5b7ba5f0dcdad0eb675b8e3436;hpb=ec516c6d57ca74d1916a2160910699f34cd51f59 diff --git a/dali-toolkit/internal/text/markup-processor.cpp b/dali-toolkit/internal/text/markup-processor.cpp index 6fef092..344cde1 100644 --- a/dali-toolkit/internal/text/markup-processor.cpp +++ b/dali-toolkit/internal/text/markup-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -27,10 +27,16 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include +#include +#include #include namespace Dali @@ -41,21 +47,6 @@ namespace Text { namespace { -// HTML-ISH tag and attribute constants. -// Note they must be lower case in order to make the comparison to work -// as the parser converts all the read tags to lower case. -const std::string XHTML_COLOR_TAG("color"); -const std::string XHTML_FONT_TAG("font"); -const std::string XHTML_B_TAG("b"); -const std::string XHTML_I_TAG("i"); -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 std::string XHTML_ANCHOR_TAG("a"); -const std::string XHTML_BACKGROUND_TAG("background"); - const char LESS_THAN = '<'; const char GREATER_THAN = '>'; const char EQUAL = '='; @@ -69,28 +60,31 @@ const char CHAR_ARRAY_END = '\0'; const char HEX_CODE = 'x'; const char WHITE_SPACE = 0x20; // ASCII value of the white space. +const char NEW_LINE = 0x0A; // ASCII value of the newline. // Range 1 0x0u < XHTML_DECIMAL_ENTITY_RANGE <= 0xD7FFu // Range 2 0xE000u < XHTML_DECIMAL_ENTITY_RANGE <= 0xFFFDu // Range 3 0x10000u < XHTML_DECIMAL_ENTITY_RANGE <= 0x10FFFFu const unsigned long XHTML_DECIMAL_ENTITY_RANGE[] = {0x0u, 0xD7FFu, 0xE000u, 0xFFFDu, 0x10000u, 0x10FFFFu}; -const unsigned int MAX_NUM_OF_ATTRIBUTES = 5u; ///< The font tag has the 'family', 'size' 'weight', 'width' and 'slant' attrubutes. +// The MAX_NUM_OF_ATTRIBUTES is the number of attributes in span tag "markup-processor-span.cpp". Because it contains the maximum number of attributes in all tags. +const unsigned int MAX_NUM_OF_ATTRIBUTES = 14u; ///< The span tag has the 'font-family', 'font-size' 'font-weight', 'font-width', 'font-slant','text-color', 'u-color', 'u-height','u-type','u-dash-gap', 'u-dash-width', 's-color', 's-height' and 'char-space-value' attrubutes. const unsigned int DEFAULT_VECTOR_SIZE = 16u; ///< Default size of run vectors. #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_MARKUP_PROCESSOR"); #endif +typedef VectorBase::SizeType RunIndex; + /** * @brief Struct used to retrieve the style runs from the mark-up string. */ +template struct StyleStack { - typedef VectorBase::SizeType RunIndex; - - Vector stack; ///< Use a vector as a style stack. Stores the indices pointing where the run is stored inside the logical model. - unsigned int topIndex; ///< Points the top of the stack. + Vector stack; ///< Use a vector as a style stack. + unsigned int topIndex; ///< Points the top of the stack. StyleStack() : stack(), @@ -99,7 +93,7 @@ struct StyleStack stack.Resize(DEFAULT_VECTOR_SIZE); } - void Push(RunIndex index) + void Push(StyleStackType item) { // Check if there is space inside the style stack. const VectorBase::SizeType size = stack.Count(); @@ -109,14 +103,14 @@ struct StyleStack stack.Resize(2u * size); } - // Set the run index in the top of the stack. - *(stack.Begin() + topIndex) = index; + // Set the item in the top of the stack. + *(stack.Begin() + topIndex) = item; // Reposition the pointer to the top of the stack. ++topIndex; } - RunIndex Pop() + StyleStackType Pop() { // Pop the top of the stack. --topIndex; @@ -125,6 +119,26 @@ struct StyleStack }; /** + * @brief Struct used to retrieve spans from the mark-up string. + */ +struct Span +{ + RunIndex colorRunIndex; + RunIndex fontRunIndex; + RunIndex underlinedCharacterRunIndex; + RunIndex backgroundColorRunIndex; + RunIndex strikethroughCharacterRunIndex; + RunIndex characterSpacingCharacterRunIndex; + + bool isColorDefined; + bool isFontDefined; + bool isUnderlinedCharacterDefined; + bool isBackgroundColorDefined; + bool isStrikethroughDefined; + bool isCharacterSpacingDefined; +}; + +/** * @brief Initializes a font run description to its defaults. * * @param[in,out] fontRun The font description run to initialize. @@ -169,6 +183,68 @@ void Initialize(UnderlinedCharacterRun& underlinedCharacterRun) } /** + * @brief Initializes a span to its defaults. + * + * @param[in,out] span The span to be initialized. + */ +void Initialize(Span& span) +{ + span.colorRunIndex = 0u; + span.isColorDefined = false; + + span.fontRunIndex = 0u; + span.isFontDefined = false; + + span.underlinedCharacterRunIndex = 0u; + span.isUnderlinedCharacterDefined = false; + span.backgroundColorRunIndex = 0u; + span.isBackgroundColorDefined = false; + + //strikethrough + span.strikethroughCharacterRunIndex = 0u; + span.isStrikethroughDefined = false; + + //characterSpacing + span.characterSpacingCharacterRunIndex = 0u; + span.isCharacterSpacingDefined = false; +} + +/** + * @brief Initializes a strikethrough character run to its defaults. + * + * @param[in,out] strikethroughCharacterRun The strikethrough character run to initialize. + */ +void Initialize(StrikethroughCharacterRun& strikethroughCharacterRun) +{ + strikethroughCharacterRun.characterRun.characterIndex = 0u; + strikethroughCharacterRun.characterRun.numberOfCharacters = 0u; + strikethroughCharacterRun.properties.colorDefined = false; +} + +/** + * @brief Initializes a bounded-paragraph character run to its defaults. + * + * @param[in,out] boundedParagraphRun The bounded paragraphRun run to initialize. + */ +void Initialize(BoundedParagraphRun& boundedParagraphRun) +{ + boundedParagraphRun.characterRun.characterIndex = 0u; + boundedParagraphRun.characterRun.numberOfCharacters = 0u; +} + +/** + * @brief Initializes a character-spacing run to its defaults. + * + * @param[in,out] characterSpacingCharacterRun The character-spacing run to initialize. + */ +void Initialize(CharacterSpacingCharacterRun& characterSpacingCharacterRun) +{ + characterSpacingCharacterRun.characterRun.characterIndex = 0u; + characterSpacingCharacterRun.characterRun.numberOfCharacters = 0u; + characterSpacingCharacterRun.value = 0.0f; +} + +/** * @brief Splits the tag string into the tag name and its attributes. * * The attributes are stored in a vector in the tag. @@ -526,10 +602,10 @@ bool XHTMLNumericEntityToUtf8(const char* markupText, char* utf8) template void ProcessTagForRun( Vector& runsContainer, - StyleStack& styleStack, + StyleStack& styleStack, const Tag& tag, const CharacterIndex characterIndex, - StyleStack::RunIndex& runIndex, + RunIndex& runIndex, int& tagReference, std::function parameterSettingFunction) { @@ -595,6 +671,30 @@ void ProcessItemTag( } /** + * @brief Processes the paragraph-tag + * + * @param[in/out] markupProcessData The markup process data + * @param[in] tag The current tag + * @param[in] isEndBuffer Whether the end of buffer + * @param[in/out] characterIndex The current character index + */ +void ProcessParagraphTag( + MarkupProcessData& markupProcessData, + const Tag tag, + bool isEndBuffer, + CharacterIndex& characterIndex) +{ + if((characterIndex > 0 && + markupProcessData.markupProcessedText[characterIndex - 1u] != NEW_LINE) && + (!(tag.isEndTag && isEndBuffer))) + { + // Insert new-line character at the start and end of paragraph. + markupProcessData.markupProcessedText.append(1u, NEW_LINE); + ++characterIndex; + } +} + +/** * @brief Processes the anchor tag * * @param[in/out] markupProcessData The markup process data @@ -627,26 +727,227 @@ void ProcessAnchorTag( } /** + * @brief Processes span tag for the color-run & font-run. + * + * @param[in] spanTag The tag we are currently processing + * @param[inout] spanStack The spans stack + * @param[inout] colorRuns The container containing all the color runs + * @param[inout] fontRuns The container containing all the font description runs + * @param[inout] underlinedCharacterRuns The container containing all the underlined character runs + * @param[inout] strikethroughCharacterRuns The container containing all the strikethroughed character runs + * @param[inout] colorRunIndex The color run index + * @param[inout] fontRunIndex The font run index + * @param[inout] underlinedCharacterRunIndex The underlined character run index + * @param[inout] strikethroughCharacterRunIndex The strikethroughed character run index + * @param[in] characterIndex The current character index + * @param[in] tagReference The tagReference we should increment/decrement + */ +void ProcessSpanForRun( + const Tag& spanTag, + StyleStack& spanStack, + Vector& colorRuns, + Vector& fontRuns, + Vector& underlinedCharacterRuns, + Vector& backgroundColorRuns, + Vector& strikethroughCharacterRuns, + Vector& characterSpacingCharacterRuns, + RunIndex& colorRunIndex, + RunIndex& fontRunIndex, + RunIndex& underlinedCharacterRunIndex, + RunIndex& backgroundColorRunIndex, + RunIndex& strikethroughCharacterRunIndex, + RunIndex& characterSpacingCharacterRunIndex, + const CharacterIndex characterIndex, + int& tagReference) +{ + if(!spanTag.isEndTag) + { + // Create a new run. + ColorRun colorRun; + Initialize(colorRun); + + FontDescriptionRun fontRun; + Initialize(fontRun); + + UnderlinedCharacterRun underlinedCharacterRun; + Initialize(underlinedCharacterRun); + + ColorRun backgroundColorRun; + Initialize(backgroundColorRun); + + StrikethroughCharacterRun strikethroughCharacterRun; + Initialize(strikethroughCharacterRun); + + CharacterSpacingCharacterRun characterSpacingCharacterRun; + Initialize(characterSpacingCharacterRun); + + Span span; + Initialize(span); + + // Fill the run with the parameters. + colorRun.characterRun.characterIndex = characterIndex; + fontRun.characterRun.characterIndex = characterIndex; + underlinedCharacterRun.characterRun.characterIndex = characterIndex; + backgroundColorRun.characterRun.characterIndex = characterIndex; + strikethroughCharacterRun.characterRun.characterIndex = characterIndex; + characterSpacingCharacterRun.characterRun.characterIndex = characterIndex; + + span.colorRunIndex = colorRunIndex; + span.fontRunIndex = fontRunIndex; + span.underlinedCharacterRunIndex = underlinedCharacterRunIndex; + span.backgroundColorRunIndex = backgroundColorRunIndex; + span.strikethroughCharacterRunIndex = strikethroughCharacterRunIndex; + span.characterSpacingCharacterRunIndex = characterSpacingCharacterRunIndex; + + ProcessSpanTag(spanTag, + colorRun, + fontRun, + underlinedCharacterRun, + backgroundColorRun, + strikethroughCharacterRun, + characterSpacingCharacterRun, + span.isColorDefined, + span.isFontDefined, + span.isUnderlinedCharacterDefined, + span.isBackgroundColorDefined, + span.isStrikethroughDefined, + span.isCharacterSpacingDefined); + + // Push the span into the stack. + spanStack.Push(span); + + // Point the next free run. + if(span.isColorDefined) + { + // Push the run in the logical model. + colorRuns.PushBack(colorRun); + ++colorRunIndex; + } + + if(span.isFontDefined) + { + // Push the run in the logical model. + fontRuns.PushBack(fontRun); + ++fontRunIndex; + } + + if(span.isUnderlinedCharacterDefined) + { + // Push the run in the logical model. + underlinedCharacterRuns.PushBack(underlinedCharacterRun); + ++underlinedCharacterRunIndex; + } + + if(span.isBackgroundColorDefined) + { + // Push the run in the logical model. + backgroundColorRuns.PushBack(backgroundColorRun); + ++backgroundColorRunIndex; + } + + if(span.isStrikethroughDefined) + { + // Push the run in the logical model. + strikethroughCharacterRuns.PushBack(strikethroughCharacterRun); + ++strikethroughCharacterRunIndex; + } + + if(span.isCharacterSpacingDefined) + { + // Push the run in the logical model. + characterSpacingCharacterRuns.PushBack(characterSpacingCharacterRun); + ++characterSpacingCharacterRunIndex; + } + + // Increase reference + ++tagReference; + } + else + { + if(tagReference > 0) + { + // Pop the top of the stack and set the number of characters of the run. + Span span = spanStack.Pop(); + + if(span.isColorDefined) + { + ColorRun& colorRun = *(colorRuns.Begin() + span.colorRunIndex); + colorRun.characterRun.numberOfCharacters = characterIndex - colorRun.characterRun.characterIndex; + } + + if(span.isFontDefined) + { + FontDescriptionRun& fontRun = *(fontRuns.Begin() + span.fontRunIndex); + fontRun.characterRun.numberOfCharacters = characterIndex - fontRun.characterRun.characterIndex; + } + + if(span.isUnderlinedCharacterDefined) + { + UnderlinedCharacterRun& underlinedCharacterRun = *(underlinedCharacterRuns.Begin() + span.underlinedCharacterRunIndex); + underlinedCharacterRun.characterRun.numberOfCharacters = characterIndex - underlinedCharacterRun.characterRun.characterIndex; + } + + if(span.isBackgroundColorDefined) + { + ColorRun& backgroundColorRun = *(backgroundColorRuns.Begin() + span.backgroundColorRunIndex); + backgroundColorRun.characterRun.numberOfCharacters = characterIndex - backgroundColorRun.characterRun.characterIndex; + } + + if(span.isStrikethroughDefined) + { + StrikethroughCharacterRun& strikethroughCharacterRun = *(strikethroughCharacterRuns.Begin() + span.strikethroughCharacterRunIndex); + strikethroughCharacterRun.characterRun.numberOfCharacters = characterIndex - strikethroughCharacterRun.characterRun.characterIndex; + } + + if(span.isCharacterSpacingDefined) + { + CharacterSpacingCharacterRun& characterSpacingCharacterRun = *(characterSpacingCharacterRuns.Begin() + span.characterSpacingCharacterRunIndex); + characterSpacingCharacterRun.characterRun.numberOfCharacters = characterIndex - characterSpacingCharacterRun.characterRun.characterIndex; + } + + --tagReference; + } + } +} + +/** * @brief Resizes the model's vectors * - * @param[in/out] markupProcessData The markup process data + * @param[inout] markupProcessData The markup process data * @param[in] fontRunIndex The font run index * @param[in] colorRunIndex The color run index * @param[in] underlinedCharacterRunIndex The underlined character run index + * @param[in] strikethroughCharacterRunIndex The strikethroughed character run index * @param[in] backgroundRunIndex The background run index + * @param[in] boundedParagraphRunIndex The bounded paragraph run index + * @param[in] characterSpacingCharacterRunIndex The character-spacing character run index + * */ -void ResizeModelVectors(MarkupProcessData& markupProcessData, const StyleStack::RunIndex fontRunIndex, const StyleStack::RunIndex colorRunIndex, const StyleStack::RunIndex underlinedCharacterRunIndex, const StyleStack::RunIndex backgroundRunIndex) +void ResizeModelVectors(MarkupProcessData& markupProcessData, + const RunIndex fontRunIndex, + const RunIndex colorRunIndex, + const RunIndex underlinedCharacterRunIndex, + const RunIndex strikethroughCharacterRunIndex, + const RunIndex backgroundRunIndex, + const RunIndex boundedParagraphRunIndex, + const RunIndex characterSpacingCharacterRunIndex) { markupProcessData.fontRuns.Resize(fontRunIndex); markupProcessData.colorRuns.Resize(colorRunIndex); markupProcessData.underlinedCharacterRuns.Resize(underlinedCharacterRunIndex); + markupProcessData.strikethroughCharacterRuns.Resize(strikethroughCharacterRunIndex); markupProcessData.backgroundColorRuns.Resize(backgroundRunIndex); + markupProcessData.boundedParagraphRuns.Resize(boundedParagraphRunIndex); + markupProcessData.characterSpacingCharacterRuns.Resize(characterSpacingCharacterRunIndex); #ifdef DEBUG_ENABLED - for(unsigned int i = 0; i < colorRunIndex; ++i) + if(gLogFilter->IsEnabledFor(Debug::Verbose)) { - 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); + for(uint32_t 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 } @@ -754,27 +1055,39 @@ void ProcessMarkupString(const std::string& markupString, MarkupProcessData& mar markupProcessData.markupProcessedText.reserve(markupStringSize); // Stores a struct with the index to the first character of the run, the type of run and its parameters. - StyleStack styleStack; + StyleStack styleStack; + + // Stores a struct with the index to the first character of the color run & color font for the span. + StyleStack spanStack; // Points the next free position in the vector of runs. - StyleStack::RunIndex colorRunIndex = 0u; - StyleStack::RunIndex fontRunIndex = 0u; - StyleStack::RunIndex underlinedCharacterRunIndex = 0u; - StyleStack::RunIndex backgroundRunIndex = 0u; + RunIndex colorRunIndex = 0u; + RunIndex fontRunIndex = 0u; + RunIndex underlinedCharacterRunIndex = 0u; + RunIndex backgroundRunIndex = 0u; + RunIndex strikethroughCharacterRunIndex = 0u; + RunIndex boundedParagraphRunIndex = 0u; + RunIndex characterSpacingCharacterRunIndex = 0u; // check tag reference - int colorTagReference = 0u; - int fontTagReference = 0u; - int iTagReference = 0u; - int bTagReference = 0u; - int uTagReference = 0u; - int backgroundTagReference = 0u; + int colorTagReference = 0u; + int fontTagReference = 0u; + int iTagReference = 0u; + int bTagReference = 0u; + int uTagReference = 0u; + int backgroundTagReference = 0u; + int spanTagReference = 0u; + int sTagReference = 0u; + int pTagReference = 0u; + int characterSpacingTagReference = 0u; // Give an initial default value to the model's vectors. markupProcessData.colorRuns.Reserve(DEFAULT_VECTOR_SIZE); markupProcessData.fontRuns.Reserve(DEFAULT_VECTOR_SIZE); markupProcessData.underlinedCharacterRuns.Reserve(DEFAULT_VECTOR_SIZE); markupProcessData.backgroundColorRuns.Reserve(DEFAULT_VECTOR_SIZE); + markupProcessData.strikethroughCharacterRuns.Reserve(DEFAULT_VECTOR_SIZE); + markupProcessData.characterSpacingCharacterRuns.Reserve(DEFAULT_VECTOR_SIZE); // Get the mark-up string buffer. const char* markupStringBuffer = markupString.c_str(); @@ -789,12 +1102,12 @@ void ProcessMarkupString(const std::string& markupString, MarkupProcessData& mar markupStringEndBuffer, tag)) { - if(TokenComparison(XHTML_COLOR_TAG, tag.buffer, tag.length)) + if(TokenComparison(MARKUP::TAG::COLOR, tag.buffer, tag.length)) { ProcessTagForRun( markupProcessData.colorRuns, styleStack, tag, characterIndex, colorRunIndex, colorTagReference, [](const Tag& tag, ColorRun& run) { ProcessColorTag(tag, run); }); } // - else if(TokenComparison(XHTML_I_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::ITALIC, tag.buffer, tag.length)) { ProcessTagForRun( markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, iTagReference, [](const Tag&, FontDescriptionRun& fontRun) { @@ -802,12 +1115,12 @@ void ProcessMarkupString(const std::string& markupString, MarkupProcessData& mar fontRun.slantDefined = true; }); } // - else if(TokenComparison(XHTML_U_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::UNDERLINE, tag.buffer, tag.length)) { ProcessTagForRun( - markupProcessData.underlinedCharacterRuns, styleStack, tag, characterIndex, underlinedCharacterRunIndex, uTagReference, [](const Tag& tag, UnderlinedCharacterRun& run) {}); + markupProcessData.underlinedCharacterRuns, styleStack, tag, characterIndex, underlinedCharacterRunIndex, uTagReference, [](const Tag& tag, UnderlinedCharacterRun& run) { ProcessUnderlineTag(tag, run); }); } // - else if(TokenComparison(XHTML_B_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::BOLD, tag.buffer, tag.length)) { ProcessTagForRun( markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, bTagReference, [](const Tag&, FontDescriptionRun& fontRun) { @@ -815,12 +1128,12 @@ void ProcessMarkupString(const std::string& markupString, MarkupProcessData& mar fontRun.weightDefined = true; }); } // - else if(TokenComparison(XHTML_FONT_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::FONT, tag.buffer, tag.length)) { ProcessTagForRun( markupProcessData.fontRuns, styleStack, tag, characterIndex, fontRunIndex, fontTagReference, [](const Tag& tag, FontDescriptionRun& fontRun) { ProcessFontTag(tag, fontRun); }); } // - else if(TokenComparison(XHTML_ANCHOR_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::ANCHOR, tag.buffer, tag.length)) { /* Anchor */ ProcessAnchorTag(markupProcessData, tag, characterIndex); @@ -830,33 +1143,74 @@ void ProcessMarkupString(const std::string& markupString, MarkupProcessData& mar run.color = Color::BLUE; ProcessColorTag(tag, run); }); - /* TODO - underline */ + /* Underline */ + ProcessTagForRun( + markupProcessData.underlinedCharacterRuns, styleStack, tag, characterIndex, underlinedCharacterRunIndex, uTagReference, [](const Tag& tag, UnderlinedCharacterRun& run) { + run.properties.color = Color::BLUE; + run.properties.colorDefined = true; + ProcessUnderlineTag(tag, run); + }); } // tizen - else if(TokenComparison(XHTML_SHADOW_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::SHADOW, tag.buffer, tag.length)) { // 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. } // - else if(TokenComparison(XHTML_GLOW_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::GLOW, tag.buffer, tag.length)) { // 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. } // - else if(TokenComparison(XHTML_OUTLINE_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::OUTLINE, tag.buffer, tag.length)) { // 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. } // - else if(TokenComparison(XHTML_ITEM_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::EMBEDDED_ITEM, tag.buffer, tag.length)) { ProcessItemTag(markupProcessData, tag, characterIndex); } - else if(TokenComparison(XHTML_BACKGROUND_TAG, tag.buffer, tag.length)) + else if(TokenComparison(MARKUP::TAG::BACKGROUND, tag.buffer, tag.length)) { ProcessTagForRun( markupProcessData.backgroundColorRuns, styleStack, tag, characterIndex, backgroundRunIndex, backgroundTagReference, [](const Tag& tag, ColorRun& run) { ProcessBackground(tag, run); }); } - } // end if( IsTag() ) + else if(TokenComparison(MARKUP::TAG::SPAN, tag.buffer, tag.length)) + { + ProcessSpanForRun(tag, + spanStack, + markupProcessData.colorRuns, + markupProcessData.fontRuns, + markupProcessData.underlinedCharacterRuns, + markupProcessData.backgroundColorRuns, + markupProcessData.strikethroughCharacterRuns, + markupProcessData.characterSpacingCharacterRuns, + colorRunIndex, + fontRunIndex, + underlinedCharacterRunIndex, + backgroundRunIndex, + strikethroughCharacterRunIndex, + characterSpacingCharacterRunIndex, + characterIndex, + spanTagReference); + } + else if(TokenComparison(MARKUP::TAG::STRIKETHROUGH, tag.buffer, tag.length)) + { + ProcessTagForRun( + markupProcessData.strikethroughCharacterRuns, styleStack, tag, characterIndex, strikethroughCharacterRunIndex, sTagReference, [](const Tag& tag, StrikethroughCharacterRun& run) { ProcessStrikethroughTag(tag, run); }); + } // + else if(TokenComparison(MARKUP::TAG::PARAGRAPH, tag.buffer, tag.length)) + { + ProcessParagraphTag(markupProcessData, tag, (markupStringBuffer == markupStringEndBuffer), characterIndex); + ProcessTagForRun( + markupProcessData.boundedParagraphRuns, styleStack, tag, characterIndex, boundedParagraphRunIndex, pTagReference, [](const Tag& tag, BoundedParagraphRun& run) { ProcessAttributesOfParagraphTag(tag, run); }); + } //

+ else if(TokenComparison(MARKUP::TAG::CHARACTER_SPACING, tag.buffer, tag.length)) + { + ProcessTagForRun( + markupProcessData.characterSpacingCharacterRuns, styleStack, tag, characterIndex, characterSpacingCharacterRunIndex, characterSpacingTagReference, [](const Tag& tag, CharacterSpacingCharacterRun& run) { ProcessCharacterSpacingTag(tag, run); }); + } // + } // end if( IsTag() ) else if(markupStringBuffer < markupStringEndBuffer) { ProcessMarkupStringBuffer(markupProcessData, markupStringBuffer, markupStringEndBuffer, characterIndex); @@ -864,7 +1218,11 @@ void ProcessMarkupString(const std::string& markupString, MarkupProcessData& mar } // Resize the model's vectors. - ResizeModelVectors(markupProcessData, fontRunIndex, colorRunIndex, underlinedCharacterRunIndex, backgroundRunIndex); + ResizeModelVectors(markupProcessData, fontRunIndex, colorRunIndex, underlinedCharacterRunIndex, strikethroughCharacterRunIndex, backgroundRunIndex, boundedParagraphRunIndex, characterSpacingCharacterRunIndex); + + // Handle the nested tags + OverrideNestedUnderlinedCharacterRuns(markupProcessData.underlinedCharacterRuns); + OverrideNestedStrikethroughCharacterRuns(markupProcessData.strikethroughCharacterRuns); } } // namespace Text