Reviewed by Ken.
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jun 2004 23:08:20 +0000 (23:08 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Jun 2004 23:08:20 +0000 (23:08 +0000)
        - fixed <rdar://problem/3655378>: (Editing:�changeDocumentBackgroundColor:�        method�nimplemented�WebKit�diting�PI))
        - made startSpeaking: actually work; previous implementation raised a DOMException

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView _changeCSSColorUsingSelector:inRange:]):
        added range parameter
        (-[WebHTMLView _entireDOMRange]):
        new convenience method
        (-[WebHTMLView changeDocumentBackgroundColor:]):
        now affects entire document, not just selected range, a la NSTextView
        (-[WebHTMLView changeColor:]):
        now passes in a range to _changeCSSColorUsingSelector:inRange:
        (-[WebHTMLView startSpeaking:]):
        now uses _entireDOMRange

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

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

index 8c345956016ce3141a1add23a6a220e45841321c..a4c0003fa67672be32be8d9fdc26f350cd5369f7 100644 (file)
@@ -1,3 +1,23 @@
+2004-06-01  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Ken.
+        
+        - fixed <rdar://problem/3655378>: (Editing:Ê-changeDocumentBackgroundColor:Ê
+        methodÊunimplementedÊ(WebKitÊeditingÊAPI))
+        - made startSpeaking: actually work; previous implementation raised a DOMException
+
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _changeCSSColorUsingSelector:inRange:]):
+        added range parameter
+        (-[WebHTMLView _entireDOMRange]):
+        new convenience method
+        (-[WebHTMLView changeDocumentBackgroundColor:]):
+        now affects entire document, not just selected range, a la NSTextView
+        (-[WebHTMLView changeColor:]):
+        now passes in a range to _changeCSSColorUsingSelector:inRange:
+        (-[WebHTMLView startSpeaking:]):
+        now uses _entireDOMRange
+
 2004-06-01  Chris Blumenberg  <cblu@apple.com>
 
        Fixed: <rdar://problem/3661505>: (REGRESSION (Safari-140) can't drag standalone images more than once)
index 744b28276680610a45818502aa08489489a1ee0e..36ba6a921c0bb5c8c21045e107c982f670dbeeca 100644 (file)
@@ -2432,19 +2432,33 @@ static WebHTMLView *lastHitView = nil;
     return style;
 }
 
-- (void)_changeCSSColorUsingSelector:(SEL)selector
+- (void)_changeCSSColorUsingSelector:(SEL)selector inRange:(DOMRange *)range
 {
     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];
+    if ([[webView _editingDelegateForwarder] webView:webView shouldApplyStyle:style toElementsInDOMRange:range]) {
+        [[self _bridge] applyStyle:style];
     }
 }
 
+- (DOMRange *)_entireDOMRange
+{
+    DOMDocument *document = [[self _bridge] DOMDocument];
+    DOMRange *range = [document createRange];
+    [range selectNode:[document documentElement]];
+    return range;
+}
+
 - (void)changeDocumentBackgroundColor:(id)sender
 {
-    [self _changeCSSColorUsingSelector:@selector(setBackgroundColor:)];
+    // Mimicking NSTextView, this method sets the background color for the
+    // entire document. There is no NSTextView API for setting the background
+    // color on the selected range only. Note that this method is currently
+    // never called from the UI (see comment in changeColor:).
+    // FIXME: this actually has no effect when called, probably due to 3654850. _entireDOMRange seems
+    // to do the right thing because it works in startSpeaking:, and I know setBackgroundColor: does the
+    // right thing because I tested it with [[self _bridge] selectedDOMRange].
+    [self _changeCSSColorUsingSelector:@selector(setBackgroundColor:) inRange:[self _entireDOMRange]];
 }
 
 - (void)changeColor:(id)sender
@@ -2454,7 +2468,7 @@ static WebHTMLView *lastHitView = nil;
     // 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:)];
+    [self _changeCSSColorUsingSelector:@selector(setColor:) inRange:[[self _bridge] selectedDOMRange]];
 }
 
 - (void)alignCenter:(id)sender
@@ -2788,9 +2802,7 @@ static WebHTMLView *lastHitView = nil;
     WebBridge *bridge = [self _bridge];
     DOMRange *range = [bridge selectedDOMRange];
     if (!range || [range collapsed]) {
-        DOMDocument *document = [bridge DOMDocument];
-        range = [document createRange];
-        [range selectNode:document];
+        range = [self _entireDOMRange];
     }
     [NSApp speakString:[bridge stringForRange:range]];
 }