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");
61 void ProcessSpanTag(const Tag& tag,
63 FontDescriptionRun& fontRun,
64 UnderlinedCharacterRun& underlinedCharacterRun,
65 ColorRun& backgroundColorRun,
66 StrikethroughCharacterRun& strikethroughRun,
69 bool& isUnderlinedCharacterDefined,
70 bool& isBackgroundColorDefined,
71 bool& isStrikethroughDefined)
74 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
75 endIt = tag.attributes.End();
79 const Attribute& attribute(*it);
81 if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
83 isColorDefined = true;
84 ProcessColor(attribute, colorRun);
86 else if(TokenComparison(XHTML_BACKGROUND_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
88 isBackgroundColorDefined = true;
89 ProcessColor(attribute, backgroundColorRun);
91 else if(TokenComparison(XHTML_FAMILY_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
94 ProcessFontFamily(attribute, fontRun);
96 else if(TokenComparison(XHTML_SIZE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
99 ProcessFontSize(attribute, fontRun);
101 else if(TokenComparison(XHTML_WEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
103 isFontDefined = true;
104 ProcessFontWeight(attribute, fontRun);
106 else if(TokenComparison(XHTML_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
108 isFontDefined = true;
109 ProcessFontWidth(attribute, fontRun);
111 else if(TokenComparison(XHTML_SLANT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
113 isFontDefined = true;
114 ProcessFontSlant(attribute, fontRun);
116 else if(TokenComparison(XHTML_UNDERLINE_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
118 isUnderlinedCharacterDefined = true;
119 ProcessColorAttribute(attribute, underlinedCharacterRun);
121 else if(TokenComparison(XHTML_UNDERLINE_HEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
123 isUnderlinedCharacterDefined = true;
124 ProcessHeightAttribute(attribute, underlinedCharacterRun);
126 else if(TokenComparison(XHTML_UNDERLINE_TYPE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
128 isUnderlinedCharacterDefined = true;
129 ProcessTypeAttribute(attribute, underlinedCharacterRun);
131 else if(TokenComparison(XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
133 isUnderlinedCharacterDefined = true;
134 ProcessDashGapAttribute(attribute, underlinedCharacterRun);
136 else if(TokenComparison(XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
138 isUnderlinedCharacterDefined = true;
139 ProcessDashWidthAttribute(attribute, underlinedCharacterRun);
141 else if(TokenComparison(XHTML_STRIKETHROUGH_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
143 isStrikethroughDefined = true;
144 ProcessColorAttribute(attribute, strikethroughRun);
151 } // namespace Toolkit