|
1 /* |
|
2 * Copyright (C) 2006, 2007 Apple Computer, 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 "Frame.h" |
|
30 #include "FrameTree.h" |
|
31 #include "Page.h" |
|
32 #include "PageCache.h" |
|
33 #include "HistoryItem.h" |
|
34 |
|
35 namespace WebCore { |
|
36 |
|
37 static void setNeedsReapplyStylesInAllFrames(Page* page) |
|
38 { |
|
39 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) |
|
40 frame->setNeedsReapplyStyles(); |
|
41 } |
|
42 |
|
43 Settings::Settings(Page* page) |
|
44 : m_page(page) |
|
45 , m_editableLinkBehavior(EditableLinkDefaultBehavior) |
|
46 , m_minimumFontSize(0) |
|
47 , m_minimumLogicalFontSize(0) |
|
48 , m_defaultFontSize(0) |
|
49 , m_defaultFixedFontSize(0) |
|
50 , m_isJavaEnabled(false) |
|
51 , m_loadsImagesAutomatically(false) |
|
52 , m_privateBrowsingEnabled(false) |
|
53 , m_arePluginsEnabled(false) |
|
54 , m_isJavaScriptEnabled(false) |
|
55 , m_javaScriptCanOpenWindowsAutomatically(false) |
|
56 , m_shouldPrintBackgrounds(false) |
|
57 , m_textAreasAreResizable(false) |
|
58 , m_usesDashboardBackwardCompatibilityMode(false) |
|
59 , m_needsAdobeFrameReloadingQuirk(false) |
|
60 , m_isDOMPasteAllowed(false) |
|
61 , m_shrinksStandaloneImagesToFit(true) |
|
62 , m_usesPageCache(false) |
|
63 , m_showsURLsInToolTips(false) |
|
64 , m_forceFTPDirectoryListings(false) |
|
65 , m_developerExtrasEnabled(false) |
|
66 , m_flatFrameSetLayoutEnabled(true) |
|
67 { |
|
68 // A Frame may not have been created yet, so we initialize the AtomicString |
|
69 // hash before trying to use it. |
|
70 AtomicString::init(); |
|
71 } |
|
72 |
|
73 void Settings::setStandardFontFamily(const AtomicString& standardFontFamily) |
|
74 { |
|
75 if (standardFontFamily == m_standardFontFamily) |
|
76 return; |
|
77 |
|
78 m_standardFontFamily = standardFontFamily; |
|
79 setNeedsReapplyStylesInAllFrames(m_page); |
|
80 } |
|
81 |
|
82 void Settings::setFixedFontFamily(const AtomicString& fixedFontFamily) |
|
83 { |
|
84 if (m_fixedFontFamily == fixedFontFamily) |
|
85 return; |
|
86 |
|
87 m_fixedFontFamily = fixedFontFamily; |
|
88 setNeedsReapplyStylesInAllFrames(m_page); |
|
89 } |
|
90 |
|
91 void Settings::setSerifFontFamily(const AtomicString& serifFontFamily) |
|
92 { |
|
93 if (m_serifFontFamily == serifFontFamily) |
|
94 return; |
|
95 |
|
96 m_serifFontFamily = serifFontFamily; |
|
97 setNeedsReapplyStylesInAllFrames(m_page); |
|
98 } |
|
99 |
|
100 void Settings::setSansSerifFontFamily(const AtomicString& sansSerifFontFamily) |
|
101 { |
|
102 if (m_sansSerifFontFamily == sansSerifFontFamily) |
|
103 return; |
|
104 |
|
105 m_sansSerifFontFamily = sansSerifFontFamily; |
|
106 setNeedsReapplyStylesInAllFrames(m_page); |
|
107 } |
|
108 |
|
109 void Settings::setCursiveFontFamily(const AtomicString& cursiveFontFamily) |
|
110 { |
|
111 if (m_cursiveFontFamily == cursiveFontFamily) |
|
112 return; |
|
113 |
|
114 m_cursiveFontFamily = cursiveFontFamily; |
|
115 setNeedsReapplyStylesInAllFrames(m_page); |
|
116 } |
|
117 |
|
118 void Settings::setFantasyFontFamily(const AtomicString& fantasyFontFamily) |
|
119 { |
|
120 if (m_fantasyFontFamily == fantasyFontFamily) |
|
121 return; |
|
122 |
|
123 m_fantasyFontFamily = fantasyFontFamily; |
|
124 setNeedsReapplyStylesInAllFrames(m_page); |
|
125 } |
|
126 |
|
127 void Settings::setMinimumFontSize(int minimumFontSize) |
|
128 { |
|
129 if (m_minimumFontSize == minimumFontSize) |
|
130 return; |
|
131 |
|
132 m_minimumFontSize = minimumFontSize; |
|
133 setNeedsReapplyStylesInAllFrames(m_page); |
|
134 } |
|
135 |
|
136 void Settings::setMinimumLogicalFontSize(int minimumLogicalFontSize) |
|
137 { |
|
138 if (m_minimumLogicalFontSize == minimumLogicalFontSize) |
|
139 return; |
|
140 |
|
141 m_minimumLogicalFontSize = minimumLogicalFontSize; |
|
142 setNeedsReapplyStylesInAllFrames(m_page); |
|
143 } |
|
144 |
|
145 void Settings::setDefaultFontSize(int defaultFontSize) |
|
146 { |
|
147 if (m_defaultFontSize == defaultFontSize) |
|
148 return; |
|
149 |
|
150 m_defaultFontSize = defaultFontSize; |
|
151 setNeedsReapplyStylesInAllFrames(m_page); |
|
152 } |
|
153 |
|
154 void Settings::setDefaultFixedFontSize(int defaultFontSize) |
|
155 { |
|
156 if (m_defaultFixedFontSize == defaultFontSize) |
|
157 return; |
|
158 |
|
159 m_defaultFixedFontSize = defaultFontSize; |
|
160 setNeedsReapplyStylesInAllFrames(m_page); |
|
161 } |
|
162 |
|
163 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically) |
|
164 { |
|
165 m_loadsImagesAutomatically = loadsImagesAutomatically; |
|
166 } |
|
167 |
|
168 void Settings::setJavaScriptEnabled(bool isJavaScriptEnabled) |
|
169 { |
|
170 m_isJavaScriptEnabled = isJavaScriptEnabled; |
|
171 } |
|
172 |
|
173 void Settings::setJavaEnabled(bool isJavaEnabled) |
|
174 { |
|
175 m_isJavaEnabled = isJavaEnabled; |
|
176 } |
|
177 |
|
178 void Settings::setPluginsEnabled(bool arePluginsEnabled) |
|
179 { |
|
180 m_arePluginsEnabled = arePluginsEnabled; |
|
181 } |
|
182 |
|
183 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled) |
|
184 { |
|
185 m_privateBrowsingEnabled = privateBrowsingEnabled; |
|
186 } |
|
187 |
|
188 void Settings::setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWindowsAutomatically) |
|
189 { |
|
190 m_javaScriptCanOpenWindowsAutomatically = javaScriptCanOpenWindowsAutomatically; |
|
191 } |
|
192 |
|
193 void Settings::setDefaultTextEncodingName(const String& defaultTextEncodingName) |
|
194 { |
|
195 m_defaultTextEncodingName = defaultTextEncodingName; |
|
196 } |
|
197 |
|
198 void Settings::setUserStyleSheetLocation(const KURL& userStyleSheetLocation) |
|
199 { |
|
200 if (m_userStyleSheetLocation == userStyleSheetLocation) |
|
201 return; |
|
202 |
|
203 m_userStyleSheetLocation = userStyleSheetLocation; |
|
204 setNeedsReapplyStylesInAllFrames(m_page); |
|
205 } |
|
206 |
|
207 void Settings::setShouldPrintBackgrounds(bool shouldPrintBackgrounds) |
|
208 { |
|
209 m_shouldPrintBackgrounds = shouldPrintBackgrounds; |
|
210 } |
|
211 |
|
212 void Settings::setTextAreasAreResizable(bool textAreasAreResizable) |
|
213 { |
|
214 if (m_textAreasAreResizable == textAreasAreResizable) |
|
215 return; |
|
216 |
|
217 m_textAreasAreResizable = textAreasAreResizable; |
|
218 setNeedsReapplyStylesInAllFrames(m_page); |
|
219 } |
|
220 |
|
221 void Settings::setEditableLinkBehavior(EditableLinkBehavior editableLinkBehavior) |
|
222 { |
|
223 m_editableLinkBehavior = editableLinkBehavior; |
|
224 } |
|
225 |
|
226 void Settings::setUsesDashboardBackwardCompatibilityMode(bool usesDashboardBackwardCompatibilityMode) |
|
227 { |
|
228 m_usesDashboardBackwardCompatibilityMode = usesDashboardBackwardCompatibilityMode; |
|
229 } |
|
230 |
|
231 // FIXME: This quirk is needed because of Radar 4674537 and 5211271. We need to phase it out once Adobe |
|
232 // can fix the bug from their end. |
|
233 void Settings::setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUnchangedSRC) |
|
234 { |
|
235 m_needsAdobeFrameReloadingQuirk = shouldNotReloadIFramesForUnchangedSRC; |
|
236 } |
|
237 |
|
238 void Settings::setDOMPasteAllowed(bool DOMPasteAllowed) |
|
239 { |
|
240 m_isDOMPasteAllowed = DOMPasteAllowed; |
|
241 } |
|
242 |
|
243 void Settings::setUsesPageCache(bool usesPageCache) |
|
244 { |
|
245 if (m_usesPageCache == usesPageCache) |
|
246 return; |
|
247 |
|
248 m_usesPageCache = usesPageCache; |
|
249 if (!m_usesPageCache) { |
|
250 HistoryItemVector& historyItems = m_page->backForwardList()->entries(); |
|
251 for (unsigned i = 0; i < historyItems.size(); i++) |
|
252 pageCache()->remove(historyItems[i].get()); |
|
253 pageCache()->releaseAutoreleasedPagesNow(); |
|
254 } |
|
255 } |
|
256 |
|
257 void Settings::setShrinksStandaloneImagesToFit(bool shrinksStandaloneImagesToFit) |
|
258 { |
|
259 m_shrinksStandaloneImagesToFit = shrinksStandaloneImagesToFit; |
|
260 } |
|
261 |
|
262 void Settings::setShowsURLsInToolTips(bool showsURLsInToolTips) |
|
263 { |
|
264 m_showsURLsInToolTips = showsURLsInToolTips; |
|
265 } |
|
266 |
|
267 void Settings::setFTPDirectoryTemplatePath(const String& path) |
|
268 { |
|
269 m_ftpDirectoryTemplatePath = path; |
|
270 } |
|
271 |
|
272 void Settings::setForceFTPDirectoryListings(bool force) |
|
273 { |
|
274 m_forceFTPDirectoryListings = force; |
|
275 } |
|
276 |
|
277 void Settings::setDeveloperExtrasEnabled(bool developerExtrasEnabled) |
|
278 { |
|
279 m_developerExtrasEnabled = developerExtrasEnabled; |
|
280 } |
|
281 |
|
282 } // namespace WebCore |