1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef RuntimeEnabledFeatures_h
#define RuntimeEnabledFeatures_h
#include "PlatformExportMacros.h"
#include <wtf/NeverDestroyed.h>
namespace WebCore {
// A class that stores static enablers for all experimental features. Note that
// the method names must line up with the JavaScript method they enable for code
// generation to work properly.
class RuntimeEnabledFeatures {
WTF_MAKE_NONCOPYABLE(RuntimeEnabledFeatures);
public:
void setLocalStorageEnabled(bool isEnabled) { m_isLocalStorageEnabled = isEnabled; }
bool localStorageEnabled() const { return m_isLocalStorageEnabled; }
void setSessionStorageEnabled(bool isEnabled) { m_isSessionStorageEnabled = isEnabled; }
bool sessionStorageEnabled() const { return m_isSessionStorageEnabled; }
void setWebkitNotificationsEnabled(bool isEnabled) { m_isWebkitNotificationsEnabled = isEnabled; }
bool webkitNotificationsEnabled() const { return m_isWebkitNotificationsEnabled; }
void setApplicationCacheEnabled(bool isEnabled) { m_isApplicationCacheEnabled = isEnabled; }
bool applicationCacheEnabled() const { return m_isApplicationCacheEnabled; }
void setDataTransferItemsEnabled(bool isEnabled) { m_isDataTransferItemsEnabled = isEnabled; }
bool dataTransferItemsEnabled() const { return m_isDataTransferItemsEnabled; }
void setGeolocationEnabled(bool isEnabled) { m_isGeolocationEnabled = isEnabled; }
bool geolocationEnabled() const { return m_isGeolocationEnabled; }
void setWebkitIndexedDBEnabled(bool isEnabled) { m_isIndexedDBEnabled = isEnabled; }
bool webkitIndexedDBEnabled() const { return m_isIndexedDBEnabled; }
bool indexedDBEnabled() const { return m_isIndexedDBEnabled; }
#if ENABLE(CSS_SHAPES)
void setCSSShapesEnabled(bool isEnabled) { m_isCSSShapesEnabled = isEnabled; }
bool cssShapesEnabled() const { return m_isCSSShapesEnabled; }
#else
void setCSSShapesEnabled(bool) { }
bool cssShapesEnabled() const { return false; }
#endif
#if ENABLE(CSS_REGIONS)
void setCSSRegionsEnabled(bool isEnabled) { m_isCSSRegionsEnabled = isEnabled; }
bool cssRegionsEnabled() const { return m_isCSSRegionsEnabled; }
#else
void setCSSRegionsEnabled(bool) { }
bool cssRegionsEnabled() const { return false; }
#endif
void setCSSCompositingEnabled(bool isEnabled) { m_isCSSCompositingEnabled = isEnabled; }
bool cssCompositingEnabled() const { return m_isCSSCompositingEnabled; }
#if ENABLE(FONT_LOAD_EVENTS)
void setFontLoadEventsEnabled(bool isEnabled) { m_isFontLoadEventsEnabled = isEnabled; }
bool fontLoadEventsEnabled() const { return m_isFontLoadEventsEnabled; }
#else
void setFontLoadEventsEnabled(bool) { }
bool fontLoadEventsEnabled() { return false; }
#endif
#if ENABLE(VIDEO)
bool audioEnabled() const;
bool htmlMediaElementEnabled() const;
bool htmlAudioElementEnabled() const;
bool htmlVideoElementEnabled() const;
bool htmlSourceElementEnabled() const;
bool mediaControllerEnabled() const;
bool mediaErrorEnabled() const;
bool timeRangesEnabled() const;
#endif
#if ENABLE(WEB_SOCKETS)
bool webSocketEnabled() const;
#endif
#if ENABLE(TOUCH_EVENTS)
bool touchEnabled() const { return m_isTouchEnabled; }
void setTouchEnabled(bool isEnabled) { m_isTouchEnabled = isEnabled; }
#endif
void setDeviceMotionEnabled(bool isEnabled) { m_isDeviceMotionEnabled = isEnabled; }
bool deviceMotionEnabled() const { return m_isDeviceMotionEnabled; }
bool deviceMotionEventEnabled() const { return m_isDeviceMotionEnabled; }
bool ondevicemotionEnabled() const { return m_isDeviceMotionEnabled; }
void setDeviceOrientationEnabled(bool isEnabled) { m_isDeviceOrientationEnabled = isEnabled; }
bool deviceOrientationEnabled() const { return m_isDeviceOrientationEnabled; }
bool deviceOrientationEventEnabled() const { return m_isDeviceOrientationEnabled; }
bool ondeviceorientationEnabled() const { return m_isDeviceOrientationEnabled; }
#if ENABLE(JAVASCRIPT_I18N_API)
bool javaScriptI18NAPIEnabled() const;
void setJavaScriptI18NAPIEnabled(bool isEnabled) { m_isJavaScriptI18NAPIEnabled = isEnabled; }
#endif
#if ENABLE(MEDIA_STREAM)
bool mediaStreamEnabled() const { return m_isMediaStreamEnabled; }
void setMediaStreamEnabled(bool isEnabled) { m_isMediaStreamEnabled = isEnabled; }
bool webkitGetUserMediaEnabled() const { return m_isMediaStreamEnabled; }
bool webkitMediaStreamEnabled() const { return m_isMediaStreamEnabled; }
bool peerConnectionEnabled() const { return m_isMediaStreamEnabled && m_isPeerConnectionEnabled; }
void setPeerConnectionEnabled(bool isEnabled) { m_isPeerConnectionEnabled = isEnabled; }
bool webkitRTCPeerConnectionEnabled() const { return peerConnectionEnabled(); }
#endif
#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES)
void setLegacyCSSVendorPrefixesEnabled(bool isEnabled) { m_isLegacyCSSVendorPrefixesEnabled = isEnabled; }
bool legacyCSSVendorPrefixesEnabled() const { return m_isLegacyCSSVendorPrefixesEnabled; }
#endif
#if ENABLE(VIDEO_TRACK)
bool webkitVideoTrackEnabled() const { return m_isVideoTrackEnabled; }
void setWebkitVideoTrackEnabled(bool isEnabled) { m_isVideoTrackEnabled = isEnabled; }
#endif
#if ENABLE(INPUT_TYPE_DATE)
bool inputTypeDateEnabled() const { return m_isInputTypeDateEnabled; }
void setInputTypeDateEnabled(bool isEnabled) { m_isInputTypeDateEnabled = isEnabled; }
#endif
#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE)
bool inputTypeDateTimeEnabled() const { return m_isInputTypeDateTimeEnabled; }
void setInputTypeDateTimeEnabled(bool isEnabled) { m_isInputTypeDateTimeEnabled = isEnabled; }
#endif
#if ENABLE(INPUT_TYPE_DATETIMELOCAL)
bool inputTypeDateTimeLocalEnabled() const { return m_isInputTypeDateTimeLocalEnabled; }
void setInputTypeDateTimeLocalEnabled(bool isEnabled) { m_isInputTypeDateTimeLocalEnabled = isEnabled; }
#endif
#if ENABLE(INPUT_TYPE_MONTH)
bool inputTypeMonthEnabled() const { return m_isInputTypeMonthEnabled; }
void setInputTypeMonthEnabled(bool isEnabled) { m_isInputTypeMonthEnabled = isEnabled; }
#endif
#if ENABLE(INPUT_TYPE_TIME)
bool inputTypeTimeEnabled() const { return m_isInputTypeTimeEnabled; }
void setInputTypeTimeEnabled(bool isEnabled) { m_isInputTypeTimeEnabled = isEnabled; }
#endif
#if ENABLE(INPUT_TYPE_WEEK)
bool inputTypeWeekEnabled() const { return m_isInputTypeWeekEnabled; }
void setInputTypeWeekEnabled(bool isEnabled) { m_isInputTypeWeekEnabled = isEnabled; }
#endif
#if ENABLE(CSP_NEXT)
bool experimentalContentSecurityPolicyFeaturesEnabled() const { return m_areExperimentalContentSecurityPolicyFeaturesEnabled; }
void setExperimentalContentSecurityPolicyFeaturesEnabled(bool isEnabled) { m_areExperimentalContentSecurityPolicyFeaturesEnabled = isEnabled; }
#endif
bool langAttributeAwareFormControlUIEnabled() const { return m_isLangAttributeAwareFormControlUIEnabled; }
// The lang attribute support is incomplete and should only be turned on for tests.
void setLangAttributeAwareFormControlUIEnabled(bool isEnabled) { m_isLangAttributeAwareFormControlUIEnabled = isEnabled; }
void setPluginReplacementEnabled(bool isEnabled) { m_isPluginReplacementEnabled = isEnabled; }
bool pluginReplacementEnabled() const { return m_isPluginReplacementEnabled; }
#if ENABLE(GAMEPAD)
void setGamepadsEnabled(bool areEnabled) { m_areGamepadsEnabled = areEnabled; }
bool gamepadsEnabled() const { return m_areGamepadsEnabled; }
#endif
#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
void setAnimationTriggersEnabled(bool areEnabled) { m_areAnimationTriggersEnabled = areEnabled; }
bool animationTriggersEnabled() const { return m_areAnimationTriggersEnabled; }
#endif
#if ENABLE(WEB_ANIMATIONS)
void setWebAnimationsEnabled(bool areEnabled) { m_areWebAnimationsEnabled = areEnabled; }
bool webAnimationsEnabled() const { return m_areWebAnimationsEnabled; }
#endif
WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures();
private:
// Never instantiate.
RuntimeEnabledFeatures();
bool m_isLocalStorageEnabled;
bool m_isSessionStorageEnabled;
bool m_isWebkitNotificationsEnabled;
bool m_isApplicationCacheEnabled;
bool m_isDataTransferItemsEnabled;
bool m_isGeolocationEnabled;
bool m_isIndexedDBEnabled;
bool m_isTouchEnabled;
bool m_isDeviceMotionEnabled;
bool m_isDeviceOrientationEnabled;
bool m_isCSSShapesEnabled;
bool m_isCSSRegionsEnabled;
bool m_isCSSCompositingEnabled;
bool m_isLangAttributeAwareFormControlUIEnabled;
bool m_isPluginReplacementEnabled;
#if ENABLE(JAVASCRIPT_I18N_API)
bool m_isJavaScriptI18NAPIEnabled;
#endif
#if ENABLE(MEDIA_STREAM)
bool m_isMediaStreamEnabled;
bool m_isPeerConnectionEnabled;
#endif
#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES)
bool m_isLegacyCSSVendorPrefixesEnabled;
#endif
#if ENABLE(VIDEO_TRACK)
bool m_isVideoTrackEnabled;
#endif
#if ENABLE(INPUT_TYPE_DATE)
bool m_isInputTypeDateEnabled;
#endif
#if ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE)
bool m_isInputTypeDateTimeEnabled;
#endif
#if ENABLE(INPUT_TYPE_DATETIMELOCAL)
bool m_isInputTypeDateTimeLocalEnabled;
#endif
#if ENABLE(INPUT_TYPE_MONTH)
bool m_isInputTypeMonthEnabled;
#endif
#if ENABLE(INPUT_TYPE_TIME)
bool m_isInputTypeTimeEnabled;
#endif
#if ENABLE(INPUT_TYPE_WEEK)
bool m_isInputTypeWeekEnabled;
#endif
#if ENABLE(CSP_NEXT)
bool m_areExperimentalContentSecurityPolicyFeaturesEnabled;
#endif
#if ENABLE(FONT_LOAD_EVENTS)
bool m_isFontLoadEventsEnabled;
#endif
#if ENABLE(GAMEPAD)
bool m_areGamepadsEnabled;
#endif
#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
bool m_areAnimationTriggersEnabled;
#endif
#if ENABLE(WEB_ANIMATIONS)
bool m_areWebAnimationsEnabled;
#endif
friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
};
} // namespace WebCore
#endif // RuntimeEnabledFeatures_h
|