WebCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Aug 2004 00:49:18 +0000 (00:49 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Aug 2004 00:49:18 +0000 (00:49 +0000)
        Reviewed by John.

        - fixed <rdar://problem/3637519> REGRESSION (125-128): unrepro crash in QListBox::sizeForNumberOfLines at istweb.apple.com

        * kwq/KWQListBox.h: Added a clearCachedTextRenderers function.
        * kwq/KWQListBox.mm:
        (itemTextRenderer): Change to use globals that are outside the function, and added retain calls.
        (groupLabelTextRenderer): Ditto.
        (QListBox::clearCachedTextRenderers): Release global text renderers and nil out the globals.

        * kwq/WebCoreBridge.h: Removed updateAllViews; not needed any more.
        * kwq/WebCoreBridge.mm: Ditto.

        * kwq/WebCoreTextRendererFactory.h: Added a clearCaches method.
        * kwq/WebCoreTextRendererFactory.mm:
        (-[WebCoreTextRendererFactory clearCaches]): Added. Tells all the views to repaint after clearing the cached
        text renderers from KWQListBox. To be more elegant, we could generalize the KWQListBox trick, but for now why bother?

        * kwq/WebCoreTextRendererFactory.m: Removed. I needed to put some C++ code in here, so changed the extension to .mm.
        * WebCore.pbproj/project.pbxproj: Removed WebCoreTextRendererFactory.m, and added WebCoreTextRendererFactory.mm.

WebKit:

        Reviewed by John.

        - part of fix for <rdar://problem/3637519> REGRESSION (125-128): unrepro crash in QListBox::sizeForNumberOfLines at istweb.apple.com

        * WebCoreSupport.subproj/WebTextRendererFactory.m: (-[WebTextRendererFactory clearCaches]):
        Call [super clearCaches].

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

WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/kwq/KWQListBox.h
WebCore/kwq/KWQListBox.mm
WebCore/kwq/WebCoreBridge.h
WebCore/kwq/WebCoreBridge.mm
WebCore/kwq/WebCoreTextRendererFactory.h
WebCore/kwq/WebCoreTextRendererFactory.m [deleted file]
WebCore/kwq/WebCoreTextRendererFactory.mm
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m

index 0d89f9179c42a7f5700211f52b30ad2f1da6a43d..70faa1637ff3a82c53ac6aabd52187b4d16b9213 100644 (file)
@@ -1,3 +1,26 @@
+2004-08-30  Darin Adler  <darin@apple.com>
+
+        Reviewed by John.
+
+        - fixed <rdar://problem/3637519> REGRESSION (125-128): unrepro crash in QListBox::sizeForNumberOfLines at istweb.apple.com
+
+        * kwq/KWQListBox.h: Added a clearCachedTextRenderers function.
+        * kwq/KWQListBox.mm:
+        (itemTextRenderer): Change to use globals that are outside the function, and added retain calls.
+        (groupLabelTextRenderer): Ditto.
+        (QListBox::clearCachedTextRenderers): Release global text renderers and nil out the globals.
+
+        * kwq/WebCoreBridge.h: Removed updateAllViews; not needed any more.
+        * kwq/WebCoreBridge.mm: Ditto.
+
+        * kwq/WebCoreTextRendererFactory.h: Added a clearCaches method.
+        * kwq/WebCoreTextRendererFactory.mm:
+        (-[WebCoreTextRendererFactory clearCaches]): Added. Tells all the views to repaint after clearing the cached
+        text renderers from KWQListBox. To be more elegant, we could generalize the KWQListBox trick, but for now why bother?
+
+        * kwq/WebCoreTextRendererFactory.m: Removed. I needed to put some C++ code in here, so changed the extension to .mm.
+        * WebCore.pbproj/project.pbxproj: Removed WebCoreTextRendererFactory.m, and added WebCoreTextRendererFactory.mm.
+
 2004-08-30  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
index bd8cfcc020c29a9aa00f8daaed07be6b14d47763..df53e37d24ae25498ebf0a421a7d4b7c0f9e1d9d 100644 (file)
                        fileEncoding = 30;
                        isa = PBXFileReference;
                        lastKnownFileType = sourcecode.c.objc;
-                       path = WebCoreTextRendererFactory.m;
+                       path = WebCoreTextRendererFactory.mm;
                        refType = 4;
                        sourceTree = "<group>";
                };
index be7f3157f2ddb3f03fa39363af44d234f8961265..db4701ab7757f592a6dca172a89ad65d506a8e1a 100644 (file)
@@ -71,6 +71,8 @@ public:
     virtual FocusPolicy focusPolicy() const;
     virtual bool checksDescendantsForFocus() const;
     
+    static void clearCachedTextRenderers();
+
 private:
     void appendItem(const QString &, bool isLabel);
 
index daebeb86c408abce2d2403c683beeafe7a60856e..4ab71fa21a2bd9d6c235d13c3dfc05a13cd59125 100644 (file)
@@ -63,6 +63,11 @@ const float rightMargin = 2;
 - (NSWritingDirection)baseWritingDirection;
 @end
 
