Reviewed by Darin.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jun 2004 21:21:07 +0000 (21:21 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jun 2004 21:21:07 +0000 (21:21 +0000)
        - fixed <rdar://problem/3657003>: (HTML Editing: Color panel doesn't work)

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView _colorPanelColorAsStyleUsingSelector:]):
        new method, returns a DOMCSSStyleDeclaration *
        (-[WebHTMLView _changeCSSColorUsingSelector:]):
        new method, sets a color-related style attribute on the selection
        (-[WebHTMLView changeDocumentBackgroundColor:]):
        call _changeCSSColorUsingSelector: with @selector(setBackgroundColor:)
        (-[WebHTMLView changeColor:]):
        call _changeCSSColorUsingSelector: with @selector(setColor:); also added
        comments explaining why changeDocumentBackgroundColor: will never actually
        be called until an AppKit code-incest mess is straighted out.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6737 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebView.subproj/WebHTMLView.m

index 89c72633799def0670ba8c0d48bcdd66c40001c5..89c9ae8f56a932dad63db9634ddc99f17b9d0853 100644 (file)
@@ -1,3 +1,21 @@
+2004-06-01  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Darin.
+        
+        - fixed <rdar://problem/3657003>: (HTML Editing: Color panel doesn't work)
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _colorPanelColorAsStyleUsingSelector:]):
+        new method, returns a DOMCSSStyleDeclaration *
+        (-[WebHTMLView _changeCSSColorUsingSelector:]):
+        new method, sets a color-related style attribute on the selection
+        (-[WebHTMLView changeDocumentBackgroundColor:]):
+        call _changeCSSColorUsingSelector: with @selector(setBackgroundColor:)
+        (-[WebHTMLView changeColor:]):
+        call _changeCSSColorUsingSelector: with @selector(setColor:); also added
+        comments explaining why changeDocumentBackgroundColor: will never actually
+        be called until an AppKit code-incest mess is straighted out.
+
 2004-06-01  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Darin
index 8845b252433098d922a192e83efa950af8ce9e6f..744b28276680610a45818502aa08489489a1ee0e 100644 (file)
@@ -2420,14 +2420,41 @@ static WebHTMLView *lastHitView = nil;
     ERROR("unimplemented");
 }
 
+- (DOMCSSStyleDeclaration *)_colorPanelColorAsStyleUsingSelector:(SEL)selector
+{
+    WebBridge *bridge = [self _bridge];
+    DOMCSSStyleDeclaration *style = [[bridge DOMDocument] createCSSStyleDeclaration];
+    NSColor *color = [[NSColorPanel sharedColorPanel] color];
+    NSString *colorAsString = [NSString stringWithFormat:@"rgb(%.0f,%.0f,%.0f)", [color redComponent]*255, [color greenComponent]*255, [color blueComponent]*255];
+    ASSERT([style respondsToSelector:selector]);
+    [style performSelector:selector withObject:colorAsString];
+    
+    return style;
+}
+
+- (void)_changeCSSColorUsingSelector:(SEL)selector
+{
+    DOMCSSStyleDeclaration *style = [self _colorPanelColorAsStyleUsingSelector:selector];
+    WebView *webView = [self _webView];
+    WebBridge *bridge = [self _bridge];
+    if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:[bridge selectedDOMRange]]) {
+        [bridge applyStyle:style];
+    }
+}
+
 - (void)changeDocumentBackgroundColor:(id)sender
 {
-    ERROR("unimplemented");
+    [self _changeCSSColorUsingSelector:@selector(setBackgroundColor:)];
 }
 
 - (void)changeColor:(id)sender
 {
-    ERROR("unimplemented");
+    // FIXME: in NSTextView, this method calls changeDocumentBackgroundColor: when a
+    // private call has earlier been made by [NSFontFontEffectsBox changeColor:], see 3674493. 
+    // AppKit will have to be revised to allow this to work with anything that isn't an 
+    // NSTextView. However, this might not be required for Tiger, since the background-color 
+    // changing box in the font panel doesn't work in Mail (3674481), though it does in TextEdit.
+    [self _changeCSSColorUsingSelector:@selector(setColor:)];
 }
 
 - (void)alignCenter:(id)sender