| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserv
ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 static void setImageLoadingSettings(Page* page) | 45 static void setImageLoadingSettings(Page* page) |
| 46 { | 46 { |
| 47 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { | 47 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { |
| 48 frame->document()->fetcher()->setImagesEnabled(page->settings().areImage
sEnabled()); | 48 frame->document()->fetcher()->setImagesEnabled(page->settings().areImage
sEnabled()); |
| 49 frame->document()->fetcher()->setAutoLoadImages(page->settings().loadsIm
agesAutomatically()); | 49 frame->document()->fetcher()->setAutoLoadImages(page->settings().loadsIm
agesAutomatically()); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Sets the entry in the font map for the given script. If family is the empty s
tring, removes the entry instead. | |
| 54 static inline void setGenericFontFamilyMap(ScriptFontFamilyMap& fontMap, const A
tomicString& family, UScriptCode script, Page* page) | |
| 55 { | |
| 56 ScriptFontFamilyMap::iterator it = fontMap.find(static_cast<int>(script)); | |
| 57 if (family.isEmpty()) { | |
| 58 if (it == fontMap.end()) | |
| 59 return; | |
| 60 fontMap.remove(it); | |
| 61 } else if (it != fontMap.end() && it->value == family) | |
| 62 return; | |
| 63 else | |
| 64 fontMap.set(static_cast<int>(script), family); | |
| 65 | |
| 66 if (page) | |
| 67 page->setNeedsRecalcStyleInAllFrames(); | |
| 68 } | |
| 69 | |
| 70 static inline const AtomicString& getGenericFontFamilyForScript(const ScriptFont
FamilyMap& fontMap, UScriptCode script) | |
| 71 { | |
| 72 ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast<int>(scrip
t)); | |
| 73 if (it != fontMap.end()) | |
| 74 return it->value; | |
| 75 if (script != USCRIPT_COMMON) | |
| 76 return getGenericFontFamilyForScript(fontMap, USCRIPT_COMMON); | |
| 77 return emptyAtom; | |
| 78 } | |
| 79 | |
| 80 // NOTEs | 53 // NOTEs |
| 81 // 1) EditingMacBehavior comprises builds on Mac; | 54 // 1) EditingMacBehavior comprises builds on Mac; |
| 82 // 2) EditingWindowsBehavior comprises builds on Windows; | 55 // 2) EditingWindowsBehavior comprises builds on Windows; |
| 83 // 3) EditingUnixBehavior comprises all unix-based systems, but Darwin/MacOS/An
droid (and then abusing the terminology); | 56 // 3) EditingUnixBehavior comprises all unix-based systems, but Darwin/MacOS/An
droid (and then abusing the terminology); |
| 84 // 4) EditingAndroidBehavior comprises Android builds. | 57 // 4) EditingAndroidBehavior comprises Android builds. |
| 85 // 99) MacEditingBehavior is used a fallback. | 58 // 99) MacEditingBehavior is used a fallback. |
| 86 static EditingBehaviorType editingBehaviorTypeForPlatform() | 59 static EditingBehaviorType editingBehaviorTypeForPlatform() |
| 87 { | 60 { |
| 88 return | 61 return |
| 89 #if OS(MACOSX) | 62 #if OS(MACOSX) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 m_page = page; // Page is not yet fully initialized wen constructing Setting
s, so keeping m_page null over initializeDefaultFontFamilies() call. | 114 m_page = page; // Page is not yet fully initialized wen constructing Setting
s, so keeping m_page null over initializeDefaultFontFamilies() call. |
| 142 } | 115 } |
| 143 | 116 |
| 144 PassOwnPtr<Settings> Settings::create(Page* page) | 117 PassOwnPtr<Settings> Settings::create(Page* page) |
| 145 { | 118 { |
| 146 return adoptPtr(new Settings(page)); | 119 return adoptPtr(new Settings(page)); |
| 147 } | 120 } |
| 148 | 121 |
| 149 SETTINGS_SETTER_BODIES | 122 SETTINGS_SETTER_BODIES |
| 150 | 123 |
| 151 const AtomicString& Settings::standardFontFamily(UScriptCode script) const | |
| 152 { | |
| 153 return getGenericFontFamilyForScript(m_standardFontFamilyMap, script); | |
| 154 } | |
| 155 | |
| 156 void Settings::setStandardFontFamily(const AtomicString& family, UScriptCode scr
ipt) | |
| 157 { | |
| 158 setGenericFontFamilyMap(m_standardFontFamilyMap, family, script, m_page); | |
| 159 } | |
| 160 | |
| 161 const AtomicString& Settings::fixedFontFamily(UScriptCode script) const | |
| 162 { | |
| 163 return getGenericFontFamilyForScript(m_fixedFontFamilyMap, script); | |
| 164 } | |
| 165 | |
| 166 void Settings::setFixedFontFamily(const AtomicString& family, UScriptCode script
) | |
| 167 { | |
| 168 setGenericFontFamilyMap(m_fixedFontFamilyMap, family, script, m_page); | |
| 169 } | |
| 170 | |
| 171 const AtomicString& Settings::serifFontFamily(UScriptCode script) const | |
| 172 { | |
| 173 return getGenericFontFamilyForScript(m_serifFontFamilyMap, script); | |
| 174 } | |
| 175 | |
| 176 void Settings::setSerifFontFamily(const AtomicString& family, UScriptCode script
) | |
| 177 { | |
| 178 setGenericFontFamilyMap(m_serifFontFamilyMap, family, script, m_page); | |
| 179 } | |
| 180 | |
| 181 const AtomicString& Settings::sansSerifFontFamily(UScriptCode script) const | |
| 182 { | |
| 183 return getGenericFontFamilyForScript(m_sansSerifFontFamilyMap, script); | |
| 184 } | |
| 185 | |
| 186 void Settings::setSansSerifFontFamily(const AtomicString& family, UScriptCode sc
ript) | |
| 187 { | |
| 188 setGenericFontFamilyMap(m_sansSerifFontFamilyMap, family, script, m_page); | |
| 189 } | |
| 190 | |
| 191 const AtomicString& Settings::cursiveFontFamily(UScriptCode script) const | |
| 192 { | |
| 193 return getGenericFontFamilyForScript(m_cursiveFontFamilyMap, script); | |
| 194 } | |
| 195 | |
| 196 void Settings::setCursiveFontFamily(const AtomicString& family, UScriptCode scri
pt) | |
| 197 { | |
| 198 setGenericFontFamilyMap(m_cursiveFontFamilyMap, family, script, m_page); | |
| 199 } | |
| 200 | |
| 201 const AtomicString& Settings::fantasyFontFamily(UScriptCode script) const | |
| 202 { | |
| 203 return getGenericFontFamilyForScript(m_fantasyFontFamilyMap, script); | |
| 204 } | |
| 205 | |
| 206 void Settings::setFantasyFontFamily(const AtomicString& family, UScriptCode scri
pt) | |
| 207 { | |
| 208 setGenericFontFamilyMap(m_fantasyFontFamilyMap, family, script, m_page); | |
| 209 } | |
| 210 | |
| 211 const AtomicString& Settings::pictographFontFamily(UScriptCode script) const | |
| 212 { | |
| 213 return getGenericFontFamilyForScript(m_pictographFontFamilyMap, script); | |
| 214 } | |
| 215 | |
| 216 void Settings::setPictographFontFamily(const AtomicString& family, UScriptCode s
cript) | |
| 217 { | |
| 218 setGenericFontFamilyMap(m_pictographFontFamilyMap, family, script, m_page); | |
| 219 } | |
| 220 | |
| 221 void Settings::setTextAutosizingEnabled(bool textAutosizingEnabled) | 124 void Settings::setTextAutosizingEnabled(bool textAutosizingEnabled) |
| 222 { | 125 { |
| 223 if (m_textAutosizingEnabled == textAutosizingEnabled) | 126 if (m_textAutosizingEnabled == textAutosizingEnabled) |
| 224 return; | 127 return; |
| 225 | 128 |
| 226 m_textAutosizingEnabled = textAutosizingEnabled; | 129 m_textAutosizingEnabled = textAutosizingEnabled; |
| 227 m_page->setNeedsRecalcStyleInAllFrames(); | 130 m_page->setNeedsRecalcStyleInAllFrames(); |
| 228 } | 131 } |
| 229 | 132 |
| 230 bool Settings::textAutosizingEnabled() const | 133 bool Settings::textAutosizingEnabled() const |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 202 |
| 300 Frame* mainFrame = m_page->mainFrame(); | 203 Frame* mainFrame = m_page->mainFrame(); |
| 301 ASSERT(mainFrame); | 204 ASSERT(mainFrame); |
| 302 FrameView* view = mainFrame->view(); | 205 FrameView* view = mainFrame->view(); |
| 303 ASSERT(view); | 206 ASSERT(view); |
| 304 | 207 |
| 305 view->setMediaType(mediaTypeOverride); | 208 view->setMediaType(mediaTypeOverride); |
| 306 m_page->setNeedsRecalcStyleInAllFrames(); | 209 m_page->setNeedsRecalcStyleInAllFrames(); |
| 307 } | 210 } |
| 308 | 211 |
| 309 void Settings::resetFontFamilies() | |
| 310 { | |
| 311 m_standardFontFamilyMap.clear(); | |
| 312 m_serifFontFamilyMap.clear(); | |
| 313 m_fixedFontFamilyMap.clear(); | |
| 314 m_sansSerifFontFamilyMap.clear(); | |
| 315 m_cursiveFontFamilyMap.clear(); | |
| 316 m_fantasyFontFamilyMap.clear(); | |
| 317 m_pictographFontFamilyMap.clear(); | |
| 318 } | |
| 319 | |
| 320 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically) | 212 void Settings::setLoadsImagesAutomatically(bool loadsImagesAutomatically) |
| 321 { | 213 { |
| 322 m_loadsImagesAutomatically = loadsImagesAutomatically; | 214 m_loadsImagesAutomatically = loadsImagesAutomatically; |
| 323 | 215 |
| 324 // Changing this setting to true might immediately start new loads for image
s that had previously had loading disabled. | 216 // Changing this setting to true might immediately start new loads for image
s that had previously had loading disabled. |
| 325 // If this happens while a WebView is being dealloc'ed, and we don't know th
e WebView is being dealloc'ed, these new loads | 217 // If this happens while a WebView is being dealloc'ed, and we don't know th
e WebView is being dealloc'ed, these new loads |
| 326 // can cause crashes downstream when the WebView memory has actually been fr
ee'd. | 218 // can cause crashes downstream when the WebView memory has actually been fr
ee'd. |
| 327 // One example where this can happen is in Mac apps that subclass WebView th
en do work in their overridden dealloc methods. | 219 // One example where this can happen is in Mac apps that subclass WebView th
en do work in their overridden dealloc methods. |
| 328 // Starting these loads synchronously is not important. By putting it on a
0-delay, properly closing the Page cancels them | 220 // Starting these loads synchronously is not important. By putting it on a
0-delay, properly closing the Page cancels them |
| 329 // before they have a chance to really start. | 221 // before they have a chance to really start. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 if (m_page->mainFrame()) | 297 if (m_page->mainFrame()) |
| 406 m_page->mainFrame()->document()->updateViewportDescription(); | 298 m_page->mainFrame()->document()->updateViewportDescription(); |
| 407 } | 299 } |
| 408 | 300 |
| 409 void Settings::setViewportMetaEnabled(bool enabled) | 301 void Settings::setViewportMetaEnabled(bool enabled) |
| 410 { | 302 { |
| 411 m_viewportMetaEnabled = enabled; | 303 m_viewportMetaEnabled = enabled; |
| 412 } | 304 } |
| 413 | 305 |
| 414 } // namespace WebCore | 306 } // namespace WebCore |
| OLD | NEW |