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

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:11:21 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 8be12a98b7d0ae9746065672b1d2b1a4ea5c1f48
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 4 19:01:08 2002 +0000

    WebCore
            Cache the NSFont in QFont after doing family based lookup.
            Use that cached font to find a text renderer.
    
            Reviewed by: Darin
    
            * kwq/KWQFont.h:
            * kwq/KWQFont.mm:
            (QFont::QFont):
            (QFont::~QFont):
            (QFont::setFamily):
            (QFont::setFirstFamily):
            (QFont::setPixelSize):
            (QFont::setWeight):
            (QFont::setItalic):
            (QFont::getNSFont):
            * kwq/KWQFontMetrics.mm:
            * kwq/KWQPainter.mm:
            (QPainter::_updateRenderer):
            * kwq/WebCoreTextRendererFactory.h:
            * kwq/WebCoreTextRendererFactory.m:
            (-[WebCoreTextRendererFactory rendererWithFont:]):
    
    WebKit
            Cache the fallback font in the same way we cache other
            fonts.
    
            Reviewed by: Darin
    
            * WebCoreSupport.subproj/WebTextRendererFactory.h:
            * WebCoreSupport.subproj/WebTextRendererFactory.m:
            (-[WebTextRendererFactory fallbackFontWithTraits:size:]):
            (-[WebTextRendererFactory fontWithFamilies:traits:size:]):
            (-[WebTextRendererFactory cachedFontFromFamily:traits:size:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2931 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c1d0c8f..2b06cfd 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,29 @@
 2002-12-04  Richard Williamson   <rjw at apple.com>
 
+        Cache the NSFont in QFont after doing family based lookup.
+        Use that cached font to find a text renderer.
+
+        Reviewed by: Darin
+
+        * kwq/KWQFont.h:
+        * kwq/KWQFont.mm:
+        (QFont::QFont):
+        (QFont::~QFont):
+        (QFont::setFamily):
+        (QFont::setFirstFamily):
+        (QFont::setPixelSize):
+        (QFont::setWeight):
+        (QFont::setItalic):
+        (QFont::getNSFont):
+        * kwq/KWQFontMetrics.mm:
+        * kwq/KWQPainter.mm:
+        (QPainter::_updateRenderer):
+        * kwq/WebCoreTextRendererFactory.h:
+        * kwq/WebCoreTextRendererFactory.m:
+        (-[WebCoreTextRendererFactory rendererWithFont:]):
+
+2002-12-04  Richard Williamson   <rjw at apple.com>
+
         Cache the last used text renderer to avoid expensive lookup
         when font hasn't changed.
 
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c1d0c8f..2b06cfd 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,29 @@
 2002-12-04  Richard Williamson   <rjw at apple.com>
 
+        Cache the NSFont in QFont after doing family based lookup.
+        Use that cached font to find a text renderer.
+
+        Reviewed by: Darin
+
+        * kwq/KWQFont.h:
+        * kwq/KWQFont.mm:
+        (QFont::QFont):
+        (QFont::~QFont):
+        (QFont::setFamily):
+        (QFont::setFirstFamily):
+        (QFont::setPixelSize):
+        (QFont::setWeight):
+        (QFont::setItalic):
+        (QFont::getNSFont):
+        * kwq/KWQFontMetrics.mm:
+        * kwq/KWQPainter.mm:
+        (QPainter::_updateRenderer):
+        * kwq/WebCoreTextRendererFactory.h:
+        * kwq/WebCoreTextRendererFactory.m:
+        (-[WebCoreTextRendererFactory rendererWithFont:]):
+
+2002-12-04  Richard Williamson   <rjw at apple.com>
+
         Cache the last used text renderer to avoid expensive lookup
         when font hasn't changed.
 
diff --git a/WebCore/kwq/KWQFont.h b/WebCore/kwq/KWQFont.h
index 7f0abcc..17cd774 100644
--- a/WebCore/kwq/KWQFont.h
+++ b/WebCore/kwq/KWQFont.h
@@ -76,12 +76,13 @@ public:
     enum Weight { Normal = 50, Bold = 63 };
 
     QFont();
-
+    ~QFont();
+    
     void setFamily(const QString &);
     QString family() const;
 
     QFontFamily* firstFamily() { return &_family; }
-    void setFirstFamily(const QFontFamily& family) { _family = family; }
+    void setFirstFamily(const QFontFamily& family) ;
     
     void setWeight(int);
     int weight() const;
@@ -90,7 +91,7 @@ public:
     void setItalic(bool);
     bool italic() const;
 
-    void setPixelSize(float s) { _size = s; }
+    void setPixelSize(float s);
     int pixelSize() const { return (int)_size; }
 
     bool operator==(const QFont &x) const;
@@ -101,11 +102,12 @@ public:
     float getNSSize() const { return _size; }
     
     NSFont *getNSFont() const;
-    
+        
 private:
     QFontFamily _family;
     int _trait;
     float _size;
+    mutable NSFont *_nsfont;
 };
 
 // Macro to create a stack array containing non-retained NSString names
diff --git a/WebCore/kwq/KWQFont.mm b/WebCore/kwq/KWQFont.mm
index cac5241..6ba087c 100644
--- a/WebCore/kwq/KWQFont.mm
+++ b/WebCore/kwq/KWQFont.mm
@@ -90,9 +90,15 @@ bool QFontFamily::operator==(const QFontFamily &compareFontFamily) const
 QFont::QFont()
     : _trait(0)
     , _size(12.0)
+    , _nsfont(0)
 {
 }
 
+QFont::~QFont()
+{ 
+    [_nsfont release];
+}
+
 QString QFont::family() const
 {
     return _family.family();
@@ -101,13 +107,39 @@ QString QFont::family() const
 void QFont::setFamily(const QString &qfamilyName)
 {
     _family.setFamily(qfamilyName);
+    [_nsfont release];
+    _nsfont = 0;
+}
+
+void QFont::setFirstFamily(const QFontFamily& family) 
+{
+    _family = family;
+    [_nsfont release];
+    _nsfont = 0;
+}
+
+void QFont::setPixelSize(float s)
+{
+    if (_size != s) {
+        [_nsfont release]; 
+        _nsfont = 0;
+    }
+    _size = s;
 }
 
 void QFont::setWeight(int weight)
 {
     if (weight == Bold) {
+        if (!(_trait & NSBoldFontMask)){
+            [_nsfont release];
+            _nsfont = 0;
+        }
         _trait |= NSBoldFontMask;
     } else if (weight == Normal) {
+        if ((_trait & NSBoldFontMask)){
+            [_nsfont release];
+            _nsfont = 0;
+        }
         _trait &= ~NSBoldFontMask;
     }
 }
@@ -120,8 +152,16 @@ int QFont::weight() const
 void QFont::setItalic(bool flag)
 {
     if (flag) {
+        if (!(_trait & NSItalicFontMask)){
+            [_nsfont release];
+            _nsfont = 0;
+        }
         _trait |= NSItalicFontMask;
     } else {
+        if ((_trait & NSItalicFontMask)){
+            [_nsfont release];
+            _nsfont = 0;
+        }
         _trait &= ~NSItalicFontMask;
     }
 }
@@ -145,10 +185,13 @@ bool QFont::operator==(const QFont &compareFont) const
 
 NSFont *QFont::getNSFont() const
 {
-    CREATE_FAMILY_ARRAY(*this, families);
-
-    return [[WebCoreTextRendererFactory sharedFactory] 
-    	fontWithFamilies:families
-                traits:getNSTraits() 
-                  size:getNSSize()];
+    if (!_nsfont){
+        CREATE_FAMILY_ARRAY(*this, families);
+    
+        _nsfont = [[[WebCoreTextRendererFactory sharedFactory] 
+            fontWithFamilies:families
+                    traits:getNSTraits() 
+                    size:getNSSize()] retain];
+    }
+    return _nsfont;
 }
diff --git a/WebCore/kwq/KWQFontMetrics.mm b/WebCore/kwq/KWQFontMetrics.mm
index 11a3ef1..cabb00c 100644
--- a/WebCore/kwq/KWQFontMetrics.mm
+++ b/WebCore/kwq/KWQFontMetrics.mm
@@ -40,9 +40,7 @@ struct QFontMetricsPrivate
     {
         refCount = 0;
 
-        CREATE_FAMILY_ARRAY(font, families);
-
-        renderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFamilies:families traits:font.getNSTraits() size:font.getNSSize()] retain];
+        renderer = [[[WebCoreTextRendererFactory sharedFactory] rendererWithFont: font.getNSFont()] retain];
         _font = font;
     }
     ~QFontMetricsPrivate()
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 17eeb11..6a21665 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -360,7 +360,7 @@ void QPainter::_updateRenderer(NSString **families)
         [data->lastTextRenderer release];
         data->lastTextRenderer = 
             [[[WebCoreTextRendererFactory sharedFactory]
-                rendererWithFamilies:families traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()] retain];
+                rendererWithFont: data->state.font.getNSFont()] retain];
     }
 }
     
