Enable to use GPU masking in image visual
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / markup-processor-strikethrough.cpp
index 3612461..10e104c 100644 (file)
@@ -22,7 +22,9 @@
 #include <dali/public-api/common/dali-vector.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/markup-processor-attribute-helper-functions.h>
 #include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
+#include <dali-toolkit/internal/text/markup-tags-and-attributes.h>
 #include <dali-toolkit/internal/text/strikethrough-character-run.h>
 
 namespace Dali
@@ -31,11 +33,6 @@ namespace Toolkit
 {
 namespace Text
 {
-namespace
-{
-const std::string XHTML_COLOR_ATTRIBUTE("color");
-}
-
 void ProcessColorAttribute(const Attribute& attribute, StrikethroughCharacterRun& strikethroughRun)
 
 {
@@ -43,6 +40,12 @@ void ProcessColorAttribute(const Attribute& attribute, StrikethroughCharacterRun
   strikethroughRun.properties.colorDefined = true;
 }
 
+void ProcessHeightAttribute(const Attribute& attribute, StrikethroughCharacterRun& strikethroughRun)
+{
+  strikethroughRun.properties.height        = ProcessFloatAttribute(attribute);
+  strikethroughRun.properties.heightDefined = true;
+}
+
 void ProcessStrikethroughTag(const Tag& tag, StrikethroughCharacterRun& strikethroughRun)
 {
   for(Vector<Attribute>::ConstIterator it    = tag.attributes.Begin(),
@@ -51,10 +54,53 @@ void ProcessStrikethroughTag(const Tag& tag, StrikethroughCharacterRun& striketh
       ++it)
   {
     const Attribute& attribute(*it);
-    if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
+
+    if(TokenComparison(MARKUP::STRIKETHROUGH_ATTRIBUTES::COLOR, attribute.nameBuffer, attribute.nameLength))
     {
       ProcessColorAttribute(attribute, strikethroughRun);
     }
+    else if(TokenComparison(MARKUP::STRIKETHROUGH_ATTRIBUTES::HEIGHT, attribute.nameBuffer, attribute.nameLength))
+    {
+      ProcessHeightAttribute(attribute, strikethroughRun);
+    }
+  }
+}
+
+void OverrideNestedStrikethroughCharacterRuns(Vector<StrikethroughCharacterRun>& strikethroughCharacterRuns)
+{
+  // Handle nested tags
+  // The inner tag inherit the attributes of the outer tag and override them when defined in the inner tag.
+  // Example:
+  // <s height='5.0f' color='blue'> outer tag before  <s color='green'> inner tag </s> outer tag after </s>
+  // "outer tag before" and  "outer tag after" have height = 5.0f and color = 'blue'
+  // "inner tag" has height = 5.0f and color = 'green'
+
+  if(strikethroughCharacterRuns.Count() > 0u)
+  {
+    Vector<StrikethroughCharacterRun>::ConstIterator preIt = strikethroughCharacterRuns.Begin();
+
+    Vector<StrikethroughCharacterRun>::Iterator      it    = strikethroughCharacterRuns.Begin() + 1;
+    Vector<StrikethroughCharacterRun>::ConstIterator endIt = strikethroughCharacterRuns.End();
+
+    while(it != endIt)
+    {
+      const StrikethroughCharacterRun& run                = *it;
+      const CharacterIndex&            characterIndex     = run.characterRun.characterIndex;
+      const Length&                    numberOfCharacters = run.characterRun.numberOfCharacters;
+
+      const StrikethroughCharacterRun& preRun                = *preIt;
+      const CharacterIndex&            preCharacterIndex     = preRun.characterRun.characterIndex;
+      const Length&                    preNumberOfCharacters = preRun.characterRun.numberOfCharacters;
+
+      if((preCharacterIndex <= characterIndex) &&
+         ((characterIndex + numberOfCharacters) <= (preCharacterIndex + preNumberOfCharacters)))
+      {
+        it->properties.CopyIfNotDefined(preIt->properties);
+      }
+
+      it++;
+      preIt++;
+    }
   }
 }