+static id <WebCoreTextRenderer> itemScreenRenderer;
+static id <WebCoreTextRenderer> itemPrinterRenderer;
+static id <WebCoreTextRenderer> groupLabelScreenRenderer;
+static id <WebCoreTextRenderer> groupLabelPrinterRenderer;
+
 static NSFont *itemFont()
 {
     static NSFont *font = [[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] retain];
@@ -78,26 +83,34 @@ static NSFont *groupLabelFont()
 static id <WebCoreTextRenderer> itemTextRenderer()
 {
     if ([NSGraphicsContext currentContextDrawingToScreen]) {
-        static id <WebCoreTextRenderer> renderer = [[WebCoreTextRendererFactory sharedFactory]
-            rendererWithFont:itemFont() usingPrinterFont:NO];
-        return renderer;
+        if (itemScreenRenderer == nil) {
+            itemScreenRenderer = [[[WebCoreTextRendererFactory sharedFactory]
+                rendererWithFont:itemFont() usingPrinterFont:NO] retain];
+        }
+        return itemScreenRenderer;
     } else {
-        static id <WebCoreTextRenderer> renderer = [[WebCoreTextRendererFactory sharedFactory]
-            rendererWithFont:itemFont() usingPrinterFont:YES];
-        return renderer;
+        if (itemPrinterRenderer == nil) {
+            itemPrinterRenderer = [[[WebCoreTextRendererFactory sharedFactory]
+                rendererWithFont:itemFont() usingPrinterFont:YES] retain];
+        }
+        return itemPrinterRenderer;
     }
 }
 
 static id <WebCoreTextRenderer> groupLabelTextRenderer()
 {
     if ([NSGraphicsContext currentContextDrawingToScreen]) {
-        static id <WebCoreTextRenderer> renderer = [[WebCoreTextRendererFactory sharedFactory]
-            rendererWithFont:groupLabelFont() usingPrinterFont:NO];
-        return renderer;
+        if (groupLabelScreenRenderer == nil) {
+            groupLabelScreenRenderer = [[[WebCoreTextRendererFactory sharedFactory]
+                rendererWithFont:groupLabelFont() usingPrinterFont:NO] retain];
+        }
+        return groupLabelScreenRenderer;
     } else {
-        static id <WebCoreTextRenderer> renderer = [[WebCoreTextRendererFactory sharedFactory]
-            rendererWithFont:groupLabelFont() usingPrinterFont:YES];
-        return renderer;
+        if (groupLabelPrinterRenderer == nil) {
+            groupLabelPrinterRenderer = [[[WebCoreTextRendererFactory sharedFactory]
+                rendererWithFont:groupLabelFont() usingPrinterFont:YES] retain];
+        }
+        return groupLabelPrinterRenderer;
     }
 }
 
@@ -318,6 +331,21 @@ void QListBox::setWritingDirection(QPainter::TextDirection d)
     KWQ_UNBLOCK_EXCEPTIONS;
 }
 
+void QListBox::clearCachedTextRenderers()
+{
+    [itemScreenRenderer release];
+    itemScreenRenderer = nil;
+
+    [itemPrinterRenderer release];
+    itemPrinterRenderer = nil;
+
+    [groupLabelScreenRenderer release];
+    groupLabelScreenRenderer = nil;
+
+    [groupLabelPrinterRenderer release];
+    groupLabelPrinterRenderer = nil;
+}
+
 @implementation KWQListBoxScrollView
 
 - (void)setFrameSize:(NSSize)size
index e7c7f2bd9e06fa5fbdb8a60f314e722fda8f4646..8a1d7f2fe4fc1a59f9d0644646b85bd47d0e4e81 100644 (file)
@@ -291,8 +291,6 @@ typedef enum {
 
 - (void)adjustViewSize;
 
-+ (void)updateAllViews;
-
 - (id)accessibilityTree;
 
 - (void)undoEditing:(id)arg;
index 371501c1dded55a9bbfa3a88e3a8fa2be538ccd7..1e35bae2b2c9ebc641028fdf5623454a6f89d1bc 100644 (file)
@@ -1263,14 +1263,6 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return [WebCoreBridge stringWithData:data textEncoding:textEncoding];
 }
 
