Remove ENABLE(TEXT_AUTOSIZING) automatic text size adjustment code
[WebKit-https.git] / Source / WebCore / testing / InternalSettings.cpp
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013 Apple Inc. All rights reserved.
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  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "InternalSettings.h"
29
30 #include "CaptionUserPreferences.h"
31 #include "Document.h"
32 #include "ExceptionCode.h"
33 #include "FrameView.h"
34 #include "Language.h"
35 #include "LocaleToScriptMapping.h"
36 #include "MainFrame.h"
37 #include "Page.h"
38 #include "PageGroup.h"
39 #include "RuntimeEnabledFeatures.h"
40 #include "Settings.h"
41 #include "Supplementable.h"
42 #include "TextRun.h"
43
44 #if ENABLE(INPUT_TYPE_COLOR)
45 #include "ColorChooser.h"
46 #endif
47
48 #define InternalSettingsGuardForSettingsReturn(returnValue) \
49     if (!settings()) { \
50         ec = INVALID_ACCESS_ERR; \
51         return returnValue; \
52     }
53
54 #define InternalSettingsGuardForSettings()  \
55     if (!settings()) { \
56         ec = INVALID_ACCESS_ERR; \
57         return; \
58     }
59
60 #define InternalSettingsGuardForPage() \
61     if (!page()) { \
62         ec = INVALID_ACCESS_ERR; \
63         return; \
64     }
65
66 namespace WebCore {
67
68 InternalSettings::Backup::Backup(Settings& settings)
69     : m_originalEditingBehavior(settings.editingBehaviorType())
70 #if ENABLE(IOS_TEXT_AUTOSIZING)
71     , m_originalTextAutosizingEnabled(settings.textAutosizingEnabled())
72     , m_originalTextAutosizingWindowSizeOverride(settings.textAutosizingWindowSizeOverride())
73 #endif
74     , m_originalMediaTypeOverride(settings.mediaTypeOverride())
75     , m_originalCanvasUsesAcceleratedDrawing(settings.canvasUsesAcceleratedDrawing())
76     , m_originalMockScrollbarsEnabled(settings.mockScrollbarsEnabled())
77     , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::sharedFeatures().langAttributeAwareFormControlUIEnabled())
78     , m_imagesEnabled(settings.areImagesEnabled())
79     , m_preferMIMETypeForImages(settings.preferMIMETypeForImages())
80     , m_minimumTimerInterval(settings.minimumDOMTimerInterval())
81 #if ENABLE(VIDEO_TRACK)
82     , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
83     , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
84     , m_shouldDisplayTextDescriptions(settings.shouldDisplayTextDescriptions())
85 #endif
86     , m_defaultVideoPosterURL(settings.defaultVideoPosterURL())
87     , m_forcePendingWebGLPolicy(settings.isForcePendingWebGLPolicy())
88     , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings.timeWithoutMouseMovementBeforeHidingControls())
89     , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
90     , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
91     , m_quickTimePluginReplacementEnabled(settings.quickTimePluginReplacementEnabled())
92     , m_youTubeFlashPluginReplacementEnabled(settings.youTubeFlashPluginReplacementEnabled())
93     , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
94     , m_fontFallbackPrefersPictographs(settings.fontFallbackPrefersPictographs())
95     , m_webFontsAlwaysFallBack(settings.webFontsAlwaysFallBack())
96     , m_backgroundShouldExtendBeyondPage(settings.backgroundShouldExtendBeyondPage())
97     , m_storageBlockingPolicy(settings.storageBlockingPolicy())
98     , m_scrollingTreeIncludesFrames(settings.scrollingTreeIncludesFrames())
99 #if ENABLE(TOUCH_EVENTS)
100     , m_touchEventEmulationEnabled(settings.isTouchEventEmulationEnabled())
101 #endif
102 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
103     , m_allowsAirPlayForMediaPlayback(settings.allowsAirPlayForMediaPlayback())
104 #endif
105     , m_allowsInlineMediaPlayback(settings.allowsInlineMediaPlayback())
106     , m_allowsInlineMediaPlaybackAfterFullscreen(settings.allowsInlineMediaPlaybackAfterFullscreen())
107     , m_inlineMediaPlaybackRequiresPlaysInlineAttribute(settings.inlineMediaPlaybackRequiresPlaysInlineAttribute())
108 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
109     , m_indexedDBWorkersEnabled(RuntimeEnabledFeatures::sharedFeatures().indexedDBWorkersEnabled())
110 #endif
111     , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
112     , m_systemLayoutDirection(settings.systemLayoutDirection())
113     , m_pdfImageCachingPolicy(settings.pdfImageCachingPolicy())
114 {
115 }
116
117 void InternalSettings::Backup::restoreTo(Settings& settings)
118 {
119     settings.setEditingBehaviorType(m_originalEditingBehavior);
120
121     for (const auto& standardFont : m_standardFontFamilies)
122         settings.setStandardFontFamily(standardFont.value, static_cast<UScriptCode>(standardFont.key));
123     m_standardFontFamilies.clear();
124
125     for (const auto& fixedFont : m_fixedFontFamilies)
126         settings.setFixedFontFamily(fixedFont.value, static_cast<UScriptCode>(fixedFont.key));
127     m_fixedFontFamilies.clear();
128
129     for (const auto& serifFont : m_serifFontFamilies)
130         settings.setSerifFontFamily(serifFont.value, static_cast<UScriptCode>(serifFont.key));
131     m_serifFontFamilies.clear();
132
133     for (const auto& sansSerifFont : m_sansSerifFontFamilies)
134         settings.setSansSerifFontFamily(sansSerifFont.value, static_cast<UScriptCode>(sansSerifFont.key));
135     m_sansSerifFontFamilies.clear();
136
137     for (const auto& cursiveFont : m_cursiveFontFamilies)
138         settings.setCursiveFontFamily(cursiveFont.value, static_cast<UScriptCode>(cursiveFont.key));
139     m_cursiveFontFamilies.clear();
140
141     for (const auto& fantasyFont : m_fantasyFontFamilies)
142         settings.setFantasyFontFamily(fantasyFont.value, static_cast<UScriptCode>(fantasyFont.key));
143     m_fantasyFontFamilies.clear();
144
145     for (const auto& pictographFont : m_pictographFontFamilies)
146         settings.setPictographFontFamily(pictographFont.value, static_cast<UScriptCode>(pictographFont.key));
147     m_pictographFontFamilies.clear();
148
149 #if ENABLE(IOS_TEXT_AUTOSIZING)
150     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
151     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
152 #endif
153     settings.setMediaTypeOverride(m_originalMediaTypeOverride);
154     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
155     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
156     settings.setImagesEnabled(m_imagesEnabled);
157     settings.setPreferMIMETypeForImages(m_preferMIMETypeForImages);
158     settings.setMinimumDOMTimerInterval(m_minimumTimerInterval);
159 #if ENABLE(VIDEO_TRACK)
160     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
161     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
162     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
163 #endif
164     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
165     settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
166     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
167     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
168     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
169     settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
170     settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
171     settings.setWebFontsAlwaysFallBack(m_webFontsAlwaysFallBack);
172     settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
173     settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
174     settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
175 #if ENABLE(TOUCH_EVENTS)
176     settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
177 #endif
178     settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
179     settings.setAllowsInlineMediaPlaybackAfterFullscreen(m_allowsInlineMediaPlaybackAfterFullscreen);
180     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
181     settings.setQuickTimePluginReplacementEnabled(m_quickTimePluginReplacementEnabled);
182     settings.setYouTubeFlashPluginReplacementEnabled(m_youTubeFlashPluginReplacementEnabled);
183 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
184     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
185 #endif
186     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
187     settings.setSystemLayoutDirection(m_systemLayoutDirection);
188     settings.setPdfImageCachingPolicy(m_pdfImageCachingPolicy);
189     Settings::setAllowsAnySSLCertificate(false);
190 }
191
192 class InternalSettingsWrapper : public Supplement<Page> {
193 public:
194     explicit InternalSettingsWrapper(Page* page)
195         : m_internalSettings(InternalSettings::create(page)) { }
196     virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
197 #if !ASSERT_DISABLED
198     bool isRefCountedWrapper() const override { return true; }
199 #endif
200     InternalSettings* internalSettings() const { return m_internalSettings.get(); }
201
202 private:
203     RefPtr<InternalSettings> m_internalSettings;
204 };
205
206 const char* InternalSettings::supplementName()
207 {
208     return "InternalSettings";
209 }
210
211 InternalSettings* InternalSettings::from(Page* page)
212 {
213     if (!Supplement<Page>::from(page, supplementName()))
214         Supplement<Page>::provideTo(page, supplementName(), std::make_unique<InternalSettingsWrapper>(page));
215     return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
216 }
217
218 InternalSettings::~InternalSettings()
219 {
220 }
221
222 InternalSettings::InternalSettings(Page* page)
223     : InternalSettingsGenerated(page)
224     , m_page(page)
225     , m_backup(page->settings())
226 {
227 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
228     setAllowsAirPlayForMediaPlayback(false);
229 #endif
230 }
231
232 void InternalSettings::resetToConsistentState()
233 {
234     page()->setPageScaleFactor(1, { 0, 0 });
235     page()->mainFrame().setPageAndTextZoomFactors(1, 1);
236     page()->setCanStartMedia(true);
237     page()->settings().setForcePendingWebGLPolicy(false);
238 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
239     setAllowsAirPlayForMediaPlayback(false);
240 #endif
241
242     m_backup.restoreTo(*settings());
243     m_backup = Backup(*settings());
244
245     InternalSettingsGenerated::resetToConsistentState();
246 }
247
248 Settings* InternalSettings::settings() const
249 {
250     if (!page())
251         return 0;
252     return &page()->settings();
253 }
254
255 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
256 {
257 #if ENABLE(TOUCH_EVENTS)
258     InternalSettingsGuardForSettings();
259     settings()->setTouchEventEmulationEnabled(enabled);
260 #else
261     UNUSED_PARAM(enabled);
262     UNUSED_PARAM(ec);
263 #endif
264 }
265
266 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
267 {
268     InternalSettingsGuardForSettings();
269     UScriptCode code = scriptNameToCode(script);
270     if (code == USCRIPT_INVALID_CODE)
271         return;
272     m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
273     settings()->setStandardFontFamily(family, code);
274 }
275
276 void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
277 {
278     InternalSettingsGuardForSettings();
279     UScriptCode code = scriptNameToCode(script);
280     if (code == USCRIPT_INVALID_CODE)
281         return;
282     m_backup.m_serifFontFamilies.add(code, settings()->serifFontFamily(code));
283     settings()->setSerifFontFamily(family, code);
284 }
285
286 void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
287 {
288     InternalSettingsGuardForSettings();
289     UScriptCode code = scriptNameToCode(script);
290     if (code == USCRIPT_INVALID_CODE)
291         return;
292     m_backup.m_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
293     settings()->setSansSerifFontFamily(family, code);
294 }
295
296 void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
297 {
298     InternalSettingsGuardForSettings();
299     UScriptCode code = scriptNameToCode(script);
300     if (code == USCRIPT_INVALID_CODE)
301         return;
302     m_backup.m_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
303     settings()->setFixedFontFamily(family, code);
304 }
305
306 void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
307 {
308     InternalSettingsGuardForSettings();
309     UScriptCode code = scriptNameToCode(script);
310     if (code == USCRIPT_INVALID_CODE)
311         return;
312     m_backup.m_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
313     settings()->setCursiveFontFamily(family, code);
314 }
315
316 void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
317 {
318     InternalSettingsGuardForSettings();
319     UScriptCode code = scriptNameToCode(script);
320     if (code == USCRIPT_INVALID_CODE)
321         return;
322     m_backup.m_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
323     settings()->setFantasyFontFamily(family, code);
324 }
325
326 void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
327 {
328     InternalSettingsGuardForSettings();
329     UScriptCode code = scriptNameToCode(script);
330     if (code == USCRIPT_INVALID_CODE)
331         return;
332     m_backup.m_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
333     settings()->setPictographFontFamily(family, code);
334 }
335
336 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
337 {
338 #if ENABLE(IOS_TEXT_AUTOSIZING)
339     InternalSettingsGuardForSettings();
340     settings()->setTextAutosizingEnabled(enabled);
341 #else
342     UNUSED_PARAM(enabled);
343     UNUSED_PARAM(ec);
344 #endif
345 }
346
347 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
348 {
349 #if ENABLE(IOS_TEXT_AUTOSIZING)
350     InternalSettingsGuardForSettings();
351     settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
352 #else
353     UNUSED_PARAM(width);
354     UNUSED_PARAM(height);
355     UNUSED_PARAM(ec);
356 #endif
357 }
358
359 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
360 {
361     InternalSettingsGuardForSettings();
362     settings()->setMediaTypeOverride(mediaType);
363 }
364
365 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
366 {
367     InternalSettingsGuardForSettings();
368     m_page->setCanStartMedia(enabled);
369 }
370
371 void InternalSettings::setAllowsAirPlayForMediaPlayback(bool allows)
372 {
373 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
374     m_page->settings().setAllowsAirPlayForMediaPlayback(allows);
375 #else
376     UNUSED_PARAM(allows);
377 #endif
378 }
379
380 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
381 {
382     InternalSettingsGuardForSettings();
383     if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
384         settings()->setEditingBehaviorType(EditingWindowsBehavior);
385     else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
386         settings()->setEditingBehaviorType(EditingMacBehavior);
387     else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
388         settings()->setEditingBehaviorType(EditingUnixBehavior);
389     else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
390         settings()->setEditingBehaviorType(EditingIOSBehavior);
391     else
392         ec = SYNTAX_ERR;
393 }
394
395 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
396 {
397     InternalSettingsGuardForSettings();
398
399 #if ENABLE(VIDEO_TRACK)
400     if (!page())
401         return;
402
403     auto& captionPreferences = page()->group().captionPreferences();
404     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
405         captionPreferences.setUserPrefersSubtitles(enabled);
406     else if (equalLettersIgnoringASCIICase(kind, "captions"))
407         captionPreferences.setUserPrefersCaptions(enabled);
408     else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
409         captionPreferences.setUserPrefersTextDescriptions(enabled);
410     else
411         ec = SYNTAX_ERR;
412 #else
413     UNUSED_PARAM(kind);
414     UNUSED_PARAM(enabled);
415 #endif
416 }
417
418 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
419 {
420     InternalSettingsGuardForSettingsReturn(false);
421
422 #if ENABLE(VIDEO_TRACK)
423     if (!page())
424         return false;
425
426     auto& captionPreferences = page()->group().captionPreferences();
427     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
428         return captionPreferences.userPrefersSubtitles();
429     if (equalLettersIgnoringASCIICase(kind, "captions"))
430         return captionPreferences.userPrefersCaptions();
431     if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
432         return captionPreferences.userPrefersTextDescriptions();
433
434     ec = SYNTAX_ERR;
435     return false;
436 #else
437     UNUSED_PARAM(kind);
438     return false;
439 #endif
440 }
441
442 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
443 {
444     InternalSettingsGuardForSettings();
445
446     if (mode == "AllowAll")
447         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
448     else if (mode == "BlockThirdParty")
449         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
450     else if (mode == "BlockAll")
451         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
452     else
453         ec = SYNTAX_ERR;
454 }
455
456 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
457 {
458     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
459 }
460
461 void InternalSettings::setPreferMIMETypeForImages(bool preferMIMETypeForImages, ExceptionCode &ec)
462 {
463     InternalSettingsGuardForSettings();
464     settings()->setPreferMIMETypeForImages(preferMIMETypeForImages);
465 }
466
467 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
468 {
469     InternalSettingsGuardForSettings();
470     settings()->setImagesEnabled(enabled);
471 }
472
473 void InternalSettings::setPDFImageCachingPolicy(const String& policy, ExceptionCode& ec)
474 {
475     InternalSettingsGuardForSettings();
476     if (equalLettersIgnoringASCIICase(policy, "disabled"))
477         settings()->setPdfImageCachingPolicy(PDFImageCachingDisabled);
478     else if (equalLettersIgnoringASCIICase(policy, "belowmemorylimit"))
479         settings()->setPdfImageCachingPolicy(PDFImageCachingBelowMemoryLimit);
480     else if (equalLettersIgnoringASCIICase(policy, "clipboundsonly"))
481         settings()->setPdfImageCachingPolicy(PDFImageCachingClipBoundsOnly);
482     else if (equalLettersIgnoringASCIICase(policy, "enabled"))
483         settings()->setPdfImageCachingPolicy(PDFImageCachingEnabled);
484     else
485         ec = SYNTAX_ERR;
486 }
487
488 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
489 {
490     InternalSettingsGuardForSettings();
491     settings()->setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
492 }
493
494 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
495 {
496     InternalSettingsGuardForSettings();
497     settings()->setDefaultVideoPosterURL(url);
498 }
499
500 void InternalSettings::setForcePendingWebGLPolicy(bool forced, ExceptionCode& ec)
501 {
502     InternalSettingsGuardForSettings();
503     settings()->setForcePendingWebGLPolicy(forced);
504 }
505
506 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
507 {
508     InternalSettingsGuardForSettings();
509     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
510 }
511
512 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
513 {
514     InternalSettingsGuardForSettings();
515     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
516 }
517
518 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
519 {
520     InternalSettingsGuardForSettings();
521     settings()->setAutoscrollForDragAndDropEnabled(enabled);
522 }
523
524 void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
525 {
526     InternalSettingsGuardForSettings();
527     settings()->setFontFallbackPrefersPictographs(preferPictographs);
528 }
529
530 void InternalSettings::setWebFontsAlwaysFallBack(bool enable, ExceptionCode& ec)
531 {
532     InternalSettingsGuardForSettings();
533     settings()->setWebFontsAlwaysFallBack(enable);
534 }
535
536 void InternalSettings::setQuickTimePluginReplacementEnabled(bool enabled, ExceptionCode& ec)
537 {
538     InternalSettingsGuardForSettings();
539     settings()->setQuickTimePluginReplacementEnabled(enabled);
540 }
541
542 void InternalSettings::setYouTubeFlashPluginReplacementEnabled(bool enabled, ExceptionCode& ec)
543 {
544     InternalSettingsGuardForSettings();
545     settings()->setYouTubeFlashPluginReplacementEnabled(enabled);
546 }
547
548 void InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode& ec)
549 {
550     InternalSettingsGuardForSettings();
551     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
552 }
553
554 void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
555 {
556     InternalSettingsGuardForSettings();
557     settings()->setShouldConvertPositionStyleOnCopy(convert);
558 }
559
560 void InternalSettings::setScrollingTreeIncludesFrames(bool enabled, ExceptionCode& ec)
561 {
562     InternalSettingsGuardForSettings();
563     settings()->setScrollingTreeIncludesFrames(enabled);
564 }
565
566 void InternalSettings::setAllowsInlineMediaPlayback(bool allows, ExceptionCode& ec)
567 {
568     InternalSettingsGuardForSettings();
569     settings()->setAllowsInlineMediaPlayback(allows);
570 }
571
572 void InternalSettings::setAllowsInlineMediaPlaybackAfterFullscreen(bool allows, ExceptionCode& ec)
573 {
574     InternalSettingsGuardForSettings();
575     settings()->setAllowsInlineMediaPlaybackAfterFullscreen(allows);
576 }
577
578 void InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires, ExceptionCode& ec)
579 {
580     InternalSettingsGuardForSettings();
581     settings()->setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
582 }
583
584 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled, ExceptionCode&)
585 {
586 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
587     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
588 #else
589     UNUSED_PARAM(enabled);
590 #endif
591 }
592
593 String InternalSettings::userInterfaceDirectionPolicy(ExceptionCode& ec)
594 {
595     InternalSettingsGuardForSettingsReturn("");
596     switch (settings()->userInterfaceDirectionPolicy()) {
597     case UserInterfaceDirectionPolicy::Content:
598         return ASCIILiteral("Content");
599     case UserInterfaceDirectionPolicy::System:
600         return ASCIILiteral("View");
601     }
602     ASSERT_NOT_REACHED();
603     return String();
604 }
605
606 void InternalSettings::setUserInterfaceDirectionPolicy(const String& policy, ExceptionCode& ec)
607 {
608     InternalSettingsGuardForSettings();
609     if (equalLettersIgnoringASCIICase(policy, "content")) {
610         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
611         return;
612     }
613     if (equalLettersIgnoringASCIICase(policy, "view")) {
614         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
615         return;
616     }
617     ec = INVALID_ACCESS_ERR;
618 }
619
620 String InternalSettings::systemLayoutDirection(ExceptionCode& ec)
621 {
622     InternalSettingsGuardForSettingsReturn("");
623     switch (settings()->systemLayoutDirection()) {
624     case LTR:
625         return ASCIILiteral("LTR");
626     case RTL:
627         return ASCIILiteral("RTL");
628     }
629     ASSERT_NOT_REACHED();
630     return String();
631 }
632
633 void InternalSettings::setSystemLayoutDirection(const String& direction, ExceptionCode& ec)
634 {
635     InternalSettingsGuardForSettings();
636     if (equalLettersIgnoringASCIICase(direction, "ltr")) {
637         settings()->setSystemLayoutDirection(LTR);
638         return;
639     }
640     if (equalLettersIgnoringASCIICase(direction, "rtl")) {
641         settings()->setSystemLayoutDirection(RTL);
642         return;
643     }
644     ec = INVALID_ACCESS_ERR;
645 }
646
647 void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
648 {
649     Settings::setAllowsAnySSLCertificate(allowsAnyCertificate);
650 }
651
652 // If you add to this list, make sure that you update the Backup class for test reproducability!
653
654 }