tizen beta release
[framework/web/webkit-efl.git] / Source / WebCore / page / Settings.cpp
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27 #include "Settings.h"
28
29 #include "BackForwardController.h"
30 #include "CachedResourceLoader.h"
31 #include "CookieStorage.h"
32 #include "DOMTimer.h"
33 #include "Database.h"
34 #include "Document.h"
35 #include "Frame.h"
36 #include "FrameTree.h"
37 #include "FrameView.h"
38 #include "HistoryItem.h"
39 #include "Page.h"
40 #include "PageCache.h"
41 #include "ResourceHandle.h"
42 #include "StorageMap.h"
43 #include <limits>
44
45 using namespace std;
46
47 namespace WebCore {
48
49 static void setLoadsImagesAutomaticallyInAllFrames(Page* page)
50 {
51     for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
52         frame->document()->cachedResourceLoader()->setAutoLoadImages(page->settings()->loadsImagesAutomatically());
53 }
54
55 static inline void setGenericFontFamilyMap(ScriptFontFamilyMap& fontMap, const AtomicString& family, UScriptCode script, Page* page)
56 {
57     ScriptFontFamilyMap::iterator it = fontMap.find(static_cast<int>(script));
58     if (it != fontMap.end() && it->second == family)
59         return;
60     fontMap.set(static_cast<int>(script), family);
61     page->setNeedsRecalcStyleInAllFrames();
62 }
63
64 static inline const AtomicString& getGenericFontFamilyForScript(const ScriptFontFamilyMap& fontMap, UScriptCode script)
65 {
66     ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast<int>(script));
67     if (it != fontMap.end())
68         return it->second;
69     if (script != USCRIPT_COMMON)
70         return getGenericFontFamilyForScript(fontMap, USCRIPT_COMMON);
71     return emptyAtom;
72 }
73
74 #if USE(SAFARI_THEME)
75 bool Settings::gShouldPaintNativeControls = true;
76 #endif
77
78 #if USE(AVFOUNDATION)
79 bool Settings::gAVFoundationEnabled(false);
80 #endif
81
82 bool Settings::gMockScrollbarsEnabled = false;
83
84 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
85 bool Settings::gShouldUseHighResolutionTimers = true;
86 #endif
87
88 #if ENABLE(TIZEN_CSS_FIXED_AS_ABSOLUTE)
89 bool Settings::m_fixedAsAbsoluteEnabled = false;
90 #endif
91
92 // NOTEs
93 //  1) EditingMacBehavior comprises Tiger, Leopard, SnowLeopard and iOS builds, as well QtWebKit and Chromium when built on Mac;
94 //  2) EditingWindowsBehavior comprises Win32 and WinCE builds, as well as QtWebKit and Chromium when built on Windows;
95 //  3) EditingUnixBehavior comprises all unix-based systems, but Darwin/MacOS (and then abusing the terminology);
96 // 99) MacEditingBehavior is used a fallback.
97 static EditingBehaviorType editingBehaviorTypeForPlatform()
98 {
99     return
100 #if OS(DARWIN)
101     EditingMacBehavior
102 #elif OS(WINDOWS)
103     EditingWindowsBehavior
104 #elif OS(UNIX)
105     EditingUnixBehavior
106 #else
107     // Fallback
108     EditingMacBehavior
109 #endif
110     ;
111 }
112
113 Settings::Settings(Page* page)
114     : m_page(page)
115     , m_editableLinkBehavior(EditableLinkDefaultBehavior)
116     , m_textDirectionSubmenuInclusionBehavior(TextDirectionSubmenuAutomaticallyIncluded)
117     , m_passwordEchoDurationInSeconds(1)
118     , m_minimumFontSize(0)
119     , m_minimumLogicalFontSize(0)
120     , m_defaultFontSize(0)
121     , m_defaultFixedFontSize(0)
122     , m_validationMessageTimerMagnification(50)
123     , m_minimumAccelerated2dCanvasSize(128 * 128)
124     , m_layoutFallbackWidth(980)
125     , m_deviceDPI(240)
126     , m_maximumDecodedImageSize(numeric_limits<size_t>::max())
127     , m_deviceWidth(480)
128     , m_deviceHeight(854)
129     , m_sessionStorageQuota(StorageMap::noQuota)
130     , m_editingBehaviorType(editingBehaviorTypeForPlatform())
131     , m_maximumHTMLParserDOMTreeDepth(defaultMaximumHTMLParserDOMTreeDepth)
132     , m_isSpatialNavigationEnabled(false)
133     , m_isJavaEnabled(false)
134     , m_loadsImagesAutomatically(false)
135     , m_loadsSiteIconsIgnoringImageLoadingSetting(false)
136     , m_privateBrowsingEnabled(false)
137     , m_caretBrowsingEnabled(false)
138     , m_areImagesEnabled(true)
139     , m_isMediaEnabled(true)
140     , m_arePluginsEnabled(false)
141     , m_localStorageEnabled(false)
142     , m_isScriptEnabled(false)
143     , m_isWebSecurityEnabled(true)
144     , m_allowUniversalAccessFromFileURLs(true)
145     , m_allowFileAccessFromFileURLs(true)
146     , m_javaScriptCanOpenWindowsAutomatically(false)
147     , m_javaScriptCanAccessClipboard(false)
148     , m_shouldPrintBackgrounds(false)
149     , m_textAreasAreResizable(false)
150 #if ENABLE(DASHBOARD_SUPPORT)
151     , m_usesDashboardBackwardCompatibilityMode(false)
152 #endif
153     , m_needsAdobeFrameReloadingQuirk(false)
154     , m_needsKeyboardEventDisambiguationQuirks(false)
155     , m_treatsAnyTextCSSLinkAsStylesheet(false)
156     , m_needsLeopardMailQuirks(false)
157     , m_isDOMPasteAllowed(false)
158     , m_shrinksStandaloneImagesToFit(true)
159     , m_usesPageCache(false)
160     , m_showsURLsInToolTips(false)
161     , m_showsToolTipOverTruncatedText(false)
162     , m_forceFTPDirectoryListings(false)
163     , m_developerExtrasEnabled(false)
164     , m_authorAndUserStylesEnabled(true)
165     , m_needsSiteSpecificQuirks(false)
166     , m_fontRenderingMode(0)
167     , m_frameFlatteningEnabled(false)
168     , m_webArchiveDebugModeEnabled(false)
169     , m_localFileContentSniffingEnabled(false)
170     , m_inApplicationChromeMode(false)
171     , m_offlineWebApplicationCacheEnabled(false)
172     , m_enforceCSSMIMETypeInNoQuirksMode(true)
173     , m_usesEncodingDetector(false)
174     , m_allowScriptsToCloseWindows(false)
175     , m_canvasUsesAcceleratedDrawing(false)
176     , m_acceleratedDrawingEnabled(false)
177     // FIXME: This should really be disabled by default as it makes platforms that don't support the feature download files
178     // they can't use by. Leaving enabled for now to not change existing behavior.
179     , m_downloadableBinaryFontsEnabled(true)
180     , m_xssAuditorEnabled(false)
181     , m_acceleratedCompositingEnabled(true)
182     , m_acceleratedCompositingFor3DTransformsEnabled(true)
183     , m_acceleratedCompositingForVideoEnabled(true)
184     , m_acceleratedCompositingForPluginsEnabled(true)
185     , m_acceleratedCompositingForCanvasEnabled(true)
186     , m_acceleratedCompositingForAnimationEnabled(true)
187     , m_acceleratedCompositingForFixedPositionEnabled(false)
188     , m_acceleratedCompositingForScrollableFramesEnabled(false)
189     , m_showDebugBorders(false)
190     , m_showRepaintCounter(false)
191     , m_experimentalNotificationsEnabled(false)
192     , m_webGLEnabled(false)
193     , m_openGLMultisamplingEnabled(true)
194     , m_privilegedWebGLExtensionsEnabled(false)
195     , m_webAudioEnabled(false)
196     , m_acceleratedCanvas2dEnabled(false)
197     , m_legacyAcceleratedCanvas2dEnabled(false)
198     , m_loadDeferringEnabled(true)
199     , m_tiledBackingStoreEnabled(false)
200     , m_paginateDuringLayoutEnabled(false)
201     , m_dnsPrefetchingEnabled(false)
202 #if ENABLE(FULLSCREEN_API)
203     , m_fullScreenAPIEnabled(false)
204 #endif
205     , m_asynchronousSpellCheckingEnabled(false)
206 #if USE(UNIFIED_TEXT_CHECKING)
207     , m_unifiedTextCheckerEnabled(true)
208 #else
209     , m_unifiedTextCheckerEnabled(false)
210 #endif
211     , m_memoryInfoEnabled(false)
212     , m_interactiveFormValidation(false)
213     , m_usePreHTML5ParserQuirks(false)
214     , m_hyperlinkAuditingEnabled(false)
215     , m_crossOriginCheckInGetMatchedCSSRulesDisabled(false)
216 #if ENABLE(TIZEN_GEOLOCATION)
217     , m_isGeolocationEnabled(false)
218 #endif
219 #if ENABLE(TIZEN_FOCUS_RING)
220     , m_isFocusRingEnabled(true)
221 #endif
222     , m_forceCompositingMode(false)
223     , m_shouldInjectUserScriptsInInitialEmptyDocument(false)
224     , m_allowDisplayOfInsecureContent(true)
225     , m_allowRunningOfInsecureContent(true)
226 #if ENABLE(SMOOTH_SCROLLING)
227     , m_scrollAnimatorEnabled(true)
228 #endif
229 #if ENABLE(WEB_SOCKETS)
230     , m_useHixie76WebSocketProtocol(true)
231 #endif
232     , m_mediaPlaybackRequiresUserGesture(false)
233     , m_mediaPlaybackAllowsInline(true)
234 #if OS(SYMBIAN)
235     , m_passwordEchoEnabled(true)
236 #else
237     , m_passwordEchoEnabled(false)
238 #endif
239     , m_suppressIncrementalRendering(false)
240     , m_backspaceKeyNavigationEnabled(true)
241     , m_visualWordMovementEnabled(false)
242     , m_loadsImagesAutomaticallyTimer(this, &Settings::loadsImagesAutomaticallyTimerFired)
243 #if ENABLE(TIZEN_ONSCROLL_EVENT_SUPPRESSION)
244     , m_onscrollEventSuppressionEnabled(false)
245 #endif
246 #if ENABLE(TIZEN_CSS_FIXED_FAST_PATH)
247     , m_fixedFastPathImprovementsEnabled(true)
248 #endif
249 {
250     // A Frame may not have been created yet, so we initialize the AtomicString 
251     // hash before trying to use it.
252     AtomicString::init();
253 }
254
255 const AtomicString& Settings::standardFontFamily(UScriptCode script) const
256 {
257     return getGenericFontFamilyForScript(m_standardFontFamilyMap, script);
258 }
259
260 void Settings::setStandardFontFamily(const AtomicString& family, UScriptCode script)
261 {
262     setGenericFontFamilyMap(m_standardFontFamilyMap, family, script, m_page);
263 }
264
265 const AtomicString& Settings::fixedFontFamily(UScriptCode script) const
266 {
267     return getGenericFontFamilyForScript(m_fixedFontFamilyMap, script);
268 }
269
270 void Settings::setFixedFontFamily(const AtomicString& family, UScriptCode script)
271 {
272     setGenericFontFamilyMap(m_fixedFontFamilyMap, family, script, m_page);
273 }
274
275 const AtomicString& Settings::serifFontFamily(UScriptCode script) const
276 {
277     return getGenericFontFamilyForScript(m_serifFontFamilyMap, script);
278 }
279
280 void Settings::setSerifFontFamily(const AtomicString& family, UScriptCode script)
281 {
282      setGenericFontFamilyMap(m_serifFontFamilyMap, family, script, m_page);
283 }
284
285 const AtomicString& Settings::sansSerifFontFamily(UScriptCode script) const
286 {
287     return getGenericFontFamilyForScript(m_sansSerifFontFamilyMap, script);
288 }
289
290 void Settings::setSansSerifFontFamily(const AtomicString& family, UScriptCode script)
291 {
292     setGenericFontFamilyMap(m_sansSerifFontFamilyMap, family, script, m_page);
293 }
294
295 const AtomicString& Settings::cursiveFontFamily(UScriptCode script) const
296 {
297     return getGenericFontFamilyForScript(m_cursiveFontFamilyMap, script);
298 }
299
300 void Settings::setCursiveFontFamily(const AtomicString& family, UScriptCode script)
301 {
302     setGenericFontFamilyMap(m_cursiveFontFamilyMap, family, script, m_page);
303 }
304
305 const AtomicString& Settings::fantasyFontFamily(UScriptCode script) const
306 {
307     return getGenericFontFamilyForScript(m_fantasyFontFamilyMap, script);
308 }
309
310 void Settings::setFantasyFontFamily(const AtomicString& family, UScriptCode script)
311 {
312     setGenericFontFamilyMap(m_fantasyFontFamilyMap, family, script, m_page);
313 }
314
315 const AtomicString& Settings::pictographFontFamily(UScriptCode script) const
316 {
317     return getGenericFontFamilyForScript(m_pictographFontFamilyMap, script);
318 }
319
320 void Settings::setPictographFontFamily(const AtomicString& family, UScriptCode script)
321 {
322     setGenericFontFamilyMap(m_pictographFontFamilyMap, family, script, m_page);
323 }
324
325 void Settings::setMinimumFontSize(int minimumFontSize)
326 {
327     if (m_minimumFontSize == minimumFontSize)
328         return;
329
330     m_minimumFontSize = minimumFontSize;
331     m_page->setNeedsRecalcStyleInAllFrames();
332 }
333
334 void Settings::setMinimumLogicalFontSize(int minimumLogicalFontSize)
335 {
336     if (m_minimumLogicalFontSize == minimumLogicalFontSize)
337         return;
338
339     m_minimumLogicalFontSize = minimumLogicalFontSize;
340     m_page->setNeedsRecalcStyleInAllFrames();
341 }
342
343 void Settings::setDefaultFontSize(int defaultFontSize)
344 {
345     if (m_defaultFontSize == defaultFontSize)
346         return;
347
348     m_defaultFontSize = defaultFontSize;
349     m_page->setNeedsRecalcStyleInAllFrames();
350 }
351
352 void Settings::setDefaultFixedFontSize(int defaultFontSize)
353 {
354     if (m_defaultFixedFontSize == defaultFontSize)
355         return;
356
357     m_defaultFixedFontSize = defaultFontSize;
358     m_page->setNeedsRecalcStyleInAllFrames();
359 }
360
361 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
362 {
363     m_loadsImagesAutomatically = loadsImagesAutomatically;
364     
365     // Changing this setting to true might immediately start new loads for images that had previously had loading disabled.
366     // If this happens while a WebView is being dealloc'ed, and we don't know the WebView is being dealloc'ed, these new loads
367     // can cause crashes downstream when the WebView memory has actually been free'd.
368     // One example where this can happen is in Mac apps that subclass WebView then do work in their overridden dealloc methods.
369     // Starting these loads synchronously is not important.  By putting it on a 0-delay, properly closing the Page cancels them
370     // before they have a chance to really start.
371     // See http://webkit.org/b/60572 for more discussion.
372     m_loadsImagesAutomaticallyTimer.startOneShot(0);
373 }
374
375 void Settings::loadsImagesAutomaticallyTimerFired(Timer<Settings>*)
376 {
377     setLoadsImagesAutomaticallyInAllFrames(m_page);
378 }
379
380 void Settings::setLoadsSiteIconsIgnoringImageLoadingSetting(bool loadsSiteIcons)
381 {
382     m_loadsSiteIconsIgnoringImageLoadingSetting = loadsSiteIcons;
383 }
384
385 void Settings::setScriptEnabled(bool isScriptEnabled)
386 {
387     m_isScriptEnabled = isScriptEnabled;
388 }
389
390 void Settings::setWebSecurityEnabled(bool isWebSecurityEnabled)
391 {
392     m_isWebSecurityEnabled = isWebSecurityEnabled;
393 }
394
395 void Settings::setAllowUniversalAccessFromFileURLs(bool allowUniversalAccessFromFileURLs)
396 {
397     m_allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
398 }
399
400 void Settings::setAllowFileAccessFromFileURLs(bool allowFileAccessFromFileURLs)
401 {
402     m_allowFileAccessFromFileURLs = allowFileAccessFromFileURLs;
403 }
404
405 void Settings::setSpatialNavigationEnabled(bool isSpatialNavigationEnabled)
406 {
407     m_isSpatialNavigationEnabled = isSpatialNavigationEnabled;
408 }
409
410 void Settings::setJavaEnabled(bool isJavaEnabled)
411 {
412     m_isJavaEnabled = isJavaEnabled;
413 }
414
415 void Settings::setImagesEnabled(bool areImagesEnabled)
416 {
417     m_areImagesEnabled = areImagesEnabled;
418 }
419
420 void Settings::setMediaEnabled(bool isMediaEnabled)
421 {
422     m_isMediaEnabled = isMediaEnabled;
423 }
424
425 void Settings::setPluginsEnabled(bool arePluginsEnabled)
426 {
427     m_arePluginsEnabled = arePluginsEnabled;
428 }
429
430 void Settings::setLocalStorageEnabled(bool localStorageEnabled)
431 {
432     m_localStorageEnabled = localStorageEnabled;
433 }
434
435 void Settings::setSessionStorageQuota(unsigned sessionStorageQuota)
436 {
437     m_sessionStorageQuota = sessionStorageQuota;
438 }
439
440 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
441 {
442     // FIXME http://webkit.org/b/67870: The private browsing storage session and cookie private
443     // browsing mode (which is used if storage sessions are not available) are global settings, so
444     // it is misleading to have them as per-page settings.
445     // In addition, if they are treated as a per Page settings, the global values can get out of
446     // sync with the per Page value in the following situation:
447     // 1. The global values get set to true when setPrivateBrowsingEnabled(true) is called.
448     // 2. All Pages are closed, so all Settings objects go away.
449     // 3. A new Page is created, and a corresponding new Settings object is created - with
450     //    m_privateBrowsingEnabled starting out as false in the constructor.
451     // 4. The WebPage settings get applied to the new Page and setPrivateBrowsingEnabled(false)
452     //    is called, but an if (m_privateBrowsingEnabled == privateBrowsingEnabled) early return
453     //    prevents the global values from getting changed from true to false.
454 #if USE(CFURLSTORAGESESSIONS)
455     ResourceHandle::setPrivateBrowsingEnabled(privateBrowsingEnabled);
456 #endif
457     setCookieStoragePrivateBrowsingEnabled(privateBrowsingEnabled);
458
459     if (m_privateBrowsingEnabled == privateBrowsingEnabled)
460         return;
461
462     m_privateBrowsingEnabled = privateBrowsingEnabled;
463     m_page->privateBrowsingStateChanged();
464 }
465
466 void Settings::setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically)
467 {
468     m_javaScriptCanOpenWindowsAutomatically = javaScriptCanOpenWindowsAutomatically;
469 }
470
471 void Settings::setJavaScriptCanAccessClipboard(bool javaScriptCanAccessClipboard)
472 {
473     m_javaScriptCanAccessClipboard = javaScriptCanAccessClipboard;
474 }
475
476 void Settings::setDefaultTextEncodingName(const String& defaultTextEncodingName)
477 {
478     m_defaultTextEncodingName = defaultTextEncodingName;
479 }
480
481 void Settings::setUserStyleSheetLocation(const KURL& userStyleSheetLocation)
482 {
483     if (m_userStyleSheetLocation == userStyleSheetLocation)
484         return;
485
486     m_userStyleSheetLocation = userStyleSheetLocation;
487
488     m_page->userStyleSheetLocationChanged();
489 }
490
491 void Settings::setShouldPrintBackgrounds(bool shouldPrintBackgrounds)
492 {
493     m_shouldPrintBackgrounds = shouldPrintBackgrounds;
494 }
495
496 void Settings::setTextAreasAreResizable(bool textAreasAreResizable)
497 {
498     if (m_textAreasAreResizable == textAreasAreResizable)
499         return;
500
501     m_textAreasAreResizable = textAreasAreResizable;
502     m_page->setNeedsRecalcStyleInAllFrames();
503 }
504
505 void Settings::setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior)
506 {
507     m_editableLinkBehavior = editableLinkBehavior;
508 }
509
510 void Settings::setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior behavior)
511 {
512     m_textDirectionSubmenuInclusionBehavior = behavior;
513 }
514
515 #if ENABLE(DASHBOARD_SUPPORT)
516 void Settings::setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode)
517 {
518     m_usesDashboardBackwardCompatibilityMode = usesDashboardBackwardCompatibilityMode;
519 }
520 #endif
521
522 // FIXME: This quirk is needed because of Radar 4674537 and 5211271. We need to phase it out once Adobe
523 // can fix the bug from their end.
524 void Settings::setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC)
525 {
526     m_needsAdobeFrameReloadingQuirk = shouldNotReloadIFramesForUnchangedSRC;
527 }
528
529 // This is a quirk we are pro-actively applying to old applications. It changes keyboard event dispatching,
530 // making keyIdentifier available on keypress events, making charCode available on keydown/keyup events,
531 // and getting keypress dispatched in more cases.
532 void Settings::setNeedsKeyboardEventDisambiguationQuirks(bool needsQuirks)
533 {
534     m_needsKeyboardEventDisambiguationQuirks = needsQuirks;
535 }
536
537 void Settings::setTreatsAnyTextCSSLinkAsStylesheet(bool treatsAnyTextCSSLinkAsStylesheet)
538 {
539     m_treatsAnyTextCSSLinkAsStylesheet = treatsAnyTextCSSLinkAsStylesheet;
540 }
541
542 void Settings::setNeedsLeopardMailQuirks(bool needsQuirks)
543 {
544     m_needsLeopardMailQuirks = needsQuirks;
545 }
546
547 void Settings::setDOMPasteAllowed(bool DOMPasteAllowed)
548 {
549     m_isDOMPasteAllowed = DOMPasteAllowed;
550 }
551
552 void Settings::setDefaultMinDOMTimerInterval(double interval)
553 {
554     DOMTimer::setDefaultMinTimerInterval(interval);
555 }
556
557 double Settings::defaultMinDOMTimerInterval()
558 {
559     return DOMTimer::defaultMinTimerInterval();
560 }
561
562 void Settings::setMinDOMTimerInterval(double interval)
563 {
564     m_page->setMinimumTimerInterval(interval);
565 }
566
567 double Settings::minDOMTimerInterval()
568 {
569     return m_page->minimumTimerInterval();
570 }
571
572 void Settings::setUsesPageCache(bool usesPageCache)
573 {
574     if (m_usesPageCache == usesPageCache)
575         return;
576         
577     m_usesPageCache = usesPageCache;
578     if (!m_usesPageCache) {
579         int first = -m_page->backForward()->backCount();
580         int last = m_page->backForward()->forwardCount();
581         for (int i = first; i <= last; i++)
582             pageCache()->remove(m_page->backForward()->itemAtIndex(i));
583         pageCache()->releaseAutoreleasedPagesNow();
584     }
585 }
586
587 void Settings::setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit)
588 {
589     m_shrinksStandaloneImagesToFit = shrinksStandaloneImagesToFit;
590 }
591
592 void Settings::setShowsURLsInToolTips(bool showsURLsInToolTips)
593 {
594     m_showsURLsInToolTips = showsURLsInToolTips;
595 }
596
597 void Settings::setShowsToolTipOverTruncatedText(bool showsToolTipForTruncatedText)
598 {
599     m_showsToolTipOverTruncatedText = showsToolTipForTruncatedText;
600 }
601
602 void Settings::setFTPDirectoryTemplatePath(const String& path)
603 {
604     m_ftpDirectoryTemplatePath = path;
605 }
606
607 void Settings::setForceFTPDirectoryListings(bool force)
608 {
609     m_forceFTPDirectoryListings = force;
610 }
611
612 void Settings::setDeveloperExtrasEnabled(bool developerExtrasEnabled)
613 {
614     m_developerExtrasEnabled = developerExtrasEnabled;
615 }
616
617 void Settings::setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)
618 {
619     if (m_authorAndUserStylesEnabled == authorAndUserStylesEnabled)
620         return;
621
622     m_authorAndUserStylesEnabled = authorAndUserStylesEnabled;
623     m_page->setNeedsRecalcStyleInAllFrames();
624 }
625
626 void Settings::setFontRenderingMode(FontRenderingMode mode)
627 {
628     if (fontRenderingMode() == mode)
629         return;
630     m_fontRenderingMode = mode;
631     m_page->setNeedsRecalcStyleInAllFrames();
632 }
633
634 FontRenderingMode Settings::fontRenderingMode() const
635 {
636     return static_cast<FontRenderingMode>(m_fontRenderingMode);
637 }
638
639 void Settings::setNeedsSiteSpecificQuirks(bool needsQuirks)
640 {
641     m_needsSiteSpecificQuirks = needsQuirks;
642 }
643
644 void Settings::setFrameFlatteningEnabled(bool frameFlatteningEnabled)
645 {
646     m_frameFlatteningEnabled = frameFlatteningEnabled;
647 }
648
649 #if ENABLE(WEB_ARCHIVE)
650 void Settings::setWebArchiveDebugModeEnabled(bool enabled)
651 {
652     m_webArchiveDebugModeEnabled = enabled;
653 }
654 #endif
655
656 void Settings::setLocalFileContentSniffingEnabled(bool enabled)
657 {
658     m_localFileContentSniffingEnabled = enabled;
659 }
660
661 void Settings::setLocalStorageDatabasePath(const String& path)
662 {
663     m_localStorageDatabasePath = path;
664 }
665
666 void Settings::setApplicationChromeMode(bool mode)
667 {
668     m_inApplicationChromeMode = mode;
669 }
670
671 void Settings::setOfflineWebApplicationCacheEnabled(bool enabled)
672 {
673     m_offlineWebApplicationCacheEnabled = enabled;
674 }
675
676 void Settings::setEnforceCSSMIMETypeInNoQuirksMode(bool enforceCSSMIMETypeInNoQuirksMode)
677 {
678     m_enforceCSSMIMETypeInNoQuirksMode = enforceCSSMIMETypeInNoQuirksMode;
679 }
680
681 #if USE(SAFARI_THEME)
682 void Settings::setShouldPaintNativeControls(bool shouldPaintNativeControls)
683 {
684     gShouldPaintNativeControls = shouldPaintNativeControls;
685 }
686 #endif
687
688 void Settings::setUsesEncodingDetector(bool usesEncodingDetector)
689 {
690     m_usesEncodingDetector = usesEncodingDetector;
691 }
692
693 void Settings::setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)
694 {
695     if (m_dnsPrefetchingEnabled == dnsPrefetchingEnabled)
696         return;
697
698     m_dnsPrefetchingEnabled = dnsPrefetchingEnabled;
699     m_page->dnsPrefetchingStateChanged();
700 }
701
702 void Settings::setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)
703 {
704     m_allowScriptsToCloseWindows = allowScriptsToCloseWindows;
705 }
706
707 void Settings::setCaretBrowsingEnabled(bool caretBrowsingEnabled)
708 {
709     m_caretBrowsingEnabled = caretBrowsingEnabled;
710 }
711
712 void Settings::setDownloadableBinaryFontsEnabled(bool downloadableBinaryFontsEnabled)
713 {
714     m_downloadableBinaryFontsEnabled = downloadableBinaryFontsEnabled;
715 }
716
717 void Settings::setXSSAuditorEnabled(bool xssAuditorEnabled)
718 {
719     m_xssAuditorEnabled = xssAuditorEnabled;
720 }
721
722 void Settings::setAcceleratedCompositingEnabled(bool enabled)
723 {
724     if (m_acceleratedCompositingEnabled == enabled)
725         return;
726         
727     m_acceleratedCompositingEnabled = enabled;
728     m_page->setNeedsRecalcStyleInAllFrames();
729 }
730
731 void Settings::setCanvasUsesAcceleratedDrawing(bool enabled)
732 {
733     m_canvasUsesAcceleratedDrawing = enabled;
734 }
735
736 void Settings::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
737 {
738     m_acceleratedCompositingFor3DTransformsEnabled = enabled;
739 }
740
741 void Settings::setAcceleratedCompositingForVideoEnabled(bool enabled)
742 {
743     m_acceleratedCompositingForVideoEnabled = enabled;
744 }
745
746 void Settings::setAcceleratedCompositingForPluginsEnabled(bool enabled)
747 {
748     m_acceleratedCompositingForPluginsEnabled = enabled;
749 }
750
751 void Settings::setAcceleratedCompositingForCanvasEnabled(bool enabled)
752 {
753     m_acceleratedCompositingForCanvasEnabled = enabled;
754 }
755
756 void Settings::setAcceleratedCompositingForAnimationEnabled(bool enabled)
757 {
758     m_acceleratedCompositingForAnimationEnabled = enabled;
759 }
760
761 void Settings::setShowDebugBorders(bool enabled)
762 {
763     if (m_showDebugBorders == enabled)
764         return;
765         
766     m_showDebugBorders = enabled;
767     m_page->setNeedsRecalcStyleInAllFrames();
768 }
769
770 void Settings::setShowRepaintCounter(bool enabled)
771 {
772     if (m_showRepaintCounter == enabled)
773         return;
774         
775     m_showRepaintCounter = enabled;
776     m_page->setNeedsRecalcStyleInAllFrames();
777 }
778
779 void Settings::setExperimentalNotificationsEnabled(bool enabled)
780 {
781     m_experimentalNotificationsEnabled = enabled;
782 }
783
784 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
785 void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
786 {
787     gShouldUseHighResolutionTimers = shouldUseHighResolutionTimers;
788 }
789 #endif
790
791 void Settings::setWebAudioEnabled(bool enabled)
792 {
793     m_webAudioEnabled = enabled;
794 }
795
796 void Settings::setWebGLEnabled(bool enabled)
797 {
798     m_webGLEnabled = enabled;
799 }
800
801 void Settings::setOpenGLMultisamplingEnabled(bool enabled)
802 {
803     m_openGLMultisamplingEnabled = enabled;
804 }
805
806 void Settings::setPrivilegedWebGLExtensionsEnabled(bool enabled)
807 {
808     m_privilegedWebGLExtensionsEnabled = enabled;
809 }
810
811 void Settings::setAccelerated2dCanvasEnabled(bool enabled)
812 {
813     m_acceleratedCanvas2dEnabled = enabled;
814 }
815
816 void Settings::setLegacyAccelerated2dCanvasEnabled(bool enabled)
817 {
818     m_legacyAcceleratedCanvas2dEnabled = enabled;
819 }
820
821 void Settings::setMinimumAccelerated2dCanvasSize(int numPixels)
822 {
823     m_minimumAccelerated2dCanvasSize = numPixels;
824 }
825
826 void Settings::setLoadDeferringEnabled(bool enabled)
827 {
828     m_loadDeferringEnabled = enabled;
829 }
830
831 void Settings::setTiledBackingStoreEnabled(bool enabled)
832 {
833     m_tiledBackingStoreEnabled = enabled;
834 #if USE(TILED_BACKING_STORE)
835     if (m_page->mainFrame())
836         m_page->mainFrame()->setTiledBackingStoreEnabled(enabled);
837 #endif
838 }
839
840 #if ENABLE(TIZEN_GEOLOCATION)
841 void Settings::setGeolocationEnabled(bool isGeolocationEnabled)
842 {
843     m_isGeolocationEnabled = isGeolocationEnabled;
844 }
845 #endif
846
847 void Settings::setMockScrollbarsEnabled(bool flag)
848 {
849     gMockScrollbarsEnabled = flag;
850 }
851
852 bool Settings::mockScrollbarsEnabled()
853 {
854     return gMockScrollbarsEnabled;
855 }
856 #if ENABLE(TIZEN_FOCUS_RING)
857 void Settings::setFocusRingEnabled(bool isFocusRingEnabled)
858 {
859     m_isFocusRingEnabled = isFocusRingEnabled;
860 }
861
862 #endif
863
864 } // namespace WebCore