1 /* 2 * Copyright (C) 2010 Google 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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #include "config.h" 32 #include "WebPreferences.h" 33 34 #include "WebView.h" 35 36 using namespace WebKit; 37 38 void WebPreferences::reset() 39 { 40 #if OS(MAC_OS_X) 41 cursiveFontFamily = WebString::fromUTF8("Apple Chancery"); 42 fantasyFontFamily = WebString::fromUTF8("Papyrus"); 43 WebString serif = WebString::fromUTF8("Times"); 44 #else 45 // These two fonts are picked from the intersection of 46 // Win XP font list and Vista font list : 47 // http://www.microsoft.com/typography/fonts/winxp.htm 48 // http://blogs.msdn.com/michkap/archive/2006/04/04/567881.aspx 49 // Some of them are installed only with CJK and complex script 50 // support enabled on Windows XP and are out of consideration here. 51 // (although we enabled both on our buildbots.) 52 // They (especially Impact for fantasy) are not typical cursive 53 // and fantasy fonts, but it should not matter for layout tests 54 // as long as they're available. 55 cursiveFontFamily = WebString::fromUTF8("Comic Sans MS"); 56 fantasyFontFamily = WebString::fromUTF8("Impact"); 57 // NOTE: case matters here, this must be 'times new roman', else 58 // some layout tests fail. 59 WebString serif = WebString::fromUTF8("times new roman"); 60 #endif 61 serifFontFamily = serif; 62 standardFontFamily = serif; 63 fixedFontFamily = WebString::fromUTF8("Courier"); 64 sansSerifFontFamily = WebString::fromUTF8("Helvetica"); 65 66 defaultFontSize = 16; 67 defaultFixedFontSize = 13; 68 minimumFontSize = 0; 69 minimumLogicalFontSize = 9; 70 71 DOMPasteAllowed = true; 72 XSSAuditorEnabled = false; 73 allowFileAccessFromFileURLs = true; 74 authorAndUserStylesEnabled = true; 75 defaultTextEncodingName = WebString::fromUTF8("ISO-8859-1"); 76 developerExtrasEnabled = true; 77 experimentalWebGLEnabled = false; 78 javaEnabled = false; 79 javaScriptCanAccessClipboard = true; 80 javaScriptCanOpenWindowsAutomatically = true; 81 javaScriptEnabled = true; 82 loadsImagesAutomatically = true; 83 localStorageEnabled = true; 84 offlineWebApplicationCacheEnabled = true; 85 pluginsEnabled = true; 86 shrinksStandaloneImagesToFit = false; 87 textAreasAreResizable = false; 88 userStyleSheetLocation = WebURL(); 89 usesPageCache = false; 90 webSecurityEnabled = true; 91 caretBrowsingEnabled = false; 92 93 // Allow those layout tests running as local files, i.e. under 94 // LayoutTests/http/tests/local, to access http server. 95 allowUniversalAccessFromFileURLs = true; 96 97 #if OS(DARWIN) 98 editingBehavior = WebSettings::EditingBehaviorMac; 99 #else 100 editingBehavior = WebSettings::EditingBehaviorWin; 101 #endif 102 103 tabsToLinks = false; 104 hyperlinkAuditingEnabled = false; 105 acceleratedCompositingEnabled = false; 106 accelerated2dCanvasEnabled = false; 107 forceCompositingMode = false; 108 } 109 110 void WebPreferences::applyTo(WebView* webView) 111 { 112 WebSettings* settings = webView->settings(); 113 settings->setCursiveFontFamily(cursiveFontFamily); 114 settings->setFantasyFontFamily(fantasyFontFamily); 115 settings->setSerifFontFamily(serifFontFamily); 116 settings->setStandardFontFamily(standardFontFamily); 117 settings->setFixedFontFamily(fixedFontFamily); 118 settings->setSansSerifFontFamily(sansSerifFontFamily); 119 120 settings->setDefaultFontSize(defaultFontSize); 121 settings->setDefaultFixedFontSize(defaultFixedFontSize); 122 settings->setMinimumFontSize(minimumFontSize); 123 settings->setMinimumLogicalFontSize(minimumLogicalFontSize); 124 125 settings->setDOMPasteAllowed(DOMPasteAllowed); 126 settings->setXSSAuditorEnabled(XSSAuditorEnabled); 127 settings->setAllowFileAccessFromFileURLs(allowFileAccessFromFileURLs); 128 settings->setAuthorAndUserStylesEnabled(authorAndUserStylesEnabled); 129 settings->setDefaultTextEncodingName(defaultTextEncodingName); 130 settings->setDeveloperExtrasEnabled(developerExtrasEnabled); 131 settings->setExperimentalWebGLEnabled(experimentalWebGLEnabled); 132 settings->setJavaEnabled(javaEnabled); 133 settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard); 134 settings->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically); 135 settings->setJavaScriptEnabled(javaScriptEnabled); 136 settings->setLoadsImagesAutomatically(loadsImagesAutomatically); 137 settings->setLocalStorageEnabled(localStorageEnabled); 138 settings->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled); 139 settings->setPluginsEnabled(pluginsEnabled); 140 settings->setShrinksStandaloneImagesToFit(shrinksStandaloneImagesToFit); 141 settings->setTextAreasAreResizable(textAreasAreResizable); 142 settings->setUserStyleSheetLocation(userStyleSheetLocation); 143 settings->setUsesPageCache(usesPageCache); 144 settings->setWebSecurityEnabled(webSecurityEnabled); 145 settings->setAllowUniversalAccessFromFileURLs(allowUniversalAccessFromFileURLs); 146 settings->setEditingBehavior(editingBehavior); 147 settings->setHyperlinkAuditingEnabled(hyperlinkAuditingEnabled); 148 // LayoutTests were written with Safari Mac in mind which does not allow 149 // tabbing to links by default. 150 webView->setTabsToLinks(tabsToLinks); 151 settings->setCaretBrowsingEnabled(caretBrowsingEnabled); 152 settings->setAcceleratedCompositingEnabled(acceleratedCompositingEnabled); 153 settings->setForceCompositingMode(forceCompositingMode); 154 settings->setAccelerated2dCanvasEnabled(accelerated2dCanvasEnabled); 155 156 // Fixed values. 157 settings->setShouldPaintCustomScrollbars(true); 158 settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); 159 settings->setDownloadableBinaryFontsEnabled(true); 160 settings->setAllowScriptsToCloseWindows(false); 161 settings->setNeedsSiteSpecificQuirks(true); 162 settings->setEditableLinkBehaviorNeverLive(); 163 settings->setFontRenderingModeNormal(); 164 settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded(); 165 settings->setUsesEncodingDetector(false); 166 settings->setImagesEnabled(true); 167 settings->setInteractiveFormValidationEnabled(true); 168 // Enable fullscreen so the fullscreen layout tests can run. 169 settings->setFullScreenEnabled(true); 170 settings->setValidationMessageTimerMagnification(-1); 171 } 172 173