diff --git a/WebCore/kwq/WebCoreTextRendererFactory.h b/WebCore/kwq/WebCoreTextRendererFactory.h
index 34dab07..112aec3 100644
--- a/WebCore/kwq/WebCoreTextRendererFactory.h
+++ b/WebCore/kwq/WebCoreTextRendererFactory.h
@@ -32,7 +32,7 @@
 }
 
 + (WebCoreTextRendererFactory *)sharedFactory;
-- (id <WebCoreTextRenderer>)rendererWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size;
+- (id <WebCoreTextRenderer>)rendererWithFont: (NSFont *)font;
 - (NSFont *)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size;
 
 @end
diff --git a/WebCore/kwq/WebCoreTextRendererFactory.m b/WebCore/kwq/WebCoreTextRendererFactory.m
index 76f8f73..2d4a399 100644
--- a/WebCore/kwq/WebCoreTextRendererFactory.m
+++ b/WebCore/kwq/WebCoreTextRendererFactory.m
@@ -46,7 +46,7 @@ static WebCoreTextRendererFactory *sharedFactory;
     return self;
 }
 
-- (id <WebCoreTextRenderer>)rendererWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
+- (id <WebCoreTextRenderer>)rendererWithFont: (NSFont *)font
 {
     return nil;
 }
