2 * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
29 #include "BackForwardController.h"
30 #include "CachedResourceLoader.h"
31 #include "CookieStorage.h"
36 #include "FrameTree.h"
37 #include "FrameView.h"
38 #include "HistoryItem.h"
40 #include "PageCache.h"
41 #include "ResourceHandle.h"
42 #include "StorageMap.h"
49 static void setImageLoadingSettings(Page* page)
51 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
52 frame->document()->cachedResourceLoader()->setImagesEnabled(page->settings()->areImagesEnabled());
53 frame->document()->cachedResourceLoader()->setAutoLoadImages(page->settings()->loadsImagesAutomatically());
57 // Sets the entry in the font map for the given script. If family is the empty string, removes the entry instead.
58 static inline void setGenericFontFamilyMap(ScriptFontFamilyMap& fontMap, const AtomicString& family, UScriptCode script, Page* page)
60 ScriptFontFamilyMap::iterator it = fontMap.find(static_cast<int>(script));
61 if (family.isEmpty()) {
62 if (it == fontMap.end())
65 } else if (it != fontMap.end() && it->value == family)
68 fontMap.set(static_cast<int>(script), family);
71 page->setNeedsRecalcStyleInAllFrames();
74 static inline const AtomicString& getGenericFontFamilyForScript(const ScriptFontFamilyMap& fontMap, UScriptCode script)
76 ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast<int>(script));
77 if (it != fontMap.end())
79 if (script != USCRIPT_COMMON)
80 return getGenericFontFamilyForScript(fontMap, USCRIPT_COMMON);
85 bool Settings::gShouldPaintNativeControls = true;
89 bool Settings::gAVFoundationEnabled(false);
92 bool Settings::gMockScrollbarsEnabled = false;
93 bool Settings::gUsesOverlayScrollbars = false;
95 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
96 bool Settings::gShouldUseHighResolutionTimers = true;
100 bool Settings::gShouldRespectPriorityInCSSAttributeSetters = false;
104 // 1) EditingMacBehavior comprises Tiger, Leopard, SnowLeopard and iOS builds, as well QtWebKit and Chromium when built on Mac;
105 // 2) EditingWindowsBehavior comprises Win32 and WinCE builds, as well as QtWebKit and Chromium when built on Windows;
106 // 3) EditingUnixBehavior comprises all unix-based systems, but Darwin/MacOS (and then abusing the terminology);
107 // 99) MacEditingBehavior is used a fallback.
108 static EditingBehaviorType editingBehaviorTypeForPlatform()
114 EditingWindowsBehavior
124 static const double defaultIncrementalRenderingSuppressionTimeoutInSeconds = 5;
126 Settings::Settings(Page* page)
128 , m_editableLinkBehavior(EditableLinkDefaultBehavior)
129 , m_textDirectionSubmenuInclusionBehavior(TextDirectionSubmenuAutomaticallyIncluded)
130 , m_passwordEchoDurationInSeconds(1)
131 , m_minimumFontSize(0)
132 , m_minimumLogicalFontSize(0)
133 , m_defaultFontSize(0)
134 , m_defaultFixedFontSize(0)
135 , m_screenFontSubstitutionEnabled(true)
136 , m_validationMessageTimerMagnification(50)
137 , m_minimumAccelerated2dCanvasSize(257 * 256)
138 , m_layoutFallbackWidth(980)
139 , m_maximumDecodedImageSize(numeric_limits<size_t>::max())
142 , m_sessionStorageQuota(StorageMap::noQuota)
143 , m_editingBehaviorType(editingBehaviorTypeForPlatform())
144 , m_maximumHTMLParserDOMTreeDepth(defaultMaximumHTMLParserDOMTreeDepth)
145 , m_storageBlockingPolicy(SecurityOrigin::AllowAllStorage)
146 #if ENABLE(TEXT_AUTOSIZING)
147 , m_textAutosizingFontScaleFactor(1)
148 #if HACK_FORCE_TEXT_AUTOSIZING_ON_DESKTOP
149 , m_textAutosizingWindowSizeOverride(320, 480)
150 , m_textAutosizingEnabled(true)
152 , m_textAutosizingEnabled(false)
155 , m_isSpatialNavigationEnabled(false)
156 , m_isJavaEnabled(false)
157 , m_isJavaEnabledForLocalFiles(true)
158 , m_loadsImagesAutomatically(false)
159 , m_loadsSiteIconsIgnoringImageLoadingSetting(false)
160 , m_privateBrowsingEnabled(false)
161 , m_caretBrowsingEnabled(false)
162 , m_areImagesEnabled(true)
163 , m_isMediaEnabled(true)
164 , m_arePluginsEnabled(false)
165 , m_localStorageEnabled(false)
166 , m_isScriptEnabled(false)
167 , m_isWebSecurityEnabled(true)
168 , m_allowUniversalAccessFromFileURLs(true)
169 , m_allowFileAccessFromFileURLs(true)
170 , m_javaScriptCanOpenWindowsAutomatically(false)
171 , m_javaScriptCanAccessClipboard(false)
172 , m_shouldPrintBackgrounds(false)
173 , m_textAreasAreResizable(false)
174 #if ENABLE(DASHBOARD_SUPPORT)
175 , m_usesDashboardBackwardCompatibilityMode(false)
177 , m_needsAdobeFrameReloadingQuirk(false)
178 , m_needsKeyboardEventDisambiguationQuirks(false)
179 , m_treatsAnyTextCSSLinkAsStylesheet(false)
180 , m_needsLeopardMailQuirks(false)
181 , m_isDOMPasteAllowed(false)
182 , m_shrinksStandaloneImagesToFit(true)
183 , m_usesPageCache(false)
184 , m_pageCacheSupportsPlugins(false)
185 , m_showsURLsInToolTips(false)
186 , m_showsToolTipOverTruncatedText(false)
187 , m_forceFTPDirectoryListings(false)
188 , m_developerExtrasEnabled(false)
189 , m_javaScriptExperimentsEnabled(false)
190 , m_authorAndUserStylesEnabled(true)
191 , m_needsSiteSpecificQuirks(false)
192 , m_fontRenderingMode(0)
193 , m_frameFlatteningEnabled(false)
194 #if ENABLE(WEB_ARCHIVE)
195 , m_webArchiveDebugModeEnabled(false)
197 , m_localFileContentSniffingEnabled(false)
198 , m_inApplicationChromeMode(false)
199 , m_offlineWebApplicationCacheEnabled(false)
200 , m_enforceCSSMIMETypeInNoQuirksMode(true)
201 , m_usesEncodingDetector(false)
202 , m_allowScriptsToCloseWindows(false)
203 , m_canvasUsesAcceleratedDrawing(false)
204 , m_acceleratedDrawingEnabled(false)
205 , m_acceleratedFiltersEnabled(false)
206 , m_isCSSCustomFilterEnabled(false)
207 #if ENABLE(CSS_STICKY_POSITION)
208 , m_cssStickyPositionEnabled(true)
210 #if ENABLE(CSS_REGIONS)
211 , m_cssRegionsEnabled(false)
213 #if ENABLE(CSS_VARIABLES)
214 , m_cssVariablesEnabled(false)
216 , m_regionBasedColumnsEnabled(false)
217 , m_cssGridLayoutEnabled(false)
218 // FIXME: This should really be disabled by default as it makes platforms that don't support the feature download files
219 // they can't use by. Leaving enabled for now to not change existing behavior.
220 , m_downloadableBinaryFontsEnabled(true)
221 , m_xssAuditorEnabled(false)
222 , m_acceleratedCompositingEnabled(true)
223 , m_acceleratedCompositingFor3DTransformsEnabled(true)
224 , m_acceleratedCompositingForVideoEnabled(true)
225 , m_acceleratedCompositingForPluginsEnabled(true)
226 , m_acceleratedCompositingForCanvasEnabled(true)
227 , m_acceleratedCompositingForAnimationEnabled(true)
228 , m_acceleratedCompositingForFixedPositionEnabled(false)
229 , m_acceleratedCompositingForScrollableFramesEnabled(false)
230 , m_showDebugBorders(false)
231 , m_showRepaintCounter(false)
232 , m_experimentalNotificationsEnabled(false)
233 , m_webGLEnabled(false)
234 , m_webGLErrorsToConsoleEnabled(false)
235 , m_openGLMultisamplingEnabled(true)
236 , m_privilegedWebGLExtensionsEnabled(false)
237 , m_webAudioEnabled(false)
238 , m_acceleratedCanvas2dEnabled(false)
239 , m_deferredCanvas2dEnabled(false)
240 , m_loadDeferringEnabled(true)
241 , m_tiledBackingStoreEnabled(false)
242 , m_paginateDuringLayoutEnabled(false)
243 , m_dnsPrefetchingEnabled(false)
244 #if ENABLE(FULLSCREEN_API)
245 , m_fullScreenAPIEnabled(false)
247 , m_asynchronousSpellCheckingEnabled(false)
248 #if USE(UNIFIED_TEXT_CHECKING)
249 , m_unifiedTextCheckerEnabled(true)
251 , m_unifiedTextCheckerEnabled(false)
253 , m_memoryInfoEnabled(false)
254 , m_quantizedMemoryInfoEnabled(false)
255 , m_interactiveFormValidation(false)
256 , m_usePreHTML5ParserQuirks(false)
257 , m_hyperlinkAuditingEnabled(false)
258 , m_crossOriginCheckInGetMatchedCSSRulesDisabled(false)
259 , m_forceCompositingMode(false)
260 , m_shouldInjectUserScriptsInInitialEmptyDocument(false)
261 , m_fixedElementsLayoutRelativeToFrame(false)
262 , m_allowDisplayOfInsecureContent(true)
263 , m_allowRunningOfInsecureContent(true)
264 #if ENABLE(SMOOTH_SCROLLING)
265 , m_scrollAnimatorEnabled(true)
267 , m_mediaPlaybackRequiresUserGesture(false)
268 , m_mediaPlaybackAllowsInline(true)
269 , m_passwordEchoEnabled(false)
270 , m_suppressesIncrementalRendering(false)
271 , m_backspaceKeyNavigationEnabled(true)
272 , m_visualWordMovementEnabled(false)
273 #if ENABLE(VIDEO_TRACK)
274 , m_shouldDisplaySubtitles(false)
275 , m_shouldDisplayCaptions(false)
276 , m_shouldDisplayTextDescriptions(false)
278 , m_scrollingCoordinatorEnabled(false)
279 , m_notificationsEnabled(true)
280 , m_needsIsLoadingInAPISenseQuirk(false)
281 #if ENABLE(TOUCH_EVENTS)
282 , m_touchEventEmulationEnabled(false)
284 , m_shouldRespectImageOrientation(false)
285 , m_wantsBalancedSetDefersLoadingBehavior(false)
286 , m_requestAnimationFrameEnabled(true)
287 , m_deviceSupportsTouch(false)
288 , m_deviceSupportsMouse(true)
289 , m_needsDidFinishLoadOrderQuirk(false)
290 , m_fixedPositionCreatesStackingContext(false)
291 , m_syncXHRInDocumentsEnabled(true)
292 , m_cookieEnabled(true)
293 , m_windowFocusRestricted(true)
294 , m_diagnosticLoggingEnabled(false)
295 , m_scrollingPerformanceLoggingEnabled(false)
296 , m_applyPageScaleFactorInCompositor(false)
297 , m_plugInSnapshottingEnabled(false)
298 , m_setImageLoadingSettingsTimer(this, &Settings::imageLoadingSettingsTimerFired)
299 , m_incrementalRenderingSuppressionTimeoutInSeconds(defaultIncrementalRenderingSuppressionTimeoutInSeconds)
301 // A Frame may not have been created yet, so we initialize the AtomicString
302 // hash before trying to use it.
303 AtomicString::init();
304 initializeDefaultFontFamilies();
305 m_page = page; // Page is not yet fully initialized wen constructing Settings, so keeping m_page null over initializeDefaultFontFamilies() call.
308 PassOwnPtr<Settings> Settings::create(Page* page)
310 return adoptPtr(new Settings(page));
313 #if !PLATFORM(MAC) && !PLATFORM(BLACKBERRY)
314 void Settings::initializeDefaultFontFamilies()
316 // Other platforms can set up fonts from a client, but on Mac, we want it in WebCore to share code between WebKit1 and WebKit2.
320 const AtomicString& Settings::standardFontFamily(UScriptCode script) const
322 return getGenericFontFamilyForScript(m_standardFontFamilyMap, script);
325 void Settings::setStandardFontFamily(const AtomicString& family, UScriptCode script)
327 setGenericFontFamilyMap(m_standardFontFamilyMap, family, script, m_page);
330 const AtomicString& Settings::fixedFontFamily(UScriptCode script) const
332 return getGenericFontFamilyForScript(m_fixedFontFamilyMap, script);
335 void Settings::setFixedFontFamily(const AtomicString& family, UScriptCode script)
337 setGenericFontFamilyMap(m_fixedFontFamilyMap, family, script, m_page);
340 const AtomicString& Settings::serifFontFamily(UScriptCode script) const
342 return getGenericFontFamilyForScript(m_serifFontFamilyMap, script);
345 void Settings::setSerifFontFamily(const AtomicString& family, UScriptCode script)
347 setGenericFontFamilyMap(m_serifFontFamilyMap, family, script, m_page);
350 const AtomicString& Settings::sansSerifFontFamily(UScriptCode script) const
352 return getGenericFontFamilyForScript(m_sansSerifFontFamilyMap, script);
355 void Settings::setSansSerifFontFamily(const AtomicString& family, UScriptCode script)
357 setGenericFontFamilyMap(m_sansSerifFontFamilyMap, family, script, m_page);
360 const AtomicString& Settings::cursiveFontFamily(UScriptCode script) const
362 return getGenericFontFamilyForScript(m_cursiveFontFamilyMap, script);
365 void Settings::setCursiveFontFamily(const AtomicString& family, UScriptCode script)
367 setGenericFontFamilyMap(m_cursiveFontFamilyMap, family, script, m_page);
370 const AtomicString& Settings::fantasyFontFamily(UScriptCode script) const
372 return getGenericFontFamilyForScript(m_fantasyFontFamilyMap, script);
375 void Settings::setFantasyFontFamily(const AtomicString& family, UScriptCode script)
377 setGenericFontFamilyMap(m_fantasyFontFamilyMap, family, script, m_page);
380 const AtomicString& Settings::pictographFontFamily(UScriptCode script) const
382 return getGenericFontFamilyForScript(m_pictographFontFamilyMap, script);
385 void Settings::setPictographFontFamily(const AtomicString& family, UScriptCode script)
387 setGenericFontFamilyMap(m_pictographFontFamilyMap, family, script, m_page);
390 void Settings::setMinimumFontSize(int minimumFontSize)
392 if (m_minimumFontSize == minimumFontSize)
395 m_minimumFontSize = minimumFontSize;
396 m_page->setNeedsRecalcStyleInAllFrames();
399 void Settings::setMinimumLogicalFontSize(int minimumLogicalFontSize)
401 if (m_minimumLogicalFontSize == minimumLogicalFontSize)
404 m_minimumLogicalFontSize = minimumLogicalFontSize;
405 m_page->setNeedsRecalcStyleInAllFrames();
408 void Settings::setDefaultFontSize(int defaultFontSize)
410 if (m_defaultFontSize == defaultFontSize)
413 m_defaultFontSize = defaultFontSize;
414 m_page->setNeedsRecalcStyleInAllFrames();
417 void Settings::setDefaultFixedFontSize(int defaultFontSize)
419 if (m_defaultFixedFontSize == defaultFontSize)
422 m_defaultFixedFontSize = defaultFontSize;
423 m_page->setNeedsRecalcStyleInAllFrames();
426 void Settings::setScreenFontSubstitutionEnabled(bool screenFontSubstitutionEnabled)
428 if (m_screenFontSubstitutionEnabled == screenFontSubstitutionEnabled)
431 m_screenFontSubstitutionEnabled = screenFontSubstitutionEnabled;
432 m_page->setNeedsRecalcStyleInAllFrames();
435 #if ENABLE(TEXT_AUTOSIZING)
436 void Settings::setTextAutosizingEnabled(bool textAutosizingEnabled)
438 if (m_textAutosizingEnabled == textAutosizingEnabled)
441 m_textAutosizingEnabled = textAutosizingEnabled;
442 m_page->setNeedsRecalcStyleInAllFrames();
445 void Settings::setTextAutosizingWindowSizeOverride(const IntSize& textAutosizingWindowSizeOverride)
447 if (m_textAutosizingWindowSizeOverride == textAutosizingWindowSizeOverride)
450 m_textAutosizingWindowSizeOverride = textAutosizingWindowSizeOverride;
451 m_page->setNeedsRecalcStyleInAllFrames();
454 void Settings::setTextAutosizingFontScaleFactor(float fontScaleFactor)
456 m_textAutosizingFontScaleFactor = fontScaleFactor;
457 m_page->setNeedsRecalcStyleInAllFrames();
462 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
464 m_loadsImagesAutomatically = loadsImagesAutomatically;
466 // Changing this setting to true might immediately start new loads for images that had previously had loading disabled.
467 // If this happens while a WebView is being dealloc'ed, and we don't know the WebView is being dealloc'ed, these new loads
468 // can cause crashes downstream when the WebView memory has actually been free'd.
469 // One example where this can happen is in Mac apps that subclass WebView then do work in their overridden dealloc methods.
470 // Starting these loads synchronously is not important. By putting it on a 0-delay, properly closing the Page cancels them
471 // before they have a chance to really start.
472 // See http://webkit.org/b/60572 for more discussion.
473 m_setImageLoadingSettingsTimer.startOneShot(0);
476 void Settings::imageLoadingSettingsTimerFired(Timer<Settings>*)
478 setImageLoadingSettings(m_page);
481 void Settings::setLoadsSiteIconsIgnoringImageLoadingSetting(bool loadsSiteIcons)
483 m_loadsSiteIconsIgnoringImageLoadingSetting = loadsSiteIcons;
486 void Settings::setScriptEnabled(bool isScriptEnabled)
488 m_isScriptEnabled = isScriptEnabled;
491 void Settings::setWebSecurityEnabled(bool isWebSecurityEnabled)
493 m_isWebSecurityEnabled = isWebSecurityEnabled;
496 void Settings::setAllowUniversalAccessFromFileURLs(bool allowUniversalAccessFromFileURLs)
498 m_allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
501 void Settings::setAllowFileAccessFromFileURLs(bool allowFileAccessFromFileURLs)
503 m_allowFileAccessFromFileURLs = allowFileAccessFromFileURLs;
506 void Settings::setSpatialNavigationEnabled(bool isSpatialNavigationEnabled)
508 m_isSpatialNavigationEnabled = isSpatialNavigationEnabled;
511 void Settings::setJavaEnabled(bool isJavaEnabled)
513 m_isJavaEnabled = isJavaEnabled;
516 void Settings::setJavaEnabledForLocalFiles(bool isJavaEnabledForLocalFiles)
518 m_isJavaEnabledForLocalFiles = isJavaEnabledForLocalFiles;
521 void Settings::setImagesEnabled(bool areImagesEnabled)
523 m_areImagesEnabled = areImagesEnabled;
525 // See comment in setLoadsImagesAutomatically.
526 m_setImageLoadingSettingsTimer.startOneShot(0);
529 void Settings::setMediaEnabled(bool isMediaEnabled)
531 m_isMediaEnabled = isMediaEnabled;
534 void Settings::setPluginsEnabled(bool arePluginsEnabled)
536 m_arePluginsEnabled = arePluginsEnabled;
539 void Settings::setLocalStorageEnabled(bool localStorageEnabled)
541 m_localStorageEnabled = localStorageEnabled;
544 void Settings::setSessionStorageQuota(unsigned sessionStorageQuota)
546 m_sessionStorageQuota = sessionStorageQuota;
549 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
551 // FIXME http://webkit.org/b/67870: The private browsing storage session and cookie private
552 // browsing mode (which is used if storage sessions are not available) are global settings, so
553 // it is misleading to have them as per-page settings.
554 // In addition, if they are treated as a per Page settings, the global values can get out of
555 // sync with the per Page value in the following situation:
556 // 1. The global values get set to true when setPrivateBrowsingEnabled(true) is called.
557 // 2. All Pages are closed, so all Settings objects go away.
558 // 3. A new Page is created, and a corresponding new Settings object is created - with
559 // m_privateBrowsingEnabled starting out as false in the constructor.
560 // 4. The WebPage settings get applied to the new Page and setPrivateBrowsingEnabled(false)
561 // is called, but an if (m_privateBrowsingEnabled == privateBrowsingEnabled) early return
562 // prevents the global values from getting changed from true to false.
563 #if USE(CFURLSTORAGESESSIONS)
564 ResourceHandle::setPrivateBrowsingEnabled(privateBrowsingEnabled);
566 setCookieStoragePrivateBrowsingEnabled(privateBrowsingEnabled);
568 if (m_privateBrowsingEnabled == privateBrowsingEnabled)
571 m_privateBrowsingEnabled = privateBrowsingEnabled;
572 m_page->privateBrowsingStateChanged();
575 void Settings::setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically)
577 m_javaScriptCanOpenWindowsAutomatically = javaScriptCanOpenWindowsAutomatically;
580 void Settings::setJavaScriptCanAccessClipboard(bool javaScriptCanAccessClipboard)
582 m_javaScriptCanAccessClipboard = javaScriptCanAccessClipboard;
585 void Settings::setDefaultTextEncodingName(const String& defaultTextEncodingName)
587 m_defaultTextEncodingName = defaultTextEncodingName;
590 void Settings::setUserStyleSheetLocation(const KURL& userStyleSheetLocation)
592 if (m_userStyleSheetLocation == userStyleSheetLocation)
595 m_userStyleSheetLocation = userStyleSheetLocation;
597 m_page->userStyleSheetLocationChanged();
600 void Settings::setFixedElementsLayoutRelativeToFrame(bool fixedElementsLayoutRelativeToFrame)
602 m_fixedElementsLayoutRelativeToFrame = fixedElementsLayoutRelativeToFrame;
605 void Settings::setShouldPrintBackgrounds(bool shouldPrintBackgrounds)
607 m_shouldPrintBackgrounds = shouldPrintBackgrounds;
610 void Settings::setTextAreasAreResizable(bool textAreasAreResizable)
612 if (m_textAreasAreResizable == textAreasAreResizable)
615 m_textAreasAreResizable = textAreasAreResizable;
616 m_page->setNeedsRecalcStyleInAllFrames();
619 void Settings::setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior)
621 m_editableLinkBehavior = editableLinkBehavior;
624 void Settings::setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior behavior)
626 m_textDirectionSubmenuInclusionBehavior = behavior;
629 #if ENABLE(DASHBOARD_SUPPORT)
630 void Settings::setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode)
632 m_usesDashboardBackwardCompatibilityMode = usesDashboardBackwardCompatibilityMode;
636 // FIXME: This quirk is needed because of Radar 4674537 and 5211271. We need to phase it out once Adobe
637 // can fix the bug from their end.
638 void Settings::setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC)
640 m_needsAdobeFrameReloadingQuirk = shouldNotReloadIFramesForUnchangedSRC;
643 // This is a quirk we are pro-actively applying to old applications. It changes keyboard event dispatching,
644 // making keyIdentifier available on keypress events, making charCode available on keydown/keyup events,
645 // and getting keypress dispatched in more cases.
646 void Settings::setNeedsKeyboardEventDisambiguationQuirks(bool needsQuirks)
648 m_needsKeyboardEventDisambiguationQuirks = needsQuirks;
651 void Settings::setTreatsAnyTextCSSLinkAsStylesheet(bool treatsAnyTextCSSLinkAsStylesheet)
653 m_treatsAnyTextCSSLinkAsStylesheet = treatsAnyTextCSSLinkAsStylesheet;
656 void Settings::setNeedsLeopardMailQuirks(bool needsQuirks)
658 m_needsLeopardMailQuirks = needsQuirks;
661 void Settings::setDOMPasteAllowed(bool DOMPasteAllowed)
663 m_isDOMPasteAllowed = DOMPasteAllowed;
666 void Settings::setDefaultMinDOMTimerInterval(double interval)
668 DOMTimer::setDefaultMinTimerInterval(interval);
671 double Settings::defaultMinDOMTimerInterval()
673 return DOMTimer::defaultMinTimerInterval();
676 void Settings::setMinDOMTimerInterval(double interval)
678 m_page->setMinimumTimerInterval(interval);
681 double Settings::minDOMTimerInterval()
683 return m_page->minimumTimerInterval();
686 void Settings::setDefaultDOMTimerAlignmentInterval(double interval)
688 DOMTimer::setDefaultTimerAlignmentInterval(interval);
691 double Settings::defaultDOMTimerAlignmentInterval()
693 return DOMTimer::defaultTimerAlignmentInterval();
696 void Settings::setDOMTimerAlignmentInterval(double interval)
698 m_page->setTimerAlignmentInterval(interval);
701 double Settings::domTimerAlignmentInterval() const
703 return m_page->timerAlignmentInterval();
706 void Settings::setUsesPageCache(bool usesPageCache)
708 if (m_usesPageCache == usesPageCache)
711 m_usesPageCache = usesPageCache;
712 if (!m_usesPageCache) {
713 int first = -m_page->backForward()->backCount();
714 int last = m_page->backForward()->forwardCount();
715 for (int i = first; i <= last; i++)
716 pageCache()->remove(m_page->backForward()->itemAtIndex(i));
717 pageCache()->releaseAutoreleasedPagesNow();
721 void Settings::setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit)
723 m_shrinksStandaloneImagesToFit = shrinksStandaloneImagesToFit;
726 void Settings::setShowsURLsInToolTips(bool showsURLsInToolTips)
728 m_showsURLsInToolTips = showsURLsInToolTips;
731 void Settings::setShowsToolTipOverTruncatedText(bool showsToolTipForTruncatedText)
733 m_showsToolTipOverTruncatedText = showsToolTipForTruncatedText;
736 void Settings::setFTPDirectoryTemplatePath(const String& path)
738 m_ftpDirectoryTemplatePath = path;
741 void Settings::setForceFTPDirectoryListings(bool force)
743 m_forceFTPDirectoryListings = force;
746 void Settings::setDeveloperExtrasEnabled(bool developerExtrasEnabled)
748 m_developerExtrasEnabled = developerExtrasEnabled;
751 void Settings::setJavaScriptExperimentsEnabled(bool javaScriptExperimentsEnabled)
753 m_javaScriptExperimentsEnabled = javaScriptExperimentsEnabled;
756 void Settings::setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)
758 if (m_authorAndUserStylesEnabled == authorAndUserStylesEnabled)
761 m_authorAndUserStylesEnabled = authorAndUserStylesEnabled;
762 m_page->setNeedsRecalcStyleInAllFrames();
765 void Settings::setFontRenderingMode(FontRenderingMode mode)
767 if (fontRenderingMode() == mode)
769 m_fontRenderingMode = mode;
770 m_page->setNeedsRecalcStyleInAllFrames();
773 FontRenderingMode Settings::fontRenderingMode() const
775 return static_cast<FontRenderingMode>(m_fontRenderingMode);
778 void Settings::setNeedsSiteSpecificQuirks(bool needsQuirks)
780 m_needsSiteSpecificQuirks = needsQuirks;
783 void Settings::setFrameFlatteningEnabled(bool frameFlatteningEnabled)
785 m_frameFlatteningEnabled = frameFlatteningEnabled;
788 #if ENABLE(WEB_ARCHIVE)
789 void Settings::setWebArchiveDebugModeEnabled(bool enabled)
791 m_webArchiveDebugModeEnabled = enabled;
795 void Settings::setLocalFileContentSniffingEnabled(bool enabled)
797 m_localFileContentSniffingEnabled = enabled;
800 void Settings::setLocalStorageDatabasePath(const String& path)
802 m_localStorageDatabasePath = path;
805 void Settings::setApplicationChromeMode(bool mode)
807 m_inApplicationChromeMode = mode;
810 void Settings::setOfflineWebApplicationCacheEnabled(bool enabled)
812 m_offlineWebApplicationCacheEnabled = enabled;
815 void Settings::setEnforceCSSMIMETypeInNoQuirksMode(bool enforceCSSMIMETypeInNoQuirksMode)
817 m_enforceCSSMIMETypeInNoQuirksMode = enforceCSSMIMETypeInNoQuirksMode;
820 #if USE(SAFARI_THEME)
821 void Settings::setShouldPaintNativeControls(bool shouldPaintNativeControls)
823 gShouldPaintNativeControls = shouldPaintNativeControls;
827 void Settings::setUsesEncodingDetector(bool usesEncodingDetector)
829 m_usesEncodingDetector = usesEncodingDetector;
832 void Settings::setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)
834 if (m_dnsPrefetchingEnabled == dnsPrefetchingEnabled)
837 m_dnsPrefetchingEnabled = dnsPrefetchingEnabled;
838 m_page->dnsPrefetchingStateChanged();
841 void Settings::setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)
843 m_allowScriptsToCloseWindows = allowScriptsToCloseWindows;
846 void Settings::setCaretBrowsingEnabled(bool caretBrowsingEnabled)
848 m_caretBrowsingEnabled = caretBrowsingEnabled;
851 void Settings::setDownloadableBinaryFontsEnabled(bool downloadableBinaryFontsEnabled)
853 m_downloadableBinaryFontsEnabled = downloadableBinaryFontsEnabled;
856 void Settings::setXSSAuditorEnabled(bool xssAuditorEnabled)
858 m_xssAuditorEnabled = xssAuditorEnabled;
861 void Settings::setAcceleratedCompositingEnabled(bool enabled)
863 if (m_acceleratedCompositingEnabled == enabled)
866 if (!enabled && m_forceCompositingMode)
869 m_acceleratedCompositingEnabled = enabled;
870 m_page->setNeedsRecalcStyleInAllFrames();
873 void Settings::setCanvasUsesAcceleratedDrawing(bool enabled)
875 m_canvasUsesAcceleratedDrawing = enabled;
878 void Settings::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
880 m_acceleratedCompositingFor3DTransformsEnabled = enabled;
883 void Settings::setAcceleratedCompositingForVideoEnabled(bool enabled)
885 m_acceleratedCompositingForVideoEnabled = enabled;
888 void Settings::setAcceleratedCompositingForPluginsEnabled(bool enabled)
890 m_acceleratedCompositingForPluginsEnabled = enabled;
893 void Settings::setAcceleratedCompositingForCanvasEnabled(bool enabled)
895 m_acceleratedCompositingForCanvasEnabled = enabled;
898 void Settings::setAcceleratedCompositingForAnimationEnabled(bool enabled)
900 m_acceleratedCompositingForAnimationEnabled = enabled;
903 void Settings::setShowDebugBorders(bool enabled)
905 if (m_showDebugBorders == enabled)
908 m_showDebugBorders = enabled;
909 m_page->setNeedsRecalcStyleInAllFrames();
912 void Settings::setShowRepaintCounter(bool enabled)
914 if (m_showRepaintCounter == enabled)
917 m_showRepaintCounter = enabled;
918 m_page->setNeedsRecalcStyleInAllFrames();
921 void Settings::setExperimentalNotificationsEnabled(bool enabled)
923 m_experimentalNotificationsEnabled = enabled;
926 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
927 void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
929 gShouldUseHighResolutionTimers = shouldUseHighResolutionTimers;
933 void Settings::setWebAudioEnabled(bool enabled)
935 m_webAudioEnabled = enabled;
938 void Settings::setWebGLEnabled(bool enabled)
940 m_webGLEnabled = enabled;
943 void Settings::setWebGLErrorsToConsoleEnabled(bool enabled)
945 m_webGLErrorsToConsoleEnabled = enabled;
948 void Settings::setOpenGLMultisamplingEnabled(bool enabled)
950 m_openGLMultisamplingEnabled = enabled;
953 void Settings::setPrivilegedWebGLExtensionsEnabled(bool enabled)
955 m_privilegedWebGLExtensionsEnabled = enabled;
958 void Settings::setAccelerated2dCanvasEnabled(bool enabled)
960 m_acceleratedCanvas2dEnabled = enabled;
963 void Settings::setDeferred2dCanvasEnabled(bool enabled)
965 m_deferredCanvas2dEnabled = enabled;
968 void Settings::setMinimumAccelerated2dCanvasSize(int numPixels)
970 m_minimumAccelerated2dCanvasSize = numPixels;
973 void Settings::setLoadDeferringEnabled(bool enabled)
975 m_loadDeferringEnabled = enabled;
978 void Settings::setStorageBlockingPolicy(SecurityOrigin::StorageBlockingPolicy enabled)
980 if (m_storageBlockingPolicy == enabled)
983 m_storageBlockingPolicy = enabled;
984 m_page->storageBlockingStateChanged();
987 void Settings::setTiledBackingStoreEnabled(bool enabled)
989 m_tiledBackingStoreEnabled = enabled;
990 #if USE(TILED_BACKING_STORE)
991 if (m_page->mainFrame())
992 m_page->mainFrame()->setTiledBackingStoreEnabled(enabled);
996 void Settings::setForceCompositingMode(bool flag)
998 m_forceCompositingMode = flag;
1001 setAcceleratedCompositingEnabled(true);
1004 void Settings::setScrollingPerformanceLoggingEnabled(bool enabled)
1006 m_scrollingPerformanceLoggingEnabled = enabled;
1008 if (m_page->mainFrame() && m_page->mainFrame()->view())
1009 m_page->mainFrame()->view()->setScrollingPerformanceLoggingEnabled(enabled);
1012 void Settings::setMockScrollbarsEnabled(bool flag)
1014 gMockScrollbarsEnabled = flag;
1017 bool Settings::mockScrollbarsEnabled()
1019 return gMockScrollbarsEnabled;
1022 void Settings::setUsesOverlayScrollbars(bool flag)
1024 gUsesOverlayScrollbars = flag;
1027 bool Settings::usesOverlayScrollbars()
1029 return gUsesOverlayScrollbars;
1033 void Settings::setShouldRespectPriorityInCSSAttributeSetters(bool flag)
1035 gShouldRespectPriorityInCSSAttributeSetters = flag;
1038 bool Settings::shouldRespectPriorityInCSSAttributeSetters()
1040 return gShouldRespectPriorityInCSSAttributeSetters;
1044 } // namespace WebCore