[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:37:56 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 57d758aedd2db3ae020c36a16fc83eb9003979f1
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Apr 30 17:30:54 2004 +0000

    WebCore:
    
            - added bridge method to get the NSFont used to render a node, to
            help with supporting the font panel
    
            Reviewed by Ken.
    
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge renderedFontForNode:]):
            return nil if no renderer, otherwise return NSFont
    
    WebKit:
    
            - more work on getting the font panel to work with editable HTML.
            The font panel in Blot now correctly reflects the first selected font when the
            selection is at least one character long.
    
            Reviewed by Ken.
    
            * WebView.subproj/WebView.m:
            removed unfinished plumbing to support reflecting selected attributes (e.g. text color,
            underline) in font panel, since this doesn't work in Mail or TextEdit either.
            (_fontFromStyle):
            removed assertion for now
            (-[WebView _updateFontPanel]):
            now uses new bridge method to get the NSFont from the node, instead of trying
            to create an NSFont from a DOMCSSStyleDeclaration
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6525 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a80efff..3b1ce04 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,15 @@
+2004-04-30  John Sullivan  <sullivan at apple.com>
+
+        - added bridge method to get the NSFont used to render a node, to
+        help with supporting the font panel
+
+        Reviewed by Ken.
+
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge renderedFontForNode:]):
+        return nil if no renderer, otherwise return NSFont
+
 2004-04-29  David Hyatt  <hyatt at apple.com>
 
 	Expose summary on tables.
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 56a2aa7..496ab92 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -258,6 +258,7 @@ typedef enum {
 - (NSSelectionAffinity)selectionAffinity;
 
 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
+- (NSFont *)renderedFontForNode:(DOMNode *)node;
 
 + (NSString *)stringWithData:(NSData *)data textEncoding:(CFStringEncoding)textEncoding;
 + (NSString *)stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 07e05df..94b15c7 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1099,6 +1099,15 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return _part->attributedString([startNode _nodeImpl], startOffset, [endNode _nodeImpl], endOffset);
 }
 
