Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: Source/platform/fonts/GenericFontFamilySettings.cpp

Issue 100653002: Introduce GenericFontFamilySettings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added missing PLATFORM_EXPORT Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/GenericFontFamilySettings.h ('k') | Source/web/WebSettingsImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "platform/fonts/GenericFontFamilySettings.h"
33
34 namespace WebCore {
35
36 // Sets the entry in the font map for the given script. If family is the empty s tring, removes the entry instead.
37 void GenericFontFamilySettings::setGenericFontFamilyMap(ScriptFontFamilyMap& fon tMap, const AtomicString& family, UScriptCode script)
38 {
39 ScriptFontFamilyMap::iterator it = fontMap.find(static_cast<int>(script));
40 if (family.isEmpty()) {
41 if (it == fontMap.end())
42 return;
43 fontMap.remove(it);
44 } else if (it != fontMap.end() && it->value == family) {
45 return;
46 } else {
47 fontMap.set(static_cast<int>(script), family);
48 }
49 }
50
51 const AtomicString& GenericFontFamilySettings::genericFontFamilyForScript(const ScriptFontFamilyMap& fontMap, UScriptCode script) const
52 {
53 ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast<int>(scrip t));
54 if (it != fontMap.end())
55 return it->value;
56 if (script != USCRIPT_COMMON)
57 return genericFontFamilyForScript(fontMap, USCRIPT_COMMON);
58 return emptyAtom;
59 }
60
61 const AtomicString& GenericFontFamilySettings::standard(UScriptCode script) cons t
62 {
63 return genericFontFamilyForScript(m_standardFontFamilyMap, script);
64 }
65
66 void GenericFontFamilySettings::setStandard(const AtomicString& family, UScriptC ode script)
67 {
68 setGenericFontFamilyMap(m_standardFontFamilyMap, family, script);
69 }
70
71 const AtomicString& GenericFontFamilySettings::fixed(UScriptCode script) const
72 {
73 return genericFontFamilyForScript(m_fixedFontFamilyMap, script);
74 }
75
76 void GenericFontFamilySettings::setFixed(const AtomicString& family, UScriptCode script)
77 {
78 setGenericFontFamilyMap(m_fixedFontFamilyMap, family, script);
79 }
80
81 const AtomicString& GenericFontFamilySettings::serif(UScriptCode script) const
82 {
83 return genericFontFamilyForScript(m_serifFontFamilyMap, script);
84 }
85
86 void GenericFontFamilySettings::setSerif(const AtomicString& family, UScriptCode script)
87 {
88 setGenericFontFamilyMap(m_serifFontFamilyMap, family, script);
89 }
90
91 const AtomicString& GenericFontFamilySettings::sansSerif(UScriptCode script) con st
92 {
93 return genericFontFamilyForScript(m_sansSerifFontFamilyMap, script);
94 }
95
96 void GenericFontFamilySettings::setSansSerif(const AtomicString& family, UScript Code script)
97 {
98 setGenericFontFamilyMap(m_sansSerifFontFamilyMap, family, script);
99 }
100
101 const AtomicString& GenericFontFamilySettings::cursive(UScriptCode script) const
102 {
103 return genericFontFamilyForScript(m_cursiveFontFamilyMap, script);
104 }
105
106 void GenericFontFamilySettings::setCursive(const AtomicString& family, UScriptCo de script)
107 {
108 setGenericFontFamilyMap(m_cursiveFontFamilyMap, family, script);
109 }
110
111 const AtomicString& GenericFontFamilySettings::fantasy(UScriptCode script) const
112 {
113 return genericFontFamilyForScript(m_fantasyFontFamilyMap, script);
114 }
115
116 void GenericFontFamilySettings::setFantasy(const AtomicString& family, UScriptCo de script)
117 {
118 setGenericFontFamilyMap(m_fantasyFontFamilyMap, family, script);
119 }
120
121 const AtomicString& GenericFontFamilySettings::pictograph(UScriptCode script) co nst
122 {
123 return genericFontFamilyForScript(m_pictographFontFamilyMap, script);
124 }
125
126 void GenericFontFamilySettings::setPictograph(const AtomicString& family, UScrip tCode script)
127 {
128 setGenericFontFamilyMap(m_pictographFontFamilyMap, family, script);
129 }
130
131 void GenericFontFamilySettings::reset()
132 {
133 m_standardFontFamilyMap.clear();
134 m_serifFontFamilyMap.clear();
135 m_fixedFontFamilyMap.clear();
136 m_sansSerifFontFamilyMap.clear();
137 m_cursiveFontFamilyMap.clear();
138 m_fantasyFontFamilyMap.clear();
139 m_pictographFontFamilyMap.clear();
140 }
141
142 }
OLDNEW
« no previous file with comments | « Source/platform/fonts/GenericFontFamilySettings.h ('k') | Source/web/WebSettingsImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698