diff --git a/WebCore/kwq/WebCoreTextRendererFactory.mm b/WebCore/kwq/WebCoreTextRendererFactory.mm
index 76f8f73..2d4a399 100644
--- a/WebCore/kwq/WebCoreTextRendererFactory.mm
+++ b/WebCore/kwq/WebCoreTextRendererFactory.mm
@@ -46,7 +46,7 @@ static WebCoreTextRendererFactory *sharedFactory;
     return self;
 }
 
-- (id <WebCoreTextRenderer>)rendererWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
+- (id <WebCoreTextRenderer>)rendererWithFont: (NSFont *)font
 {
     return nil;
 }
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 5dd23ca..1ca3bac 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,18 @@
 2002-12-04  Richard Williamson   <rjw at apple.com>
 
+        Cache the fallback font in the same way we cache other
+        fonts.
+        
+        Reviewed by: Darin
+
+        * WebCoreSupport.subproj/WebTextRendererFactory.h:
+        * WebCoreSupport.subproj/WebTextRendererFactory.m:
+        (-[WebTextRendererFactory fallbackFontWithTraits:size:]):
+        (-[WebTextRendererFactory fontWithFamilies:traits:size:]):
+        (-[WebTextRendererFactory cachedFontFromFamily:traits:size:]):
+
+2002-12-04  Richard Williamson   <rjw at apple.com>
+
         Fixed massive performance regression.
         We were leaking WebFontCacheKey.
         Added a cache of missing fonts to avoid
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.h b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.h
index b98dee0..b48f548 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.h
+++ b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.h
@@ -19,7 +19,6 @@
 + (void)createSharedFactory;
 + (WebTextRendererFactory *)sharedFactory;
 - (NSFont *)cachedFontFromFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size;
-- (NSFont *)cachedFontFromFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size;
 - init;
 
 - (WebTextRenderer *)rendererWithFont:(NSFont *)font;
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
index e746478..db6cda1 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
@@ -186,9 +186,26 @@
     return renderer;
 }
 
+- (NSFont *)fallbackFontWithTraits:(NSFontTraitMask)traits size:(float)size 
+{
+    return [self cachedFontFromFamily:@"Helvetica" traits:traits size:size];
+}
+
 - (NSFont *)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
 {
-    return [self cachedFontFromFamilies: families traits: traits size: size];
+    NSFont *font = nil;
+    NSString *family;
+    int i = 0;
+    
+    while (families && families[i] != 0 && font == nil){
+        family = families[i++];
+        if ([family length] != 0)
+            font = [self cachedFontFromFamily: family traits:traits size:size];
+    }
+    if (font == nil)
+        font = [self fallbackFontWithTraits:traits size:size];
+
+    return font;
 }
 
 - (NSFont *)fontWithFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size
@@ -247,11 +264,6 @@
     return nil;
 }
 
-+ (NSFont *)fallbackFontWithTraits:(NSFontTraitMask)traits size:(float)size 
-{
-    return [[NSFontManager sharedFontManager] fontWithFamily:@"Helvetica" traits:traits weight:5 size:size];
-}
-
 - (NSFont *)cachedFontFromFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size
 {
     static NSMutableDictionary *fontCache = nil;
@@ -280,38 +292,16 @@
             }
         }
     }
-    [fontKey release];
-    
-    return font;
-}
-
-- (NSFont *)cachedFontFromFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
-{
-    NSFont *font = nil;
-    
-#ifdef DEBUG_GETFONT
-    static int getFontCount = 0;
-    getFontCount++;
-    printf("getFountCount = %d, family = %s, traits = 0x%08x, size = %f\n", getFontCount, [_family lossyCString], _trait, _size);
+#ifdef DEBUG_MISSING_FONT
+    static int unableToFindFontCount = 0;
+    if (font == nil){
+        unableToFindFontCount++;
+        NSLog (@"unableToFindFontCount %@, traits 0x%08x, size %f, %d\n", family, traits, size, unableToFindFontCount);
+    }
 #endif
-
-    NSString *family;
-    int i = 0;
+    [fontKey release];
     
-    while (families && families[i] != 0 && font == nil){
-        family = families[i++];
-        if ([family length] != 0)
-            font = [self cachedFontFromFamily: family traits:traits size:size];
-    }
-    if (font == nil)
-        font = [WebTextRendererFactory fallbackFontWithTraits:traits size:size];
-
     return font;
 }
 
-- (id <WebCoreTextRenderer>)rendererWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
-{
-    return [self rendererWithFont:[self cachedFontFromFamilies:families traits:traits size:size]];
-}
-
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list