Regions, Shapes and Tracks don't need runtime features
[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     , m_originalTextAutosizingFontScaleFactor(settings.textAutosizingFontScaleFactor())
74 #endif
75     , m_originalMediaTypeOverride(settings.mediaTypeOverride())
76     , m_originalCanvasUsesAcceleratedDrawing(settings.canvasUsesAcceleratedDrawing())
77     , m_originalMockScrollbarsEnabled(settings.mockScrollbarsEnabled())
78     , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::sharedFeatures().langAttributeAwareFormControlUIEnabled())
79     , m_imagesEnabled(settings.areImagesEnabled())
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_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
92     , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
93     , m_fontFallbackPrefersPictographs(settings.fontFallbackPrefersPictographs())
94     , m_backgroundShouldExtendBeyondPage(settings.backgroundShouldExtendBeyondPage())
95     , m_storageBlockingPolicy(settings.storageBlockingPolicy())
96     , m_scrollingTreeIncludesFrames(settings.scrollingTreeIncludesFrames())
97 #if ENABLE(TOUCH_EVENTS)
98     , m_touchEventEmulationEnabled(settings.isTouchEventEmulationEnabled())
99 #endif
100 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
101     , m_allowsAirPlayForMediaPlayback(settings.allowsAirPlayForMediaPlayback())
102 #endif
103     , m_allowsInlineMediaPlayback(settings.allowsInlineMediaPlayback())
104     , m_inlineMediaPlaybackRequiresPlaysInlineAttribute(settings.inlineMediaPlaybackRequiresPlaysInlineAttribute())
105 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
106     , m_indexedDBWorkersEnabled(RuntimeEnabledFeatures::sharedFeatures().indexedDBWorkersEnabled())
107 #endif
108     , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
109     , m_systemLayoutDirection(settings.systemLayoutDirection())
110 {
111 }
112
113 void InternalSettings::Backup::restoreTo(Settings& settings)
114 {
115     settings.setEditingBehaviorType(m_originalEditingBehavior);
116
117     for (const auto& standardFont : m_standardFontFamilies)
118         settings.setStandardFontFamily(standardFont.value, static_cast<UScriptCode>(standardFont.key));
119     m_standardFontFamilies.clear();
120
121     for (const auto& fixedFont : m_fixedFontFamilies)
122         settings.setFixedFontFamily(fixedFont.value, static_cast<UScriptCode>(fixedFont.key));
123     m_fixedFontFamilies.clear();
124
125     for (const auto& serifFont : m_serifFontFamilies)
126         settings.setSerifFontFamily(serifFont.value, static_cast<UScriptCode>(serifFont.key));
127     m_serifFontFamilies.clear();
128
129     for (const auto& sansSerifFont : m_sansSerifFontFamilies)
130         settings.setSansSerifFontFamily(sansSerifFont.value, static_cast<UScriptCode>(sansSerifFont.key));
131     m_sansSerifFontFamilies.clear();
132
133     for (const auto& cursiveFont : m_cursiveFontFamilies)
134         settings.setCursiveFontFamily(cursiveFont.value, static_cast<UScriptCode>(cursiveFont.key));
135     m_cursiveFontFamilies.clear();
136
137     for (const auto& fantasyFont : m_fantasyFontFamilies)
138         settings.setFantasyFontFamily(fantasyFont.value, static_cast<UScriptCode>(fantasyFont.key));
139     m_fantasyFontFamilies.clear();
140
141     for (const auto& pictographFont : m_pictographFontFamilies)
142         settings.setPictographFontFamily(pictographFont.value, static_cast<UScriptCode>(pictographFont.key));
143     m_pictographFontFamilies.clear();
144
145 #if ENABLE(TEXT_AUTOSIZING)
146     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
147     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
148     settings.setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
149 #endif
150     settings.setMediaTypeOverride(m_originalMediaTypeOverride);
151     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
152     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(m_langAttributeAwareFormControlUIEnabled);
153     settings.setImagesEnabled(m_imagesEnabled);
154     settings.setMinimumDOMTimerInterval(m_minimumTimerInterval);
155 #if ENABLE(VIDEO_TRACK)
156     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
157     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
158     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
159 #endif
160     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
161     settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
162     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
163     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
164     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
165     settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
166     settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
167     settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
168     settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
169     settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
170 #if ENABLE(TOUCH_EVENTS)
171     settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
172 #endif
173     settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
174     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
175     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
176 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
177     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
178 #endif
179     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
180     settings.setSystemLayoutDirection(m_systemLayoutDirection);
181 }
182
183 class InternalSettingsWrapper : public Supplement<Page> {
184 public:
185     explicit InternalSettingsWrapper(Page* page)
186         : m_internalSettings(InternalSettings::create(page)) { }
187     virtual ~InternalSettingsWrapper() { m_internalSettings->hostDestroyed(); }
188 #if !ASSERT_DISABLED
189     bool isRefCountedWrapper() const override { return true; }
190 #endif
191     InternalSettings* internalSettings() const { return m_internalSettings.get(); }
192
193 private:
194     RefPtr<InternalSettings> m_internalSettings;
195 };
196
197 const char* InternalSettings::supplementName()
198 {
199     return "InternalSettings";
200 }
201
202 InternalSettings* InternalSettings::from(Page* page)
203 {
204     if (!Supplement<Page>::from(page, supplementName()))
205         Supplement<Page>::provideTo(page, supplementName(), std::make_unique<InternalSettingsWrapper>(page));
206     return static_cast<InternalSettingsWrapper*>(Supplement<Page>::from(page, supplementName()))->internalSettings();
207 }
208
209 InternalSettings::~InternalSettings()
210 {
211 }
212
213 InternalSettings::InternalSettings(Page* page)
214     : InternalSettingsGenerated(page)
215     , m_page(page)
216     , m_backup(page->settings())
217 {
218 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
219     page->settings().setAllowsAirPlayForMediaPlayback(false);
220 #endif
221 }
222
223 void InternalSettings::resetToConsistentState()
224 {
225     page()->setPageScaleFactor(1, IntPoint(0, 0));
226     page()->setCanStartMedia(true);
227     page()->settings().setForcePendingWebGLPolicy(false);
228 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
229     m_page->settings().setAllowsAirPlayForMediaPlayback(false);
230 #endif
231
232     m_backup.restoreTo(*settings());
233     m_backup = Backup(*settings());
234
235     InternalSettingsGenerated::resetToConsistentState();
236 }
237
238 Settings* InternalSettings::settings() const
239 {
240     if (!page())
241         return 0;
242     return &page()->settings();
243 }
244
245 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionCode& ec)
246 {
247 #if ENABLE(TOUCH_EVENTS)
248     InternalSettingsGuardForSettings();
249     settings()->setTouchEventEmulationEnabled(enabled);
250 #else
251     UNUSED_PARAM(enabled);
252     UNUSED_PARAM(ec);
253 #endif
254 }
255
256 void InternalSettings::setStandardFontFamily(const String& family, const String& script, ExceptionCode& ec)
257 {
258     InternalSettingsGuardForSettings();
259     UScriptCode code = scriptNameToCode(script);
260     if (code == USCRIPT_INVALID_CODE)
261         return;
262     m_backup.m_standardFontFamilies.add(code, settings()->standardFontFamily(code));
263     settings()->setStandardFontFamily(family, code);
264 }
265
266 void InternalSettings::setSerifFontFamily(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_serifFontFamilies.add(code, settings()->serifFontFamily(code));
273     settings()->setSerifFontFamily(family, code);
274 }
275
276 void InternalSettings::setSansSerifFontFamily(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_sansSerifFontFamilies.add(code, settings()->sansSerifFontFamily(code));
283     settings()->setSansSerifFontFamily(family, code);
284 }
285
286 void InternalSettings::setFixedFontFamily(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_fixedFontFamilies.add(code, settings()->fixedFontFamily(code));
293     settings()->setFixedFontFamily(family, code);
294 }
295
296 void InternalSettings::setCursiveFontFamily(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_cursiveFontFamilies.add(code, settings()->cursiveFontFamily(code));
303     settings()->setCursiveFontFamily(family, code);
304 }
305
306 void InternalSettings::setFantasyFontFamily(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_fantasyFontFamilies.add(code, settings()->fantasyFontFamily(code));
313     settings()->setFantasyFontFamily(family, code);
314 }
315
316 void InternalSettings::setPictographFontFamily(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_pictographFontFamilies.add(code, settings()->pictographFontFamily(code));
323     settings()->setPictographFontFamily(family, code);
324 }
325
326 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionCode& ec)
327 {
328 #if ENABLE(TEXT_AUTOSIZING)
329     InternalSettingsGuardForSettings();
330     settings()->setTextAutosizingEnabled(enabled);
331 #else
332     UNUSED_PARAM(enabled);
333     UNUSED_PARAM(ec);
334 #endif
335 }
336
337 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height, ExceptionCode& ec)
338 {
339 #if ENABLE(TEXT_AUTOSIZING)
340     InternalSettingsGuardForSettings();
341     settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height));
342 #else
343     UNUSED_PARAM(width);
344     UNUSED_PARAM(height);
345     UNUSED_PARAM(ec);
346 #endif
347 }
348
349 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionCode& ec)
350 {
351     InternalSettingsGuardForSettings();
352     settings()->setMediaTypeOverride(mediaType);
353 }
354
355 void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
356 {
357 #if ENABLE(TEXT_AUTOSIZING)
358     InternalSettingsGuardForSettings();
359     settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
360 #else
361     UNUSED_PARAM(fontScaleFactor);
362     UNUSED_PARAM(ec);
363 #endif
364 }
365
366 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
367 {
368     InternalSettingsGuardForSettings();
369     m_page->setCanStartMedia(enabled);
370 }
371
372 void InternalSettings::setWirelessPlaybackDisabled(bool available)
373 {
374 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
375     m_page->settings().setAllowsAirPlayForMediaPlayback(available);
376 #else
377     UNUSED_PARAM(available);
378 #endif
379 }
380
381 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
382 {
383     InternalSettingsGuardForSettings();
384     if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
385         settings()->setEditingBehaviorType(EditingWindowsBehavior);
386     else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
387         settings()->setEditingBehaviorType(EditingMacBehavior);
388     else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
389         settings()->setEditingBehaviorType(EditingUnixBehavior);
390     else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
391         settings()->setEditingBehaviorType(EditingIOSBehavior);
392     else
393         ec = SYNTAX_ERR;
394 }
395
396 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
397 {
398     InternalSettingsGuardForSettings();
399
400 #if ENABLE(VIDEO_TRACK)
401     if (!page())
402         return;
403
404     auto& captionPreferences = page()->group().captionPreferences();
405     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
406         captionPreferences.setUserPrefersSubtitles(enabled);
407     else if (equalLettersIgnoringASCIICase(kind, "captions"))
408         captionPreferences.setUserPrefersCaptions(enabled);
409     else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
410         captionPreferences.setUserPrefersTextDescriptions(enabled);
411     else
412         ec = SYNTAX_ERR;
413 #else
414     UNUSED_PARAM(kind);
415     UNUSED_PARAM(enabled);
416 #endif
417 }
418
419 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
420 {
421     InternalSettingsGuardForSettingsReturn(false);
422
423 #if ENABLE(VIDEO_TRACK)
424     if (!page())
425         return false;
426
427     auto& captionPreferences = page()->group().captionPreferences();
428     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
429         return captionPreferences.userPrefersSubtitles();
430     if (equalLettersIgnoringASCIICase(kind, "captions"))
431         return captionPreferences.userPrefersCaptions();
432     if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
433         return captionPreferences.userPrefersTextDescriptions();
434
435     ec = SYNTAX_ERR;
436     return false;
437 #else
438     UNUSED_PARAM(kind);
439     return false;
440 #endif
441 }
442
443 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
444 {
445     InternalSettingsGuardForSettings();
446
447     if (mode == "AllowAll")
448         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
449     else if (mode == "BlockThirdParty")
450         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
451     else if (mode == "BlockAll")
452         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
453     else
454         ec = SYNTAX_ERR;
455 }
456
457 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
458 {
459     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
460 }
461
462 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
463 {
464     InternalSettingsGuardForSettings();
465     settings()->setImagesEnabled(enabled);
466 }
467
468 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
469 {
470     InternalSettingsGuardForSettings();
471     settings()->setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
472 }
473
474 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
475 {
476     InternalSettingsGuardForSettings();
477     settings()->setDefaultVideoPosterURL(url);
478 }
479
480 void InternalSettings::setForcePendingWebGLPolicy(bool forced, ExceptionCode& ec)
481 {
482     InternalSettingsGuardForSettings();
483     settings()->setForcePendingWebGLPolicy(forced);
484 }
485
486 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
487 {
488     InternalSettingsGuardForSettings();
489     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
490 }
491
492 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
493 {
494     InternalSettingsGuardForSettings();
495     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
496 }
497
498 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
499 {
500     InternalSettingsGuardForSettings();
501     settings()->setAutoscrollForDragAndDropEnabled(enabled);
502 }
503
504 void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
505 {
506     InternalSettingsGuardForSettings();
507     settings()->setFontFallbackPrefersPictographs(preferPictographs);
508 }
509
510 void InternalSettings::setPluginReplacementEnabled(bool enabled)
511 {
512     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(enabled);
513 }
514
515 void InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode& ec)
516 {
517     InternalSettingsGuardForSettings();
518     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
519 }
520
521 void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
522 {
523     InternalSettingsGuardForSettings();
524     settings()->setShouldConvertPositionStyleOnCopy(convert);
525 }
526
527 void InternalSettings::setScrollingTreeIncludesFrames(bool enabled, ExceptionCode& ec)
528 {
529     InternalSettingsGuardForSettings();
530     settings()->setScrollingTreeIncludesFrames(enabled);
531 }
532
533 void InternalSettings::setAllowsInlineMediaPlayback(bool allows, ExceptionCode& ec)
534 {
535     InternalSettingsGuardForSettings();
536     settings()->setAllowsInlineMediaPlayback(allows);
537 }
538
539 void InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires, ExceptionCode& ec)
540 {
541     InternalSettingsGuardForSettings();
542     settings()->setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
543 }
544
545 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled, ExceptionCode&)
546 {
547 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
548     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
549 #else
550     UNUSED_PARAM(enabled);
551 #endif
552 }
553
554 String InternalSettings::userInterfaceDirectionPolicy(ExceptionCode& ec)
555 {
556     InternalSettingsGuardForSettingsReturn("");
557     switch (settings()->userInterfaceDirectionPolicy()) {
558     case UserInterfaceDirectionPolicy::Content:
559         return ASCIILiteral("Content");
560     case UserInterfaceDirectionPolicy::System:
561         return ASCIILiteral("View");
562     }
563     ASSERT_NOT_REACHED();
564     return String();
565 }
566
567 void InternalSettings::setUserInterfaceDirectionPolicy(const String& policy, ExceptionCode& ec)
568 {
569     InternalSettingsGuardForSettings();
570     if (equalLettersIgnoringASCIICase(policy, "content")) {
571         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
572         return;
573     }
574     if (equalLettersIgnoringASCIICase(policy, "view")) {
575         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
576         return;
577     }
578     ec = INVALID_ACCESS_ERR;
579 }
580
581 String InternalSettings::systemLayoutDirection(ExceptionCode& ec)
582 {
583     InternalSettingsGuardForSettingsReturn("");
584     switch (settings()->systemLayoutDirection()) {
585     case LTR:
586         return ASCIILiteral("LTR");
587     case RTL:
588         return ASCIILiteral("RTL");
589     }
590     ASSERT_NOT_REACHED();
591     return String();
592 }
593
594 void InternalSettings::setSystemLayoutDirection(const String& direction, ExceptionCode& ec)
595 {
596     InternalSettingsGuardForSettings();
597     if (equalLettersIgnoringASCIICase(direction, "ltr")) {
598         settings()->setSystemLayoutDirection(LTR);
599         return;
600     }
601     if (equalLettersIgnoringASCIICase(direction, "rtl")) {
602         settings()->setSystemLayoutDirection(RTL);
603         return;
604     }
605     ec = INVALID_ACCESS_ERR;
606 }
607
608 // If you add to this list, make sure that you update the Backup class for test reproducability!
609
610 }