📄 webpreferences.mm
字号:
return o;}- (NSString *)_stringValueForKey:(NSString *)key{ id s = [self _valueForKey:key]; return [s isKindOfClass:[NSString class]] ? (NSString *)s : nil;}- (void)_setStringValue:(NSString *)value forKey:(NSString *)key{ if ([[self _stringValueForKey:key] isEqualToString:value]) return; NSString *_key = KEY(key); [_private->values setObject:value forKey:_key]; if (_private->autosaves) [[NSUserDefaults standardUserDefaults] setObject:value forKey:_key]; [self _postPreferencesChangesNotification];}- (int)_integerValueForKey:(NSString *)key{ id o = [self _valueForKey:key]; return [o respondsToSelector:@selector(intValue)] ? [o intValue] : 0;}- (void)_setIntegerValue:(int)value forKey:(NSString *)key{ if ([self _integerValueForKey:key] == value) return; NSString *_key = KEY(key); [_private->values _webkit_setInt:value forKey:_key]; if (_private->autosaves) [[NSUserDefaults standardUserDefaults] setInteger:value forKey:_key]; [self _postPreferencesChangesNotification];}- (float)_floatValueForKey:(NSString *)key{ id o = [self _valueForKey:key]; return [o respondsToSelector:@selector(floatValue)] ? [o floatValue] : 0.0f;}- (void)_setFloatValue:(float)value forKey:(NSString *)key{ if ([self _floatValueForKey:key] == value) return; NSString *_key = KEY(key); [_private->values _webkit_setFloat:value forKey:_key]; if (_private->autosaves) [[NSUserDefaults standardUserDefaults] setFloat:value forKey:_key]; [self _postPreferencesChangesNotification];}- (BOOL)_boolValueForKey:(NSString *)key{ return [self _integerValueForKey:key] != 0;}- (void)_setBoolValue:(BOOL)value forKey:(NSString *)key{ if ([self _boolValueForKey:key] == value) return; NSString *_key = KEY(key); [_private->values _webkit_setBool:value forKey:_key]; if (_private->autosaves) [[NSUserDefaults standardUserDefaults] setBool:value forKey:_key]; [self _postPreferencesChangesNotification];}- (unsigned long long)_unsignedLongLongValueForKey:(NSString *)key{ id o = [self _valueForKey:key]; return [o respondsToSelector:@selector(unsignedLongLongValue)] ? [o unsignedLongLongValue] : 0;}- (void)_setUnsignedLongLongValue:(unsigned long long)value forKey:(NSString *)key{ if ([self _unsignedLongLongValueForKey:key] == value) return; NSString *_key = KEY(key); [_private->values _webkit_setUnsignedLongLong:value forKey:_key]; if (_private->autosaves) [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedLongLong:value] forKey:_key]; [self _postPreferencesChangesNotification];}- (NSString *)standardFontFamily{ return [self _stringValueForKey: WebKitStandardFontPreferenceKey];}- (void)setStandardFontFamily:(NSString *)family{ [self _setStringValue: family forKey: WebKitStandardFontPreferenceKey];}- (NSString *)fixedFontFamily{ return [self _stringValueForKey: WebKitFixedFontPreferenceKey];}- (void)setFixedFontFamily:(NSString *)family{ [self _setStringValue: family forKey: WebKitFixedFontPreferenceKey];}- (NSString *)serifFontFamily{ return [self _stringValueForKey: WebKitSerifFontPreferenceKey];}- (void)setSerifFontFamily:(NSString *)family { [self _setStringValue: family forKey: WebKitSerifFontPreferenceKey];}- (NSString *)sansSerifFontFamily{ return [self _stringValueForKey: WebKitSansSerifFontPreferenceKey];}- (void)setSansSerifFontFamily:(NSString *)family{ [self _setStringValue: family forKey: WebKitSansSerifFontPreferenceKey];}- (NSString *)cursiveFontFamily{ return [self _stringValueForKey: WebKitCursiveFontPreferenceKey];}- (void)setCursiveFontFamily:(NSString *)family{ [self _setStringValue: family forKey: WebKitCursiveFontPreferenceKey];}- (NSString *)fantasyFontFamily{ return [self _stringValueForKey: WebKitFantasyFontPreferenceKey];}- (void)setFantasyFontFamily:(NSString *)family{ [self _setStringValue: family forKey: WebKitFantasyFontPreferenceKey];}- (int)defaultFontSize{ return [self _integerValueForKey: WebKitDefaultFontSizePreferenceKey];}- (void)setDefaultFontSize:(int)size{ [self _setIntegerValue: size forKey: WebKitDefaultFontSizePreferenceKey];}- (int)defaultFixedFontSize{ return [self _integerValueForKey: WebKitDefaultFixedFontSizePreferenceKey];}- (void)setDefaultFixedFontSize:(int)size{ [self _setIntegerValue: size forKey: WebKitDefaultFixedFontSizePreferenceKey];}- (int)minimumFontSize{ return [self _integerValueForKey: WebKitMinimumFontSizePreferenceKey];}- (void)setMinimumFontSize:(int)size{ [self _setIntegerValue: size forKey: WebKitMinimumFontSizePreferenceKey];}- (int)minimumLogicalFontSize{ return [self _integerValueForKey: WebKitMinimumLogicalFontSizePreferenceKey];}- (void)setMinimumLogicalFontSize:(int)size{ [self _setIntegerValue: size forKey: WebKitMinimumLogicalFontSizePreferenceKey];}- (NSString *)defaultTextEncodingName{ return [self _stringValueForKey: WebKitDefaultTextEncodingNamePreferenceKey];}- (void)setDefaultTextEncodingName:(NSString *)encoding{ [self _setStringValue: encoding forKey: WebKitDefaultTextEncodingNamePreferenceKey];}- (BOOL)userStyleSheetEnabled{ return [self _boolValueForKey: WebKitUserStyleSheetEnabledPreferenceKey];}- (void)setUserStyleSheetEnabled:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitUserStyleSheetEnabledPreferenceKey];}- (NSURL *)userStyleSheetLocation{ NSString *locationString = [self _stringValueForKey: WebKitUserStyleSheetLocationPreferenceKey]; if ([locationString _webkit_looksLikeAbsoluteURL]) { return [NSURL _web_URLWithDataAsString:locationString]; } else { locationString = [locationString stringByExpandingTildeInPath]; return [NSURL fileURLWithPath:locationString]; }}- (void)setUserStyleSheetLocation:(NSURL *)URL{ NSString *locationString; if ([URL isFileURL]) { locationString = [[URL path] _web_stringByAbbreviatingWithTildeInPath]; } else { locationString = [URL _web_originalDataAsString]; } [self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];}- (BOOL)shouldPrintBackgrounds{ return [self _boolValueForKey: WebKitShouldPrintBackgroundsPreferenceKey];}- (void)setShouldPrintBackgrounds:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitShouldPrintBackgroundsPreferenceKey];}- (BOOL)isJavaEnabled{ return [self _boolValueForKey: WebKitJavaEnabledPreferenceKey];}- (void)setJavaEnabled:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitJavaEnabledPreferenceKey];}- (BOOL)isJavaScriptEnabled{ return [self _boolValueForKey: WebKitJavaScriptEnabledPreferenceKey];}- (void)setJavaScriptEnabled:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitJavaScriptEnabledPreferenceKey];}- (BOOL)javaScriptCanOpenWindowsAutomatically{ return [self _boolValueForKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];}- (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey];}- (BOOL)arePlugInsEnabled{ return [self _boolValueForKey: WebKitPluginsEnabledPreferenceKey];}- (void)setPlugInsEnabled:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitPluginsEnabledPreferenceKey];}- (BOOL)allowsAnimatedImages{ return [self _boolValueForKey: WebKitAllowAnimatedImagesPreferenceKey];}- (void)setAllowsAnimatedImages:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitAllowAnimatedImagesPreferenceKey];}- (BOOL)allowsAnimatedImageLooping{ return [self _boolValueForKey: WebKitAllowAnimatedImageLoopingPreferenceKey];}- (void)setAllowsAnimatedImageLooping: (BOOL)flag{ [self _setBoolValue: flag forKey: WebKitAllowAnimatedImageLoopingPreferenceKey];}- (void)setLoadsImagesAutomatically: (BOOL)flag{ [self _setBoolValue: flag forKey: WebKitDisplayImagesKey];}- (BOOL)loadsImagesAutomatically{ return [self _boolValueForKey: WebKitDisplayImagesKey];}- (void)setAutosaves:(BOOL)flag{ _private->autosaves = flag;}- (BOOL)autosaves{ return _private->autosaves;}- (void)setTabsToLinks:(BOOL)flag{ [self _setBoolValue: flag forKey: WebKitTabToLinksPreferenceKey];}- (BOOL)tabsToLinks{ return [self _boolValueForKey:WebKitTabToLinksPreferenceKey];}- (void)setPrivateBrowsingEnabled:(BOOL)flag{ [self _setBoolValue:flag forKey:WebKitPrivateBrowsingEnabledPreferenceKey];}- (BOOL)privateBrowsingEnabled{ return [self _boolValueForKey:WebKitPrivateBrowsingEnabledPreferenceKey];}- (void)setUsesPageCache:(BOOL)usesPageCache{ [self _setBoolValue:usesPageCache forKey:WebKitUsesPageCachePreferenceKey];}- (BOOL)usesPageCache{ return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];}- (void)setCacheModel:(WebCacheModel)cacheModel{ [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey]; [self setAutomaticallyDetectsCacheModel:NO];}- (WebCacheModel)cacheModel{ return [self _integerValueForKey:WebKitCacheModelPreferenceKey];}@end@implementation WebPreferences (WebPrivate)- (BOOL)developerExtrasEnabled{ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults boolForKey:@"DisableWebKitDeveloperExtras"]) return NO;#ifdef NDEBUG if ([defaults boolForKey:@"WebKitDeveloperExtras"] || [defaults boolForKey:@"IncludeDebugMenu"]) return YES; return [self _boolValueForKey:WebKitDeveloperExtrasEnabledPreferenceKey];#else return YES; // always enable in debug builds#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -