[webkit-changes] cvs commit: WebCore/kwq KWQListBox.h KWQListBox.mm
Adele
adele at opensource.apple.com
Thu Aug 11 18:30:36 PDT 2005
adele 05/08/11 18:30:36
Modified: . ChangeLog
kwq KWQListBox.h KWQListBox.mm
Log:
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
1.4564 +19 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4563
retrieving revision 1.4564
diff -u -r1.4563 -r1.4564
--- ChangeLog 11 Aug 2005 21:36:58 -0000 1.4563
+++ ChangeLog 12 Aug 2005 01:30:24 -0000 1.4564
@@ -1,3 +1,22 @@
+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-11 David Hyatt <hyatt at apple.com>
Refine the baseline alignment rule for inline blocks to cover for a hole in the spec. The spec doesnt say what to do
1.23 +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.23
diff -u -r1.22 -r1.23
--- KWQListBox.h 31 Aug 2004 00:49:17 -0000 1.22
+++ KWQListBox.h 12 Aug 2005 01:30:35 -0000 1.23
@@ -72,6 +72,7 @@
virtual bool checksDescendantsForFocus() const;
static void clearCachedTextRenderers();
+ void setFont(const QFont &font);
private:
void appendItem(const QString &, bool isLabel);
1.54 +65 -9 WebCore/kwq/KWQListBox.mm
Index: KWQListBox.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQListBox.mm,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- KWQListBox.mm 14 Jul 2005 23:53:33 -0000 1.53
+++ KWQListBox.mm 12 Aug 2005 01:30:35 -0000 1.54
@@ -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];
@@ -593,8 +627,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;
@@ -613,7 +660,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);
@@ -651,4 +698,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