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.
17 #ifndef URLMATCHESSTYLER_H_
18 #define URLMATCHESSTYLER_H_
22 #include <boost/algorithm/string.hpp>
23 #include <boost/regex.hpp>
24 #include "BrowserLogger.h"
28 namespace tizen_browser {
31 class UrlMatchesStyler {
34 virtual ~UrlMatchesStyler();
37 * @brief Get string containing EFL tags, which are highlighting given keywords.
38 * @param styledUrl url which will be styled
39 * @param highlightingKeyword keywords (entered url) indicating which
40 * fragments should be highlighted
41 * @return styledUrl enriched with EFL tags
43 string getUrlHighlightedMatches(const string& styledUrl,
44 const string& highlightingKeywords) const;
47 typedef vector<pair<int, int>> int_pairs;
48 const string FONT_COLOR_HIGHLIGHT = "#4088D3";
49 const string FONT_COLOR_NORMAL = "#888888";
50 const string FONT_SIZE = "35";
51 const string TAG_WHOLE_URL;
52 const string TAG_WHOLE_URL_CLOSE;
53 const string TAG_HIGHLIGHT, TAG_HIGHLIGHT_CLOSE;
54 const string TAG_COLOR, TAG_COLOR_CLOSE;
55 const string TAG_COMPLETE, TAG_COMPLETE_CLOSE;
56 const int TAGS_COMPLETE_LEN;
59 * @brief adds '/' to a tag (<a> -> </a>)
60 * @param tag tag to be closed
63 string closeTag(const string& tag) const;
65 * @brief splits given string by removing spaces
66 * @param keywordsString string to split
67 * @param resultKeywords vector to which result strings are stored
69 void splitKeywordsString(const string& keywordsString,
70 vector<string>& resultKeywords) const;
72 * @brief Fills vector with ranges describing beginnings end ends of occurrences of one string in another.
73 * @param checkedString the subject of search
74 * @param searchedMatch match to be searched for
75 * @param resultRanges vector filled with found ranges
77 void fillOccuranceRanges(const string& checkedString,
78 const string& searchedMatch, int_pairs& resultRanges) const;
80 * @brief Searches the string for positions of occurrences of another string.
81 * @param checkedString the subject of search
82 * @param searchedMatch string to be searched for
83 * @param resultPositions vector filled with result positions
85 void getMatchesPositions(const string& checkedString,
86 const string& searchedMatch, vector<int>& resultPositions) const;
88 * @brief merges ranges
89 * @param ranges vector of ranges to merge
90 * @param result vector filled with merged ranges
92 void mergeRanges(int_pairs& ranges, int_pairs& result) const;
94 * @brief get string enriched with opening and closing tags on given positions
95 * @param strToHighlight string to be enriched with tags
96 * @param ranges positions of opening and closing tags
97 * @param tag opening tag (for every pair.first)
98 * @param tagClose closing tag (for every pair.second)
99 * @return string with tags
101 string getTaggedString(const string& strToHighlight,
102 const int_pairs& ranges) const;
106 } /* namespace base_ui */
107 } /* namespace tizen_browser */
109 #endif /* URLMATCHESSTYLER_H_ */