1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 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 "BackForwardList.h"
30 #include "Frame.h"
31 #include "FrameTree.h"
32 #include "FrameView.h"
33 #include "HistoryItem.h"
34 #include "Page.h"
35 #include "PageCache.h"
36 #include <limits>
37
38 using namespace std;
39
40 namespace WebCore {
41
setNeedsReapplyStylesInAllFrames(Page * page)42 static void setNeedsReapplyStylesInAllFrames(Page* page)
43 {
44 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext())
45 frame->setNeedsReapplyStyles();
46 }
47
48 #if USE(SAFARI_THEME)
49 bool Settings::gShouldPaintNativeControls = true;
50 #endif
51
52 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
53 bool Settings::gShouldUseHighResolutionTimers = true;
54 #endif
55
Settings(Page * page)56 Settings::Settings(Page* page)
57 : m_page(page)
58 #ifdef ANDROID_LAYOUT
59 , m_layoutAlgorithm(kLayoutFitColumnToScreen)
60 #endif
61 , m_editableLinkBehavior(EditableLinkDefaultBehavior)
62 , m_textDirectionSubmenuInclusionBehavior(TextDirectionSubmenuAutomaticallyIncluded)
63 , m_minimumFontSize(0)
64 , m_minimumLogicalFontSize(0)
65 , m_defaultFontSize(0)
66 , m_defaultFixedFontSize(0)
67 #ifdef ANDROID_LAYOUT
68 , m_useWideViewport(false)
69 #endif
70 #ifdef ANDROID_MULTIPLE_WINDOWS
71 , m_supportMultipleWindows(true)
72 #endif
73 #ifdef ANDROID_BLOCK_NETWORK_IMAGE
74 , m_blockNetworkImage(false)
75 #endif
76 , m_maximumDecodedImageSize(numeric_limits<size_t>::max())
77 , m_localStorageQuota(5 * 1024 * 1024) // Suggested by the HTML5 spec.
78 , m_pluginAllowedRunTime(numeric_limits<unsigned>::max())
79 , m_isJavaEnabled(false)
80 , m_loadsImagesAutomatically(false)
81 , m_privateBrowsingEnabled(false)
82 , m_caretBrowsingEnabled(false)
83 , m_areImagesEnabled(true)
84 , m_arePluginsEnabled(false)
85 , m_databasesEnabled(false)
86 , m_localStorageEnabled(false)
87 , m_isJavaScriptEnabled(false)
88 , m_isWebSecurityEnabled(true)
89 , m_allowUniversalAccessFromFileURLs(true)
90 , m_javaScriptCanOpenWindowsAutomatically(false)
91 , m_shouldPrintBackgrounds(false)
92 , m_textAreasAreResizable(false)
93 #if ENABLE(DASHBOARD_SUPPORT)
94 , m_usesDashboardBackwardCompatibilityMode(false)
95 #endif
96 , m_needsAdobeFrameReloadingQuirk(false)
97 , m_needsKeyboardEventDisambiguationQuirks(false)
98 , m_treatsAnyTextCSSLinkAsStylesheet(false)
99 , m_needsLeopardMailQuirks(false)
100 , m_needsTigerMailQuirks(false)
101 , m_isDOMPasteAllowed(false)
102 , m_shrinksStandaloneImagesToFit(true)
103 , m_usesPageCache(false)
104 , m_showsURLsInToolTips(false)
105 , m_forceFTPDirectoryListings(false)
106 , m_developerExtrasEnabled(false)
107 , m_authorAndUserStylesEnabled(true)
108 , m_needsSiteSpecificQuirks(false)
109 , m_fontRenderingMode(0)
110 , m_frameSetFlatteningEnabled(false)
111 , m_webArchiveDebugModeEnabled(false)
112 , m_localFileContentSniffingEnabled(false)
113 , m_inApplicationChromeMode(false)
114 , m_offlineWebApplicationCacheEnabled(false)
115 , m_shouldPaintCustomScrollbars(false)
116 , m_zoomsTextOnly(false)
117 , m_enforceCSSMIMETypeInStrictMode(true)
118 , m_usesEncodingDetector(false)
119 , m_allowScriptsToCloseWindows(false)
120 , m_editingBehavior(
121 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
122 // (PLATFORM(MAC) is always false in Chromium, hence the extra condition.)
123 EditingMacBehavior
124 #else
125 EditingWindowsBehavior
126 #endif
127 )
128 // FIXME: This should really be disabled by default as it makes platforms that don't support the feature download files
129 // they can't use by. Leaving enabled for now to not change existing behavior.
130 , m_downloadableBinaryFontsEnabled(true)
131 , m_xssAuditorEnabled(false)
132 , m_acceleratedCompositingEnabled(true)
133 , m_showDebugBorders(false)
134 , m_showRepaintCounter(false)
135 , m_experimentalNotificationsEnabled(false)
136 , m_webGLEnabled(false)
137 , m_geolocationEnabled(true)
138 , m_loadDeferringEnabled(true)
139 #ifdef ANDROID_PLUGINS
140 , m_pluginsOnDemand(false)
141 #endif
142 {
143 // A Frame may not have been created yet, so we initialize the AtomicString
144 // hash before trying to use it.
145 AtomicString::init();
146 #ifdef ANDROID_META_SUPPORT
147 resetMetadataSettings();
148 #endif
149 }
150
setStandardFontFamily(const AtomicString & standardFontFamily)151 void Settings::setStandardFontFamily(const AtomicString& standardFontFamily)
152 {
153 if (standardFontFamily == m_standardFontFamily)
154 return;
155
156 m_standardFontFamily = standardFontFamily;
157 setNeedsReapplyStylesInAllFrames(m_page);
158 }
159
setFixedFontFamily(const AtomicString & fixedFontFamily)160 void Settings::setFixedFontFamily(const AtomicString& fixedFontFamily)
161 {
162 if (m_fixedFontFamily == fixedFontFamily)
163 return;
164
165 m_fixedFontFamily = fixedFontFamily;
166 setNeedsReapplyStylesInAllFrames(m_page);
167 }
168
setSerifFontFamily(const AtomicString & serifFontFamily)169 void Settings::setSerifFontFamily(const AtomicString& serifFontFamily)
170 {
171 if (m_serifFontFamily == serifFontFamily)
172 return;
173
174 m_serifFontFamily = serifFontFamily;
175 setNeedsReapplyStylesInAllFrames(m_page);
176 }
177
setSansSerifFontFamily(const AtomicString & sansSerifFontFamily)178 void Settings::setSansSerifFontFamily(const AtomicString& sansSerifFontFamily)
179 {
180 if (m_sansSerifFontFamily == sansSerifFontFamily)
181 return;
182
183 m_sansSerifFontFamily = sansSerifFontFamily;
184 setNeedsReapplyStylesInAllFrames(m_page);
185 }
186
setCursiveFontFamily(const AtomicString & cursiveFontFamily)187 void Settings::setCursiveFontFamily(const AtomicString& cursiveFontFamily)
188 {
189 if (m_cursiveFontFamily == cursiveFontFamily)
190 return;
191
192 m_cursiveFontFamily = cursiveFontFamily;
193 setNeedsReapplyStylesInAllFrames(m_page);
194 }
195
setFantasyFontFamily(const AtomicString & fantasyFontFamily)196 void Settings::setFantasyFontFamily(const AtomicString& fantasyFontFamily)
197 {
198 if (m_fantasyFontFamily == fantasyFontFamily)
199 return;
200
201 m_fantasyFontFamily = fantasyFontFamily;
202 setNeedsReapplyStylesInAllFrames(m_page);
203 }
204
setMinimumFontSize(int minimumFontSize)205 void Settings::setMinimumFontSize(int minimumFontSize)
206 {
207 if (m_minimumFontSize == minimumFontSize)
208 return;
209
210 m_minimumFontSize = minimumFontSize;
211 setNeedsReapplyStylesInAllFrames(m_page);
212 }
213
setMinimumLogicalFontSize(int minimumLogicalFontSize)214 void Settings::setMinimumLogicalFontSize(int minimumLogicalFontSize)
215 {
216 if (m_minimumLogicalFontSize == minimumLogicalFontSize)
217 return;
218
219 m_minimumLogicalFontSize = minimumLogicalFontSize;
220 setNeedsReapplyStylesInAllFrames(m_page);
221 }
222
setDefaultFontSize(int defaultFontSize)223 void Settings::setDefaultFontSize(int defaultFontSize)
224 {
225 if (m_defaultFontSize == defaultFontSize)
226 return;
227
228 m_defaultFontSize = defaultFontSize;
229 setNeedsReapplyStylesInAllFrames(m_page);
230 }
231
setDefaultFixedFontSize(int defaultFontSize)232 void Settings::setDefaultFixedFontSize(int defaultFontSize)
233 {
234 if (m_defaultFixedFontSize == defaultFontSize)
235 return;
236
237 m_defaultFixedFontSize = defaultFontSize;
238 setNeedsReapplyStylesInAllFrames(m_page);
239 }
240
241 #ifdef ANDROID_BLOCK_NETWORK_IMAGE
setBlockNetworkImage(bool blockNetworkImage)242 void Settings::setBlockNetworkImage(bool blockNetworkImage)
243 {
244 m_blockNetworkImage = blockNetworkImage;
245 }
246 #endif
247
setLoadsImagesAutomatically(bool loadsImagesAutomatically)248 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically)
249 {
250 m_loadsImagesAutomatically = loadsImagesAutomatically;
251 }
252
setJavaScriptEnabled(bool isJavaScriptEnabled)253 void Settings::setJavaScriptEnabled(bool isJavaScriptEnabled)
254 {
255 m_isJavaScriptEnabled = isJavaScriptEnabled;
256 }
257
setWebSecurityEnabled(bool isWebSecurityEnabled)258 void Settings::setWebSecurityEnabled(bool isWebSecurityEnabled)
259 {
260 m_isWebSecurityEnabled = isWebSecurityEnabled;
261 }
262
setAllowUniversalAccessFromFileURLs(bool allowUniversalAccessFromFileURLs)263 void Settings::setAllowUniversalAccessFromFileURLs(bool allowUniversalAccessFromFileURLs)
264 {
265 m_allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
266 }
267
setJavaEnabled(bool isJavaEnabled)268 void Settings::setJavaEnabled(bool isJavaEnabled)
269 {
270 m_isJavaEnabled = isJavaEnabled;
271 }
272
setImagesEnabled(bool areImagesEnabled)273 void Settings::setImagesEnabled(bool areImagesEnabled)
274 {
275 m_areImagesEnabled = areImagesEnabled;
276 }
277
setPluginsEnabled(bool arePluginsEnabled)278 void Settings::setPluginsEnabled(bool arePluginsEnabled)
279 {
280 m_arePluginsEnabled = arePluginsEnabled;
281 }
282
setDatabasesEnabled(bool databasesEnabled)283 void Settings::setDatabasesEnabled(bool databasesEnabled)
284 {
285 m_databasesEnabled = databasesEnabled;
286 }
287
setLocalStorageEnabled(bool localStorageEnabled)288 void Settings::setLocalStorageEnabled(bool localStorageEnabled)
289 {
290 m_localStorageEnabled = localStorageEnabled;
291 }
292
setLocalStorageQuota(unsigned localStorageQuota)293 void Settings::setLocalStorageQuota(unsigned localStorageQuota)
294 {
295 m_localStorageQuota = localStorageQuota;
296 }
297
setPrivateBrowsingEnabled(bool privateBrowsingEnabled)298 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
299 {
300 m_privateBrowsingEnabled = privateBrowsingEnabled;
301 }
302
setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically)303 void Settings::setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically)
304 {
305 m_javaScriptCanOpenWindowsAutomatically = javaScriptCanOpenWindowsAutomatically;
306 }
307
setDefaultTextEncodingName(const String & defaultTextEncodingName)308 void Settings::setDefaultTextEncodingName(const String& defaultTextEncodingName)
309 {
310 m_defaultTextEncodingName = defaultTextEncodingName;
311 }
312
setUserStyleSheetLocation(const KURL & userStyleSheetLocation)313 void Settings::setUserStyleSheetLocation(const KURL& userStyleSheetLocation)
314 {
315 if (m_userStyleSheetLocation == userStyleSheetLocation)
316 return;
317
318 m_userStyleSheetLocation = userStyleSheetLocation;
319
320 m_page->userStyleSheetLocationChanged();
321 }
322
setShouldPrintBackgrounds(bool shouldPrintBackgrounds)323 void Settings::setShouldPrintBackgrounds(bool shouldPrintBackgrounds)
324 {
325 m_shouldPrintBackgrounds = shouldPrintBackgrounds;
326 }
327
setTextAreasAreResizable(bool textAreasAreResizable)328 void Settings::setTextAreasAreResizable(bool textAreasAreResizable)
329 {
330 if (m_textAreasAreResizable == textAreasAreResizable)
331 return;
332
333 m_textAreasAreResizable = textAreasAreResizable;
334 setNeedsReapplyStylesInAllFrames(m_page);
335 }
336
setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior)337 void Settings::setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior)
338 {
339 m_editableLinkBehavior = editableLinkBehavior;
340 }
341
setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior behavior)342 void Settings::setTextDirectionSubmenuInclusionBehavior(TextDirectionSubmenuInclusionBehavior behavior)
343 {
344 m_textDirectionSubmenuInclusionBehavior = behavior;
345 }
346
347 #if ENABLE(DASHBOARD_SUPPORT)
setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode)348 void Settings::setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode)
349 {
350 m_usesDashboardBackwardCompatibilityMode = usesDashboardBackwardCompatibilityMode;
351 }
352 #endif
353
354 // FIXME: This quirk is needed because of Radar 4674537 and 5211271. We need to phase it out once Adobe
355 // can fix the bug from their end.
setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC)356 void Settings::setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC)
357 {
358 m_needsAdobeFrameReloadingQuirk = shouldNotReloadIFramesForUnchangedSRC;
359 }
360
361 // This is a quirk we are pro-actively applying to old applications. It changes keyboard event dispatching,
362 // making keyIdentifier available on keypress events, making charCode available on keydown/keyup events,
363 // and getting keypress dispatched in more cases.
setNeedsKeyboardEventDisambiguationQuirks(bool needsQuirks)364 void Settings::setNeedsKeyboardEventDisambiguationQuirks(bool needsQuirks)
365 {
366 m_needsKeyboardEventDisambiguationQuirks = needsQuirks;
367 }
368
setTreatsAnyTextCSSLinkAsStylesheet(bool treatsAnyTextCSSLinkAsStylesheet)369 void Settings::setTreatsAnyTextCSSLinkAsStylesheet(bool treatsAnyTextCSSLinkAsStylesheet)
370 {
371 m_treatsAnyTextCSSLinkAsStylesheet = treatsAnyTextCSSLinkAsStylesheet;
372 }
373
setNeedsLeopardMailQuirks(bool needsQuirks)374 void Settings::setNeedsLeopardMailQuirks(bool needsQuirks)
375 {
376 m_needsLeopardMailQuirks = needsQuirks;
377 }
378
setNeedsTigerMailQuirks(bool needsQuirks)379 void Settings::setNeedsTigerMailQuirks(bool needsQuirks)
380 {
381 m_needsTigerMailQuirks = needsQuirks;
382 }
383
setDOMPasteAllowed(bool DOMPasteAllowed)384 void Settings::setDOMPasteAllowed(bool DOMPasteAllowed)
385 {
386 m_isDOMPasteAllowed = DOMPasteAllowed;
387 }
388
setUsesPageCache(bool usesPageCache)389 void Settings::setUsesPageCache(bool usesPageCache)
390 {
391 if (m_usesPageCache == usesPageCache)
392 return;
393
394 m_usesPageCache = usesPageCache;
395 if (!m_usesPageCache) {
396 HistoryItemVector& historyItems = m_page->backForwardList()->entries();
397 for (unsigned i = 0; i < historyItems.size(); i++)
398 pageCache()->remove(historyItems[i].get());
399 pageCache()->releaseAutoreleasedPagesNow();
400 }
401 }
402
setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit)403 void Settings::setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit)
404 {
405 m_shrinksStandaloneImagesToFit = shrinksStandaloneImagesToFit;
406 }
407
setShowsURLsInToolTips(bool showsURLsInToolTips)408 void Settings::setShowsURLsInToolTips(bool showsURLsInToolTips)
409 {
410 m_showsURLsInToolTips = showsURLsInToolTips;
411 }
412
setFTPDirectoryTemplatePath(const String & path)413 void Settings::setFTPDirectoryTemplatePath(const String& path)
414 {
415 m_ftpDirectoryTemplatePath = path;
416 }
417
setForceFTPDirectoryListings(bool force)418 void Settings::setForceFTPDirectoryListings(bool force)
419 {
420 m_forceFTPDirectoryListings = force;
421 }
422
setDeveloperExtrasEnabled(bool developerExtrasEnabled)423 void Settings::setDeveloperExtrasEnabled(bool developerExtrasEnabled)
424 {
425 m_developerExtrasEnabled = developerExtrasEnabled;
426 }
427
428 #ifdef ANDROID_META_SUPPORT
resetMetadataSettings()429 void Settings::resetMetadataSettings()
430 {
431 m_viewport_width = -1;
432 m_viewport_height = -1;
433 m_viewport_initial_scale = 0;
434 m_viewport_minimum_scale = 0;
435 m_viewport_maximum_scale = 0;
436 m_viewport_user_scalable = true;
437 m_viewport_target_densitydpi = -1;
438 m_format_detection_telephone = true;
439 m_format_detection_address = true;
440 m_format_detection_email = true;
441 }
442
setMetadataSettings(const String & key,const String & value)443 void Settings::setMetadataSettings(const String& key, const String& value)
444 {
445 if (key == "width") {
446 if (value == "device-width") {
447 m_viewport_width = 0;
448 } else {
449 int width = value.toInt();
450 if (width <= 10000) {
451 if (width <= 320) {
452 // This is a hack to accommodate the pages designed for the
453 // original iPhone. The new version, since 10/2007, is to
454 // use device-width which works for both portrait and
455 // landscape modes.
456 m_viewport_width = 0;
457 } else {
458 m_viewport_width = width;
459 }
460 }
461 }
462 } else if (key == "height") {
463 if (value == "device-height") {
464 m_viewport_height = 0;
465 } else {
466 int height = value.toInt();
467 if (height >= 200 && height <= 10000) {
468 m_viewport_height = height;
469 }
470 }
471 } else if (key == "initial-scale") {
472 int scale = int(value.toFloat() * 100);
473 if (scale >= 1 && scale <= 1000) {
474 m_viewport_initial_scale = scale;
475 }
476 } else if (key == "minimum-scale") {
477 int scale = int(value.toFloat() * 100);
478 if (scale >= 1 && scale <= 1000) {
479 m_viewport_minimum_scale = scale;
480 }
481 } else if (key == "maximum-scale") {
482 int scale = int(value.toFloat() * 100);
483 if (scale >= 1 && scale <= 1000) {
484 m_viewport_maximum_scale = scale;
485 }
486 } else if (key == "user-scalable") {
487 // even Apple doc says using "no", "0" is common in the real world, and
488 // some sites, e.g. gomoviesapp.com, use "false".
489 if (value == "no" || value == "0" || value == "false") {
490 m_viewport_user_scalable = false;
491 }
492 } else if (key == "target-densitydpi") {
493 if (value == "device-dpi") {
494 m_viewport_target_densitydpi = 0;
495 } else if (value == "low-dpi") {
496 m_viewport_target_densitydpi = 120;
497 } else if (value == "medium-dpi") {
498 m_viewport_target_densitydpi = 160;
499 } else if (value == "high-dpi") {
500 m_viewport_target_densitydpi = 240;
501 } else {
502 int dpi = value.toInt();
503 if (dpi >= 70 && dpi <= 400) {
504 m_viewport_target_densitydpi = dpi;
505 }
506 }
507 } else if (key == "telephone") {
508 if (value == "no") {
509 m_format_detection_telephone = false;
510 }
511 } else if (key == "address") {
512 if (value == "no") {
513 m_format_detection_address = false;
514 }
515 } else if (key == "email") {
516 if (value == "no") {
517 m_format_detection_email = false;
518 }
519 } else if (key == "format-detection") {
520 // even Apple doc says "format-detection" should be the name of the
521 // <meta> tag. In the real world, e.g. amazon.com, use
522 // "format-detection=no" in the "viewport" <meta> tag to disable all
523 // format detection.
524 if (value == "no") {
525 m_format_detection_telephone = false;
526 m_format_detection_address = false;
527 m_format_detection_email = false;
528 }
529 }
530 }
531
setViewportWidth(int width)532 void Settings::setViewportWidth(int width)
533 {
534 if (width < 0 || width > 10000)
535 m_viewport_width = -1;
536 else
537 m_viewport_width = width;
538 }
539
setViewportHeight(int height)540 void Settings::setViewportHeight(int height)
541 {
542 if (height < 0 || height > 10000)
543 m_viewport_height = -1;
544 else
545 m_viewport_height = height;
546 }
547
setViewportInitialScale(int scale)548 void Settings::setViewportInitialScale(int scale)
549 {
550 if (scale < 1 || scale > 1000)
551 m_viewport_initial_scale = 0;
552 else
553 m_viewport_initial_scale = scale;
554 }
555
setViewportMinimumScale(int scale)556 void Settings::setViewportMinimumScale(int scale)
557 {
558 if (scale < 1 || scale > 1000)
559 m_viewport_minimum_scale = 0;
560 else
561 m_viewport_minimum_scale = scale;
562 }
563
setViewportMaximumScale(int scale)564 void Settings::setViewportMaximumScale(int scale)
565 {
566 if (scale < 1 || scale > 1000)
567 m_viewport_maximum_scale = 0;
568 else
569 m_viewport_maximum_scale = scale;
570 }
571
setViewportUserScalable(bool scalable)572 void Settings::setViewportUserScalable(bool scalable)
573 {
574 m_viewport_user_scalable = scalable;
575 }
576
setViewportTargetDensityDpi(int dpi)577 void Settings::setViewportTargetDensityDpi(int dpi)
578 {
579 if (dpi < 0 || dpi > 400)
580 m_viewport_target_densitydpi = -1;
581 else
582 m_viewport_target_densitydpi = dpi;
583 }
584
setFormatDetectionAddress(bool detect)585 void Settings::setFormatDetectionAddress(bool detect)
586 {
587 m_format_detection_address = detect;
588 }
589
setFormatDetectionEmail(bool detect)590 void Settings::setFormatDetectionEmail(bool detect)
591 {
592 m_format_detection_email = detect;
593 }
594
setFormatDetectionTelephone(bool detect)595 void Settings::setFormatDetectionTelephone(bool detect)
596 {
597 m_format_detection_telephone = detect;
598 }
599 #endif
600
setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)601 void Settings::setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)
602 {
603 if (m_authorAndUserStylesEnabled == authorAndUserStylesEnabled)
604 return;
605
606 m_authorAndUserStylesEnabled = authorAndUserStylesEnabled;
607 setNeedsReapplyStylesInAllFrames(m_page);
608 }
609
setFontRenderingMode(FontRenderingMode mode)610 void Settings::setFontRenderingMode(FontRenderingMode mode)
611 {
612 if (fontRenderingMode() == mode)
613 return;
614 m_fontRenderingMode = mode;
615 setNeedsReapplyStylesInAllFrames(m_page);
616 }
617
fontRenderingMode() const618 FontRenderingMode Settings::fontRenderingMode() const
619 {
620 return static_cast<FontRenderingMode>(m_fontRenderingMode);
621 }
622
setNeedsSiteSpecificQuirks(bool needsQuirks)623 void Settings::setNeedsSiteSpecificQuirks(bool needsQuirks)
624 {
625 m_needsSiteSpecificQuirks = needsQuirks;
626 }
627
setFrameSetFlatteningEnabled(bool frameSetFlatteningEnabled)628 void Settings::setFrameSetFlatteningEnabled(bool frameSetFlatteningEnabled)
629 {
630 m_frameSetFlatteningEnabled = frameSetFlatteningEnabled;
631 }
632
setWebArchiveDebugModeEnabled(bool enabled)633 void Settings::setWebArchiveDebugModeEnabled(bool enabled)
634 {
635 m_webArchiveDebugModeEnabled = enabled;
636 }
637
setLocalFileContentSniffingEnabled(bool enabled)638 void Settings::setLocalFileContentSniffingEnabled(bool enabled)
639 {
640 m_localFileContentSniffingEnabled = enabled;
641 }
642
setLocalStorageDatabasePath(const String & path)643 void Settings::setLocalStorageDatabasePath(const String& path)
644 {
645 m_localStorageDatabasePath = path;
646 }
647
setApplicationChromeMode(bool mode)648 void Settings::setApplicationChromeMode(bool mode)
649 {
650 m_inApplicationChromeMode = mode;
651 }
652
setOfflineWebApplicationCacheEnabled(bool enabled)653 void Settings::setOfflineWebApplicationCacheEnabled(bool enabled)
654 {
655 m_offlineWebApplicationCacheEnabled = enabled;
656 }
657
setShouldPaintCustomScrollbars(bool shouldPaintCustomScrollbars)658 void Settings::setShouldPaintCustomScrollbars(bool shouldPaintCustomScrollbars)
659 {
660 m_shouldPaintCustomScrollbars = shouldPaintCustomScrollbars;
661 }
662
setZoomsTextOnly(bool zoomsTextOnly)663 void Settings::setZoomsTextOnly(bool zoomsTextOnly)
664 {
665 if (zoomsTextOnly == m_zoomsTextOnly)
666 return;
667
668 m_zoomsTextOnly = zoomsTextOnly;
669 setNeedsReapplyStylesInAllFrames(m_page);
670 }
671
setEnforceCSSMIMETypeInStrictMode(bool enforceCSSMIMETypeInStrictMode)672 void Settings::setEnforceCSSMIMETypeInStrictMode(bool enforceCSSMIMETypeInStrictMode)
673 {
674 m_enforceCSSMIMETypeInStrictMode = enforceCSSMIMETypeInStrictMode;
675 }
676
677 #if USE(SAFARI_THEME)
setShouldPaintNativeControls(bool shouldPaintNativeControls)678 void Settings::setShouldPaintNativeControls(bool shouldPaintNativeControls)
679 {
680 gShouldPaintNativeControls = shouldPaintNativeControls;
681 }
682 #endif
683
setUsesEncodingDetector(bool usesEncodingDetector)684 void Settings::setUsesEncodingDetector(bool usesEncodingDetector)
685 {
686 m_usesEncodingDetector = usesEncodingDetector;
687 }
688
setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)689 void Settings::setAllowScriptsToCloseWindows(bool allowScriptsToCloseWindows)
690 {
691 m_allowScriptsToCloseWindows = allowScriptsToCloseWindows;
692 }
693
setCaretBrowsingEnabled(bool caretBrowsingEnabled)694 void Settings::setCaretBrowsingEnabled(bool caretBrowsingEnabled)
695 {
696 m_caretBrowsingEnabled = caretBrowsingEnabled;
697 }
698
setDownloadableBinaryFontsEnabled(bool downloadableBinaryFontsEnabled)699 void Settings::setDownloadableBinaryFontsEnabled(bool downloadableBinaryFontsEnabled)
700 {
701 m_downloadableBinaryFontsEnabled = downloadableBinaryFontsEnabled;
702 }
703
setXSSAuditorEnabled(bool xssAuditorEnabled)704 void Settings::setXSSAuditorEnabled(bool xssAuditorEnabled)
705 {
706 m_xssAuditorEnabled = xssAuditorEnabled;
707 }
708
setAcceleratedCompositingEnabled(bool enabled)709 void Settings::setAcceleratedCompositingEnabled(bool enabled)
710 {
711 if (m_acceleratedCompositingEnabled == enabled)
712 return;
713
714 m_acceleratedCompositingEnabled = enabled;
715 setNeedsReapplyStylesInAllFrames(m_page);
716 }
717
setShowDebugBorders(bool enabled)718 void Settings::setShowDebugBorders(bool enabled)
719 {
720 if (m_showDebugBorders == enabled)
721 return;
722
723 m_showDebugBorders = enabled;
724 setNeedsReapplyStylesInAllFrames(m_page);
725 }
726
setShowRepaintCounter(bool enabled)727 void Settings::setShowRepaintCounter(bool enabled)
728 {
729 if (m_showRepaintCounter == enabled)
730 return;
731
732 m_showRepaintCounter = enabled;
733 setNeedsReapplyStylesInAllFrames(m_page);
734 }
735
setExperimentalNotificationsEnabled(bool enabled)736 void Settings::setExperimentalNotificationsEnabled(bool enabled)
737 {
738 m_experimentalNotificationsEnabled = enabled;
739 }
740
setPluginAllowedRunTime(unsigned runTime)741 void Settings::setPluginAllowedRunTime(unsigned runTime)
742 {
743 m_pluginAllowedRunTime = runTime;
744 m_page->pluginAllowedRunTimeChanged();
745 }
746
747 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)748 void Settings::setShouldUseHighResolutionTimers(bool shouldUseHighResolutionTimers)
749 {
750 gShouldUseHighResolutionTimers = shouldUseHighResolutionTimers;
751 }
752 #endif
753
setWebGLEnabled(bool enabled)754 void Settings::setWebGLEnabled(bool enabled)
755 {
756 m_webGLEnabled = enabled;
757 }
758
setGeolocationEnabled(bool enabled)759 void Settings::setGeolocationEnabled(bool enabled)
760 {
761 m_geolocationEnabled = enabled;
762 }
763
setLoadDeferringEnabled(bool enabled)764 void Settings::setLoadDeferringEnabled(bool enabled)
765 {
766 m_loadDeferringEnabled = enabled;
767 }
768
769 } // namespace WebCore
770