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 "Frame.h"
35 #include "FrameTree.h"
36 #include "FrameView.h"
37 #include "HistoryItem.h"
38 #include "Page.h"
39 #include "PageCache.h"
40 #include "ResourceHandle.h"
41 #include "StorageMap.h"
42 #include <limits>
43
44 using namespace std;
45
46 namespace WebCore {
47
setLoadsImagesAutomaticallyInAllFrames(Page * page)48 static void setLoadsImagesAutomaticallyInAllFrames(Page* page)
49 {
50 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
51 frame->document()->cachedResourceLoader()->setAutoLoadImages(page->settings()->loadsImagesAutomatically());
52 }
53
54 #if USE(SAFARI_THEME)
55 bool Settings::gShouldPaintNativeControls = true;
56 #endif
57
58 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
59 bool Settings::gShouldUseHighResolutionTimers = true;
60 #endif
61
62 // NOTEs
63 // 1) EditingMacBehavior comprises Tiger, Leopard, SnowLeopard and iOS builds, as well QtWebKit and Chromium when built on Mac;
64 // 2) EditingWindowsBehavior comprises Win32 and WinCE builds, as well as QtWebKit and Chromium when built on Windows;
65 // 3) EditingUnixBehavior comprises all unix-based systems, but Darwin/MacOS (and then abusing the terminology);
66 // 99) MacEditingBehavior is used a fallback.
editingBehaviorTypeForPlatform()67 static EditingBehaviorType editingBehaviorTypeForPlatform()
68 {
69 return
70 #if OS(DARWIN)
71 EditingMacBehavior
72 #elif OS(WINDOWS)
73 EditingWindowsBehavior
74 #elif OS(UNIX)
75 EditingUnixBehavior
76 #else
77 // Fallback
78 EditingMacBehavior
79 #endif
80 ;
81 }
82
Settings(Page * page)83 Settings::Settings(Page* page)
84 : m_page(page)
85 , m_editableLinkBehavior(EditableLinkDefaultBehavior)
86 , m_textDirectionSubmenuInclusionBehavior(TextDirectionSubmenuAutomaticallyIncluded)
87 , m_minimumFontSize(0)
88 , m_minimumLogicalFontSize(0)
89 , m_defaultFontSize(0)
90 , m_defaultFixedFontSize(0)
91 , m_validationMessageTimerMagnification(50)
92 , m_maximumDecodedImageSize(numeric_limits<size_t>::max())
93 #if ENABLE(DOM_STORAGE)
94 , m_sessionStorageQuota(StorageMap::noQuota)
95 #endif
96 , m_pluginAllowedRunTime(numeric_limits<unsigned>::max())
97 , m_editingBehaviorType(editingBehaviorTypeForPlatform())
98 #ifdef ANDROID_LAYOUT
99 , m_layoutAlgorithm(kLayoutFitColumnToScreen)
100 #endif
101 , m_passwordEchoDurationInSeconds(1)
102 , m_isSpatialNavigationEnabled(false)
103 , m_isJavaEnabled(false)
104 , m_loadsImagesAutomatically(false)
105 , m_loadsSiteIconsIgnoringImageLoadingSetting(false)
106 , m_privateBrowsingEnabled(false)
107 , m_caretBrowsingEnabled(false)
108 , m_areImagesEnabled(true)
109 , m_isMediaEnabled(true)
110 , m_arePluginsEnabled(false)
111 , m_localStorageEnabled(false)
112 , m_isJavaScriptEnabled(false)
113 , m_isWebSecurityEnabled(true)
114 , m_allowUniversalAccessFromFileURLs(true)
115 , m_allowFileAccessFromFileURLs(true)
116 , m_javaScriptCanOpenWindowsAutomatically(false)
117 , m_javaScriptCanAccessClipboard(false)
118 , m_shouldPrintBackgrounds(false)
119 , m_textAreasAreResizable(false)
120 #if ENABLE(DASHBOARD_SUPPORT)
121 , m_usesDashboardBackwardCompatibilityMode(false)
122 #endif
123 , m_needsAdobeFrameReloadingQuirk(false)
124 , m_needsKeyboardEventDisambiguationQuirks(false)
125 , m_treatsAnyTextCSSLinkAsStylesheet(false)
126 , m_needsLeopardMailQuirks(false)
127 , m_needsTigerMailQuirks(false)
128 , m_isDOMPasteAllowed(false)
129 , m_shrinksStandaloneImagesToFit(true)
130 , m_usesPageCache(false)
131 , m_showsURLsInToolTips(false)
132 , m_forceFTPDirectoryListings(false)
133 , m_developerExtrasEnabled(false)
134 , m_authorAndUserStylesEnabled(true)
135 , m_needsSiteSpecificQuirks(false)
136 , m_fontRenderingMode(0)
137 , m_frameFlatteningEnabled(false)
138 , m_webArchiveDebugModeEnabled(false)
139 , m_localFileContentSniffingEnabled(false)
140 , m_inApplicationChromeMode(false)
141 , m_offlineWebApplicationCacheEnabled(false)
142 , m_shouldPaintCustomScrollbars(false)
143 , m_enforceCSSMIMETypeInNoQuirksMode(true)
144 , m_usesEncodingDetector(false)
145 , m_allowScriptsToCloseWindows(false)
146 , m_canvasUsesAcceleratedDrawing(false)
147 , m_acceleratedDrawingEnabled(false)
148 // FIXME: This should really be disabled by default as it makes platforms that don't support the feature download files
149 // they can't use by. Leaving enabled for now to not change existing behavior.
150 , m_downloadableBinaryFontsEnabled(true)
151 , m_xssAuditorEnabled(false)
152 #if ENABLE(LINK_PREFETCH)
153 , m_linkPrefetchEnabled(true)
154 #endif
155 , m_acceleratedCompositingEnabled(true)
156 , m_acceleratedCompositingFor3DTransformsEnabled(true)
157 , m_acceleratedCompositingForVideoEnabled(true)
158 , m_acceleratedCompositingForPluginsEnabled(true)
159 , m_acceleratedCompositingForCanvasEnabled(true)
160 , m_acceleratedCompositingForAnimationEnabled(true)
161 , m_showDebugBorders(false)
162 , m_showRepaintCounter(false)
163 , m_experimentalNotificationsEnabled(false)
164 , m_webGLEnabled(false)
165 , m_openGLMultisamplingEnabled(true)
166 , m_webAudioEnabled(false)
167 , m_acceleratedCanvas2dEnabled(false)
168 , m_loadDeferringEnabled(true)
169 , m_tiledBackingStoreEnabled(false)
170 , m_paginateDuringLayoutEnabled(false)
171 , m_dnsPrefetchingEnabled(true)
172 #if ENABLE(FULLSCREEN_API)
173 , m_fullScreenAPIEnabled(false)
174 #endif
175 , m_asynchronousSpellCheckingEnabled(false)
176 , m_memoryInfoEnabled(false)
177 , m_interactiveFormValidation(false)
178 , m_usePreHTML5ParserQuirks(false)
179 , m_hyperlinkAuditingEnabled(false)
180 , m_crossOriginCheckInGetMatchedCSSRulesDisabled(false)
181 , m_useQuickLookResourceCachingQuirks(false)
182 , m_forceCompositingMode(false)
183 , m_shouldInjectUserScriptsInInitialEmptyDocument(false)
184 #ifdef ANDROID_LAYOUT
185 , m_useWideViewport(false)
186 #endif
187 #ifdef ANDROID_MULTIPLE_WINDOWS
188 , m_supportMultipleWindows(true)
189 #endif
190 #ifdef ANDROID_BLOCK_NETWORK_IMAGE
191 , m_blockNetworkImage(false)
192 #endif
193 #if ENABLE(WEB_AUTOFILL)
194 , m_autoFillEnabled(false)
195 #endif
196 #ifdef ANDROID_PLUGINS
197 , m_pluginsOnDemand(false)
198 #endif
199 #if OS(SYMBIAN)
200 , m_passwordEchoEnabled(true)
201 #else
202 , m_passwordEchoEnabled(false)
203 #endif
204 {
205 // A Frame may not have been created yet, so we initialize the AtomicString
206 // hash before trying to use it.
207 AtomicString::init();
208 #ifdef ANDROID_META_SUPPORT
209 m_default_format_detection = true;
210 resetMetadataSettings();
211 #endif
212 }
213
setStandardFontFamily(const AtomicString & standardFontFamily)214 void Settings::setStandardFontFamily(const AtomicString& standardFontFamily)
215 {
216 if (standardFontFamily == m_standardFontFamily)
217 return;
218
219 m_standardFontFamily = standardFontFamily;
220 m_page->setNeedsRecalcStyleInAllFrames();
221 }
222
setFixedFontFamily(const AtomicString & fixedFontFamily)223 void Settings::setFixedFontFamily(const AtomicString& fixedFontFamily)
224 {
225 if (m_fixedFontFamily == fixedFontFamily)
226 return;
227
228 m_fixedFontFamily = fixedFontFamily;
229 m_page->setNeedsRecalcStyleInAllFrames();
230 }
231
setSerifFontFamily(const AtomicString & serifFontFamily)232 void Settings::setSerifFontFamily(const AtomicString& serifFontFamily)
233 {
234 if (m_serifFontFamily == serifFontFamily)
235 return;
236
237 m_serifFontFamily = serifFontFamily;
238 m_page->setNeedsRecalcStyleInAllFrames();
239 }
240
setSansSerifFontFamily(const AtomicString & sansSerifFontFamily)241 void Settings::setSansSerifFontFamily(const AtomicString& sansSerifFontFamily)
242 {
243 if (m_sansSerifFontFamily == sansSerifFontFamily)
244 return;
245
246 m_sansSerifFontFamily = sansSerifFontFamily;
247 m_page->setNeedsRecalcStyleInAllFrames();
248 }
249
setCursiveFontFamily(const AtomicString & cursiveFontFamily)250 void Settings::setCursiveFontFamily(const AtomicString& cursiveFontFamily)
251 {
252 if (m_cursiveFontFamily == cursiveFontFamily)
253 return;
254
255 m_cursiveFontFamily = cursiveFontFamily;
256 m_page->setNeedsRecalcStyleInAllFrames();
257 }
258
setFantasyFontFamily(const AtomicString & fantasyFontFamily)259 void Settings::setFantasyFontFamily(const AtomicString& fantasyFontFamily)
260 {
261 if (m_fantasyFontFamily == fantasyFontFamily)
262 return;
263
264 m_fantasyFontFamily = fantasyFontFamily;
265 m_page->setNeedsRecalcStyleInAllFrames();
266 }
267
setMinimumFontSize(int minimumFontSize)268 void Settings::setMinimumFontSize(int minimumFontSize)
269 {
270 if (m_minimumFontSize == minimumFontSize)
271 return;
272
273 m_minimumFontSize = minimumFontSize;
274 m_page->setNeedsRecalcStyleInAllFrames();
275 }
276
setMinimumLogicalFontSize(int minimumLogicalFontSize)277 void Settings::setMinimumLogicalFontSize(int minimumLogicalFontSize)
278 {
279 if (m_minimumLogicalFontSize == minimumLogicalFontSize)
280 return;
281
282 m_minimumLogicalFontSize = minimumLogicalFontSize;
283 m_page->setNeedsRecalcStyleInAllFrames();
284 }
285
setDefaultFontSize(int defaultFontSize)286 void Settings::setDefaultFontSize(int defaultFontSize)
287 {
288 if (m_defaultFontSize == defaultFontSize)
289 return;
290
291 m_defaultFontSize = defaultFontSize;
292 m_page->setNeedsRecalcStyleInAllFrames();
293 }
294
setDefaultFixedFontSize(int defaultFontSize)295 void Settings::setDefaultFixedFontSize(int defaultFontSize)
296 {
297 if (m_defaultFixedFontSize == defaultFontSize)
298 return;
299
300 m_defaultFixedFontSize = defaultFontSize;
301 m_page->setNeedsRecalcStyleInAllFrames();
302 }
303
304 #ifdef ANDROID_BLOCK_NETWORK_IMAGE
setBlockNetworkImage(bool blockNetworkImage)305 void Settings::setBlockNetworkImage(bool blockNetworkImage)
306 {
307 m_blockNetworkImage = blockNetworkImage;
308 }
309 #endif
310
setLoadsImagesAutomatically(bool loadsImagesAutomatically)311 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
312 {
313 m_loadsImagesAutomatically = loadsImagesAutomatically;
314 setLoadsImagesAutomaticallyInAllFrames(m_page);
315 }
316
setLoadsSiteIconsIgnoringImageLoadingSetting(bool loadsSiteIcons)317 void Settings::setLoadsSiteIconsIgnoringImageLoadingSetting(bool loadsSiteIcons)
318 {
319 m_loadsSiteIconsIgnoringImageLoadingSetting = loadsSiteIcons;
320 }
321
setJavaScriptEnabled(bool isJavaScriptEnabled)322 void Settings::setJavaScriptEnabled(bool isJavaScriptEnabled)
323 {
324 m_isJavaScriptEnabled = isJavaScriptEnabled;
325 }
326
setWebSecurityEnabled(bool isWebSecurityEnabled)327 void Settings::setWebSecurityEnabled(bool isWebSecurityEnabled)
328 {
329 m_isWebSecurityEnabled = isWebSecurityEnabled;
330 }
331
setAllowUniversalAccessFromFileURLs(bool allowUniversalAccessFromFileURLs)332 void Settings::setAllowUniversalAccessFromFileURLs(bool allowUniversalAccessFromFileURLs)
333 {
334 m_allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
335 }
336
setAllowFileAccessFromFileURLs(bool allowFileAccessFromFileURLs)337 void Settings::setAllowFileAccessFromFileURLs(bool allowFileAccessFromFileURLs)
338 {
339 m_allowFileAccessFromFileURLs = allowFileAccessFromFileURLs;
340 }
341
setSpatialNavigationEnabled(bool isSpatialNavigationEnabled)342 void Settings::setSpatialNavigationEnabled(bool isSpatialNavigationEnabled)
343 {
344 m_isSpatialNavigationEnabled = isSpatialNavigationEnabled;
345 }
346
setJavaEnabled(bool isJavaEnabled)347 void Settings::setJavaEnabled(bool isJavaEnabled)
348 {
349 m_isJavaEnabled = isJavaEnabled;
350 }
351
setImagesEnabled(bool areImagesEnabled)352 void Settings::setImagesEnabled(bool areImagesEnabled)
353 {
354 m_areImagesEnabled = areImagesEnabled;
355 }
356
setMediaEnabled(bool isMediaEnabled)357 void Settings::setMediaEnabled(bool isMediaEnabled)
358 {
359 m_isMediaEnabled = isMediaEnabled;
360 }
361
setPluginsEnabled(bool arePluginsEnabled)362 void Settings::setPluginsEnabled(bool arePluginsEnabled)
363 {
364 m_arePluginsEnabled = arePluginsEnabled;
365 }
366
setLocalStorageEnabled(bool localStorageEnabled)367 void Settings::setLocalStorageEnabled(bool localStorageEnabled)
368 {
369 m_localStorageEnabled = localStorageEnabled;
370 }
371
372 #if ENABLE(DOM_STORAGE)
setSessionStorageQuota(unsigned sessionStorageQuota)373 void Settings::setSessionStorageQuota(unsigned sessionStorageQuota)
374 {
375 m_sessionStorageQuota = sessionStorageQuota;
376 }
377 #endif
378
setPrivateBrowsingEnabled(bool privateBrowsingEnabled)379 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
380 {
381 if (m_privateBrowsingEnabled == privateBrowsingEnabled)
382 return;
383
384 #if USE(CFURLSTORAGESESSIONS)
385 ResourceHandle::setPrivateBrowsingEnabled(privateBrowsingEnabled);
386 #endif
387
388 // FIXME: We can only enable cookie private browsing mode globally, so it's misleading to have it as a per-page setting.
389 setCookieStoragePrivateBrowsingEnabled(privateBrowsingEnabled);
390
391 m_privateBrowsingEnabled = privateBrowsingEnabled;
392 m_page->privateBrowsingStateChanged();
393 }
394
setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically)395 void Settings::setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically)
396 {
397 m_javaScriptCanOpenWindowsAutomatically = javaScriptCanOpenWindowsAutomatically;
398 }
399
setJavaScriptCanAccessClipboard(bool javaScriptCanAccessClipboard)400 void Settings::setJavaScriptCanAccessClipboard(bool javaScriptCanAccessClipboard)
401 {
402 m_javaScriptCanAccessClipboard = javaScriptCanAccessClipboard;
403 }
404
setDefaultTextEncodingName(const String & defaultTextEncodingName)405 void Settings::setDefaultTextEncodingName(const String& defaultTextEncodingName)
406 {
407 m_defaultTextEncodingName = defaultTextEncodingName;
408 }
409
setUserStyleSheetLocation(const KURL & userStyleSheetLocation)410 void Settings::setUserStyleSheetLocation(const KURL& userStyleSheetLocation)
411 {
412 if (m_userStyleSheetLocation == userStyleSheetLocation)
413 return;
414
415 m_userStyleSheetLocation = userStyleSheetLocation;
416
417 m_page->userStyleSheetLocationChanged();
418 }
419
setShouldPrintBackgrounds(bool shouldPrintBackgrounds)420 void Settings::setShouldPrintBackgrounds(bool shouldPrintBackgrounds)
421 {
422 m_shouldPrintBackgrounds = shouldPrintBackgrounds;
423 }
424
setTextAreasAreResizable(bool textAreasAreResizable)425 void Settings::setTextAreasAreResizable(bool textAreasAreResizable)
426 {
427 if (m_textAreasAreResizable == textAreasAreResizable)
428 return;
429
430 m_textAreasAreResizable = textAreasAreResizable;
431 m_page->setNeedsRecalcStyleInAllFrames();
432 }
433
setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior)434 void Settings::setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior)
435 {
436 m_editableLinkBehavior = editableLinkBehavior;
437 }
438
setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior behavior)439 void Settings::setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior behavior)
440 {
441 m_textDirectionSubmenuInclusionBehavior = behavior;
442 }
443
444 #if ENABLE(DASHBOARD_SUPPORT)
setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode)445 void Settings::setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode)
446 {
447 m_usesDashboardBackwardCompatibilityMode = usesDashboardBackwardCompatibilityMode;
448 }
449 #endif
450
451 // FIXME: This quirk is needed because of Radar 4674537 and 5211271. We need to phase it out once Adobe
452 // can fix the bug from their end.
setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC)453 void Settings::setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC)
454 {
455 m_needsAdobeFrameReloadingQuirk = shouldNotReloadIFramesForUnchangedSRC;
456 }
457
458 // This is a quirk we are pro-actively applying to old applications. It changes keyboard event dispatching,
459 // making keyIdentifier available on keypress events, making charCode available on keydown/keyup events,
460 // and getting keypress dispatched in more cases.
setNeedsKeyboardEventDisambiguationQuirks(bool needsQuirks)461 void Settings::setNeedsKeyboardEventDisambiguationQuirks(bool needsQuirks)
462 {
463 m_needsKeyboardEventDisambiguationQuirks = needsQuirks;
464 }
465
setTreatsAnyTextCSSLinkAsStylesheet(bool treatsAnyTextCSSLinkAsStylesheet)466 void Settings::setTreatsAnyTextCSSLinkAsStylesheet(bool treatsAnyTextCSSLinkAsStylesheet)
467 {
468 m_treatsAnyTextCSSLinkAsStylesheet = treatsAnyTextCSSLinkAsStylesheet;
469 }
470
setNeedsLeopardMailQuirks(bool needsQuirks)471 void Settings::setNeedsLeopardMailQuirks(bool needsQuirks)
472 {
473 m_needsLeopardMailQuirks = needsQuirks;
474 }
475
setNeedsTigerMailQuirks(bool needsQuirks)476 void Settings::setNeedsTigerMailQuirks(bool needsQuirks)
477 {
478 m_needsTigerMailQuirks = needsQuirks;
479 }
480
setDOMPasteAllowed(bool DOMPasteAllowed)481 void Settings::setDOMPasteAllowed(bool DOMPasteAllowed)
482 {
483 m_isDOMPasteAllowed = DOMPasteAllowed;
484 }
485
setDefaultMinDOMTimerInterval(double interval)486 void Settings::setDefaultMinDOMTimerInterval(double interval)
487 {
488 DOMTimer::setDefaultMinTimerInterval(interval);
489 }
490
defaultMinDOMTimerInterval()491 double Settings::defaultMinDOMTimerInterval()
492 {
493 return DOMTimer::defaultMinTimerInterval();
494 }
495
setMinDOMTimerInterval(double interval)496 void Settings::setMinDOMTimerInterval(double interval)
497 {
498 m_page->setMinimumTimerInterval(interval);
499 }
500
minDOMTimerInterval()501 double Settings::minDOMTimerInterval()
502 {
503 return m_page->minimumTimerInterval();
504 }
505
setUsesPageCache(bool usesPageCache)506 void Settings::setUsesPageCache(bool usesPageCache)
507 {
508 if (m_usesPageCache == usesPageCache)
509 return;
510
511 m_usesPageCache = usesPageCache;
512 if (!m_usesPageCache) {
513 int first = -m_page->backForward()->backCount();
514 int last = m_page->backForward()->forwardCount();
515 for (int i = first; i <= last; i++)
516 pageCache()->remove(m_page->backForward()->itemAtIndex(i));
517 pageCache()->releaseAutoreleasedPagesNow();
518 }
519 }
520
setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit)521 void Settings::setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit)
522 {
523 m_shrinksStandaloneImagesToFit = shrinksStandaloneImagesToFit;
524 }
525
setShowsURLsInToolTips(bool showsURLsInToolTips)526 void Settings::setShowsURLsInToolTips(bool showsURLsInToolTips)
527 {
528 m_showsURLsInToolTips = showsURLsInToolTips;
529 }
530
setFTPDirectoryTemplatePath(const String & path)531 void Settings::setFTPDirectoryTemplatePath(const String& path)
532 {
533 m_ftpDirectoryTemplatePath = path;
534 }
535
setForceFTPDirectoryListings(bool force)536 void Settings::setForceFTPDirectoryListings(bool force)
537 {
538 m_forceFTPDirectoryListings = force;
539 }
540
setDeveloperExtrasEnabled(bool developerExtrasEnabled)541 void Settings::setDeveloperExtrasEnabled(bool developerExtrasEnabled)
542 {
543 m_developerExtrasEnabled = developerExtrasEnabled;
544 }
545
546 #ifdef ANDROID_META_SUPPORT
resetMetadataSettings()547 void Settings::resetMetadataSettings()
548 {
549 m_viewport_width = -1;
550 m_viewport_height = -1;
551 m_viewport_initial_scale = 0;
552 m_viewport_minimum_scale = 0;
553 m_viewport_maximum_scale = 0;
554 m_viewport_user_scalable = true;
555 m_viewport_target_densitydpi = -1;
556 m_format_detection_telephone = m_default_format_detection;
557 m_format_detection_address = m_default_format_detection;
558 m_format_detection_email = m_default_format_detection;
559 }
560
setMetadataSettings(const String & key,const String & value)561 void Settings::setMetadataSettings(const String& key, const String& value)
562 {
563 if (key == "width") {
564 if (value == "device-width") {
565 m_viewport_width = 0;
566 } else {
567 int width = value.toInt();
568 if (width <= 10000) {
569 if (width <= 320) {
570 // This is a hack to accommodate the pages designed for the
571 // original iPhone. The new version, since 10/2007, is to
572 // use device-width which works for both portrait and
573 // landscape modes.
574 m_viewport_width = 0;
575 } else {
576 m_viewport_width = width;
577 }
578 }
579 }
580 } else if (key == "height") {
581 if (value == "device-height") {
582 m_viewport_height = 0;
583 } else {
584 int height = value.toInt();
585 if (height >= 200 && height <= 10000) {
586 m_viewport_height = height;
587 }
588 }
589 } else if (key == "initial-scale") {
590 int scale = int(value.toFloat() * 100);
591 if (scale >= 1 && scale <= 1000) {
592 m_viewport_initial_scale = scale;
593 }
594 } else if (key == "minimum-scale") {
595 int scale = int(value.toFloat() * 100);
596 if (scale >= 1 && scale <= 1000) {
597 m_viewport_minimum_scale = scale;
598 }
599 } else if (key == "maximum-scale") {
600 int scale = int(value.toFloat() * 100);
601 if (scale >= 1 && scale <= 1000) {
602 m_viewport_maximum_scale = scale;
603 }
604 } else if (key == "user-scalable") {
605 // even Apple doc says using "no", "0" is common in the real world, and
606 // some sites, e.g. gomoviesapp.com, use "false".
607 if (value == "no" || value == "0" || value == "false") {
608 m_viewport_user_scalable = false;
609 }
610 } else if (key == "target-densitydpi") {
611 if (value == "device-dpi") {
612 m_viewport_target_densitydpi = 0;
613 } else if (value == "low-dpi") {
614 m_viewport_target_densitydpi = 120;
615 } else if (value == "medium-dpi") {
616 m_viewport_target_densitydpi = 160;
617 } else if (value == "high-dpi") {
618 m_viewport_target_densitydpi = 240;
619 } else {
620 int dpi = value.toInt();
621 if (dpi >= 70 && dpi <= 400) {
622 m_viewport_target_densitydpi = dpi;
623 }
624 }
625 } else if (key == "telephone") {
626 if (value == "no") {
627 m_format_detection_telephone = false;
628 }
629 } else if (key == "address") {
630 if (value == "no") {
631 m_format_detection_address = false;
632 }
633 } else if (key == "email") {
634 if (value == "no") {
635 m_format_detection_email = false;
636 }
637 } else if (key == "format-detection") {
638 // even Apple doc says "format-detection" should be the name of the
639 // <meta> tag. In the real world, e.g. amazon.com, use
640 // "format-detection=no" in the "viewport" <meta> tag to disable all
641 // format detection.
642 if (value == "no") {
643 m_format_detection_telephone = false;
644 m_format_detection_address = false;
645 m_format_detection_email = false;
646 }
647 }
648 }
649
setViewportWidth(int width)650 void Settings::setViewportWidth(int width)
651 {
652 if (width < 0 || width > 10000)
653 m_viewport_width = -1;
654 else
655 m_viewport_width = width;
656 }
657
setViewportHeight(int height)658 void Settings::setViewportHeight(int height)
659 {
660 if (height < 0 || height > 10000)
661 m_viewport_height = -1;
662 else
663 m_viewport_height = height;
664 }
665
setViewportInitialScale(int scale)666 void Settings::setViewportInitialScale(int scale)
667 {
668 if (scale < 1 || scale > 1000)
669 m_viewport_initial_scale = 0;
670 else
671 m_viewport_initial_scale = scale;
672 }
673
setViewportMinimumScale(int scale)674 void Settings::setViewportMinimumScale(int scale)
675 {
676 if (scale < 1 || scale > 1000)
677 m_viewport_minimum_scale = 0;
678 else
679 m_viewport_minimum_scale = scale;
680 }
681
setViewportMaximumScale(int scale)682 void Settings::setViewportMaximumScale(int scale)
683 {
684 if (scale < 1 || scale > 1000)
685 m_viewport_maximum_scale = 0;
686 else
687 m_viewport_maximum_scale = scale;
688 }
689
setViewportUserScalable(bool scalable)690 void Settings::setViewportUserScalable(bool scalable)
691 {
692 m_viewport_user_scalable = scalable;
693 }
694
setViewportTargetDensityDpi(int dpi)695 void Settings::setViewportTargetDensityDpi(int dpi)
696 {
697 if (dpi < 0 || dpi > 400)
698 m_viewport_target_densitydpi = -1;
699 else
700 m_viewport_target_densitydpi = dpi;
701 }
702
setFormatDetectionAddress(bool detect)703 void Settings::setFormatDetectionAddress(bool detect)
704 {
705 m_format_detection_address = detect;
706 }
707
setFormatDetectionEmail(bool detect)708 void Settings::setFormatDetectionEmail(bool detect)
709 {
710 m_format_detection_email = detect;
711 }
712
setFormatDetectionTelephone(bool detect)713 void Settings::setFormatDetectionTelephone(bool detect)
714 {
715 m_format_detection_telephone = detect;
716 }
717 #endif
718
setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)719 void Settings::setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)
720 {
721 if (m_authorAndUserStylesEnabled == authorAndUserStylesEnabled)
722 return;
723
724 m_authorAndUserStylesEnabled = authorAndUserStylesEnabled;
725 m_page->setNeedsRecalcStyleInAllFrames();
726 }
727
setFontRenderingMode(FontRenderingMode mode)728 void Settings::setFontRenderingMode(FontRenderingMode mode)
729 {
730 if (fontRenderingMode() == mode)
731 return;
732 m_fontRenderingMode = mode;
733 m_page->setNeedsRecalcStyleInAllFrames();
734 }
735
fontRenderingMode() const736 FontRenderingMode Settings::fontRenderingMode() const
737 {
738 return static_cast<FontRenderingMode>(m_fontRenderingMode);
739 }
740
setNeedsSiteSpecificQuirks(bool needsQuirks)741 void Settings::setNeedsSiteSpecificQuirks(bool needsQuirks)
742 {
743 m_needsSiteSpecificQuirks = needsQuirks;
744 }
745
setFrameFlatteningEnabled(bool frameFlatteningEnabled)746 void Settings::setFrameFlatteningEnabled(bool frameFlatteningEnabled)
747 {
748 m_frameFlatteningEnabled = frameFlatteningEnabled;
749 }
750
751 #if ENABLE(WEB_ARCHIVE)
setWebArchiveDebugModeEnabled(bool enabled)752 void Settings::setWebArchiveDebugModeEnabled(bool enabled)
753 {
754 m_webArchiveDebugModeEnabled = enabled;
755 }
756 #endif
757
setLocalFileContentSniffingEnabled(bool enabled)758 void Settings::setLocalFileContentSniffingEnabled(bool enabled)
759 {
760 m_localFileContentSniffingEnabled = enabled;
761 }
762
setLocalStorageDatabasePath(const String & path)763 void Settings::setLocalStorageDatabasePath(const String& path)
764 {
765 m_localStorageDatabasePath = path;
766 }
767
setApplicationChromeMode(bool mode)768 void Settings::setApplicationChromeMode(bool mode)
769 {
770 m_inApplicationChromeMode = mode;
771 }
772
setOfflineWebApplicationCacheEnabled(bool enabled)773 void Settings::setOfflineWebApplicationCacheEnabled(bool enabled)
774 {
775 m_offlineWebApplicationCacheEnabled = enabled;
776 }
777
setShouldPaintCustomScrollbars(bool shouldPaintCustomScrollbars)778 void Settings::setShouldPaintCustomScrollbars(bool shouldPaintCustomScrollbars)
779 {
780 m_shouldPaintCustomScrollbars = shouldPaintCustomScrollbars;
781 }
782
setEnforceCSSMIMETypeInNoQuirksMode(bool enforceCSSMIMETypeInNoQuirksMode)783 void Settings::setEnforceCSSMIMETypeInNoQuirksMode(bool enforceCSSMIMETypeInNoQuirksMode)
784 {
785 m_enforceCSSMIMETypeInNoQuirksMode = enforceCSSMIMETypeInNoQuirksMode;
786 }
787
788 #if USE(SAFARI_THEME)
setShouldPaintNativeControls(bool shouldPaintNativeControls)789 void Settings::setShouldPaintNativeControls(bool shouldPaintNativeControls)
790 {
791 gShouldPaintNativeControls = shouldPaintNativeControls;
792 }
793 #endif
794
setUsesEncodingDetector(bool usesEncodingDetector)795 void Settings::setUsesEncodingDetector(bool usesEncodingDetector)
796 {
797 m_usesEncodingDetector = usesEncodingDetector;
798 }
799
setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)800 void Settings::setDNSPrefetchingEnabled(bool dnsPrefetchingEnabled)
801 {
802 if (m_dnsPrefetchingEnabled == dnsPrefetchingEnabled)
803 return;
804
805 m_dnsPrefetchingEnabled = dnsPrefetchingEnabled;
806 m_page->dnsPrefetchingStateChanged();
807 }
808
setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)809 void Settings::setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)
810 {
811 m_allowScriptsToCloseWindows = allowScriptsToCloseWindows;
812 }
813
setCaretBrowsingEnabled(bool caretBrowsingEnabled)814 void Settings::setCaretBrowsingEnabled(bool caretBrowsingEnabled)
815 {
816 m_caretBrowsingEnabled = caretBrowsingEnabled;
817 }
818
setDownloadableBinaryFontsEnabled(bool downloadableBinaryFontsEnabled)819 void Settings::setDownloadableBinaryFontsEnabled(bool downloadableBinaryFontsEnabled)
820 {
821 m_downloadableBinaryFontsEnabled = downloadableBinaryFontsEnabled;
822 }
823
setXSSAuditorEnabled(bool xssAuditorEnabled)824 void Settings::setXSSAuditorEnabled(bool xssAuditorEnabled)
825 {
826 m_xssAuditorEnabled = xssAuditorEnabled;
827 }
828
829 #if ENABLE(LINK_PREFETCH)
setLinkPrefetchEnabled(bool linkPrefetchEnabled)830 void Settings::setLinkPrefetchEnabled(bool linkPrefetchEnabled)
831 {
832 m_linkPrefetchEnabled = linkPrefetchEnabled;
833 }
834 #endif
835
setAcceleratedCompositingEnabled(bool enabled)836 void Settings::setAcceleratedCompositingEnabled(bool enabled)
837 {
838 if (m_acceleratedCompositingEnabled == enabled)
839 return;
840
841 m_acceleratedCompositingEnabled = enabled;
842 m_page->setNeedsRecalcStyleInAllFrames();
843 }
844
setCanvasUsesAcceleratedDrawing(bool enabled)845 void Settings::setCanvasUsesAcceleratedDrawing(bool enabled)
846 {
847 m_canvasUsesAcceleratedDrawing = enabled;
848 }
849
setAcceleratedDrawingEnabled(bool enabled)850 void Settings::setAcceleratedDrawingEnabled(bool enabled)
851 {
852 m_acceleratedDrawingEnabled = enabled;
853 }
854
setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)855 void Settings::setAcceleratedCompositingFor3DTransformsEnabled(bool enabled)
856 {
857 m_acceleratedCompositingFor3DTransformsEnabled = enabled;
858 }
859
setAcceleratedCompositingForVideoEnabled(bool enabled)860 void Settings::setAcceleratedCompositingForVideoEnabled(bool enabled)
861 {
862 m_acceleratedCompositingForVideoEnabled = enabled;
863 }
864
setAcceleratedCompositingForPluginsEnabled(bool enabled)865 void Settings::setAcceleratedCompositingForPluginsEnabled(bool enabled)
866 {
867 m_acceleratedCompositingForPluginsEnabled = enabled;
868 }
869
setAcceleratedCompositingForCanvasEnabled(bool enabled)870 void Settings::setAcceleratedCompositingForCanvasEnabled(bool enabled)
871 {
872 m_acceleratedCompositingForCanvasEnabled = enabled;
873 }
874
setAcceleratedCompositingForAnimationEnabled(bool enabled)875 void Settings::setAcceleratedCompositingForAnimationEnabled(bool enabled)
876 {
877 m_acceleratedCompositingForAnimationEnabled = enabled;
878 }
879
setShowDebugBorders(bool enabled)880 void Settings::setShowDebugBorders(bool enabled)
881 {
882 if (m_showDebugBorders == enabled)
883 return;
884
885 m_showDebugBorders = enabled;
886 m_page->setNeedsRecalcStyleInAllFrames();
887 }
888
setShowRepaintCounter(bool enabled)889 void Settings::setShowRepaintCounter(bool enabled)
890 {
891 if (m_showRepaintCounter == enabled)
892 return;
893
894 m_showRepaintCounter = enabled;
895 m_page->setNeedsRecalcStyleInAllFrames();
896 }
897
setExperimentalNotificationsEnabled(bool enabled)898 void Settings::setExperimentalNotificationsEnabled(bool enabled)
899 {
900 m_experimentalNotificationsEnabled = enabled;
901 }
902
setPluginAllowedRunTime(unsigned runTime)903 void Settings::setPluginAllowedRunTime(unsigned runTime)
904 {
905 m_pluginAllowedRunTime = runTime;
906 m_page->pluginAllowedRunTimeChanged();
907 }
908
909 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)910 void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
911 {
912 gShouldUseHighResolutionTimers = shouldUseHighResolutionTimers;
913 }
914 #endif
915
setWebAudioEnabled(bool enabled)916 void Settings::setWebAudioEnabled(bool enabled)
917 {
918 m_webAudioEnabled = enabled;
919 }
920
setWebGLEnabled(bool enabled)921 void Settings::setWebGLEnabled(bool enabled)
922 {
923 m_webGLEnabled = enabled;
924 }
925
setOpenGLMultisamplingEnabled(bool enabled)926 void Settings::setOpenGLMultisamplingEnabled(bool enabled)
927 {
928 m_openGLMultisamplingEnabled = enabled;
929 }
930
setAccelerated2dCanvasEnabled(bool enabled)931 void Settings::setAccelerated2dCanvasEnabled(bool enabled)
932 {
933 m_acceleratedCanvas2dEnabled = enabled;
934 }
935
setLoadDeferringEnabled(bool enabled)936 void Settings::setLoadDeferringEnabled(bool enabled)
937 {
938 m_loadDeferringEnabled = enabled;
939 }
940
setTiledBackingStoreEnabled(bool enabled)941 void Settings::setTiledBackingStoreEnabled(bool enabled)
942 {
943 m_tiledBackingStoreEnabled = enabled;
944 #if ENABLE(TILED_BACKING_STORE)
945 if (m_page->mainFrame())
946 m_page->mainFrame()->setTiledBackingStoreEnabled(enabled);
947 #endif
948 }
949
950 } // namespace WebCore
951