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-underline.h>
39 const std::string XHTML_FAMILY_ATTRIBUTE("font-family");
40 const std::string XHTML_SIZE_ATTRIBUTE("font-size");
41 const std::string XHTML_WEIGHT_ATTRIBUTE("font-weight");
42 const std::string XHTML_WIDTH_ATTRIBUTE("font-width");
43 const std::string XHTML_SLANT_ATTRIBUTE("font-slant");
45 const std::string XHTML_COLOR_ATTRIBUTE("text-color");
46 const std::string XHTML_BACKGROUND_COLOR_ATTRIBUTE("background-color");
48 //the underlined character's attributes
49 const std::string XHTML_UNDERLINE_COLOR_ATTRIBUTE("u-color");
50 const std::string XHTML_UNDERLINE_HEIGHT_ATTRIBUTE("u-height");
51 const std::string XHTML_UNDERLINE_TYPE_ATTRIBUTE("u-type");
52 const std::string XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE("u-dash-gap");
53 const std::string XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE("u-dash-width");
56 void ProcessSpanTag(const Tag& tag,
58 FontDescriptionRun& fontRun,
59 UnderlinedCharacterRun& underlinedCharacterRun,
60 ColorRun& backgroundColorRun,
63 bool& isUnderlinedCharacterDefined,
64 bool& isBackgroundColorDefined)
66 for(Vector<Attribute>::ConstIterator it = tag.attributes.Begin(),
67 endIt = tag.attributes.End();
71 const Attribute& attribute(*it);
73 if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
75 isColorDefined = true;
76 ProcessColor(attribute, colorRun);
78 else if(TokenComparison(XHTML_BACKGROUND_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
80 isBackgroundColorDefined = true;
81 ProcessColor(attribute, backgroundColorRun);
83 else if(TokenComparison(XHTML_FAMILY_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
86 ProcessFontFamily(attribute, fontRun);
88 else if(TokenComparison(XHTML_SIZE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
91 ProcessFontSize(attribute, fontRun);
93 else if(TokenComparison(XHTML_WEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
96 ProcessFontWeight(attribute, fontRun);
98 else if(TokenComparison(XHTML_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
100 isFontDefined = true;
101 ProcessFontWidth(attribute, fontRun);
103 else if(TokenComparison(XHTML_SLANT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
105 isFontDefined = true;
106 ProcessFontSlant(attribute, fontRun);
108 else if(TokenComparison(XHTML_UNDERLINE_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
110 isUnderlinedCharacterDefined = true;
111 ProcessColorAttribute(attribute, underlinedCharacterRun);
113 else if(TokenComparison(XHTML_UNDERLINE_HEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
115 isUnderlinedCharacterDefined = true;
116 ProcessHeightAttribute(attribute, underlinedCharacterRun);
118 else if(TokenComparison(XHTML_UNDERLINE_TYPE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
120 isUnderlinedCharacterDefined = true;
121 ProcessTypeAttribute(attribute, underlinedCharacterRun);
123 else if(TokenComparison(XHTML_UNDERLINE_DASH_GAP_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
125 isUnderlinedCharacterDefined = true;
126 ProcessDashGapAttribute(attribute, underlinedCharacterRun);
128 else if(TokenComparison(XHTML_UNDERLINE_DASH_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
130 isUnderlinedCharacterDefined = true;
131 ProcessDashWidthAttribute(attribute, underlinedCharacterRun);
138 } // namespace Toolkit