Text not visible while external font downloading
[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) || ENABLE(IOS_TEXT_AUTOSIZING)
71     , m_originalTextAutosizingEnabled(settings.textAutosizingEnabled())
72     , m_originalTextAutosizingWindowSizeOverride(settings.textAutosizingWindowSizeOverride())
73 #endif
74 #if ENABLE(TEXT_AUTOSIZING)
75     , m_originalTextAutosizingFontScaleFactor(settings.textAutosizingFontScaleFactor())
76 #endif
77     , m_originalMediaTypeOverride(settings.mediaTypeOverride())
78     , m_originalCanvasUsesAcceleratedDrawing(settings.canvasUsesAcceleratedDrawing())
79     , m_originalMockScrollbarsEnabled(settings.mockScrollbarsEnabled())
80     , m_langAttributeAwareFormControlUIEnabled(RuntimeEnabledFeatures::sharedFeatures().langAttributeAwareFormControlUIEnabled())
81     , m_imagesEnabled(settings.areImagesEnabled())
82     , m_minimumTimerInterval(settings.minimumDOMTimerInterval())
83 #if ENABLE(VIDEO_TRACK)
84     , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
85     , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
86     , m_shouldDisplayTextDescriptions(settings.shouldDisplayTextDescriptions())
87 #endif
88     , m_defaultVideoPosterURL(settings.defaultVideoPosterURL())
89     , m_forcePendingWebGLPolicy(settings.isForcePendingWebGLPolicy())
90     , m_originalTimeWithoutMouseMovementBeforeHidingControls(settings.timeWithoutMouseMovementBeforeHidingControls())
91     , m_useLegacyBackgroundSizeShorthandBehavior(settings.useLegacyBackgroundSizeShorthandBehavior())
92     , m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
93     , m_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
94     , m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
95     , m_fontFallbackPrefersPictographs(settings.fontFallbackPrefersPictographs())
96     , m_webFontsAlwaysFallBack(settings.webFontsAlwaysFallBack())
97     , m_backgroundShouldExtendBeyondPage(settings.backgroundShouldExtendBeyondPage())
98     , m_storageBlockingPolicy(settings.storageBlockingPolicy())
99     , m_scrollingTreeIncludesFrames(settings.scrollingTreeIncludesFrames())
100 #if ENABLE(TOUCH_EVENTS)
101     , m_touchEventEmulationEnabled(settings.isTouchEventEmulationEnabled())
102 #endif
103 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
104     , m_allowsAirPlayForMediaPlayback(settings.allowsAirPlayForMediaPlayback())
105 #endif
106     , m_allowsInlineMediaPlayback(settings.allowsInlineMediaPlayback())
107     , m_allowsInlineMediaPlaybackAfterFullscreen(settings.allowsInlineMediaPlaybackAfterFullscreen())
108     , m_inlineMediaPlaybackRequiresPlaysInlineAttribute(settings.inlineMediaPlaybackRequiresPlaysInlineAttribute())
109 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
110     , m_indexedDBWorkersEnabled(RuntimeEnabledFeatures::sharedFeatures().indexedDBWorkersEnabled())
111 #endif
112     , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy())
113     , m_systemLayoutDirection(settings.systemLayoutDirection())
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(TEXT_AUTOSIZING) || ENABLE(IOS_TEXT_AUTOSIZING)
150     settings.setTextAutosizingEnabled(m_originalTextAutosizingEnabled);
151     settings.setTextAutosizingWindowSizeOverride(m_originalTextAutosizingWindowSizeOverride);
152 #endif
153 #if ENABLE(TEXT_AUTOSIZING)
154     settings.setTextAutosizingFontScaleFactor(m_originalTextAutosizingFontScaleFactor);
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.setMinimumDOMTimerInterval(m_minimumTimerInterval);
161 #if ENABLE(VIDEO_TRACK)
162     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
163     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
164     settings.setShouldDisplayTextDescriptions(m_shouldDisplayTextDescriptions);
165 #endif
166     settings.setDefaultVideoPosterURL(m_defaultVideoPosterURL);
167     settings.setForcePendingWebGLPolicy(m_forcePendingWebGLPolicy);
168     settings.setTimeWithoutMouseMovementBeforeHidingControls(m_originalTimeWithoutMouseMovementBeforeHidingControls);
169     settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
170     settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
171     settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
172     settings.setFontFallbackPrefersPictographs(m_fontFallbackPrefersPictographs);
173     settings.setWebFontsAlwaysFallBack(m_webFontsAlwaysFallBack);
174     settings.setBackgroundShouldExtendBeyondPage(m_backgroundShouldExtendBeyondPage);
175     settings.setStorageBlockingPolicy(m_storageBlockingPolicy);
176     settings.setScrollingTreeIncludesFrames(m_scrollingTreeIncludesFrames);
177 #if ENABLE(TOUCH_EVENTS)
178     settings.setTouchEventEmulationEnabled(m_touchEventEmulationEnabled);
179 #endif
180     settings.setAllowsInlineMediaPlayback(m_allowsInlineMediaPlayback);
181     settings.setAllowsInlineMediaPlaybackAfterFullscreen(m_allowsInlineMediaPlaybackAfterFullscreen);
182     settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(m_inlineMediaPlaybackRequiresPlaysInlineAttribute);
183     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
184 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
185     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
186 #endif
187     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
188     settings.setSystemLayoutDirection(m_systemLayoutDirection);
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     page->settings().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     page()->settings().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(TEXT_AUTOSIZING) || 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(TEXT_AUTOSIZING) || 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::setTextAutosizingFontScaleFactor(float fontScaleFactor, ExceptionCode& ec)
366 {
367 #if ENABLE(TEXT_AUTOSIZING)
368     InternalSettingsGuardForSettings();
369     settings()->setTextAutosizingFontScaleFactor(fontScaleFactor);
370 #else
371     UNUSED_PARAM(fontScaleFactor);
372     UNUSED_PARAM(ec);
373 #endif
374 }
375
376 void InternalSettings::setCanStartMedia(bool enabled, ExceptionCode& ec)
377 {
378     InternalSettingsGuardForSettings();
379     m_page->setCanStartMedia(enabled);
380 }
381
382 void InternalSettings::setWirelessPlaybackDisabled(bool available)
383 {
384 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
385     m_page->settings().setAllowsAirPlayForMediaPlayback(available);
386 #else
387     UNUSED_PARAM(available);
388 #endif
389 }
390
391 void InternalSettings::setEditingBehavior(const String& editingBehavior, ExceptionCode& ec)
392 {
393     InternalSettingsGuardForSettings();
394     if (equalLettersIgnoringASCIICase(editingBehavior, "win"))
395         settings()->setEditingBehaviorType(EditingWindowsBehavior);
396     else if (equalLettersIgnoringASCIICase(editingBehavior, "mac"))
397         settings()->setEditingBehaviorType(EditingMacBehavior);
398     else if (equalLettersIgnoringASCIICase(editingBehavior, "unix"))
399         settings()->setEditingBehaviorType(EditingUnixBehavior);
400     else if (equalLettersIgnoringASCIICase(editingBehavior, "ios"))
401         settings()->setEditingBehaviorType(EditingIOSBehavior);
402     else
403         ec = SYNTAX_ERR;
404 }
405
406 void InternalSettings::setShouldDisplayTrackKind(const String& kind, bool enabled, ExceptionCode& ec)
407 {
408     InternalSettingsGuardForSettings();
409
410 #if ENABLE(VIDEO_TRACK)
411     if (!page())
412         return;
413
414     auto& captionPreferences = page()->group().captionPreferences();
415     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
416         captionPreferences.setUserPrefersSubtitles(enabled);
417     else if (equalLettersIgnoringASCIICase(kind, "captions"))
418         captionPreferences.setUserPrefersCaptions(enabled);
419     else if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
420         captionPreferences.setUserPrefersTextDescriptions(enabled);
421     else
422         ec = SYNTAX_ERR;
423 #else
424     UNUSED_PARAM(kind);
425     UNUSED_PARAM(enabled);
426 #endif
427 }
428
429 bool InternalSettings::shouldDisplayTrackKind(const String& kind, ExceptionCode& ec)
430 {
431     InternalSettingsGuardForSettingsReturn(false);
432
433 #if ENABLE(VIDEO_TRACK)
434     if (!page())
435         return false;
436
437     auto& captionPreferences = page()->group().captionPreferences();
438     if (equalLettersIgnoringASCIICase(kind, "subtitles"))
439         return captionPreferences.userPrefersSubtitles();
440     if (equalLettersIgnoringASCIICase(kind, "captions"))
441         return captionPreferences.userPrefersCaptions();
442     if (equalLettersIgnoringASCIICase(kind, "textdescriptions"))
443         return captionPreferences.userPrefersTextDescriptions();
444
445     ec = SYNTAX_ERR;
446     return false;
447 #else
448     UNUSED_PARAM(kind);
449     return false;
450 #endif
451 }
452
453 void InternalSettings::setStorageBlockingPolicy(const String& mode, ExceptionCode& ec)
454 {
455     InternalSettingsGuardForSettings();
456
457     if (mode == "AllowAll")
458         settings()->setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
459     else if (mode == "BlockThirdParty")
460         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockThirdPartyStorage);
461     else if (mode == "BlockAll")
462         settings()->setStorageBlockingPolicy(SecurityOrigin::BlockAllStorage);
463     else
464         ec = SYNTAX_ERR;
465 }
466
467 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled)
468 {
469     RuntimeEnabledFeatures::sharedFeatures().setLangAttributeAwareFormControlUIEnabled(enabled);
470 }
471
472 void InternalSettings::setImagesEnabled(bool enabled, ExceptionCode& ec)
473 {
474     InternalSettingsGuardForSettings();
475     settings()->setImagesEnabled(enabled);
476 }
477
478 void InternalSettings::setMinimumTimerInterval(double intervalInSeconds, ExceptionCode& ec)
479 {
480     InternalSettingsGuardForSettings();
481     settings()->setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
482 }
483
484 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionCode& ec)
485 {
486     InternalSettingsGuardForSettings();
487     settings()->setDefaultVideoPosterURL(url);
488 }
489
490 void InternalSettings::setForcePendingWebGLPolicy(bool forced, ExceptionCode& ec)
491 {
492     InternalSettingsGuardForSettings();
493     settings()->setForcePendingWebGLPolicy(forced);
494 }
495
496 void InternalSettings::setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode& ec)
497 {
498     InternalSettingsGuardForSettings();
499     settings()->setTimeWithoutMouseMovementBeforeHidingControls(time);
500 }
501
502 void InternalSettings::setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode& ec)
503 {
504     InternalSettingsGuardForSettings();
505     settings()->setUseLegacyBackgroundSizeShorthandBehavior(enabled);
506 }
507
508 void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode& ec)
509 {
510     InternalSettingsGuardForSettings();
511     settings()->setAutoscrollForDragAndDropEnabled(enabled);
512 }
513
514 void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
515 {
516     InternalSettingsGuardForSettings();
517     settings()->setFontFallbackPrefersPictographs(preferPictographs);
518 }
519
520 void InternalSettings::setWebFontsAlwaysFallBack(bool enable, ExceptionCode& ec)
521 {
522     InternalSettingsGuardForSettings();
523     settings()->setWebFontsAlwaysFallBack(enable);
524 }
525
526 void InternalSettings::setPluginReplacementEnabled(bool enabled)
527 {
528     RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(enabled);
529 }
530
531 void InternalSettings::setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode& ec)
532 {
533     InternalSettingsGuardForSettings();
534     settings()->setBackgroundShouldExtendBeyondPage(hasExtendedBackground);
535 }
536
537 void InternalSettings::setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode& ec)
538 {
539     InternalSettingsGuardForSettings();
540     settings()->setShouldConvertPositionStyleOnCopy(convert);
541 }
542
543 void InternalSettings::setScrollingTreeIncludesFrames(bool enabled, ExceptionCode& ec)
544 {
545     InternalSettingsGuardForSettings();
546     settings()->setScrollingTreeIncludesFrames(enabled);
547 }
548
549 void InternalSettings::setAllowsInlineMediaPlayback(bool allows, ExceptionCode& ec)
550 {
551     InternalSettingsGuardForSettings();
552     settings()->setAllowsInlineMediaPlayback(allows);
553 }
554
555 void InternalSettings::setAllowsInlineMediaPlaybackAfterFullscreen(bool allows, ExceptionCode& ec)
556 {
557     InternalSettingsGuardForSettings();
558     settings()->setAllowsInlineMediaPlaybackAfterFullscreen(allows);
559 }
560
561 void InternalSettings::setInlineMediaPlaybackRequiresPlaysInlineAttribute(bool requires, ExceptionCode& ec)
562 {
563     InternalSettingsGuardForSettings();
564     settings()->setInlineMediaPlaybackRequiresPlaysInlineAttribute(requires);
565 }
566
567 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled, ExceptionCode&)
568 {
569 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
570     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(enabled);
571 #else
572     UNUSED_PARAM(enabled);
573 #endif
574 }
575
576 String InternalSettings::userInterfaceDirectionPolicy(ExceptionCode& ec)
577 {
578     InternalSettingsGuardForSettingsReturn("");
579     switch (settings()->userInterfaceDirectionPolicy()) {
580     case UserInterfaceDirectionPolicy::Content:
581         return ASCIILiteral("Content");
582     case UserInterfaceDirectionPolicy::System:
583         return ASCIILiteral("View");
584     }
585     ASSERT_NOT_REACHED();
586     return String();
587 }
588
589 void InternalSettings::setUserInterfaceDirectionPolicy(const String& policy, ExceptionCode& ec)
590 {
591     InternalSettingsGuardForSettings();
592     if (equalLettersIgnoringASCIICase(policy, "content")) {
593         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::Content);
594         return;
595     }
596     if (equalLettersIgnoringASCIICase(policy, "view")) {
597         settings()->setUserInterfaceDirectionPolicy(UserInterfaceDirectionPolicy::System);
598         return;
599     }
600     ec = INVALID_ACCESS_ERR;
601 }
602
603 String InternalSettings::systemLayoutDirection(ExceptionCode& ec)
604 {
605     InternalSettingsGuardForSettingsReturn("");
606     switch (settings()->systemLayoutDirection()) {
607     case LTR:
608         return ASCIILiteral("LTR");
609     case RTL:
610         return ASCIILiteral("RTL");
611     }
612     ASSERT_NOT_REACHED();
613     return String();
614 }
615
616 void InternalSettings::setSystemLayoutDirection(const String& direction, ExceptionCode& ec)
617 {
618     InternalSettingsGuardForSettings();
619     if (equalLettersIgnoringASCIICase(direction, "ltr")) {
620         settings()->setSystemLayoutDirection(LTR);
621         return;
622     }
623     if (equalLettersIgnoringASCIICase(direction, "rtl")) {
624         settings()->setSystemLayoutDirection(RTL);
625         return;
626     }
627     ec = INVALID_ACCESS_ERR;
628 }
629
630 void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
631 {
632     Settings::setAllowsAnySSLCertificate(allowsAnyCertificate);
633 }
634
635 // If you add to this list, make sure that you update the Backup class for test reproducability!
636
637 }