| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
| 34 #include "core/page/Settings.h" | 34 #include "core/page/Settings.h" |
| 35 #include "platform/ColorChooser.h" | 35 #include "platform/ColorChooser.h" |
| 36 #include "platform/Supplementable.h" | 36 #include "platform/Supplementable.h" |
| 37 #include "platform/text/LocaleToScriptMapping.h" | 37 #include "platform/text/LocaleToScriptMapping.h" |
| 38 | 38 |
| 39 #define InternalSettingsGuardForSettingsReturn(returnValue) \ | 39 #define InternalSettingsGuardForSettingsReturn(returnValue) \ |
| 40 if (!settings()) { \ | 40 if (!settings()) { \ |
| 41 es.throwUninformativeAndGenericDOMException(InvalidAccessError); \ | 41 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); \ |
| 42 return returnValue; \ | 42 return returnValue; \ |
| 43 } | 43 } |
| 44 | 44 |
| 45 #define InternalSettingsGuardForSettings() \ | 45 #define InternalSettingsGuardForSettings() \ |
| 46 if (!settings()) { \ | 46 if (!settings()) { \ |
| 47 es.throwUninformativeAndGenericDOMException(InvalidAccessError); \ | 47 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); \ |
| 48 return; \ | 48 return; \ |
| 49 } | 49 } |
| 50 | 50 |
| 51 #define InternalSettingsGuardForPage() \ | 51 #define InternalSettingsGuardForPage() \ |
| 52 if (!page()) { \ | 52 if (!page()) { \ |
| 53 es.throwUninformativeAndGenericDOMException(InvalidAccessError); \ | 53 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); \ |
| 54 return; \ | 54 return; \ |
| 55 } | 55 } |
| 56 | 56 |
| 57 namespace WebCore { | 57 namespace WebCore { |
| 58 | 58 |
| 59 InternalSettings::Backup::Backup(Settings* settings) | 59 InternalSettings::Backup::Backup(Settings* settings) |
| 60 : m_originalCSSExclusionsEnabled(RuntimeEnabledFeatures::cssExclusionsEnable
d()) | 60 : m_originalCSSExclusionsEnabled(RuntimeEnabledFeatures::cssExclusionsEnable
d()) |
| 61 , m_originalAuthorShadowDOMForAnyElementEnabled(RuntimeEnabledFeatures::auth
orShadowDOMForAnyElementEnabled()) | 61 , m_originalAuthorShadowDOMForAnyElementEnabled(RuntimeEnabledFeatures::auth
orShadowDOMForAnyElementEnabled()) |
| 62 , m_originalExperimentalWebSocketEnabled(settings->experimentalWebSocketEnab
led()) | 62 , m_originalExperimentalWebSocketEnabled(settings->experimentalWebSocketEnab
led()) |
| 63 , m_originalStyleScoped(RuntimeEnabledFeatures::styleScopedEnabled()) | 63 , m_originalStyleScoped(RuntimeEnabledFeatures::styleScopedEnabled()) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 InternalSettingsGenerated::resetToConsistentState(); | 153 InternalSettingsGenerated::resetToConsistentState(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 Settings* InternalSettings::settings() const | 156 Settings* InternalSettings::settings() const |
| 157 { | 157 { |
| 158 if (!page()) | 158 if (!page()) |
| 159 return 0; | 159 return 0; |
| 160 return &page()->settings(); | 160 return &page()->settings(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionState& es
) | 163 void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionState& ex
ceptionState) |
| 164 { | 164 { |
| 165 InternalSettingsGuardForSettings(); | 165 InternalSettingsGuardForSettings(); |
| 166 settings()->setMockScrollbarsEnabled(enabled); | 166 settings()->setMockScrollbarsEnabled(enabled); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void InternalSettings::setAuthorShadowDOMForAnyElementEnabled(bool isEnabled) | 169 void InternalSettings::setAuthorShadowDOMForAnyElementEnabled(bool isEnabled) |
| 170 { | 170 { |
| 171 RuntimeEnabledFeatures::setAuthorShadowDOMForAnyElementEnabled(isEnabled); | 171 RuntimeEnabledFeatures::setAuthorShadowDOMForAnyElementEnabled(isEnabled); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void InternalSettings::setExperimentalWebSocketEnabled(bool isEnabled) | 174 void InternalSettings::setExperimentalWebSocketEnabled(bool isEnabled) |
| 175 { | 175 { |
| 176 settings()->setExperimentalWebSocketEnabled(isEnabled); | 176 settings()->setExperimentalWebSocketEnabled(isEnabled); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void InternalSettings::setStyleScopedEnabled(bool enabled) | 179 void InternalSettings::setStyleScopedEnabled(bool enabled) |
| 180 { | 180 { |
| 181 RuntimeEnabledFeatures::setStyleScopedEnabled(enabled); | 181 RuntimeEnabledFeatures::setStyleScopedEnabled(enabled); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void InternalSettings::setOverlayScrollbarsEnabled(bool enabled) | 184 void InternalSettings::setOverlayScrollbarsEnabled(bool enabled) |
| 185 { | 185 { |
| 186 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(enabled); | 186 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(enabled); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionStat
e& es) | 189 void InternalSettings::setTouchEventEmulationEnabled(bool enabled, ExceptionStat
e& exceptionState) |
| 190 { | 190 { |
| 191 InternalSettingsGuardForSettings(); | 191 InternalSettingsGuardForSettings(); |
| 192 settings()->setTouchEventEmulationEnabled(enabled); | 192 settings()->setTouchEventEmulationEnabled(enabled); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void InternalSettings::setViewportEnabled(bool enabled, ExceptionState& es) | 195 void InternalSettings::setViewportEnabled(bool enabled, ExceptionState& exceptio
nState) |
| 196 { | 196 { |
| 197 InternalSettingsGuardForSettings(); | 197 InternalSettingsGuardForSettings(); |
| 198 settings()->setViewportEnabled(enabled); | 198 settings()->setViewportEnabled(enabled); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // FIXME: This is a temporary flag and should be removed once accelerated | 201 // FIXME: This is a temporary flag and should be removed once accelerated |
| 202 // overflow scroll is ready (crbug.com/254111). | 202 // overflow scroll is ready (crbug.com/254111). |
| 203 void InternalSettings::setCompositorDrivenAcceleratedScrollingEnabled(bool enabl
ed, ExceptionState& es) | 203 void InternalSettings::setCompositorDrivenAcceleratedScrollingEnabled(bool enabl
ed, ExceptionState& exceptionState) |
| 204 { | 204 { |
| 205 InternalSettingsGuardForSettings(); | 205 InternalSettingsGuardForSettings(); |
| 206 settings()->setCompositorDrivenAcceleratedScrollingEnabled(enabled); | 206 settings()->setCompositorDrivenAcceleratedScrollingEnabled(enabled); |
| 207 } | 207 } |
| 208 | 208 |
| 209 typedef void (Settings::*SetFontFamilyFunction)(const AtomicString&, UScriptCode
); | 209 typedef void (Settings::*SetFontFamilyFunction)(const AtomicString&, UScriptCode
); |
| 210 static void setFontFamily(Settings* settings, const String& family, const String
& script, SetFontFamilyFunction setter) | 210 static void setFontFamily(Settings* settings, const String& family, const String
& script, SetFontFamilyFunction setter) |
| 211 { | 211 { |
| 212 UScriptCode code = scriptNameToCode(script); | 212 UScriptCode code = scriptNameToCode(script); |
| 213 if (code != USCRIPT_INVALID_CODE) | 213 if (code != USCRIPT_INVALID_CODE) |
| 214 (settings->*setter)(family, code); | 214 (settings->*setter)(family, code); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void InternalSettings::setStandardFontFamily(const String& family, const String&
script, ExceptionState& es) | 217 void InternalSettings::setStandardFontFamily(const String& family, const String&
script, ExceptionState& exceptionState) |
| 218 { | 218 { |
| 219 InternalSettingsGuardForSettings(); | 219 InternalSettingsGuardForSettings(); |
| 220 setFontFamily(settings(), family, script, &Settings::setStandardFontFamily); | 220 setFontFamily(settings(), family, script, &Settings::setStandardFontFamily); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void InternalSettings::setSerifFontFamily(const String& family, const String& sc
ript, ExceptionState& es) | 223 void InternalSettings::setSerifFontFamily(const String& family, const String& sc
ript, ExceptionState& exceptionState) |
| 224 { | 224 { |
| 225 InternalSettingsGuardForSettings(); | 225 InternalSettingsGuardForSettings(); |
| 226 setFontFamily(settings(), family, script, &Settings::setSerifFontFamily); | 226 setFontFamily(settings(), family, script, &Settings::setSerifFontFamily); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void InternalSettings::setSansSerifFontFamily(const String& family, const String
& script, ExceptionState& es) | 229 void InternalSettings::setSansSerifFontFamily(const String& family, const String
& script, ExceptionState& exceptionState) |
| 230 { | 230 { |
| 231 InternalSettingsGuardForSettings(); | 231 InternalSettingsGuardForSettings(); |
| 232 setFontFamily(settings(), family, script, &Settings::setSansSerifFontFamily)
; | 232 setFontFamily(settings(), family, script, &Settings::setSansSerifFontFamily)
; |
| 233 } | 233 } |
| 234 | 234 |
| 235 void InternalSettings::setFixedFontFamily(const String& family, const String& sc
ript, ExceptionState& es) | 235 void InternalSettings::setFixedFontFamily(const String& family, const String& sc
ript, ExceptionState& exceptionState) |
| 236 { | 236 { |
| 237 InternalSettingsGuardForSettings(); | 237 InternalSettingsGuardForSettings(); |
| 238 setFontFamily(settings(), family, script, &Settings::setFixedFontFamily); | 238 setFontFamily(settings(), family, script, &Settings::setFixedFontFamily); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void InternalSettings::setCursiveFontFamily(const String& family, const String&
script, ExceptionState& es) | 241 void InternalSettings::setCursiveFontFamily(const String& family, const String&
script, ExceptionState& exceptionState) |
| 242 { | 242 { |
| 243 InternalSettingsGuardForSettings(); | 243 InternalSettingsGuardForSettings(); |
| 244 setFontFamily(settings(), family, script, &Settings::setCursiveFontFamily); | 244 setFontFamily(settings(), family, script, &Settings::setCursiveFontFamily); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void InternalSettings::setFantasyFontFamily(const String& family, const String&
script, ExceptionState& es) | 247 void InternalSettings::setFantasyFontFamily(const String& family, const String&
script, ExceptionState& exceptionState) |
| 248 { | 248 { |
| 249 InternalSettingsGuardForSettings(); | 249 InternalSettingsGuardForSettings(); |
| 250 setFontFamily(settings(), family, script, &Settings::setFantasyFontFamily); | 250 setFontFamily(settings(), family, script, &Settings::setFantasyFontFamily); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void InternalSettings::setPictographFontFamily(const String& family, const Strin
g& script, ExceptionState& es) | 253 void InternalSettings::setPictographFontFamily(const String& family, const Strin
g& script, ExceptionState& exceptionState) |
| 254 { | 254 { |
| 255 InternalSettingsGuardForSettings(); | 255 InternalSettingsGuardForSettings(); |
| 256 setFontFamily(settings(), family, script, &Settings::setPictographFontFamily
); | 256 setFontFamily(settings(), family, script, &Settings::setPictographFontFamily
); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionState& es
) | 259 void InternalSettings::setTextAutosizingEnabled(bool enabled, ExceptionState& ex
ceptionState) |
| 260 { | 260 { |
| 261 InternalSettingsGuardForSettings(); | 261 InternalSettingsGuardForSettings(); |
| 262 settings()->setTextAutosizingEnabled(enabled); | 262 settings()->setTextAutosizingEnabled(enabled); |
| 263 } | 263 } |
| 264 | 264 |
| 265 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height
, ExceptionState& es) | 265 void InternalSettings::setTextAutosizingWindowSizeOverride(int width, int height
, ExceptionState& exceptionState) |
| 266 { | 266 { |
| 267 InternalSettingsGuardForSettings(); | 267 InternalSettingsGuardForSettings(); |
| 268 settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height)); | 268 settings()->setTextAutosizingWindowSizeOverride(IntSize(width, height)); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionSt
ate& es) | 271 void InternalSettings::setMediaTypeOverride(const String& mediaType, ExceptionSt
ate& exceptionState) |
| 272 { | 272 { |
| 273 InternalSettingsGuardForSettings(); | 273 InternalSettingsGuardForSettings(); |
| 274 settings()->setMediaTypeOverride(mediaType); | 274 settings()->setMediaTypeOverride(mediaType); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, E
xceptionState& es) | 277 void InternalSettings::setTextAutosizingFontScaleFactor(float fontScaleFactor, E
xceptionState& exceptionState) |
| 278 { | 278 { |
| 279 InternalSettingsGuardForSettings(); | 279 InternalSettingsGuardForSettings(); |
| 280 settings()->setTextAutosizingFontScaleFactor(fontScaleFactor); | 280 settings()->setTextAutosizingFontScaleFactor(fontScaleFactor); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void InternalSettings::setCSSExclusionsEnabled(bool enabled) | 283 void InternalSettings::setCSSExclusionsEnabled(bool enabled) |
| 284 { | 284 { |
| 285 RuntimeEnabledFeatures::setCSSExclusionsEnabled(enabled); | 285 RuntimeEnabledFeatures::setCSSExclusionsEnabled(enabled); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void InternalSettings::setEditingBehavior(const String& editingBehavior, Excepti
onState& es) | 288 void InternalSettings::setEditingBehavior(const String& editingBehavior, Excepti
onState& exceptionState) |
| 289 { | 289 { |
| 290 InternalSettingsGuardForSettings(); | 290 InternalSettingsGuardForSettings(); |
| 291 if (equalIgnoringCase(editingBehavior, "win")) | 291 if (equalIgnoringCase(editingBehavior, "win")) |
| 292 settings()->setEditingBehaviorType(EditingWindowsBehavior); | 292 settings()->setEditingBehaviorType(EditingWindowsBehavior); |
| 293 else if (equalIgnoringCase(editingBehavior, "mac")) | 293 else if (equalIgnoringCase(editingBehavior, "mac")) |
| 294 settings()->setEditingBehaviorType(EditingMacBehavior); | 294 settings()->setEditingBehaviorType(EditingMacBehavior); |
| 295 else if (equalIgnoringCase(editingBehavior, "unix")) | 295 else if (equalIgnoringCase(editingBehavior, "unix")) |
| 296 settings()->setEditingBehaviorType(EditingUnixBehavior); | 296 settings()->setEditingBehaviorType(EditingUnixBehavior); |
| 297 else if (equalIgnoringCase(editingBehavior, "android")) | 297 else if (equalIgnoringCase(editingBehavior, "android")) |
| 298 settings()->setEditingBehaviorType(EditingAndroidBehavior); | 298 settings()->setEditingBehaviorType(EditingAndroidBehavior); |
| 299 else | 299 else |
| 300 es.throwUninformativeAndGenericDOMException(SyntaxError); | 300 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled) | 303 void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled) |
| 304 { | 304 { |
| 305 RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(enabled); | 305 RuntimeEnabledFeatures::setLangAttributeAwareFormControlUIEnabled(enabled); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void InternalSettings::setImagesEnabled(bool enabled, ExceptionState& es) | 308 void InternalSettings::setImagesEnabled(bool enabled, ExceptionState& exceptionS
tate) |
| 309 { | 309 { |
| 310 InternalSettingsGuardForSettings(); | 310 InternalSettingsGuardForSettings(); |
| 311 settings()->setImagesEnabled(enabled); | 311 settings()->setImagesEnabled(enabled); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionStat
e& es) | 314 void InternalSettings::setDefaultVideoPosterURL(const String& url, ExceptionStat
e& exceptionState) |
| 315 { | 315 { |
| 316 InternalSettingsGuardForSettings(); | 316 InternalSettingsGuardForSettings(); |
| 317 settings()->setDefaultVideoPosterURL(url); | 317 settings()->setDefaultVideoPosterURL(url); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void InternalSettings::setPasswordGenerationDecorationEnabled(bool enabled, Exce
ptionState& es) | 320 void InternalSettings::setPasswordGenerationDecorationEnabled(bool enabled, Exce
ptionState& exceptionState) |
| 321 { | 321 { |
| 322 InternalSettingsGuardForSettings(); | 322 InternalSettingsGuardForSettings(); |
| 323 settings()->setPasswordGenerationDecorationEnabled(enabled); | 323 settings()->setPasswordGenerationDecorationEnabled(enabled); |
| 324 } | 324 } |
| 325 | 325 |
| 326 } | 326 } |
| OLD | NEW |