1 | /* |
2 | * Copyright (C) 2003-2016 Apple Inc. All rights reserved. |
3 | * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
18 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
19 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
20 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
21 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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. |
25 | */ |
26 | |
27 | #pragma once |
28 | |
29 | #include "ClipboardAccessPolicy.h" |
30 | #include "ContentType.h" |
31 | #include "EditingBehaviorTypes.h" |
32 | #include "IntSize.h" |
33 | #include "SecurityOrigin.h" |
34 | #include "StorageMap.h" |
35 | #include "TextFlags.h" |
36 | #include "Timer.h" |
37 | #include <wtf/URL.h> |
38 | #include "WritingMode.h" |
39 | #include <JavaScriptCore/RuntimeFlags.h> |
40 | #include <unicode/uscript.h> |
41 | #include <wtf/HashMap.h> |
42 | #include <wtf/RefCounted.h> |
43 | #include <wtf/text/AtomString.h> |
44 | #include <wtf/text/AtomStringHash.h> |
45 | |
46 | #if ENABLE(DATA_DETECTION) |
47 | #include "DataDetection.h" |
48 | #endif |
49 | |
50 | namespace WebCore { |
51 | |
52 | class FontGenericFamilies; |
53 | class Page; |
54 | |
55 | enum EditableLinkBehavior { |
56 | EditableLinkDefaultBehavior, |
57 | EditableLinkAlwaysLive, |
58 | EditableLinkOnlyLiveWithShiftKey, |
59 | EditableLinkLiveWhenNotFocused, |
60 | EditableLinkNeverLive |
61 | }; |
62 | |
63 | enum { |
64 | , |
65 | , |
66 | |
67 | }; |
68 | |
69 | enum DebugOverlayRegionFlags { |
70 | NonFastScrollableRegion = 1 << 0, |
71 | WheelEventHandlerRegion = 1 << 1, |
72 | }; |
73 | |
74 | enum class UserInterfaceDirectionPolicy { |
75 | Content, |
76 | System |
77 | }; |
78 | |
79 | enum PDFImageCachingPolicy { |
80 | PDFImageCachingEnabled, |
81 | PDFImageCachingBelowMemoryLimit, |
82 | PDFImageCachingDisabled, |
83 | PDFImageCachingClipBoundsOnly, |
84 | #if PLATFORM(IOS_FAMILY) |
85 | PDFImageCachingDefault = PDFImageCachingBelowMemoryLimit |
86 | #else |
87 | PDFImageCachingDefault = PDFImageCachingEnabled |
88 | #endif |
89 | }; |
90 | |
91 | enum class FrameFlattening { |
92 | Disabled, |
93 | EnabledForNonFullScreenIFrames, |
94 | FullyEnabled |
95 | }; |
96 | |
97 | typedef unsigned DebugOverlayRegions; |
98 | |
99 | class SettingsBase { |
100 | WTF_MAKE_NONCOPYABLE(SettingsBase); WTF_MAKE_FAST_ALLOCATED; |
101 | public: |
102 | ~SettingsBase(); |
103 | |
104 | void pageDestroyed() { m_page = nullptr; } |
105 | |
106 | enum class FontLoadTimingOverride { None, Block, Swap, Failure }; |
107 | |
108 | // FIXME: Move these default values to SettingsDefaultValues.h |
109 | |
110 | enum class ForcedAccessibilityValue { System, On, Off }; |
111 | static const SettingsBase::ForcedAccessibilityValue defaultForcedColorsAreInvertedAccessibilityValue = ForcedAccessibilityValue::System; |
112 | static const SettingsBase::ForcedAccessibilityValue defaultForcedDisplayIsMonochromeAccessibilityValue = ForcedAccessibilityValue::System; |
113 | static const SettingsBase::ForcedAccessibilityValue defaultForcedPrefersReducedMotionAccessibilityValue = ForcedAccessibilityValue::System; |
114 | |
115 | WEBCORE_EXPORT static bool defaultTextAutosizingEnabled(); |
116 | WEBCORE_EXPORT static float defaultMinimumZoomFontSize(); |
117 | WEBCORE_EXPORT static bool defaultDownloadableBinaryFontsEnabled(); |
118 | WEBCORE_EXPORT static bool defaultContentChangeObserverEnabled(); |
119 | |
120 | #if ENABLE(MEDIA_SOURCE) |
121 | WEBCORE_EXPORT static bool platformDefaultMediaSourceEnabled(); |
122 | #endif |
123 | |
124 | static const unsigned defaultMaximumHTMLParserDOMTreeDepth = 512; |
125 | static const unsigned defaultMaximumRenderTreeDepth = 512; |
126 | |
127 | #if ENABLE(TEXT_AUTOSIZING) |
128 | constexpr static const float boostedOneLineTextMultiplierCoefficient = 2.23125f; |
129 | constexpr static const float boostedMultiLineTextMultiplierCoefficient = 2.48125f; |
130 | constexpr static const float boostedMaxTextAutosizingScaleIncrease = 5.0f; |
131 | constexpr static const float defaultOneLineTextMultiplierCoefficient = 1.7f; |
132 | constexpr static const float defaultMultiLineTextMultiplierCoefficient = 1.95f; |
133 | constexpr static const float defaultMaxTextAutosizingScaleIncrease = 1.7f; |
134 | #endif |
135 | |
136 | WEBCORE_EXPORT void setStandardFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
137 | WEBCORE_EXPORT const AtomString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const; |
138 | |
139 | WEBCORE_EXPORT void setFixedFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
140 | WEBCORE_EXPORT const AtomString& fixedFontFamily(UScriptCode = USCRIPT_COMMON) const; |
141 | |
142 | WEBCORE_EXPORT void setSerifFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
143 | WEBCORE_EXPORT const AtomString& serifFontFamily(UScriptCode = USCRIPT_COMMON) const; |
144 | |
145 | WEBCORE_EXPORT void setSansSerifFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
146 | WEBCORE_EXPORT const AtomString& sansSerifFontFamily(UScriptCode = USCRIPT_COMMON) const; |
147 | |
148 | WEBCORE_EXPORT void setCursiveFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
149 | WEBCORE_EXPORT const AtomString& cursiveFontFamily(UScriptCode = USCRIPT_COMMON) const; |
150 | |
151 | WEBCORE_EXPORT void setFantasyFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
152 | WEBCORE_EXPORT const AtomString& fantasyFontFamily(UScriptCode = USCRIPT_COMMON) const; |
153 | |
154 | WEBCORE_EXPORT void setPictographFontFamily(const AtomString&, UScriptCode = USCRIPT_COMMON); |
155 | WEBCORE_EXPORT const AtomString& pictographFontFamily(UScriptCode = USCRIPT_COMMON) const; |
156 | |
157 | WEBCORE_EXPORT void setMinimumDOMTimerInterval(Seconds); // Initialized to DOMTimer::defaultMinimumInterval(). |
158 | Seconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; } |
159 | |
160 | WEBCORE_EXPORT void setLayoutInterval(Seconds); |
161 | Seconds layoutInterval() const { return m_layoutInterval; } |
162 | |
163 | #if ENABLE(TEXT_AUTOSIZING) |
164 | float oneLineTextMultiplierCoefficient() const { return m_oneLineTextMultiplierCoefficient; } |
165 | float multiLineTextMultiplierCoefficient() const { return m_multiLineTextMultiplierCoefficient; } |
166 | float maxTextAutosizingScaleIncrease() const { return m_maxTextAutosizingScaleIncrease; } |
167 | #endif |
168 | |
169 | WEBCORE_EXPORT static const String& defaultMediaContentTypesRequiringHardwareSupport(); |
170 | WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const Vector<ContentType>&); |
171 | WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const String&); |
172 | const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const { return m_mediaContentTypesRequiringHardwareSupport; } |
173 | |
174 | protected: |
175 | explicit SettingsBase(Page*); |
176 | |
177 | void initializeDefaultFontFamilies(); |
178 | |
179 | void imageLoadingSettingsTimerFired(); |
180 | |
181 | // Helpers used by generated Settings.cpp. |
182 | void setNeedsRecalcStyleInAllFrames(); |
183 | void setNeedsRelayoutAllFrames(); |
184 | void mediaTypeOverrideChanged(); |
185 | void imagesEnabledChanged(); |
186 | void pluginsEnabledChanged(); |
187 | void userStyleSheetLocationChanged(); |
188 | void usesPageCacheChanged(); |
189 | void dnsPrefetchingEnabledChanged(); |
190 | void storageBlockingPolicyChanged(); |
191 | void backgroundShouldExtendBeyondPageChanged(); |
192 | void scrollingPerformanceLoggingEnabledChanged(); |
193 | void hiddenPageDOMTimerThrottlingStateChanged(); |
194 | void hiddenPageCSSAnimationSuspensionEnabledChanged(); |
195 | void resourceUsageOverlayVisibleChanged(); |
196 | void iceCandidateFilteringEnabledChanged(); |
197 | #if ENABLE(TEXT_AUTOSIZING) |
198 | void shouldEnableTextAutosizingBoostChanged(); |
199 | #endif |
200 | #if ENABLE(MEDIA_STREAM) |
201 | void mockCaptureDevicesEnabledChanged(); |
202 | #endif |
203 | |
204 | Page* m_page; |
205 | |
206 | const std::unique_ptr<FontGenericFamilies> m_fontGenericFamilies; |
207 | Seconds m_layoutInterval; |
208 | Seconds m_minimumDOMTimerInterval; |
209 | |
210 | Timer m_setImageLoadingSettingsTimer; |
211 | |
212 | Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport; |
213 | |
214 | #if ENABLE(TEXT_AUTOSIZING) |
215 | float m_oneLineTextMultiplierCoefficient { defaultOneLineTextMultiplierCoefficient }; |
216 | float m_multiLineTextMultiplierCoefficient { defaultMultiLineTextMultiplierCoefficient }; |
217 | float m_maxTextAutosizingScaleIncrease { defaultMaxTextAutosizingScaleIncrease }; |
218 | #endif |
219 | }; |
220 | |
221 | } // namespace WebCore |
222 | |