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