-+ (void)updateAllViews
-{
-    for (QPtrListIterator<KWQKHTMLPart> it(KWQKHTMLPart::instances()); it.current(); ++it) {
-        KWQKHTMLPart *part = it.current();
-        [part->bridge() setNeedsReapplyStyles];
-    }
-}
-
 - (BOOL)needsLayout
 {
     RenderObject *renderer = _part->renderer();
index 0937d5e559ddb1449c25f092e9ce0f8115d46fa1..1f60851123cf0bb456d972e3bf6227078d94ca85 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,8 +28,6 @@
 @protocol WebCoreTextRenderer;
 
 @interface WebCoreTextRendererFactory : NSObject
-{
-}
 
 + (WebCoreTextRendererFactory *)sharedFactory;
 
@@ -37,4 +35,6 @@
 - (BOOL)isFontFixedPitch:(NSFont *)font;
 - (id <WebCoreTextRenderer>)rendererWithFont:(NSFont *)font usingPrinterFont:(BOOL)usingPrinterFont;
 
+- (void)clearCaches;
+
 @end
diff --git a/WebCore/kwq/WebCoreTextRendererFactory.m b/WebCore/kwq/WebCoreTextRendererFactory.m
deleted file mode 100644 (file)
index b4e3a31..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "WebCoreTextRenderer.h"
-#import "WebCoreTextRendererFactory.h"
-
-#import "KWQAssertions.h"
-
-void WebCoreInitializeTextRun(WebCoreTextRun *run, const UniChar *characters, unsigned int length, int from, int to)
-{
-    run->characters = characters;
-    run->length = length;
-    run->from = from;
-    run->to = to;
-}
-
-void WebCoreInitializeEmptyTextStyle(WebCoreTextStyle *style)
-{
-    style->padding = 0;
-    style->textColor = nil;
-    style->backgroundColor = nil;
-    style->rtl = false;
-    style->visuallyOrdered = false;
-    style->letterSpacing = 0;
-    style->wordSpacing = 0;
-    style->smallCaps = false;
-    style->applyRunRounding = true;
-    style->applyWordRounding = true;
-    style->attemptFontSubstitution = true;
-    style->families = nil;
-}
-
-void WebCoreInitializeEmptyTextGeometry(WebCoreTextGeometry *geometry)
-{
-    geometry->point = NSMakePoint(0,0);
-    geometry->selectionY = 0;
-    geometry->selectionHeight = 0;
-    geometry->selectionMinX = 0;
-    geometry->selectionMaxX = 0;
-    geometry->useFontMetricsForSelectionYAndHeight = true;
-}
-
-@implementation WebCoreTextRendererFactory
-
-static WebCoreTextRendererFactory *sharedFactory;
-
-+ (WebCoreTextRendererFactory *)sharedFactory
-{
-    return sharedFactory;
-}
-
-- init
-{
-    [super init];
-    
-    ASSERT(!sharedFactory);
-    sharedFactory = [self retain];
-    
-    return self;
-}
-
-- (NSFont *)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
-{
-    return nil;
-}
-
-- (BOOL)isFontFixedPitch:(NSFont *)font
-{
-    return NO;
-}
-
-- (id <WebCoreTextRenderer>)rendererWithFont:(NSFont *)font usingPrinterFont:(BOOL)usingPrinterFont
-{
-    return nil;
-}
-
-@end
index b4e3a318ba991901399658d643ce95182400b8fb..742c22f132f59ee78272ad194a2483c2a079c95c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +27,9 @@
 #import "WebCoreTextRendererFactory.h"
 
 #import "KWQAssertions.h"
+#import "KWQKHTMLPart.h"
+#import "KWQListBox.h"
+#import "WebCoreBridge.h"
 
 void WebCoreInitializeTextRun(WebCoreTextRun *run, const UniChar *characters, unsigned int length, int from, int to)
 {
@@ -96,4 +99,12 @@ static WebCoreTextRendererFactory *sharedFactory;
     return nil;
 }
 
+- (void)clearCaches
+{
+    QListBox::clearCachedTextRenderers();
+    for (QPtrListIterator<KWQKHTMLPart> it(KWQKHTMLPart::instances()); it.current(); ++it) {
+        [it.current()->bridge() setNeedsReapplyStyles];
+    }
+}
+
 @end
index 4e3ca25840243d22fa172a84e225a4a2347eba88..19809666bab35f6a5e912c038097ba90fedca176 100644 (file)
@@ -1,3 +1,12 @@
+2004-08-30  Darin Adler  <darin@apple.com>
+
+        Reviewed by John.
+
+        - part of fix for <rdar://problem/3637519> REGRESSION (125-128): unrepro crash in QListBox::sizeForNumberOfLines at istweb.apple.com
+
+        * WebCoreSupport.subproj/WebTextRendererFactory.m: (-[WebTextRendererFactory clearCaches]):
+        Call [super clearCaches].
+
 2004-08-30  Darin Adler  <darin@apple.com>
 
         Reviewed by Chris.
index d65caac26b401d85e6c8556445f0f873bb7532af..d3526163036c5ea78128a349faedaea2e0948ce5 100644 (file)
@@ -190,10 +190,10 @@ static CFMutableDictionaryRef fontCache = NULL;
     cacheForPrinter = [[NSMutableDictionary alloc] init];
 
     if (fontCache)
-        CFRelease (fontCache);
+        CFRelease(fontCache);
     fontCache = NULL;
     
-    [WebBridge updateAllViews];
+    [super clearCaches];
 }
 
 static void