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