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