+- (NSFont *)renderedFontForNode:(DOMNode *)node
+{
+    RenderObject *renderer = [node _nodeImpl]->renderer();
+    if (renderer) {
+        return renderer->style()->font().getNSFont();
+    }
+    return nil;
+}
+
 - (DOMNode *)selectionStart
 {
     return [DOMNode _nodeWithImpl:_part->selectionStart()];
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 09437dc..186fc68 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,20 @@
+2004-04-30  John Sullivan  <sullivan at apple.com>
+
+        - more work on getting the font panel to work with editable HTML.
+        The font panel in Blot now correctly reflects the first selected font when the
+        selection is at least one character long.
+
+        Reviewed by Ken.
+
+        * WebView.subproj/WebView.m:
+        removed unfinished plumbing to support reflecting selected attributes (e.g. text color,
+        underline) in font panel, since this doesn't work in Mail or TextEdit either.
+        (_fontFromStyle):
+        removed assertion for now
+        (-[WebView _updateFontPanel]):
+        now uses new bridge method to get the NSFont from the node, instead of trying
+        to create an NSFont from a DOMCSSStyleDeclaration
+
 2004-04-29  John Sullivan  <sullivan at apple.com>
 
         - more work on getting the font panel to work with editable HTML
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index afdd342..b1a00fb 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -2150,7 +2150,6 @@ static NSDictionary *_textAttributesFromStyle(DOMCSSStyleDeclaration *style)
 
 static NSFont *_fontFromStyle(DOMCSSStyleDeclaration *style)
 {
-    ASSERT_ARG(style, style != nil);
     // FIXME: can't get at CSS_PROP_FONT_FAMILY and such from cssproperties.h in WebCore
     // because that header file isn't available to WebKit. Is that a problem?
     // FIXME: calling [DOMCSSStyleDeclaration fontFamily] doesn't work yet, returns nil.
@@ -2161,18 +2160,6 @@ static NSFont *_fontFromStyle(DOMCSSStyleDeclaration *style)
     return nil;
 }
 
-static BOOL _stylesRepresentSameFont(DOMCSSStyleDeclaration *style, DOMCSSStyleDeclaration *otherStyle)
-{
-    ERROR("unimplemented");
-    return NO;
-}
-
-static BOOL _stylesRepresentSameAttributes(DOMCSSStyleDeclaration *style, DOMCSSStyleDeclaration *otherStyle)
-{
-    ERROR("unimplemented");
-    return NO;
-}
-
 - (void)_updateFontPanel
 {
     // FIXME: NSTextView bails out if becoming or resigning first responder, for which it has ivar flags. Not
@@ -2189,11 +2176,14 @@ static BOOL _stylesRepresentSameAttributes(DOMCSSStyleDeclaration *style, DOMCSS
     }
     
     BOOL onlyOneFontInSelection = YES;
-    BOOL attributesIdenticalThroughoutSelection = YES;
     DOMCSSStyleDeclaration *style = nil;
+    NSFont *font = nil;
     
     if (![[self _bridgeForCurrentSelection] haveSelection]) {
         style = [self typingStyle];
+        font = _fontFromStyle(style);
+        // FIXME: We're currently thinking that typingStyle will always specify a font, but we need to
+        // make sure that it's implemented that way when it is implemented.
     } else {
         // FIXME: This code is being reached after backspacing with only an insertion
         // point showing; this must be a bug in haveSelection or underlying code.
@@ -2205,6 +2195,7 @@ static BOOL _stylesRepresentSameAttributes(DOMCSSStyleDeclaration *style, DOMCSS
         }
         ASSERT([firstSelectedElement isKindOfClass:[DOMElement class]]);
         
+        font = [[self _bridgeForCurrentSelection] renderedFontForNode:firstSelectedElement];
         style = [self computedStyleForElement:(DOMElement *)firstSelectedElement pseudoElement:nil];
         
         // Iterate through all selected elements to see if fonts or attributes change.
@@ -2229,17 +2220,9 @@ static BOOL _stylesRepresentSameAttributes(DOMCSSStyleDeclaration *style, DOMCSS
                     ASSERT([element isKindOfClass:[DOMElement class]]);
                     
                     DOMCSSStyleDeclaration *otherStyle = [self computedStyleForElement:(DOMElement *)element pseudoElement:nil];
-                    if (onlyOneFontInSelection && !_stylesRepresentSameFont(style, otherStyle)) {
+                    NSFont *otherFont = [[self _bridgeForCurrentSelection] renderedFontForNode:element];
+                    if (![font isEqual:otherFont]) {
                         onlyOneFontInSelection = NO;
-                    }
-                    
-                    if (attributesIdenticalThroughoutSelection && !_stylesRepresentSameAttributes(style, otherStyle)) {
-                        attributesIdenticalThroughoutSelection = NO;
-                    }
-                    
-                    // If we've concluded that the selection contains more than one font and
-                    // more than one set of attributes, then we needn't check further.
-                    if (!onlyOneFontInSelection && !attributesIdenticalThroughoutSelection) {
                         break;
                     }
                 }
@@ -2249,12 +2232,8 @@ static BOOL _stylesRepresentSameAttributes(DOMCSSStyleDeclaration *style, DOMCSS
         }
     }
     
-    // FIXME: getting a font from the DOMCSSStyleDeclaration is probably not reliable.
-    // We might need some API that asks the renderer what font was actually used.
-    NSFont *font = _fontFromStyle(style);
     // FIXME: for now, return a bogus font that distinguishes the empty selection from the non-empty
-    // selection. We should be able to replace this with ASSERT(style != nil) once _fontFromStyle() and
-    // [self typingStyle] both work.
+    // selection. We should be able to remove this once the rest of this code works properly.
     if (font == nil) {
         if (![[self _bridgeForCurrentSelection] haveSelection]) {
             font = [NSFont toolTipsFontOfSize:17];
@@ -2266,7 +2245,9 @@ static BOOL _stylesRepresentSameAttributes(DOMCSSStyleDeclaration *style, DOMCSS
         
     NSFontManager *fm = [NSFontManager sharedFontManager];
     [fm setSelectedFont:font isMultiple:!onlyOneFontInSelection];
-    [fm setSelectedAttributes:_textAttributesFromStyle(style) isMultiple:!attributesIdenticalThroughoutSelection];
+    // FIXME: we don't keep track of selected attributes, or set them on the font panel. This
+    // appears to have no effect on the UI. E.g., underlined text in Mail or TextEdit is
+    // not reflected in the font panel. Maybe someday this will change.
 }
 
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list