From e939bee76410eca241bda2ed4a732e0a13be00af Mon Sep 17 00:00:00 2001 From: abdullah Date: Mon, 7 Feb 2022 16:20:03 +0200 Subject: [PATCH] fix issue when strikethrough used without ending tag when we use without ending tag, only one character get strike through, other tags do not apply the tag at all. fixed the behavior to be like the other tags. Change-Id: I94419b923772401af0f0c3e17524521bf2ade892 --- .../utc-Dali-TextEditor-internal.cpp | 25 +++++++++++++++++++ .../utc-Dali-TextField-internal.cpp | 25 +++++++++++++++++++ .../utc-Dali-TextLabel-internal.cpp | 25 +++++++++++++++++++ .../internal/text/logical-model-impl.cpp | 5 ++++ .../internal/text/logical-model-impl.h | 5 ++++ .../internal/text/text-controller-impl.cpp | 11 ++++++-- 6 files changed, 94 insertions(+), 2 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp index 0c55d97eec..c52141b8f7 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp @@ -376,3 +376,28 @@ int UtcDaliTextEditorMarkupStrikethrough(void) END_TEST; } + +int UtcDaliTextEditorMarkupStrikethroughNoEndTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextEditorMarkupStrikethroughNoEndTag "); + + TextEditor textEditor = TextEditor::New(); + + application.GetScene().Add(textEditor); + + textEditor.SetProperty(TextEditor::Property::TEXT, "ABC"); + textEditor.SetProperty(TextEditor ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfStrikethroughGlyphs = 0u; + + Toolkit::Internal::TextEditor& textEditorImpl = GetImpl(textEditor); + Text::Length numberOfStrikethroughRuns = textEditorImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp index 57fb32b4a6..ae1c1fc19d 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextField-internal.cpp @@ -450,3 +450,28 @@ int UtcDaliTextFieldMarkupStrikethrough(void) END_TEST; } + +int UtcDaliTextFieldMarkupStrikethroughNoEndTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextFieldMarkupStrikethroughNoEndTag "); + + TextField textField = TextField::New(); + + application.GetScene().Add(textField); + + textField.SetProperty(TextField::Property::TEXT, "ABC"); + textField.SetProperty(TextField ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfStrikethroughGlyphs = 0u; + + Toolkit::Internal::TextField& textFieldImpl = GetImpl(textField); + Text::Length numberOfStrikethroughRuns = textFieldImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp index ba067f6de7..81519c27bb 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextLabel-internal.cpp @@ -262,3 +262,28 @@ int UtcDaliTextLabelMarkupStrikethrough(void) END_TEST; } + +int UtcDaliTextLabelMarkupStrikethroughNoEndTag(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliTextLabelMarkupStrikethroughNoEndTag "); + + TextLabel textLabel = TextLabel::New(); + + application.GetScene().Add(textLabel); + + textLabel.SetProperty(TextLabel::Property::TEXT, "ABC"); + textLabel.SetProperty(TextLabel ::Property::ENABLE_MARKUP, true); + + application.SendNotification(); + application.Render(); + + uint32_t expectedNumberOfStrikethroughGlyphs = 0u; + + Toolkit::Internal::TextLabel& textLabelImpl = GetImpl(textLabel); + Text::Length numberOfStrikethroughRuns = textLabelImpl.GetTextController()->GetTextModel()->GetNumberOfStrikethroughRuns(); + + DALI_TEST_EQUALS(numberOfStrikethroughRuns, expectedNumberOfStrikethroughGlyphs, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file diff --git a/dali-toolkit/internal/text/logical-model-impl.cpp b/dali-toolkit/internal/text/logical-model-impl.cpp index f1fd1f5938..4516662c76 100644 --- a/dali-toolkit/internal/text/logical-model-impl.cpp +++ b/dali-toolkit/internal/text/logical-model-impl.cpp @@ -471,6 +471,11 @@ void LogicalModel::ClearFontDescriptionRuns() FreeFontFamilyNames(mFontDescriptionRuns); } +void LogicalModel::ClearStrikethroughRuns() +{ + mStrikethroughCharacterRuns.Clear(); +} + void LogicalModel::CreateParagraphInfo(CharacterIndex startIndex, Length numberOfCharacters) { diff --git a/dali-toolkit/internal/text/logical-model-impl.h b/dali-toolkit/internal/text/logical-model-impl.h index 1bed3428bb..08c636d11f 100644 --- a/dali-toolkit/internal/text/logical-model-impl.h +++ b/dali-toolkit/internal/text/logical-model-impl.h @@ -153,6 +153,11 @@ public: */ void ClearFontDescriptionRuns(); + /** + * @brief Clears the strikethrough runs. + */ + void ClearStrikethroughRuns(); + // Paragraphs /** diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index db6fde1c81..1b6666513f 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -1639,8 +1639,14 @@ void Controller::Impl::CopyStrikethroughFromLogicalToVisualModels() for(Vector::ConstIterator it = strikethroughCharacterRuns.Begin(), endIt = strikethroughCharacterRuns.End(); it != endIt; ++it) { - CharacterIndex characterIndex = it->characterRun.characterIndex; - Length numberOfCharacters = it->characterRun.numberOfCharacters; + CharacterIndex characterIndex = it->characterRun.characterIndex; + Length numberOfCharacters = it->characterRun.numberOfCharacters; + + if(numberOfCharacters == 0) + { + continue; + } + StrikethroughGlyphRun strikethroughGlyphRun; strikethroughGlyphRun.color = it->color; strikethroughGlyphRun.isColorSet = it->isColorSet; @@ -1836,6 +1842,7 @@ void Controller::Impl::ClearStyleData() { mModel->mLogicalModel->mColorRuns.Clear(); mModel->mLogicalModel->ClearFontDescriptionRuns(); + mModel->mLogicalModel->ClearStrikethroughRuns(); } void Controller::Impl::ResetScrollPosition() -- 2.34.1