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