Reviewed by Ken.
- WebKit part of fix for <rdar://problem/
3734466> ER: Support standard editing keystrokes
like Cmd-B while editing rich text
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _toggleBold]):
new method, toggles font-weight from "bold" to "normal"
(-[WebHTMLView _toggleItalic]):
new method, toggles font-style from "italic" to "normal"
(-[WebHTMLView _handleStyleKeyEquivalent:]):
new method, if the new preference is set and we're in an editable state, check for standard
key equivalents for toggling styles (just command-B and command-I for now).
(-[WebHTMLView performKeyEquivalent:]):
Moved in file, now calls _handleStyleKeyEquivalent:
* WebView.subproj/WebPreferenceKeysPrivate.h:
new preference key WebKitRespectStandardStyleKeyEquivalentsPreferenceKey
* WebView.subproj/WebPreferences.m:
(+[WebPreferences initialize]):
initial value of WebKitRespectStandardStyleKeyEquivalentsPreferenceKey is NO (maybe we'll
change our minds about this, but this is more guaranteed to be backward-compatible)
(-[WebPreferences respectStandardStyleKeyEquivalents]):
read WebKitRespectStandardStyleKeyEquivalentsPreferenceKey
(-[WebPreferences setRespectStandardStyleKeyEquivalents:]):
write WebKitRespectStandardStyleKeyEquivalentsPreferenceKey
* WebView.subproj/WebPreferencesPrivate.h:
declare getter and setter
* English.lproj/StringsNotToBeLocalized.txt:
updated for these and other recent changes
WebBrowser:
Reviewed by Ken.
- WebBrowser part of fix for <rdar://problem/
3734466> ER: Support standard editing keystrokes
like Cmd-B while editing rich text
* AppController.m:
(-[AppController applicationDidFinishLaunching:]):
turn on the new WebKit preference that makes command-B and command-I toggle styles in
editable text.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7697
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-09-27 John Sullivan <sullivan@apple.com>
+
+ Reviewed by Ken.
+
+ - WebKit part of fix for <rdar://problem/3734466> ER: Support standard editing keystrokes
+ like Cmd-B while editing rich text
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _toggleBold]):
+ new method, toggles font-weight from "bold" to "normal"
+ (-[WebHTMLView _toggleItalic]):
+ new method, toggles font-style from "italic" to "normal"
+ (-[WebHTMLView _handleStyleKeyEquivalent:]):
+ new method, if the new preference is set and we're in an editable state, check for standard
+ key equivalents for toggling styles (just command-B and command-I for now).
+ (-[WebHTMLView performKeyEquivalent:]):
+ Moved in file, now calls _handleStyleKeyEquivalent:
+
+ * WebView.subproj/WebPreferenceKeysPrivate.h:
+ new preference key WebKitRespectStandardStyleKeyEquivalentsPreferenceKey
+ * WebView.subproj/WebPreferences.m:
+ (+[WebPreferences initialize]):
+ initial value of WebKitRespectStandardStyleKeyEquivalentsPreferenceKey is NO (maybe we'll
+ change our minds about this, but this is more guaranteed to be backward-compatible)
+ (-[WebPreferences respectStandardStyleKeyEquivalents]):
+ read WebKitRespectStandardStyleKeyEquivalentsPreferenceKey
+ (-[WebPreferences setRespectStandardStyleKeyEquivalents:]):
+ write WebKitRespectStandardStyleKeyEquivalentsPreferenceKey
+
+ * WebView.subproj/WebPreferencesPrivate.h:
+ declare getter and setter
+
+ * English.lproj/StringsNotToBeLocalized.txt:
+ updated for these and other recent changes
+
2004-09-27 Chris Blumenberg <cblu@apple.com>
Fixed: <rdar://problem/3806649> assertion failure after control-click of webcam
"%@"
"%@/%s"
"%@/Library/Preferences/%@"
-"%@: Don't know how to pack glyphs for font %@ %f"
"%@:%u"
"%@://%@"
"%d"
";"
"<!--framePath "
"<%@ %@>"
-"="
+"<html"
"=================\nARGUMENT BAD: %s, %s (%s:%d %s)\n=================\n"
"=================\nASSERTION FAILED: "
"=================\nASSERTION FAILED: %s (%s:%d %s)\n=================\n"
"BP_CreatePluginMIMETypesPreferences"
"BufferTextDrawing"
"CFBundleVersion"
+"Cache-Control"
"Content-Length"
"Courier"
"DOCBASE"
+"DelayTime"
"DirectionAL"
"DirectionAN"
"DirectionB"
"GroupName"
"Helvetica"
"ISO-8859-1"
+"If-Modified-Since"
"JoiningCausing"
"JoiningDual"
"JoiningOther"
"NSFileModificationDate"
"NSFileOwnerAccountName"
"NSFilePosixPermissions"
+"NeXT smart paste pasteboard type"
"POST"
"Papyrus"
+"SAMILang"
+"SAMIStyle"
"Set-Cookie"
"SpellingDot"
"Times"
"WebKitPageCacheSizePreferenceKey"
"WebKitPluginsEnabled"
"WebKitPrivateBrowsingEnabled"
+"WebKitRespectStandardStyleKeyEquivalents"
"WebKitSansSerifFont"
"WebKitSerifFont"
"WebKitShouldPrintBackgroundsPreferenceKey"
"WebViewDidChangeTypingStyleNotification"
"WebViewDidEndEditingNotification"
"WebViewEditingContextMenu"
-"\""
"\"@?"
"\"\\"
"\0"
"\r"
"\r\n"
"\t"
-"__KHTML__"
"_blank"
"_current"
"_parent"
"com.apple.WebKit"
"com.apple.hiview"
"com.apple.universalaccess"
+"com.microsoft.WMP.defaultplugin"
"destination-atop"
"destination-in"
"destination-out"
"mainFrameTitle"
"mainFrameURL"
"missing_image"
+"must-revalidate"
"nullplugin"
"pluginspage"
+"proxy-revalidate"
+"public.tiff"
"rgb(%.0f,%.0f,%.0f)"
+"rgba(%.0f,%.0f,%.0f,%f)"
"source-atop"
"source-in"
"source-out"
"webarchive"
"x"
"x-apple-web-kit/"
+"{GIF}"
"~/Library/Icons"
DOM.subproj/WebDOMOperations.m:"background"
DOM.subproj/WebDOMOperations.m:"data"
WebCoreSupport.subproj/WebTextRendererFactory.m:"Urdu"
WebView.subproj/WebDataSource.m:"Refresh"
WebView.subproj/WebHTMLView.m:"%0.fpx"
+WebView.subproj/WebHTMLView.m:"Version:"
+WebView.subproj/WebHTMLView.m:"b"
WebView.subproj/WebHTMLView.m:"baseline"
WebView.subproj/WebHTMLView.m:"black"
WebView.subproj/WebHTMLView.m:"bold"
WebView.subproj/WebHTMLView.m:"center"
+WebView.subproj/WebHTMLView.m:"i"
WebView.subproj/WebHTMLView.m:"italic"
WebView.subproj/WebHTMLView.m:"justify"
WebView.subproj/WebHTMLView.m:"left"
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebPluginController.h>
#import <WebKit/WebPreferences.h>
+#import <WebKit/WebPreferencesPrivate.h>
#import <WebKit/WebResourcePrivate.h>
#import <WebKit/WebStringTruncator.h>
#import <WebKit/WebTextRenderer.h>
[[self window] setAutodisplay:YES];
}
-- (BOOL)performKeyEquivalent:(NSEvent *)event
-{
- // Pass command-key combos through WebCore if there is a key binding available for
- // this event. This lets web pages have a crack at intercepting command-modified keypresses.
- if ([self _web_firstResponderIsSelfOrDescendantView] && [[self _bridge] interceptKeyEvent:event toView:self]) {
- return YES;
- }
- return [super performKeyEquivalent:event];
-}
-
- (BOOL)_interceptEditingKeyEvent:(NSEvent *)event
{
// Work around this bug:
}
}
+- (void)_toggleBold
+{
+ DOMCSSStyleDeclaration *style = [self _emptyStyle];
+ [style setFontWeight:@"bold"];
+ if ([[self _bridge] selectionStartHasStyle:style])
+ [style setFontWeight:@"normal"];
+ [self _applyStyleToSelection:style];
+}
+
+- (void)_toggleItalic
+{
+ DOMCSSStyleDeclaration *style = [self _emptyStyle];
+ [style setFontStyle:@"italic"];
+ if ([[self _bridge] selectionStartHasStyle:style])
+ [style setFontStyle:@"normal"];
+ [self _applyStyleToSelection:style];
+}
+
+- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
+{
+ if (![[WebPreferences standardPreferences] respectStandardStyleKeyEquivalents]) {
+ return NO;
+ }
+
+ if (![self _canEdit])
+ return NO;
+
+ NSString *string = [event charactersIgnoringModifiers];
+ if ([string isEqualToString:@"b"]) {
+ [self _toggleBold];
+ return YES;
+ }
+ if ([string isEqualToString:@"i"]) {
+ [self _toggleItalic];
+ return YES;
+ }
+
+ return NO;
+}
+
+- (BOOL)performKeyEquivalent:(NSEvent *)event
+{
+ if ([self _handleStyleKeyEquivalent:event]) {
+ return YES;
+ }
+
+ // Pass command-key combos through WebCore if there is a key binding available for
+ // this event. This lets web pages have a crack at intercepting command-modified keypresses.
+ if ([self _web_firstResponderIsSelfOrDescendantView] && [[self _bridge] interceptKeyEvent:event toView:self]) {
+ return YES;
+ }
+ return [super performKeyEquivalent:event];
+}
+
- (void)copyFont:(id)sender
{
// Put RTF with font attributes on the pasteboard.
#define WebKitBackForwardCacheExpirationIntervalKey @"WebKitBackForwardCacheExpirationIntervalKey"
#define WebKitTabToLinksPreferenceKey @"WebKitTabToLinksPreferenceKey"
#define WebKitPrivateBrowsingEnabledPreferenceKey @"WebKitPrivateBrowsingEnabled"
+
+// These are private both because callers should be using the cover methods and because the
+// cover methods themselves are private.
+#define WebKitRespectStandardStyleKeyEquivalentsPreferenceKey @"WebKitRespectStandardStyleKeyEquivalents"
+
+ (NSString *)_IBCreatorID;
@end
+@interface WebPreferences (WebForwardDeclarations)
+// This pseudo-category is needed so these methods can be used from within other category implementations
+// without being in the public header file.
+- (BOOL)_boolValueForKey:(NSString *)key;
+- (void)_setBoolValue:(BOOL)value forKey:(NSString *)key;
+@end
+
@implementation WebPreferences
- init
@"1800", WebKitBackForwardCacheExpirationIntervalKey,
[NSNumber numberWithBool:NO], WebKitTabToLinksPreferenceKey,
[NSNumber numberWithBool:NO], WebKitPrivateBrowsingEnabledPreferenceKey,
+ [NSNumber numberWithBool:NO], WebKitRespectStandardStyleKeyEquivalentsPreferenceKey,
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
@implementation WebPreferences (WebPrivate)
+- (BOOL)respectStandardStyleKeyEquivalents
+{
+ return [self _boolValueForKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
+}
+
+- (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag
+{
+ [self _setBoolValue:flag forKey:WebKitRespectStandardStyleKeyEquivalentsPreferenceKey];
+}
+
- (int)_pageCacheSize
{
return [[NSUserDefaults standardUserDefaults] integerForKey:WebKitPageCacheSizePreferenceKey];
@interface WebPreferences (WebPrivate)
+// Preferences that might be public in a future release
+- (BOOL)respectStandardStyleKeyEquivalents;
+- (void)setRespectStandardStyleKeyEquivalents:(BOOL)flag;
+
+// Other private methods
- (int)_pageCacheSize;
- (int)_objectCacheSize;
- (void)_postPreferencesChangesNotification;