Changeset 12930 in webkit


Ignore:
Timestamp:
Feb 21, 2006 4:55:26 PM (18 years ago)
Author:
kdecker
Message:

Reviewed by Darin.

Backed out my previous check in. Since these methods are internal to WebKit (and not private)
it's perfectly OK for them to remain as categories.

  • ChangeLog:
  • WebView/WebPreferences.m: (-[WebPreferences _integerValueForKey:]): (-[WebPreferences _setIntegerValue:forKey:]): (-[WebPreferences _floatValueForKey:]): (-[WebPreferences _setFloatValue:forKey:]): (-[WebPreferences _boolValueForKey:]): (-[WebPreferences _setBoolValue:forKey:]):
  • WebView/WebPreferencesPrivate.h:
Location:
trunk/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r12926 r12930  
    112006-02-21  Kevin Decker  <kdecker@apple.com>
    22
    3         Reviewed by Timo O.
    4 
    5         Moved these (already private) methods into the private WebPreferences header.
    6         Slightly better style than sprinkling the code with categories.
    7        
     3        Reviewed by Darin.
     4
     5        Backed out my previous check in. Since these methods are internal to WebKit (and not private)
     6        it's perfectly OK for them to remain as categories.
     7        * ChangeLog:
    88        * WebView/WebPreferences.m:
    9         (-[WebPreferences _integerValueForKey:]): Moved to WebPreferences (WebPrivate).
    10         (-[WebPreferences _floatValueForKey:]): Ditto.
    11         (-[WebPreferences _boolValueForKey:]): Ditto.
    12         (-[WebPreferences _setBoolValue:forKey:]): Ditto.
    13         (-[WebPreferences _setFloatValue:forKey:]): Ditto.
    14         (-[WebPreferences _setIntegerValue:forKey:]): Ditto.
    15         * WebView/WebPreferencesPrivate.h: Added the above methods.
     9        (-[WebPreferences _integerValueForKey:]):
     10        (-[WebPreferences _setIntegerValue:forKey:]):
     11        (-[WebPreferences _floatValueForKey:]):
     12        (-[WebPreferences _setFloatValue:forKey:]):
     13        (-[WebPreferences _boolValueForKey:]):
     14        (-[WebPreferences _setBoolValue:forKey:]):
     15        * WebView/WebPreferencesPrivate.h:
    1616
    17172006-02-20  Darin Adler  <darin@apple.com>
  • trunk/WebKit/WebView/WebPreferences.m

    r12926 r12930  
    6767+ (NSString *)_concatenateKeyWithIBCreatorID:(NSString *)key;
    6868+ (NSString *)_IBCreatorID;
     69@end
     70
     71@interface WebPreferences (WebForwardDeclarations)
     72// This pseudo-category is needed so these methods can be used from within other category implementations
     73// without being in the public header file.
     74- (BOOL)_boolValueForKey:(NSString *)key;
     75- (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
     76- (int)_integerValueForKey:(NSString *)key;
     77- (void)_setIntegerValue:(int)value forKey:(NSString *)key;
     78- (float)_floatValueForKey:(NSString *)key;
     79- (void)_setFloatValue:(float)value forKey:(NSString *)key;
    6980@end
    7081
     
    269280}
    270281
    271 - (NSString *)standardFontFamily
    272 {
    273     return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
    274 }
    275 
    276 - (void)setStandardFontFamily:(NSString *)family
    277 {
    278     [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
    279 }
    280 
    281 - (NSString *)fixedFontFamily
    282 {
    283     return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
    284 }
    285 
    286 - (void)setFixedFontFamily:(NSString *)family
    287 {
    288     [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
    289 }
    290 
    291 - (NSString *)serifFontFamily
    292 {
    293     return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
    294 }
    295 
    296 - (void)setSerifFontFamily:(NSString *)family
    297 {
    298     [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
    299 }
    300 
    301 - (NSString *)sansSerifFontFamily
    302 {
    303     return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
    304 }
    305 
    306 - (void)setSansSerifFontFamily:(NSString *)family
    307 {
    308     [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
    309 }
    310 
    311 - (NSString *)cursiveFontFamily
    312 {
    313     return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
    314 }
    315 
    316 - (void)setCursiveFontFamily:(NSString *)family
    317 {
    318     [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
    319 }
    320 
    321 - (NSString *)fantasyFontFamily
    322 {
    323     return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
    324 }
    325 
    326 - (void)setFantasyFontFamily:(NSString *)family
    327 {
    328     [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
    329 }
    330 
    331 - (int)defaultFontSize
    332 {
    333     return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
    334 }
    335 
    336 - (void)setDefaultFontSize:(int)size
    337 {
    338     [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
    339 }
    340 
    341 - (int)defaultFixedFontSize
    342 {
    343     return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
    344 }
    345 
    346 - (void)setDefaultFixedFontSize:(int)size
    347 {
    348     [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
    349 }
    350 
    351 - (int)minimumFontSize
    352 {
    353     return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
    354 }
    355 
    356 - (void)setMinimumFontSize:(int)size
    357 {
    358     [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
    359 }
    360 
    361 - (int)minimumLogicalFontSize
    362 {
    363   return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
    364 }
    365 
    366 - (void)setMinimumLogicalFontSize:(int)size
    367 {
    368   [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
    369 }
    370 
    371 - (NSString *)defaultTextEncodingName
    372 {
    373     return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
    374 }
    375 
    376 - (void)setDefaultTextEncodingName:(NSString *)encoding
    377 {
    378     [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
    379 }
    380 
    381 - (BOOL)userStyleSheetEnabled
    382 {
    383     return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
    384 }
    385 
    386 - (void)setUserStyleSheetEnabled:(BOOL)flag
    387 {
    388     [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
    389 }
    390 
    391 - (NSURL *)userStyleSheetLocation
    392 {
    393     NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
    394    
    395     if ([locationString _webkit_looksLikeAbsoluteURL]) {
    396         return [NSURL _web_URLWithDataAsString:locationString];
    397     } else {
    398         locationString = [locationString stringByExpandingTildeInPath];
    399         return [NSURL fileURLWithPath:locationString];
    400     }
    401 }
    402 
    403 - (void)setUserStyleSheetLocation:(NSURL *)URL
    404 {
    405     NSString *locationString;
    406    
    407     if ([URL isFileURL]) {
    408         locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
    409     } else {
    410         locationString = [URL _web_originalDataAsString];
    411     }
    412    
    413     [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
    414 }
    415 
    416 - (BOOL)shouldPrintBackgrounds
    417 {
    418     return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
    419 }
    420 
    421 - (void)setShouldPrintBackgrounds:(BOOL)flag
    422 {
    423     [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
    424 }
    425 
    426 - (BOOL)isJavaEnabled
    427 {
    428     return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
    429 }
    430 
    431 - (void)setJavaEnabled:(BOOL)flag
    432 {
    433     [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
    434 }
    435 
    436 - (BOOL)isJavaScriptEnabled
    437 {
    438     return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
    439 }
    440 
    441 - (void)setJavaScriptEnabled:(BOOL)flag
    442 {
    443     [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
    444 }
    445 
    446 - (BOOL)javaScriptCanOpenWindowsAutomatically
    447 {
    448     return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
    449 }
    450 
    451 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
    452 {
    453     [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
    454 }
    455 
    456 - (BOOL)arePlugInsEnabled
    457 {
    458     return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
    459 }
    460 
    461 - (void)setPlugInsEnabled:(BOOL)flag
    462 {
    463     [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
    464 }
    465 
    466 - (BOOL)allowsAnimatedImages
    467 {
    468     return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
    469 }
    470 
    471 - (void)setAllowsAnimatedImages:(BOOL)flag;
    472 {
    473     [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
    474 }
    475 
    476 - (BOOL)allowsAnimatedImageLooping
    477 {
    478     return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
    479 }
    480 
    481 - (void)setAllowsAnimatedImageLooping: (BOOL)flag
    482 {
    483     [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
    484 }
    485 
    486 - (void)setLoadsImagesAutomatically: (BOOL)flag
    487 {
    488     [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
    489 }
    490 
    491 - (BOOL)loadsImagesAutomatically
    492 {
    493     return [self _boolValueForKey: WebKitDisplayImagesKey];
    494 }
    495 
    496 - (void)setAutosaves:(BOOL)flag;
    497 {
    498     _private->autosaves = flag;
    499 }
    500 
    501 - (BOOL)autosaves
    502 {
    503     return _private->autosaves;
    504 }
    505 
    506 - (void)setTabsToLinks:(BOOL)flag
    507 {
    508     [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
    509 }
    510 
    511 - (BOOL)tabsToLinks
    512 {
    513     return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
    514 }
    515 
    516 - (void)setPrivateBrowsingEnabled:(BOOL)flag
    517 {
    518     [self _setBoolValue:flag forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
    519 }
    520 
    521 - (BOOL)privateBrowsingEnabled
    522 {
    523     return [self _boolValueForKey:WebKitPrivateBrowsingEnabledPreferenceKey];
    524 }
    525 
    526 @end
    527 
    528 @implementation WebPreferences (WebPrivate)
    529 
    530282- (int)_integerValueForKey:(NSString *)key
    531283{
     
    534286}
    535287
     288- (void)_setIntegerValue:(int)value forKey:(NSString *)key
     289{
     290    if ([self _integerValueForKey:key] == value)
     291        return;
     292    NSString *_key = KEY(key);
     293    [_private->values _webkit_setInt:value forKey:_key];
     294    if (_private->autosaves)
     295        [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
     296    [self _postPreferencesChangesNotification];
     297}
     298
    536299- (float)_floatValueForKey:(NSString *)key
    537300{
     
    540303}
    541304
     305- (void)_setFloatValue:(float)value forKey:(NSString *)key
     306{
     307    if ([self _floatValueForKey:key] == value)
     308        return;
     309    NSString *_key = KEY(key);
     310    [_private->values _webkit_setFloat:value forKey:_key];
     311    if (_private->autosaves)
     312        [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
     313    [self _postPreferencesChangesNotification];
     314}
    542315
    543316- (BOOL)_boolValueForKey:(NSString *)key
     
    557330}
    558331
    559 - (void)_setFloatValue:(float)value forKey:(NSString *)key
    560 {
    561     if ([self _floatValueForKey:key] == value)
    562         return;
    563     NSString *_key = KEY(key);
    564     [_private->values _webkit_setFloat:value forKey:_key];
    565     if (_private->autosaves)
    566         [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key];
    567     [self _postPreferencesChangesNotification];
    568 }
    569 
    570 - (void)_setIntegerValue:(int)value forKey:(NSString *)key
    571 {
    572     if ([self _integerValueForKey:key] == value)
    573         return;
    574     NSString *_key = KEY(key);
    575     [_private->values _webkit_setInt:value forKey:_key];
    576     if (_private->autosaves)
    577         [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key];
    578     [self _postPreferencesChangesNotification];
    579 }
     332- (NSString *)standardFontFamily
     333{
     334    return [self _stringValueForKey: WebKitStandardFontPreferenceKey];
     335}
     336
     337- (void)setStandardFontFamily:(NSString *)family
     338{
     339    [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];
     340}
     341
     342- (NSString *)fixedFontFamily
     343{
     344    return [self _stringValueForKey: WebKitFixedFontPreferenceKey];
     345}
     346
     347- (void)setFixedFontFamily:(NSString *)family
     348{
     349    [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];
     350}
     351
     352- (NSString *)serifFontFamily
     353{
     354    return [self _stringValueForKey: WebKitSerifFontPreferenceKey];
     355}
     356
     357- (void)setSerifFontFamily:(NSString *)family
     358{
     359    [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];
     360}
     361
     362- (NSString *)sansSerifFontFamily
     363{
     364    return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];
     365}
     366
     367- (void)setSansSerifFontFamily:(NSString *)family
     368{
     369    [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];
     370}
     371
     372- (NSString *)cursiveFontFamily
     373{
     374    return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];
     375}
     376
     377- (void)setCursiveFontFamily:(NSString *)family
     378{
     379    [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];
     380}
     381
     382- (NSString *)fantasyFontFamily
     383{
     384    return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];
     385}
     386
     387- (void)setFantasyFontFamily:(NSString *)family
     388{
     389    [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];
     390}
     391
     392- (int)defaultFontSize
     393{
     394    return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];
     395}
     396
     397- (void)setDefaultFontSize:(int)size
     398{
     399    [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];
     400}
     401
     402- (int)defaultFixedFontSize
     403{
     404    return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];
     405}
     406
     407- (void)setDefaultFixedFontSize:(int)size
     408{
     409    [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];
     410}
     411
     412- (int)minimumFontSize
     413{
     414    return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];
     415}
     416
     417- (void)setMinimumFontSize:(int)size
     418{
     419    [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];
     420}
     421
     422- (int)minimumLogicalFontSize
     423{
     424  return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];
     425}
     426
     427- (void)setMinimumLogicalFontSize:(int)size
     428{
     429  [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];
     430}
     431
     432- (NSString *)defaultTextEncodingName
     433{
     434    return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];
     435}
     436
     437- (void)setDefaultTextEncodingName:(NSString *)encoding
     438{
     439    [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];
     440}
     441
     442- (BOOL)userStyleSheetEnabled
     443{
     444    return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];
     445}
     446
     447- (void)setUserStyleSheetEnabled:(BOOL)flag
     448{
     449    [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];
     450}
     451
     452- (NSURL *)userStyleSheetLocation
     453{
     454    NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey];
     455   
     456    if ([locationString _webkit_looksLikeAbsoluteURL]) {
     457        return [NSURL _web_URLWithDataAsString:locationString];
     458    } else {
     459        locationString = [locationString stringByExpandingTildeInPath];
     460        return [NSURL fileURLWithPath:locationString];
     461    }
     462}
     463
     464- (void)setUserStyleSheetLocation:(NSURL *)URL
     465{
     466    NSString *locationString;
     467   
     468    if ([URL isFileURL]) {
     469        locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath];
     470    } else {
     471        locationString = [URL _web_originalDataAsString];
     472    }
     473   
     474    [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
     475}
     476
     477- (BOOL)shouldPrintBackgrounds
     478{
     479    return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];
     480}
     481
     482- (void)setShouldPrintBackgrounds:(BOOL)flag
     483{
     484    [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];
     485}
     486
     487- (BOOL)isJavaEnabled
     488{
     489    return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];
     490}
     491
     492- (void)setJavaEnabled:(BOOL)flag
     493{
     494    [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];
     495}
     496
     497- (BOOL)isJavaScriptEnabled
     498{
     499    return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];
     500}
     501
     502- (void)setJavaScriptEnabled:(BOOL)flag
     503{
     504    [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];
     505}
     506
     507- (BOOL)javaScriptCanOpenWindowsAutomatically
     508{
     509    return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
     510}
     511
     512- (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag
     513{
     514    [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];
     515}
     516
     517- (BOOL)arePlugInsEnabled
     518{
     519    return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];
     520}
     521
     522- (void)setPlugInsEnabled:(BOOL)flag
     523{
     524    [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];
     525}
     526
     527- (BOOL)allowsAnimatedImages
     528{
     529    return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];
     530}
     531
     532- (void)setAllowsAnimatedImages:(BOOL)flag;
     533{
     534    [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];
     535}
     536
     537- (BOOL)allowsAnimatedImageLooping
     538{
     539    return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
     540}
     541
     542- (void)setAllowsAnimatedImageLooping: (BOOL)flag
     543{
     544    [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];
     545}
     546
     547- (void)setLoadsImagesAutomatically: (BOOL)flag
     548{
     549    [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];
     550}
     551
     552- (BOOL)loadsImagesAutomatically
     553{
     554    return [self _boolValueForKey: WebKitDisplayImagesKey];
     555}
     556
     557- (void)setAutosaves:(BOOL)flag;
     558{
     559    _private->autosaves = flag;
     560}
     561
     562- (BOOL)autosaves
     563{
     564    return _private->autosaves;
     565}
     566
     567- (void)setTabsToLinks:(BOOL)flag
     568{
     569    [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];
     570}
     571
     572- (BOOL)tabsToLinks
     573{
     574    return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];
     575}
     576
     577- (void)setPrivateBrowsingEnabled:(BOOL)flag
     578{
     579    [self _setBoolValue:flag forKey:WebKitPrivateBrowsingEnabledPreferenceKey];
     580}
     581
     582- (BOOL)privateBrowsingEnabled
     583{
     584    return [self _boolValueForKey:WebKitPrivateBrowsingEnabledPreferenceKey];
     585}
     586
     587@end
     588
     589@implementation WebPreferences (WebPrivate)
    580590
    581591- (BOOL)respectStandardStyleKeyEquivalents
  • trunk/WebKit/WebView/WebPreferencesPrivate.h

    r12926 r12930  
    6363
    6464// Other private methods
    65 - (BOOL)_boolValueForKey:(NSString *)key;
    66 - (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
    67 - (int)_integerValueForKey:(NSString *)key;
    68 - (void)_setIntegerValue:(int)value forKey:(NSString *)key;
    69 - (float)_floatValueForKey:(NSString *)key;
    70 - (void)_setFloatValue:(float)value forKey:(NSString *)key;
    71 
    7265- (size_t)_pageCacheSize;
    7366- (size_t)_objectCacheSize;
Note: See TracChangeset for help on using the changeset viewer.