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

Side by Side Diff: Source/core/page/Settings.h

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/core/inspector/InspectorOverlay.cpp ('k') | Source/core/page/Settings.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef Settings_h 27 #ifndef Settings_h
28 #define Settings_h 28 #define Settings_h
29 29
30 #include "SettingsMacros.h" 30 #include "SettingsMacros.h"
31 #include "core/editing/EditingBehaviorTypes.h" 31 #include "core/editing/EditingBehaviorTypes.h"
32 #include "platform/Timer.h" 32 #include "platform/Timer.h"
33 #include "platform/fonts/GenericFontFamilySettings.h"
33 #include "platform/geometry/IntSize.h" 34 #include "platform/geometry/IntSize.h"
34 #include "platform/weborigin/KURL.h" 35 #include "platform/weborigin/KURL.h"
35 #include "wtf/HashMap.h"
36 #include "wtf/text/AtomicString.h"
37 #include "wtf/text/AtomicStringHash.h"
38 36
39 namespace WebCore { 37 namespace WebCore {
40 38
41 class Page; 39 class Page;
42 40
43 enum EditableLinkBehavior { 41 enum EditableLinkBehavior {
44 EditableLinkDefaultBehavior, 42 EditableLinkDefaultBehavior,
45 EditableLinkAlwaysLive, 43 EditableLinkAlwaysLive,
46 EditableLinkOnlyLiveWithShiftKey, 44 EditableLinkOnlyLiveWithShiftKey,
47 EditableLinkLiveWhenNotFocused, 45 EditableLinkLiveWhenNotFocused,
48 EditableLinkNeverLive 46 EditableLinkNeverLive
49 }; 47 };
50 48
51 // UScriptCode uses -1 and 0 for UScriptInvalidCode and UScriptCommon.
52 // We need to use -2 and -3 for empty value and deleted value.
53 struct UScriptCodeHashTraits : WTF::GenericHashTraits<int> {
54 static const bool emptyValueIsZero = false;
55 static int emptyValue() { return -2; }
56 static void constructDeletedValue(int& slot) { slot = -3; }
57 static bool isDeletedValue(int value) { return value == -3; }
58 };
59
60 typedef HashMap<int, AtomicString, DefaultHash<int>::Hash, UScriptCodeHashTraits > ScriptFontFamilyMap;
61
62 class Settings { 49 class Settings {
63 WTF_MAKE_NONCOPYABLE(Settings); WTF_MAKE_FAST_ALLOCATED; 50 WTF_MAKE_NONCOPYABLE(Settings); WTF_MAKE_FAST_ALLOCATED;
64 public: 51 public:
65 static PassOwnPtr<Settings> create(Page*); 52 static PassOwnPtr<Settings> create(Page*);
66 53
67 void setStandardFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON ); 54 GenericFontFamilySettings& genericFontFamilySettings() { return m_genericFon tFamilySettings; }
68 const AtomicString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const;
69
70 void setFixedFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
71 const AtomicString& fixedFontFamily(UScriptCode = USCRIPT_COMMON) const;
72
73 void setSerifFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
74 const AtomicString& serifFontFamily(UScriptCode = USCRIPT_COMMON) const;
75
76 void setSansSerifFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMO N);
77 const AtomicString& sansSerifFontFamily(UScriptCode = USCRIPT_COMMON) const;
78
79 void setCursiveFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON) ;
80 const AtomicString& cursiveFontFamily(UScriptCode = USCRIPT_COMMON) const;
81
82 void setFantasyFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON) ;
83 const AtomicString& fantasyFontFamily(UScriptCode = USCRIPT_COMMON) const;
84
85 void setPictographFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMM ON);
86 const AtomicString& pictographFontFamily(UScriptCode = USCRIPT_COMMON) const ;
87 55
88 void setTextAutosizingEnabled(bool); 56 void setTextAutosizingEnabled(bool);
89 bool textAutosizingEnabled() const; 57 bool textAutosizingEnabled() const;
90 58
91 // Font scale factor for accessibility, applied as part of text autosizing. 59 // Font scale factor for accessibility, applied as part of text autosizing.
92 void setAccessibilityFontScaleFactor(float); 60 void setAccessibilityFontScaleFactor(float);
93 float accessibilityFontScaleFactor() const { return m_accessibilityFontScale Factor; } 61 float accessibilityFontScaleFactor() const { return m_accessibilityFontScale Factor; }
94 62
95 // Compensates for poor text legibility on mobile devices. This value is 63 // Compensates for poor text legibility on mobile devices. This value is
96 // multiplied by the font scale factor when performing text autosizing of 64 // multiplied by the font scale factor when performing text autosizing of
97 // websites that do not set an explicit viewport description. 65 // websites that do not set an explicit viewport description.
98 void setDeviceScaleAdjustment(float); 66 void setDeviceScaleAdjustment(float);
99 float deviceScaleAdjustment() const; 67 float deviceScaleAdjustment() const;
100 68
101 // Only set by Layout Tests, and only used if textAutosizingEnabled() return s true. 69 // Only set by Layout Tests, and only used if textAutosizingEnabled() return s true.
102 void setTextAutosizingWindowSizeOverride(const IntSize&); 70 void setTextAutosizingWindowSizeOverride(const IntSize&);
103 const IntSize& textAutosizingWindowSizeOverride() const { return m_textAutos izingWindowSizeOverride; } 71 const IntSize& textAutosizingWindowSizeOverride() const { return m_textAutos izingWindowSizeOverride; }
104 72
105 void setUseWideViewport(bool); 73 void setUseWideViewport(bool);
106 bool useWideViewport() const { return m_useWideViewport; } 74 bool useWideViewport() const { return m_useWideViewport; }
107 75
108 void setLoadWithOverviewMode(bool); 76 void setLoadWithOverviewMode(bool);
109 bool loadWithOverviewMode() const { return m_loadWithOverviewMode; } 77 bool loadWithOverviewMode() const { return m_loadWithOverviewMode; }
110 78
111 // Only set by Layout Tests. 79 // Only set by Layout Tests.
112 void setMediaTypeOverride(const String&); 80 void setMediaTypeOverride(const String&);
113 const String& mediaTypeOverride() const { return m_mediaTypeOverride; } 81 const String& mediaTypeOverride() const { return m_mediaTypeOverride; }
114 82
115 // Only called by InternalSettings to clear font family maps.
116 void resetFontFamilies();
117
118 // Unlike areImagesEnabled, this only suppresses the network load of 83 // Unlike areImagesEnabled, this only suppresses the network load of
119 // the image URL. A cached image will still be rendered if requested. 84 // the image URL. A cached image will still be rendered if requested.
120 void setLoadsImagesAutomatically(bool); 85 void setLoadsImagesAutomatically(bool);
121 bool loadsImagesAutomatically() const { return m_loadsImagesAutomatically; } 86 bool loadsImagesAutomatically() const { return m_loadsImagesAutomatically; }
122 87
123 // Clients that execute script should call ScriptController::canExecuteScrip ts() 88 // Clients that execute script should call ScriptController::canExecuteScrip ts()
124 // instead of this function. ScriptController::canExecuteScripts() checks th e 89 // instead of this function. ScriptController::canExecuteScripts() checks th e
125 // HTML sandbox, plug-in sandboxing, and other important details. 90 // HTML sandbox, plug-in sandboxing, and other important details.
126 bool isScriptEnabled() const { return m_isScriptEnabled; } 91 bool isScriptEnabled() const { return m_isScriptEnabled; }
127 void setScriptEnabled(bool); 92 void setScriptEnabled(bool);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // (crbug.com/261605) 134 // (crbug.com/261605)
170 void setLayerSquashingEnabled(bool enabled) { m_layerSquashingEnabled = enab led; } 135 void setLayerSquashingEnabled(bool enabled) { m_layerSquashingEnabled = enab led; }
171 bool isLayerSquashingEnabled() const { return m_layerSquashingEnabled; } 136 bool isLayerSquashingEnabled() const { return m_layerSquashingEnabled; }
172 137
173 private: 138 private:
174 explicit Settings(Page*); 139 explicit Settings(Page*);
175 140
176 Page* m_page; 141 Page* m_page;
177 142
178 String m_mediaTypeOverride; 143 String m_mediaTypeOverride;
179 ScriptFontFamilyMap m_standardFontFamilyMap; 144 GenericFontFamilySettings m_genericFontFamilySettings;
180 ScriptFontFamilyMap m_serifFontFamilyMap;
181 ScriptFontFamilyMap m_fixedFontFamilyMap;
182 ScriptFontFamilyMap m_sansSerifFontFamilyMap;
183 ScriptFontFamilyMap m_cursiveFontFamilyMap;
184 ScriptFontFamilyMap m_fantasyFontFamilyMap;
185 ScriptFontFamilyMap m_pictographFontFamilyMap;
186 float m_accessibilityFontScaleFactor; 145 float m_accessibilityFontScaleFactor;
187 float m_deviceScaleAdjustment; 146 float m_deviceScaleAdjustment;
188 IntSize m_textAutosizingWindowSizeOverride; 147 IntSize m_textAutosizingWindowSizeOverride;
189 bool m_textAutosizingEnabled : 1; 148 bool m_textAutosizingEnabled : 1;
190 bool m_useWideViewport : 1; 149 bool m_useWideViewport : 1;
191 bool m_loadWithOverviewMode : 1; 150 bool m_loadWithOverviewMode : 1;
192 151
193 SETTINGS_MEMBER_VARIABLES 152 SETTINGS_MEMBER_VARIABLES
194 153
195 bool m_isJavaEnabled : 1; 154 bool m_isJavaEnabled : 1;
(...skipping 16 matching lines...) Expand all
212 bool m_layerSquashingEnabled : 1; 171 bool m_layerSquashingEnabled : 1;
213 172
214 Timer<Settings> m_setImageLoadingSettingsTimer; 173 Timer<Settings> m_setImageLoadingSettingsTimer;
215 void imageLoadingSettingsTimerFired(Timer<Settings>*); 174 void imageLoadingSettingsTimerFired(Timer<Settings>*);
216 void recalculateTextAutosizingMultipliers(); 175 void recalculateTextAutosizingMultipliers();
217 }; 176 };
218 177
219 } // namespace WebCore 178 } // namespace WebCore
220 179
221 #endif // Settings_h 180 #endif // Settings_h
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorOverlay.cpp ('k') | Source/core/page/Settings.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698