2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/markup-processor-color.h>
22 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/internal/text/color-run.h>
26 #include <dali-toolkit/internal/text/font-description-run.h>
27 #include <dali-toolkit/internal/text/markup-processor-font.h>
28 #include <dali-toolkit/internal/text/markup-processor-helper-functions.h>
29 #include <dali-toolkit/internal/text/markup-processor-strikethrough.h>
30 #include <dali-toolkit/internal/text/markup-processor-underline.h>
40 const std::string XHTML_FAMILY_ATTRIBUTE("font-family");
41 const std::string XHTML_SIZE_ATTRIBUTE("font-size");
42 const std::string XHTML_WEIGHT_ATTRIBUTE("font-weight");
43 const std::string XHTML_WIDTH_ATTRIBUTE("font-width");
44 const std::string XHTML_SLANT_ATTRIBUTE("font-slant");
46 const std::string XHTML_COLOR_ATTRIBUTE("text-color");
47 const std::string XHTML_BACKGROUND_COLOR_ATTRIBUTE("background-color");
49 //the underlined character's attributes
50 const std::string XHTML_UNDERLINE_COLOR_ATTRIBUTE("u-color");
51 const std::string XHTML_UNDERLINE_HEIGHT_ATTRIBUTE("u-height");
52 const std::string XHTML_UNDERLINE_TYPE_ATTRIBUTE("u-type");
53 const std::string XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE("u-dash-gap");
54 const std::string XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE("u-dash-width");
56 //the strikethroughed character's attributes
57 const std::string XHTML_STRIKETHROUGH_COLOR_ATTRIBUTE("s-color");
58 const std::string XHTML_STRIKETHROUGH_HEIGHT_ATTRIBUTE("s-height");
62 void ProcessSpanTag(const Tag& tag,
64 FontDescriptionRun& fontRun,
65 UnderlinedCharacterRun& underlinedCharacterRun,
66 ColorRun& backgroundColorRun,
67 StrikethroughCharacterRun& strikethroughRun,
70 bool& isUnderlinedCharacterDefined,
71 bool& isBackgroundColorDefined,
72 bool& isStrikethroughDefined)
75 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
76 endIt = tag.attributes.End();
80 const Attribute& attribute(*it);
82 if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
84 isColorDefined = true;
85 ProcessColor(attribute, colorRun);
87 else if(TokenComparison(XHTML_BACKGROUND_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
89 isBackgroundColorDefined = true;
90 ProcessColor(attribute, backgroundColorRun);
92 else if(TokenComparison(XHTML_FAMILY_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
95 ProcessFontFamily(attribute, fontRun);
97 else if(TokenComparison(XHTML_SIZE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
100 ProcessFontSize(attribute, fontRun);
102 else if(TokenComparison(XHTML_WEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
104 isFontDefined = true;
105 ProcessFontWeight(attribute, fontRun);
107 else if(TokenComparison(XHTML_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
109 isFontDefined = true;
110 ProcessFontWidth(attribute, fontRun);
112 else if(TokenComparison(XHTML_SLANT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
114 isFontDefined = true;
115 ProcessFontSlant(attribute, fontRun);
117 else if(TokenComparison(XHTML_UNDERLINE_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
119 isUnderlinedCharacterDefined = true;
120 ProcessColorAttribute(attribute, underlinedCharacterRun);
122 else if(TokenComparison(XHTML_UNDERLINE_HEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
124 isUnderlinedCharacterDefined = true;
125 ProcessHeightAttribute(attribute, underlinedCharacterRun);
127 else if(TokenComparison(XHTML_UNDERLINE_TYPE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
129 isUnderlinedCharacterDefined = true;
130 ProcessTypeAttribute(attribute, underlinedCharacterRun);
132 else if(TokenComparison(XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
134 isUnderlinedCharacterDefined = true;
135 ProcessDashGapAttribute(attribute, underlinedCharacterRun);
137 else if(TokenComparison(XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
139 isUnderlinedCharacterDefined = true;
140 ProcessDashWidthAttribute(attribute, underlinedCharacterRun);
142 else if(TokenComparison(XHTML_STRIKETHROUGH_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
144 isStrikethroughDefined = true;
145 ProcessColorAttribute(attribute, strikethroughRun);
147 else if(TokenComparison(XHTML_STRIKETHROUGH_HEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
149 isStrikethroughDefined = true;
150 ProcessHeightAttribute(attribute, strikethroughRun);
157 } // namespace Toolkit