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/AtomicString.h> |
44 | #include <wtf/text/AtomicStringHash.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 | static bool defaultTextAutosizingUsesIdempotentMode(); |
117 | WEBCORE_EXPORT static float defaultMinimumZoomFontSize(); |
118 | WEBCORE_EXPORT static bool defaultDownloadableBinaryFontsEnabled(); |
119 | WEBCORE_EXPORT static bool defaultContentChangeObserverEnabled(); |
120 | |
121 | #if ENABLE(MEDIA_SOURCE) |
122 | WEBCORE_EXPORT static bool platformDefaultMediaSourceEnabled(); |
123 | #endif |
124 | |
125 | static const unsigned defaultMaximumHTMLParserDOMTreeDepth = 512; |
126 | static const unsigned defaultMaximumRenderTreeDepth = 512; |
127 | |
128 | #if ENABLE(TEXT_AUTOSIZING) |
129 | constexpr static const float boostedOneLineTextMultiplierCoefficient = 2.23125f; |
130 | constexpr static const float boostedMultiLineTextMultiplierCoefficient = 2.48125f; |
131 | constexpr static const float boostedMaxTextAutosizingScaleIncrease = 5.0f; |
132 | constexpr static const float defaultOneLineTextMultiplierCoefficient = 1.7f; |
133 | constexpr static const float defaultMultiLineTextMultiplierCoefficient = 1.95f; |
134 | constexpr static const float defaultMaxTextAutosizingScaleIncrease = 1.7f; |
135 | #endif |
136 | |
137 | WEBCORE_EXPORT void setStandardFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
138 | WEBCORE_EXPORT const AtomicString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const; |
139 | |
140 | WEBCORE_EXPORT void setFixedFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
141 | WEBCORE_EXPORT const AtomicString& fixedFontFamily(UScriptCode = USCRIPT_COMMON) const; |
142 | |
143 | WEBCORE_EXPORT void setSerifFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
144 | WEBCORE_EXPORT const AtomicString& serifFontFamily(UScriptCode = USCRIPT_COMMON) const; |
145 | |
146 | WEBCORE_EXPORT void setSansSerifFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
147 | WEBCORE_EXPORT const AtomicString& sansSerifFontFamily(UScriptCode = USCRIPT_COMMON) const; |
148 | |
149 | WEBCORE_EXPORT void setCursiveFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
150 | WEBCORE_EXPORT const AtomicString& cursiveFontFamily(UScriptCode = USCRIPT_COMMON) const; |
151 | |
152 | WEBCORE_EXPORT void setFantasyFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
153 | WEBCORE_EXPORT const AtomicString& fantasyFontFamily(UScriptCode = USCRIPT_COMMON) const; |
154 | |
155 | WEBCORE_EXPORT void setPictographFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON); |
156 | WEBCORE_EXPORT const AtomicString& pictographFontFamily(UScriptCode = USCRIPT_COMMON) const; |
157 | |
158 | WEBCORE_EXPORT void setMinimumDOMTimerInterval(Seconds); // Initialized to DOMTimer::defaultMinimumInterval(). |
159 | Seconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; } |
160 | |
161 | WEBCORE_EXPORT void setLayoutInterval(Seconds); |
162 | Seconds layoutInterval() const { return m_layoutInterval; } |
163 | |
164 | #if ENABLE(TEXT_AUTOSIZING) |
165 | float oneLineTextMultiplierCoefficient() const { return m_oneLineTextMultiplierCoefficient; } |
166 | float multiLineTextMultiplierCoefficient() const { return m_multiLineTextMultiplierCoefficient; } |
167 | float maxTextAutosizingScaleIncrease() const { return m_maxTextAutosizingScaleIncrease; } |
168 | #endif |
169 | |
170 | WEBCORE_EXPORT static const String& defaultMediaContentTypesRequiringHardwareSupport(); |
171 | WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const Vector<ContentType>&); |
172 | WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const String&); |
173 | const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const { return m_mediaContentTypesRequiringHardwareSupport; } |
174 | |
175 | protected: |
176 | explicit SettingsBase(Page*); |
177 | |
178 | void initializeDefaultFontFamilies(); |
179 | |
180 | void imageLoadingSettingsTimerFired(); |
181 | |
182 | // Helpers used by generated Settings.cpp. |
183 | void setNeedsRecalcStyleInAllFrames(); |
184 | void setNeedsRelayoutAllFrames(); |
185 | void mediaTypeOverrideChanged(); |
186 | void imagesEnabledChanged(); |
187 | void pluginsEnabledChanged(); |
188 | void userStyleSheetLocationChanged(); |
189 | void usesPageCacheChanged(); |
190 | void dnsPrefetchingEnabledChanged(); |
191 | void storageBlockingPolicyChanged(); |
192 | void backgroundShouldExtendBeyondPageChanged(); |
193 | void scrollingPerformanceLoggingEnabledChanged(); |
194 | void hiddenPageDOMTimerThrottlingStateChanged(); |
195 | void hiddenPageCSSAnimationSuspensionEnabledChanged(); |
196 | void resourceUsageOverlayVisibleChanged(); |
197 | void iceCandidateFilteringEnabledChanged(); |
198 | #if ENABLE(TEXT_AUTOSIZING) |
199 | void shouldEnableTextAutosizingBoostChanged(); |
200 | #endif |
201 | #if ENABLE(MEDIA_STREAM) |
202 | void mockCaptureDevicesEnabledChanged(); |
203 | #endif |
204 | |
205 | Page* m_page; |
206 | |
207 | const std::unique_ptr<FontGenericFamilies> m_fontGenericFamilies; |
208 | Seconds m_layoutInterval; |
209 | Seconds m_minimumDOMTimerInterval; |
210 | |
211 | Timer m_setImageLoadingSettingsTimer; |
212 | |
213 | Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport; |
214 | |
215 | #if ENABLE(TEXT_AUTOSIZING) |
216 | float m_oneLineTextMultiplierCoefficient { defaultOneLineTextMultiplierCoefficient }; |
217 | float m_multiLineTextMultiplierCoefficient { defaultMultiLineTextMultiplierCoefficient }; |
218 | float m_maxTextAutosizingScaleIncrease { defaultMaxTextAutosizingScaleIncrease }; |
219 | #endif |
220 | |
221 | #if USE(APPLE_INTERNAL_SDK) |
222 | #include <WebKitAdditions/SettingsAdditions.h> |
223 | #endif |
224 | }; |
225 | |
226 | } // namespace WebCore |
227 | |