Merge "Add InputFilter to TextField, TextEditor" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / markup-processor-span.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // FILE HEADER
19 #include <dali-toolkit/internal/text/markup-processor-color.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23
24 // INTERNAL INCLUDES
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
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Text
35 {
36 namespace
37 {
38 const std::string XHTML_FAMILY_ATTRIBUTE("font-family");
39 const std::string XHTML_SIZE_ATTRIBUTE("font-size");
40 const std::string XHTML_WEIGHT_ATTRIBUTE("font-weight");
41 const std::string XHTML_WIDTH_ATTRIBUTE("font-width");
42 const std::string XHTML_SLANT_ATTRIBUTE("font-slant");
43
44 const std::string XHTML_COLOR_ATTRIBUTE("text-color");
45 } // namespace
46
47 void ProcessSpanTag(const Tag& tag, ColorRun& colorRun, FontDescriptionRun& fontRun, bool& isColorDefined, bool& isFontDefined)
48 {
49   for(Vector<Attribute>::ConstIterator it    = tag.attributes.Begin(),
50                                        endIt = tag.attributes.End();
51       it != endIt;
52       ++it)
53   {
54     const Attribute& attribute(*it);
55
56     if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
57     {
58       isColorDefined = true;
59       ProcessColor(attribute, colorRun);
60     }
61     else if(TokenComparison(XHTML_FAMILY_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
62     {
63       isFontDefined = true;
64       ProcessFontFamily(attribute, fontRun);
65     }
66     else if(TokenComparison(XHTML_SIZE_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
67     {
68       isFontDefined = true;
69       ProcessFontSize(attribute, fontRun);
70     }
71     else if(TokenComparison(XHTML_WEIGHT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
72     {
73       isFontDefined = true;
74       ProcessFontWeight(attribute, fontRun);
75     }
76     else if(TokenComparison(XHTML_WIDTH_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
77     {
78       isFontDefined = true;
79       ProcessFontWidth(attribute, fontRun);
80     }
81     else if(TokenComparison(XHTML_SLANT_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength))
82     {
83       isFontDefined = true;
84       ProcessFontSlant(attribute, fontRun);
85     }
86   }
87 }
88
89 } // namespace Text
90
91 } // namespace Toolkit
92
93 } // namespace Dali