From: Bowon Ryu Date: Wed, 23 Mar 2022 05:48:55 +0000 (+0000) Subject: Merge "Resolve cases for strikethrough when using multiple tags" into devel/master X-Git-Tag: dali_2.1.15~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=6877b751dc17e58428b7ae6ea35bbef6c030453c;hp=-c Merge "Resolve cases for strikethrough when using multiple tags" into devel/master --- 6877b751dc17e58428b7ae6ea35bbef6c030453c diff --combined automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp index 0af3a34,48f44a6..3ff87d6 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp @@@ -682,37 -682,6 +682,37 @@@ int UtcDaliTextEditorBackgroundTag(void //red color DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); + + //yellow color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextEditorSpanBackgroundTag(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextEditorSpanBackgroundTag\n"); + + TextEditor editor = TextEditor::New(); + DALI_TEST_CHECK(editor); + + editor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + editor.SetProperty(TextEditor::Property::TEXT, "He World"); + application.GetScene().Add(editor); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextEditor& editorImpl = GetImpl(editor); + const ColorIndex* const backgroundColorIndicesBuffer = editorImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); + + DALI_TEST_CHECK(backgroundColorIndicesBuffer); + + //default color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); + + //red color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); //yellow color DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); @@@ -888,12 -857,12 +888,12 @@@ int UtcDaliTextEditorMarkupStrikethroug //ABC have strikethrough DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION); DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION); - DALI_TEST_CHECK(!strikethroughRuns[0u].isColorSet); + DALI_TEST_CHECK(!strikethroughRuns[0u].properties.colorDefined); //GH have strikethrough DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION); DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION); - DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet); + DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined); END_TEST; } diff --combined automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp index 2bc211d,07b097b..42ca11c --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp @@@ -773,37 -773,6 +773,37 @@@ int UtcDaliTextFieldBackgroundTag(void END_TEST; } +int UtcDaliTextFieldSpanBackgroundTag(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextFieldSpanBackgroundTag\n"); + + TextField field = TextField::New(); + DALI_TEST_CHECK(field); + + field.SetProperty(TextField ::Property::ENABLE_MARKUP, true); + field.SetProperty(TextField::Property::TEXT, "He World"); + application.GetScene().Add(field); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextField& fieldImpl = GetImpl(field); + const ColorIndex* const backgroundColorIndicesBuffer = fieldImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); + + DALI_TEST_CHECK(backgroundColorIndicesBuffer); + + //default color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); + + //red color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); + + //yellow color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); + + END_TEST; +} + int UtcDaliToolkitTextFieldEllipsisInternalAPIs(void) { ToolkitTestApplication application; @@@ -964,12 -933,12 +964,12 @@@ int UtcDaliTextFieldMarkupStrikethrough //ABC have strikethrough DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION); DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION); - DALI_TEST_CHECK(!strikethroughRuns[0u].isColorSet); + DALI_TEST_CHECK(!strikethroughRuns[0u].properties.colorDefined); //GH have strikethrough DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION); DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION); - DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet); + DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined); END_TEST; } diff --combined automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp index 68c25dd,5fa2eaf..b1bba97 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp @@@ -585,37 -585,6 +585,37 @@@ int UtcDaliTextLabelBackgroundTag(void //red color DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); + + //yellow color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliTextLabelSpanBackgroundTag(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextLabelSpanBackgroundTag\n"); + + TextLabel label = TextLabel::New(); + DALI_TEST_CHECK(label); + + label.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + label.SetProperty(TextLabel::Property::TEXT, "He World"); + application.GetScene().Add(label); + application.SendNotification(); + application.Render(); + + Toolkit::Internal::TextLabel& labelImpl = GetImpl(label); + const ColorIndex* const backgroundColorIndicesBuffer = labelImpl.GetTextController()->GetTextModel()->GetBackgroundColorIndices(); + + DALI_TEST_CHECK(backgroundColorIndicesBuffer); + + //default color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[0], 0u, TEST_LOCATION); + + //red color + DALI_TEST_EQUALS(backgroundColorIndicesBuffer[1], 1u, TEST_LOCATION); //yellow color DALI_TEST_EQUALS(backgroundColorIndicesBuffer[7], 2u, TEST_LOCATION); @@@ -770,18 -739,18 +770,18 @@@ int UtcDaliTextLabelMarkupStrikethrough //ABC have strikethrough DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.glyphIndex, 0u, TEST_LOCATION); DALI_TEST_EQUALS(strikethroughRuns[0u].glyphRun.numberOfGlyphs, 3u, TEST_LOCATION); - DALI_TEST_CHECK(strikethroughRuns[0u].isColorSet); - DALI_TEST_EQUALS(strikethroughRuns[0u].color.r, 1u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[0u].color.g, 0u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[0u].color.b, 0u, TEST_LOCATION); + DALI_TEST_CHECK(strikethroughRuns[0u].properties.colorDefined); + DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.r, 1u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.g, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[0u].properties.color.b, 0u, TEST_LOCATION); //GH have strikethrough DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.glyphIndex, 5u, TEST_LOCATION); DALI_TEST_EQUALS(strikethroughRuns[1u].glyphRun.numberOfGlyphs, 2u, TEST_LOCATION); - DALI_TEST_CHECK(strikethroughRuns[1u].isColorSet); - DALI_TEST_EQUALS(strikethroughRuns[1u].color.r, 0u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[1u].color.g, 1u, TEST_LOCATION); - DALI_TEST_EQUALS(strikethroughRuns[1u].color.b, 0u, TEST_LOCATION); + DALI_TEST_CHECK(strikethroughRuns[1u].properties.colorDefined); + DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.r, 0u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.g, 1u, TEST_LOCATION); + DALI_TEST_EQUALS(strikethroughRuns[1u].properties.color.b, 0u, TEST_LOCATION); END_TEST; } diff --combined dali-toolkit/internal/text/markup-processor.cpp index 68b0632,e44fbde..1671075 --- a/dali-toolkit/internal/text/markup-processor.cpp +++ b/dali-toolkit/internal/text/markup-processor.cpp @@@ -141,11 -141,9 +141,11 @@@ struct Spa RunIndex colorRunIndex; RunIndex fontRunIndex; RunIndex underlinedCharacterRunIndex; + RunIndex backgroundColorRunIndex; bool isColorDefined; bool isFontDefined; bool isUnderlinedCharacterDefined; + bool isBackgroundColorDefined; }; /** @@@ -205,8 -203,6 +205,8 @@@ void Initialize(Span& span span.isFontDefined = false; span.underlinedCharacterRunIndex = 0u; span.isUnderlinedCharacterDefined = false; + span.backgroundColorRunIndex = 0u; + span.isBackgroundColorDefined = false; } /** @@@ -218,7 -214,7 +218,7 @@@ void Initialize(StrikethroughCharacterR { strikethroughCharacterRun.characterRun.characterIndex = 0u; strikethroughCharacterRun.characterRun.numberOfCharacters = 0u; - strikethroughCharacterRun.isColorSet = false; + strikethroughCharacterRun.properties.colorDefined = false; } /** @@@ -732,11 -728,9 +732,11 @@@ void ProcessSpanForRun Vector& colorRuns, Vector& fontRuns, Vector& underlinedCharacterRuns, + Vector& backgroundColorRuns, RunIndex& colorRunIndex, RunIndex& fontRunIndex, RunIndex& underlinedCharacterRunIndex, + RunIndex& backgroundColorRunIndex, const CharacterIndex characterIndex, int& tagReference) { @@@ -752,9 -746,6 +752,9 @@@ UnderlinedCharacterRun underlinedCharacterRun; Initialize(underlinedCharacterRun); + ColorRun backgroundColorRun; + Initialize(backgroundColorRun); + Span span; Initialize(span); @@@ -762,14 -753,12 +762,14 @@@ colorRun.characterRun.characterIndex = characterIndex; fontRun.characterRun.characterIndex = characterIndex; underlinedCharacterRun.characterRun.characterIndex = characterIndex; + backgroundColorRun.characterRun.characterIndex = characterIndex; span.colorRunIndex = colorRunIndex; span.fontRunIndex = fontRunIndex; span.underlinedCharacterRunIndex = underlinedCharacterRunIndex; + span.backgroundColorRunIndex = backgroundColorRunIndex; - ProcessSpanTag(spanTag, colorRun, fontRun, underlinedCharacterRun, span.isColorDefined, span.isFontDefined, span.isUnderlinedCharacterDefined); + ProcessSpanTag(spanTag, colorRun, fontRun, underlinedCharacterRun, backgroundColorRun, span.isColorDefined, span.isFontDefined, span.isUnderlinedCharacterDefined, span.isBackgroundColorDefined); // Push the span into the stack. spanStack.Push(span); @@@ -796,13 -785,6 +796,13 @@@ ++underlinedCharacterRunIndex; } + if(span.isBackgroundColorDefined) + { + // Push the run in the logical model. + backgroundColorRuns.PushBack(backgroundColorRun); + ++backgroundColorRunIndex; + } + // Increase reference ++tagReference; } @@@ -831,12 -813,6 +831,12 @@@ underlinedCharacterRun.characterRun.numberOfCharacters = characterIndex - underlinedCharacterRun.characterRun.characterIndex; } + if(span.isBackgroundColorDefined) + { + ColorRun& backgroundColorRun = *(backgroundColorRuns.Begin() + span.backgroundColorRunIndex); + backgroundColorRun.characterRun.numberOfCharacters = characterIndex - backgroundColorRun.characterRun.characterIndex; + } + --tagReference; } } @@@ -1096,7 -1072,7 +1096,7 @@@ void ProcessMarkupString(const std::str } else if(TokenComparison(XHTML_SPAN_TAG, tag.buffer, tag.length)) { - ProcessSpanForRun(tag, spanStack, markupProcessData.colorRuns, markupProcessData.fontRuns, markupProcessData.underlinedCharacterRuns, colorRunIndex, fontRunIndex, underlinedCharacterRunIndex, characterIndex, spanTagReference); + ProcessSpanForRun(tag, spanStack, markupProcessData.colorRuns, markupProcessData.fontRuns, markupProcessData.underlinedCharacterRuns, markupProcessData.backgroundColorRuns, colorRunIndex, fontRunIndex, underlinedCharacterRunIndex, backgroundRunIndex, characterIndex, spanTagReference); } else if(TokenComparison(XHTML_STRIKETHROUGH_TAG, tag.buffer, tag.length)) {