Put variation fonts work behind a compile-time flag
[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(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 #if ENABLE(VARIATION_FONTS)
112     , m_variationFontsEnabled(settings.variationFontsEnabled())
113 #endif
114     , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
115     , m_systemLayoutDirection(settings.systemLayoutDirection())
116     , m_pdfImageCachingPolicy(settings.pdfImageCachingPolicy())
117 {
118 }
119
120 void InternalSettings::Backup::restoreTo(Settings& settings)
121 {
122     settings.setEditingBehaviorType(m_originalEditingBehavior);
123
124     for (const auto& standardFont : m_standardFontFamilies)
125         settings.setStandardFontFamily(standardFont.value, static_cast<UScriptCode>(standardFont.key));
126     m_standardFontFamilies.clear();
127
128     for (const auto& fixedFont : m_fixedFontFamilies)
129         settings.setFixedFontFamily(fixedFont.value, static_cast<UScriptCode>(fixedFont.key));
130     m_fixedFontFamilies.clear();
131
132     for (const auto& serifFont : m_serifFontFamilies)
133         settings.setSerifFontFamily(serifFont.value, static_cast<UScriptCode>(serifFont.key));
134     m_serifFontFamilies.clear();
135
136     for (const auto& sansSerifFont : m_sansSerifFontFamilies)
137         settings.setSansSerifFontFamily(sansSerifFont.value, static_cast<UScriptCode>(sansSerifFont.key));
138     m_sansSerifFontFamilies.clear();
139
140     for (const auto& cursiveFont : m_cursiveFontFamilies)
141         settings.setCursiveFontFamily(cursiveFont.value, static_cast<UScriptCode>(cursiveFont.key));
142     m_cursiveFontFamilies.clear();
143
144     for (const auto& fantasyFont : m_fantasyFontFamilies)
145         settings.setFantasyFontFamily(fantasyFont.value, static_cast<UScriptCode>(fantasyFont.key));
146     m_fantasyFontFamilies.clear();
147
148     for (const auto& pictographFont : m_pictographFontFamilies)
149         settings.setPictographFontFamily(pictographFont.value, static_cast<UScriptCode>(pictographFont.key));
150     m_pictographFontFamilies.clear();
151
152 #if ENABLE(TEXT_AUTOSIZING)
153     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
154     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
155 #endif
156     settings.setMediaTypeOverride(m_originalMediaTypeOverride);
157     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
158     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
159     settings.setImagesEnabled(m_imagesEnabled);
160     settings.setPreferMIMETypeForImages(m_preferMIMETypeForImages);
161     settings.setMinimumDOMTimerInterval(m_minimumTimerInterval);
162 #if ENABLE(VIDEO_TRACK)
163     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
164     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
165     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
166 #endif
167     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
168     settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
169     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
170     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
171     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
172     settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
173     settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
174     settings.setWebFontsAlwaysFallBack(m_webFontsAlwaysFallBack);
175     settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
176     settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
177     settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
178 #if ENABLE(TOUCH_EVENTS)
179     settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
180 #endif
181     settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
182     settings.setAllowsInlineMediaPlaybackAfterFullscreen(m_allowsInlineMediaPlaybackAfterFullscreen);
183     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
184     settings.setQuickTimePluginReplacementEnabled(m_quickTimePluginReplacementEnabled);
185     settings.setYouTubeFlashPluginReplacementEnabled(m_youTubeFlashPluginReplacementEnabled);
186 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
187     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
188 #endif
189 #if ENABLE(VARIATION_FONTS)
190     settings.setVariationFontsEnabled(m_variationFontsEnabled);
191 #endif
192     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
193     settings.setSystemLayoutDirection(m_systemLayoutDirection);
194     settings.setPdfImageCachingPolicy(m_pdfImageCachingPolicy);
195     Settings::setAllowsAnySSLCertificate(false);
196 }
197
198 class InternalSettingsWrapper : public Supplement<Page> {
199 public:
200     explicit InternalSettingsWrapper(Page* page)
201         : m_internalSettings(InternalSettings::create(page)) { }
202     virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
203 #if !ASSERT_DISABLED
204     bool isRefCountedWrapper() const override { return true; }
205 #endif
206     InternalSettings* internalSettings() const { return m_internalSettings.get(); }
207
208 private:
209     RefPtr<InternalSettings> m_internalSettings;
210 };
211
212 const char* InternalSettings::supplementName()
213 {
214     return "InternalSettings";
215 }
216
217 InternalSettings* InternalSettings::from(Page* page)
218 {
219     if (!Supplement<Page>::from(page, supplementName()))
220         Supplement<Page>::provideTo(page, supplementName(), std::make_unique<InternalSettingsWrapper>(page));
221     return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
222 }
223
224 InternalSettings::~InternalSettings()
225 {
226 }
227
228 InternalSettings::InternalSettings(Page* page)
229     : InternalSettingsGenerated(page)
230     , m_page(page)
231     , m_backup(page->settings())
232 {
233 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
234     setAllowsAirPlayForMediaPlayback(false);
235 #endif
236 }
237
238 void InternalSettings::resetToConsistentState()
239 {
240     page()->setPageScaleFactor(1, { 0, 0 });
241     page()->mainFrame().setPageAndTextZoomFactors(1, 1);
242     page()->setCanStartMedia(true);
243     page()->settings().setForcePendingWebGLPolicy(false);
244 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
245     setAllowsAirPlayForMediaPlayback(false);
246 #endif
247
248     m_backup.restoreTo(*settings());
249     m_backup = Backup(*settings());
250
251     InternalSettingsGenerated::resetToConsistentState();
252 }
253
254 Settings* InternalSettings::settings() const
255 {
256     if (!page())
257         return 0;
258     return &page()->settings();
259 }
260
261 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
262 {
263 #if ENABLE(TOUCH_EVENTS)
264     InternalSettingsGuardForSettings();
265     settings()->setTouchEventEmulationEnabled(enabled);
266 #else
267     UNUSED_PARAM(enabled);
268     UNUSED_PARAM(ec);
269 #endif
270 }
271
272 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
273 {
274     InternalSettingsGuardForSettings();
275     UScriptCode code = scriptNameToCode(script);
276     if (code == USCRIPT_INVALID_CODE)
277         return;
278     m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
279     settings()->setStandardFontFamily(family, code);
280 }
281
282 void InternalSettings::setSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
283 {
284     InternalSettingsGuardForSettings();
285     UScriptCode code = scriptNameToCode(script);
286     if (code == USCRIPT_INVALID_CODE)
287         return;
288     m_backup.m_serifFontFamilies.add(code, settings()->serifFontFamily(code));
289     settings()->setSerifFontFamily(family, code);
290 }
291
292 void InternalSettings::setSansSerifFontFamily(const String& family, const String& script, ExceptionCode& ec)
293 {
294     InternalSettingsGuardForSettings();
295     UScriptCode code = scriptNameToCode(script);
296     if (code == USCRIPT_INVALID_CODE)
297         return;
298     m_backup.m_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
299     settings()->setSansSerifFontFamily(family, code);
300 }
301
302 void InternalSettings::setFixedFontFamily(const String& family, const String& script, ExceptionCode& ec)
303 {
304     InternalSettingsGuardForSettings();
305     UScriptCode code = scriptNameToCode(script);
306     if (code == USCRIPT_INVALID_CODE)
307         return;
308     m_backup.m_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
309     settings()->setFixedFontFamily(family, code);
310 }
311
312 void InternalSettings::setCursiveFontFamily(const String& family, const String& script, ExceptionCode& ec)
313 {
314     InternalSettingsGuardForSettings();
315     UScriptCode code = scriptNameToCode(script);
316     if (code == USCRIPT_INVALID_CODE)
317         return;
318     m_backup.m_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
319     settings()->setCursiveFontFamily(family, code);
320 }
321
322 void InternalSettings::setFantasyFontFamily(const String& family, const String& script, ExceptionCode& ec)
323 {
324     InternalSettingsGuardForSettings();
325     UScriptCode code = scriptNameToCode(script);
326     if (code == USCRIPT_INVALID_CODE)
327         return;
328     m_backup.m_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
329     settings()->setFantasyFontFamily(family, code);
330 }
331
332 void InternalSettings::setPictographFontFamily(const String& family, const String& script, ExceptionCode& ec)
333 {
334     InternalSettingsGuardForSettings();
335     UScriptCode code = scriptNameToCode(script);
336     if (code == USCRIPT_INVALID_CODE)
337         return;
338     m_backup.m_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
339     settings()->setPictographFontFamily(family, code);
340 }
341
342 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
343 {
344 #if ENABLE(TEXT_AUTOSIZING)
345     InternalSettingsGuardForSettings();
346     settings()->setTextAutosizingEnabled(enabled);
347 #else
348     UNUSED_PARAM(enabled);
349     UNUSED_PARAM(ec);
350 #endif
351 }
352
353 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
354 {
355 #if ENABLE(TEXT_AUTOSIZING)
356     InternalSettingsGuardForSettings();
357     settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
358 #else
359     UNUSED_PARAM(width);
360     UNUSED_PARAM(height);
361     UNUSED_PARAM(ec);
362 #endif
363 }
364
365 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
366 {
367     InternalSettingsGuardForSettings();
368     settings()->setMediaTypeOverride(mediaType);
369 }
370
371 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
372 {
373     InternalSettingsGuardForSettings();
374     m_page->setCanStartMedia(enabled);
375 }
376
377 void InternalSettings::setAllowsAirPlayForMediaPlayback(bool allows)
378 {
379 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
380     m_page->settings().setAllowsAirPlayForMediaPlayback(allows);
381 #else
382     UNUSED_PARAM(allows);
383 #endif
384 }
385
386 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
387 {
388     InternalSettingsGuardForSettings();
389     if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
390         settings()->setEditingBehaviorType(EditingWindowsBehavior);
391     else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
392         settings()->setEditingBehaviorType(EditingMacBehavior);
393     else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
394         settings()->setEditingBehaviorType(EditingUnixBehavior);
395     else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
396         settings()->setEditingBehaviorType(EditingIOSBehavior);
397     else
398         ec = SYNTAX_ERR;
399 }
400
401 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
402 {
403     InternalSettingsGuardForSettings();
404
405 #if ENABLE(VIDEO_TRACK)
406     if (!page())
407         return;
408
409     auto& captionPreferences = page()->group().captionPreferences();
410     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
411         captionPreferences.setUserPrefersSubtitles(enabled);
412     else if (equalLettersIgnoringASCIICase(kind, "captions"))
413         captionPreferences.setUserPrefersCaptions(enabled);
414     else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
415         captionPreferences.setUserPrefersTextDescriptions(enabled);
416     else
417         ec = SYNTAX_ERR;
418 #else
419     UNUSED_PARAM(kind);
420     UNUSED_PARAM(enabled);
421 #endif
422 }
423
424 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
425 {
426     InternalSettingsGuardForSettingsReturn(false);
427
428 #if ENABLE(VIDEO_TRACK)
429     if (!page())
430         return false;
431
432     auto& captionPreferences = page()->group().captionPreferences();
433     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
434         return captionPreferences.userPrefersSubtitles();
435     if (equalLettersIgnoringASCIICase(kind, "captions"))
436         return captionPreferences.userPrefersCaptions();
437     if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
438         return captionPreferences.userPrefersTextDescriptions();
439
440     ec = SYNTAX_ERR;
441     return false;
442 #else
443     UNUSED_PARAM(kind);
444     return false;
445 #endif
446 }
447
448 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
449 {
450     InternalSettingsGuardForSettings();
451
452     if (mode == "AllowAll")
453         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
454     else if (mode == "BlockThirdParty")
455         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
456     else if (mode == "BlockAll")
457         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
458     else
459         ec = SYNTAX_ERR;
460 }
461
462 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
463 {
464     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
465 }
466
467 void InternalSettings::setPreferMIMETypeForImages(bool preferMIMETypeForImages, ExceptionCode &ec)
468 {
469     InternalSettingsGuardForSettings();
470     settings()->setPreferMIMETypeForImages(preferMIMETypeForImages);
471 }
472
473 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
474 {
475     InternalSettingsGuardForSettings();
476     settings()->setImagesEnabled(enabled);
477 }
478
479 void InternalSettings::setPDFImageCachingPolicy(const String& policy, ExceptionCode& ec)
480 {
481     InternalSettingsGuardForSettings();
482     if (equalLettersIgnoringASCIICase(policy, "disabled"))
483         settings()->setPdfImageCachingPolicy(PDFImageCachingDisabled);
484     else if (equalLettersIgnoringASCIICase(policy, "belowmemorylimit"))
485         settings()->setPdfImageCachingPolicy(PDFImageCachingBelowMemoryLimit);
486     else if (equalLettersIgnoringASCIICase(policy, "clipboundsonly"))
487         settings()->setPdfImageCachingPolicy(PDFImageCachingClipBoundsOnly);
488     else if (equalLettersIgnoringASCIICase(policy, "enabled"))
489         settings()->setPdfImageCachingPolicy(PDFImageCachingEnabled);
490     else
491         ec = SYNTAX_ERR;
492 }
493
494 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
495 {
496     InternalSettingsGuardForSettings();
497     settings()->setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
498 }
499
500 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
501 {
502     InternalSettingsGuardForSettings();
503     settings()->setDefaultVideoPosterURL(url);
504 }
505
506 void InternalSettings::setForcePendingWebGLPolicy(bool forced, ExceptionCode& ec)
507 {
508     InternalSettingsGuardForSettings();
509     settings()->setForcePendingWebGLPolicy(forced);
510 }
511
512 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
513 {
514     InternalSettingsGuardForSettings();
515     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
516 }
517
518 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
519 {
520     InternalSettingsGuardForSettings();
521     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
522 }
523
524 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
525 {
526     InternalSettingsGuardForSettings();
527     settings()->setAutoscrollForDragAndDropEnabled(enabled);
528 }
529
530 void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
531 {
532     InternalSettingsGuardForSettings();
533     settings()->setFontFallbackPrefersPictographs(preferPictographs);
534 }
535
536 void InternalSettings::setWebFontsAlwaysFallBack(bool enable, ExceptionCode& ec)
537 {
538     InternalSettingsGuardForSettings();
539     settings()->setWebFontsAlwaysFallBack(enable);
540 }
541
542 void InternalSettings::setQuickTimePluginReplacementEnabled(bool enabled, ExceptionCode& ec)
543 {
544     InternalSettingsGuardForSettings();
545     settings()->setQuickTimePluginReplacementEnabled(enabled);
546 }
547
548 void InternalSettings::setYouTubeFlashPluginReplacementEnabled(bool enabled, ExceptionCode& ec)
549 {
550     InternalSettingsGuardForSettings();
551     settings()->setYouTubeFlashPluginReplacementEnabled(enabled);
552 }
553
554 void InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode& ec)
555 {
556     InternalSettingsGuardForSettings();
557     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
558 }
559
560 void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
561 {
562     InternalSettingsGuardForSettings();
563     settings()->setShouldConvertPositionStyleOnCopy(convert);
564 }
565
566 void InternalSettings::setScrollingTreeIncludesFrames(bool enabled, ExceptionCode& ec)
567 {
568     InternalSettingsGuardForSettings();
569     settings()->setScrollingTreeIncludesFrames(enabled);
570 }
571
572 void InternalSettings::setAllowsInlineMediaPlayback(bool allows, ExceptionCode& ec)
573 {
574     InternalSettingsGuardForSettings();
575     settings()->setAllowsInlineMediaPlayback(allows);
576 }
577
578 void InternalSettings::setAllowsInlineMediaPlaybackAfterFullscreen(bool allows, ExceptionCode& ec)
579 {
580     InternalSettingsGuardForSettings();
581     settings()->setAllowsInlineMediaPlaybackAfterFullscreen(allows);
582 }
583
584 void InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires, ExceptionCode& ec)
585 {
586     InternalSettingsGuardForSettings();
587     settings()->setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
588 }
589
590 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled, ExceptionCode&)
591 {
592 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
593     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
594 #else
595     UNUSED_PARAM(enabled);
596 #endif
597 }
598
599 String InternalSettings::userInterfaceDirectionPolicy(ExceptionCode& ec)
600 {
601     InternalSettingsGuardForSettingsReturn("");
602     switch (settings()->userInterfaceDirectionPolicy()) {
603     case UserInterfaceDirectionPolicy::Content:
604         return ASCIILiteral("Content");
605     case UserInterfaceDirectionPolicy::System:
606         return ASCIILiteral("View");
607     }
608     ASSERT_NOT_REACHED();
609     return String();
610 }
611
612 void InternalSettings::setUserInterfaceDirectionPolicy(const String& policy, ExceptionCode& ec)
613 {
614     InternalSettingsGuardForSettings();
615     if (equalLettersIgnoringASCIICase(policy, "content")) {
616         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
617         return;
618     }
619     if (equalLettersIgnoringASCIICase(policy, "view")) {
620         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
621         return;
622     }
623     ec = INVALID_ACCESS_ERR;
624 }
625
626 String InternalSettings::systemLayoutDirection(ExceptionCode& ec)
627 {
628     InternalSettingsGuardForSettingsReturn("");
629     switch (settings()->systemLayoutDirection()) {
630     case LTR:
631         return ASCIILiteral("LTR");
632     case RTL:
633         return ASCIILiteral("RTL");
634     }
635     ASSERT_NOT_REACHED();
636     return String();
637 }
638
639 void InternalSettings::setSystemLayoutDirection(const String& direction, ExceptionCode& ec)
640 {
641     InternalSettingsGuardForSettings();
642     if (equalLettersIgnoringASCIICase(direction, "ltr")) {
643         settings()->setSystemLayoutDirection(LTR);
644         return;
645     }
646     if (equalLettersIgnoringASCIICase(direction, "rtl")) {
647         settings()->setSystemLayoutDirection(RTL);
648         return;
649     }
650     ec = INVALID_ACCESS_ERR;
651 }
652
653 void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
654 {
655     Settings::setAllowsAnySSLCertificate(allowsAnyCertificate);
656 }
657
658 bool InternalSettings::variationFontsEnabled(ExceptionCode& ec)
659 {
660 #if ENABLE(VARIATION_FONTS)
661     InternalSettingsGuardForSettingsReturn(true);
662     return settings()->variationFontsEnabled();
663 #else
664     UNUSED_PARAM(ec);
665     return false;
666 #endif
667 }
668
669 void InternalSettings::setVariationFontsEnabled(bool enabled, ExceptionCode& ec)
670 {
671 #if ENABLE(VARIATION_FONTS)
672     InternalSettingsGuardForSettings();
673     settings()->setVariationFontsEnabled(enabled);
674 #else
675     UNUSED_PARAM(enabled);
676     UNUSED_PARAM(ec);
677 #endif
678 }
679
680 // If you add to this list, make sure that you update the Backup class for test reproducability!
681
682 }