[webkit-changes] cvs commit: WebCore/kwq KWQListBox.h KWQListBox.mm

Adele adele at opensource.apple.com
Thu Aug 11 18:35:22 PDT 2005


adele       05/08/11 18:35:21

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               kwq      Tag: Safari-2-0-branch KWQListBox.h KWQListBox.mm
  Log:
          Merged fix from TOT to Safari-2-0-branch
  
      2005-08-11  Adele Peterson  <adele at apple.com>
  
          Reviewed by Darin.
  
          Test cases added: (NONE)
  
          -fixed <rdar://problem/4166839> CSS font-family and font-size ignored on <select> element with size > 1
  
          Changed KWQListBox to get the font from the widget.
  
          * kwq/KWQListBox.h: added setFont method
          * kwq/KWQListBox.mm:
          (QListBox::setFont): Added.
          (QListBox::sizeForNumberOfLines): if the new font is the same as the system font, use the old system for cacheing the text renderer.
          Otherwise, create a text renderer based on the new font, and a bold version of the new font.
          (-[KWQTableView drawRow:clipRect:]): ditto.
          (-[KWQTableView initWithListBox:]): moved setRowHeight call to fontChanged, so the height will reflect the new font.
          (-[KWQTableView fontChanged]): Added.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4104.2.110 +23 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4104.2.109
  retrieving revision 1.4104.2.110
  diff -u -r1.4104.2.109 -r1.4104.2.110
  --- ChangeLog	11 Aug 2005 00:28:22 -0000	1.4104.2.109
  +++ ChangeLog	12 Aug 2005 01:35:13 -0000	1.4104.2.110
  @@ -1,3 +1,26 @@
  +2005-08-11  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
  +    2005-08-11  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Darin.
  +
  +        Test cases added: (NONE)
  +
  +        -fixed <rdar://problem/4166839> CSS font-family and font-size ignored on <select> element with size > 1
  +
  +        Changed KWQListBox to get the font from the widget.
  +
  +        * kwq/KWQListBox.h: added setFont method
  +        * kwq/KWQListBox.mm:
  +        (QListBox::setFont): Added.
  +        (QListBox::sizeForNumberOfLines): if the new font is the same as the system font, use the old system for cacheing the text renderer.
  +        Otherwise, create a text renderer based on the new font, and a bold version of the new font.
  +        (-[KWQTableView drawRow:clipRect:]): ditto.
  +        (-[KWQTableView initWithListBox:]): moved setRowHeight call to fontChanged, so the height will reflect the new font.
  +        (-[KWQTableView fontChanged]): Added.
  +
   2005-08-10  Adele Peterson  <adele at apple.com>
   
           Merged fix from TOT to Safari-2-0-branch
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.22.10.1 +1 -0      WebCore/kwq/KWQListBox.h
  
  Index: KWQListBox.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQListBox.h,v
  retrieving revision 1.22
  retrieving revision 1.22.10.1
  diff -u -r1.22 -r1.22.10.1
  --- KWQListBox.h	31 Aug 2004 00:49:17 -0000	1.22
  +++ KWQListBox.h	12 Aug 2005 01:35:21 -0000	1.22.10.1
  @@ -72,6 +72,7 @@
       virtual bool checksDescendantsForFocus() const;
       
       static void clearCachedTextRenderers();
  +    void setFont(const QFont &font);
   
   private:
       void appendItem(const QString &, bool isLabel);
  
  
  
  1.51.8.2  +65 -9     WebCore/kwq/KWQListBox.mm
  
  Index: KWQListBox.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQListBox.mm,v
  retrieving revision 1.51.8.1
  retrieving revision 1.51.8.2
  diff -u -r1.51.8.1 -r1.51.8.2
  --- KWQListBox.mm	22 Jul 2005 01:18:36 -0000	1.51.8.1
  +++ KWQListBox.mm	12 Aug 2005 01:35:21 -0000	1.51.8.2
  @@ -52,11 +52,13 @@
   
   @interface KWQTableView : NSTableView <KWQWidgetHolder>
   {
  + at public
       QListBox *_box;
       BOOL processingMouseEvent;
       BOOL clickedDuringMouseEvent;
       BOOL inNextValidKeyView;
       NSWritingDirection _direction;
  +    BOOL isSystemFont;
   }
   - (id)initWithListBox:(QListBox *)b;
   - (void)detach;
  @@ -64,6 +66,7 @@
   - (QWidget *)widget;
   - (void)setBaseWritingDirection:(NSWritingDirection)direction;
   - (NSWritingDirection)baseWritingDirection;
  +- (void)fontChanged;
   @end
   
   static id <WebCoreTextRenderer> itemScreenRenderer;
  @@ -150,7 +153,7 @@
       [scrollView setDocumentView:tableView];
       [tableView release];
       [scrollView setVerticalLineScroll:[tableView rowHeight]];
  -    
  +        
       KWQ_UNBLOCK_EXCEPTIONS;
   }
   
  @@ -236,7 +239,7 @@
   void QListBox::setEnabled(bool enabled)
   {
       if (enabled != _enabled) {
  -        // You would think this would work, but not until AppKit bug 2177792 if fixed.
  +        // You would think this would work, but not until AppKit bug 2177792 is fixed.
           //KWQ_BLOCK_EXCEPTIONS;
           //NSTableView *tableView = [(NSScrollView *)getView() documentView];
           //[tableView setEnabled:enabled];
  @@ -274,17 +277,40 @@
               style.rtl = [tableView baseWritingDirection] == NSWritingDirectionRightToLeft;
               style.applyRunRounding = NO;
               style.applyWordRounding = NO;
  +            
  +            id <WebCoreTextRenderer> renderer;
  +            id <WebCoreTextRenderer> groupLabelRenderer;
  +            
  +            if (tableView->isSystemFont) {        
  +                renderer = itemTextRenderer();
  +                groupLabelRenderer = groupLabelTextRenderer();
  +            }
  +            else {
  +                NSFont *f = font().getNSFont();
  +                QFont b = font();
  +                b.setWeight(QFont::Bold);
  +                NSFont *boldFont = b.getNSFont();
  +            
  +            
  +                renderer = [[WebCoreTextRendererFactory sharedFactory]
  +                    rendererWithFont:f usingPrinterFont:![NSGraphicsContext currentContextDrawingToScreen]];
  +
  +                groupLabelRenderer = [[WebCoreTextRendererFactory sharedFactory]
  +                    rendererWithFont:boldFont usingPrinterFont:![NSGraphicsContext currentContextDrawingToScreen]];
  +            }
  +            
               do {
                   const QString &s = (*i).string;
  -                id <WebCoreTextRenderer> renderer = (*i).isGroupLabel ? groupLabelTextRenderer() : itemTextRenderer();
  -                ++i;
   
                   WebCoreTextRun run;
                   int length = s.length();
                   WebCoreInitializeTextRun(&run, reinterpret_cast<const UniChar *>(s.unicode()), length, 0, length);
   
  -                float textWidth = [renderer floatWidthForRun:&run style:&style widths:0];
  +                float textWidth = [((*i).isGroupLabel ? groupLabelRenderer : renderer) floatWidthForRun:&run style:&style widths:0];
                   width = kMax(width, textWidth);
  +                
  +                ++i;
  +            
               } while (i != e);
           }
           _width = ceilf(width);
  @@ -349,6 +375,15 @@
       groupLabelPrinterRenderer = nil;
   }
   
  +void QListBox::setFont(const QFont &font)
  +{
  +    QWidget::setFont(font);
  +
  +    NSScrollView *scrollView = static_cast<NSScrollView *>(getView());
  +    KWQTableView *tableView = [scrollView documentView];
  +    [tableView fontChanged];
  +}
  +
   @implementation KWQListBoxScrollView
   
   - (id)initWithListBox:(QListBox *)b
  @@ -403,7 +438,6 @@
       [self setAllowsMultipleSelection:NO];
       [self setHeaderView:nil];
       [self setIntercellSpacing:NSMakeSize(0, 0)];
  -    [self setRowHeight:ceilf([itemFont() ascender] - [itemFont() descender] + bottomMargin)];
       
       [self setDataSource:self];
       [self setDelegate:self];
  @@ -592,8 +626,21 @@
   
       bool RTL = _direction == NSWritingDirectionRightToLeft;
   
  -    id <WebCoreTextRenderer> renderer = item.isGroupLabel ? groupLabelTextRenderer() : itemTextRenderer();
  -
  +    NSFont *font = _box->font().getNSFont();
  +    
  +    id <WebCoreTextRenderer> renderer;
  +    if (isSystemFont) {
  +        renderer = item.isGroupLabel ? groupLabelTextRenderer() : itemTextRenderer();
  +    } else {
  +        if (item.isGroupLabel) {
  +            QFont boldFont = _box->font();
  +            boldFont.setWeight(QFont::Bold);
  +            font = boldFont.getNSFont();
  +        }
  +        renderer = [[WebCoreTextRendererFactory sharedFactory]
  +            rendererWithFont:font usingPrinterFont:![NSGraphicsContext currentContextDrawingToScreen]];
  +    }
  +   
       WebCoreTextStyle style;
       WebCoreInitializeEmptyTextStyle(&style);
       style.rtl = RTL;
  @@ -612,7 +659,7 @@
       } else {
           point.x = NSMaxX(cellRect) - rightMargin - [renderer floatWidthForRun:&run style:&style widths:0];
       }
  -    point.y = NSMaxY(cellRect) + [itemFont() descender] - bottomMargin;
  +    point.y = NSMaxY(cellRect) + [font descender] - bottomMargin;
   
       WebCoreTextGeometry geometry;
       WebCoreInitializeEmptyTextGeometry(&geometry);
  @@ -650,4 +697,13 @@
       return cell;
   }
   
  +- (void)fontChanged
  +{
  +    NSFont *font = _box->font().getNSFont();
  +    isSystemFont = [[font fontName] isEqualToString:[itemFont() fontName]] && ([font pointSize] == [itemFont() pointSize]);
  +    
  +    [self setRowHeight:ceilf([font ascender] - [font descender] + bottomMargin)];
  +    [self setNeedsDisplay:YES];
  +}
  +
   @end
  
  
  



More information about the webkit-changes mailing list