[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 05:52:15 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 89718cdb9441e32549807a75c7609cd364d1abc1
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 13 04:33:33 2001 +0000
Lots of changes to improve text rendering and some early attempts to optimize font
metrics.
Fixed drawing of lines.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@445 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index e44e521..13f362e 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -120,8 +120,10 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
// doing something better.
underlineOffset+=2;
- if(deco & UNDERLINE)
+ if(deco & UNDERLINE){
+ //fprintf (stderr, "UNDERLINE (%d, %d) to (%d, %d)\n", _tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
+ }
if(deco & OVERLINE)
pt->drawLine(_tx, _ty, _tx + width, _ty );
if(deco & LINE_THROUGH)
diff --git a/WebCore/kwq/KWQFontMetrics.h b/WebCore/kwq/KWQFontMetrics.h
index 5c0ad3e..925daa8 100644
--- a/WebCore/kwq/KWQFontMetrics.h
+++ b/WebCore/kwq/KWQFontMetrics.h
@@ -39,6 +39,9 @@
#import <Cocoa/Cocoa.h>
#endif
+class QFontMetricsPrivate;
+
+
// class QFontMetrics ==========================================================
class QFontMetrics {
@@ -80,19 +83,15 @@ public:
#ifdef _KWQ_
void _initialize();
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- void _initializeWithFont(NSFont *);
+ void _initializeWithData(QFontMetricsPrivate *);
+ NSRect _rectOfString(NSString *) const;
#else
- void _initializeWithFont(void *);
+ void _initializeWithData(void *);
+// int _rectOfString(void *) const;
#endif
void _free();
- struct KWQFontMetricsData {
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSFont *font;
-#else
- void *font;
-#endif
- } *data;
+ QFontMetricsPrivate *data;
#endif
void _freeWithData(struct KWQFontMetricsData *);
diff --git a/WebCore/kwq/KWQFontMetrics.mm b/WebCore/kwq/KWQFontMetrics.mm
index 56b0bdf..01d4c69 100644
--- a/WebCore/kwq/KWQFontMetrics.mm
+++ b/WebCore/kwq/KWQFontMetrics.mm
@@ -29,6 +29,53 @@
#define ROUND_TO_INT(f) ((int)rint((f)))
+struct QFontMetricsPrivate {
+friend class QFontMetrics;
+public:
+ QFontMetricsPrivate() :
+ font(0),
+ textContainer(0),
+ layoutManager(0),
+ attributes(0),
+ boundingRectCache(0),
+ lastLength(0)
+ {
+ }
+
+ ~QFontMetricsPrivate()
+ {
+ if (font){
+ [font release];
+ font = 0;
+ }
+ if (textContainer){
+ [textContainer release];
+ textContainer = 0;
+ }
+ if (layoutManager){
+ [layoutManager release];
+ layoutManager = 0;
+ }
+ if (attributes){
+ [attributes release];
+ attributes = 0;
+ }
+ if (boundingRectCache){
+ [boundingRectCache release];
+ boundingRectCache = 0;
+ }
+ }
+
+private:
+ NSFont *font;
+ NSTextContainer *textContainer;
+ NSLayoutManager *layoutManager;
+ NSDictionary *attributes;
+ NSMutableDictionary *boundingRectCache;
+ int lastLength;
+};
+
+
QFontMetrics::QFontMetrics()
{
_initialize();
@@ -37,43 +84,46 @@ QFontMetrics::QFontMetrics()
QFontMetrics::QFontMetrics(const QFont &withFont)
{
- _initializeWithFont (withFont.font);
+ _initializeWithData (0);
+ data->font = [withFont.font retain];
}
QFontMetrics::QFontMetrics(const QFontMetrics ©From)
{
- struct KWQFontMetricsData *oldData = data;
- _initializeWithFont(copyFrom.data->font);
- _freeWithData (oldData);
+ _initializeWithData(copyFrom.data);
}
void QFontMetrics::_initialize()
{
- _initializeWithFont (0);
+ _initializeWithData (0);
}
-void QFontMetrics::_initializeWithFont (NSFont *withFont)
+void QFontMetrics::_initializeWithData (QFontMetricsPrivate *withData)
{
- data = (struct KWQFontMetricsData *)calloc (1, sizeof (struct KWQFontMetricsData));
- if (withFont == 0)
+ data = new QFontMetricsPrivate();
+
+ if (withData == 0){
data->font = [QFont::defaultNSFont() retain];
- else
- data->font = [withFont retain];
+ data->textContainer = 0;
+ data->layoutManager = 0;
+ data->attributes = 0;
+ data->boundingRectCache = 0;
+ }
+ else {
+ data->font = [withData->font retain];
+ data->textContainer = [withData->textContainer retain];
+ data->layoutManager = [withData->layoutManager retain];
+ data->attributes = [withData->attributes retain];
+ data->boundingRectCache = [withData->boundingRectCache retain];
+ }
}
void QFontMetrics::_free(){
- _freeWithData (data);
+ delete data;
}
-void QFontMetrics::_freeWithData(struct KWQFontMetricsData *freeData){
- if (freeData != 0){
- //[freeData->font release];
- //free (freeData);
- }
-}
-
QFontMetrics::~QFontMetrics()
{
_free();
@@ -97,19 +147,73 @@ int QFontMetrics::height() const
return ROUND_TO_INT([data->font defaultLineHeightForFont]);
}
+const float LargeNumberForText = 1.0e7;
+
+NSRect QFontMetrics::_rectOfString(NSString *string) const
+ {
+ NSValue *cachedValue;
+ NSTextStorage *textStorage;
+
+ if (data->boundingRectCache == nil){
+ data->boundingRectCache = [[NSMutableDictionary alloc] init];
+ }
+
+ cachedValue = [data->boundingRectCache objectForKey: string];
+ if (cachedValue != nil){
+ return [cachedValue rectValue];
+ }
+
+ if (data->textContainer == nil){
+ data->textContainer = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+ data->layoutManager = [[NSLayoutManager alloc] init];
+ // data->textStorage = [[NSTextStorage alloc] initWithString:string attributes:[NSDictionary dictionaryWithObjectsAndKeys:data->font, NSFontAttributeName, nil]];
+ [data->layoutManager addTextContainer: data->textContainer];
+// [data->textStorage addLayoutManager: data->layoutManager];
+ data->attributes = [[NSDictionary dictionaryWithObjectsAndKeys:data->font, NSFontAttributeName, nil] retain];
+ }
+// else {
+// [data->textStorage beginEditing];
+// [data->textStorage replaceCharactersInRange: NSMakeRange (0,[data->textStorage length]) withString: string];
+// [data->textStorage endEditing];
+// }
+
+ textStorage = [[NSTextStorage alloc] initWithString:string attributes: data->attributes];
+ [textStorage addLayoutManager: data->layoutManager];
+
+ //[data->layoutManager addTextContainer: data->textContainer];
+ //[data->textStorage addLayoutManager: data->layoutManager];
+
+ unsigned numberOfGlyphs = [data->layoutManager numberOfGlyphs];
+ NSRect glyphRect = [data->layoutManager boundingRectForGlyphRange: NSMakeRange (0, numberOfGlyphs) inTextContainer: data->textContainer];
+
+ [textStorage removeLayoutManager: data->layoutManager];
+ [textStorage release];
+
+ //[data->layoutManager removeTextContainerAtIndex: 0];
+
+ [data->boundingRectCache setObject: [NSValue valueWithRect: glyphRect] forKey: string];
+
+ return glyphRect;
+}
+
+
+
int QFontMetrics::width(QChar qc) const
{
ushort c = qc.unicode();
NSString *string = [NSString stringWithCharacters: (const unichar *)&c length: 1];
- return ROUND_TO_INT([data->font widthOfString: string]);
+ int stringWidth = ROUND_TO_INT(_rectOfString(string).size.width);
+ return stringWidth;
}
+
int QFontMetrics::width(char c) const
{
NSString *string = [NSString stringWithCString: &c length: 1];
- return ROUND_TO_INT([data->font widthOfString: string]);
+ int stringWidth = ROUND_TO_INT(_rectOfString(string).size.width);
+ return stringWidth;
}
@@ -121,7 +225,8 @@ int QFontMetrics::width(const QString &qstring, int len) const
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
string = QSTRING_TO_NSSTRING (qstring);
- return ROUND_TO_INT([data->font widthOfString: string]);
+ int stringWidth = ROUND_TO_INT(_rectOfString(string).size.width);
+ return stringWidth;
}
@@ -131,17 +236,33 @@ int QFontMetrics::descent() const
}
-QRect QFontMetrics::boundingRect(const QString &, int len=-1) const
+QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
{
- _logNotYetImplemented();
- return QRect();
+ NSString *string;
+
+ if (len != -1)
+ string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
+ else
+ string = QSTRING_TO_NSSTRING (qstring);
+ NSRect rect = _rectOfString(string);
+
+ return QRect(ROUND_TO_INT(rect.origin.x),
+ ROUND_TO_INT(rect.origin.y),
+ ROUND_TO_INT(rect.size.width),
+ ROUND_TO_INT(rect.size.height));
}
-QRect QFontMetrics::boundingRect(QChar) const
+QRect QFontMetrics::boundingRect(QChar qc) const
{
- _logNotYetImplemented();
- return QRect();
+ ushort c = qc.unicode();
+ NSString *string = [NSString stringWithCharacters: (const unichar *)&c length: 1];
+ NSRect rect = _rectOfString(string);
+
+ return QRect(ROUND_TO_INT(rect.origin.x),
+ ROUND_TO_INT(rect.origin.y),
+ ROUND_TO_INT(rect.size.width),
+ ROUND_TO_INT(rect.size.height));
}
@@ -184,7 +305,7 @@ int QFontMetrics::leftBearing(QChar) const
QFontMetrics &QFontMetrics::operator=(const QFontMetrics &assignFrom)
{
_free();
- _initializeWithFont(assignFrom.data->font);
+ _initializeWithData(assignFrom.data);
return *this;
}
diff --git a/WebCore/kwq/KWQPaintDeviceMetrics.mm b/WebCore/kwq/KWQPaintDeviceMetrics.mm
index 6ef92bf..7f70afc 100644
--- a/WebCore/kwq/KWQPaintDeviceMetrics.mm
+++ b/WebCore/kwq/KWQPaintDeviceMetrics.mm
@@ -35,7 +35,7 @@ QPaintDeviceMetrics::QPaintDeviceMetrics(const QPaintDevice *)
int QPaintDeviceMetrics::logicalDpiY() const
{
//_logPartiallyImplemented();
- return 72;
+ return 96;
}
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index b4dd9cd..fa5b8fd 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -245,16 +245,28 @@ void QPainter::drawLine(int x1, int y1, int x2, int y2)
{
NSBezierPath *path;
- [NSBezierPath setDefaultLineWidth:0];
-
_lockFocus();
_setColorFromPen();
- path = [NSBezierPath bezierPath];
- [path setLineWidth:0];
+
+ NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
+ BOOL flag = [graphicsContext shouldAntialias];
+
+ [graphicsContext setShouldAntialias: NO];
+
+#if 0
+ NSBezierPath *path = [NSBezierPath bezierPath];
+ [path setLineWidth:(float)0.1];
[path moveToPoint:NSMakePoint(x1, y1)];
[path lineToPoint:NSMakePoint(x2, y2)];
[path closePath];
[path stroke];
+#endif
+
+ [NSBezierPath setDefaultLineWidth:1.0f];
+ [NSBezierPath strokeLineFromPoint: NSMakePoint (x1,y1-0.5f) toPoint: NSMakePoint (x2,y2-0.5f)];
+
+ [graphicsContext setShouldAntialias: flag];
+
_unlockFocus();
}
@@ -616,7 +628,9 @@ QPaintDevice *QPainter::device() const
return (QPaintDevice *)data->bufferDevice;
}
-void QPainter::_lockFocus(){
+void QPainter::_lockFocus()
+{
+#if 0
if (data->isFocusLocked == 0){
if (data->bufferDevice != 0L){
const QPixmap *pixmap = (QPixmap *)(data->bufferDevice);
@@ -627,9 +641,12 @@ void QPainter::_lockFocus(){
}
data->isFocusLocked = 1;
}
+#endif
}
-void QPainter::_unlockFocus(){
+void QPainter::_unlockFocus()
+{
+#if 0
if (data->isFocusLocked == 1){
if (data->bufferDevice != 0L){
const QPixmap *pixmap = (QPixmap *)(data->bufferDevice);
@@ -640,6 +657,7 @@ void QPainter::_unlockFocus(){
}
data->isFocusLocked = 0;
}
+#endif
}
diff --git a/WebCore/kwq/KWQView.mm b/WebCore/kwq/KWQView.mm
index 0496286..f4aa132 100644
--- a/WebCore/kwq/KWQView.mm
+++ b/WebCore/kwq/KWQView.mm
@@ -136,11 +136,14 @@
[self layout];
- QPainter p(widget);
+ QPainter p(widget);
+
+ [self lockFocus];
((KHTMLView *)widget)->drawContents( &p, (int)rect.origin.x,
(int)rect.origin.y,
(int)rect.size.width,
(int)rect.size.height );
+ [self unlockFocus];
}
}
diff --git a/WebCore/kwq/qt/qfontmetrics.h b/WebCore/kwq/qt/qfontmetrics.h
index 5c0ad3e..925daa8 100644
--- a/WebCore/kwq/qt/qfontmetrics.h
+++ b/WebCore/kwq/qt/qfontmetrics.h
@@ -39,6 +39,9 @@
#import <Cocoa/Cocoa.h>
#endif
+class QFontMetricsPrivate;
+
+
// class QFontMetrics ==========================================================
class QFontMetrics {
@@ -80,19 +83,15 @@ public:
#ifdef _KWQ_
void _initialize();
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- void _initializeWithFont(NSFont *);
+ void _initializeWithData(QFontMetricsPrivate *);
+ NSRect _rectOfString(NSString *) const;
#else
- void _initializeWithFont(void *);
+ void _initializeWithData(void *);
+// int _rectOfString(void *) const;
#endif
void _free();
- struct KWQFontMetricsData {
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSFont *font;
-#else
- void *font;
-#endif
- } *data;
+ QFontMetricsPrivate *data;
#endif
void _freeWithData(struct KWQFontMetricsData *);
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
index e44e521..13f362e 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
@@ -120,8 +120,10 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
// doing something better.
underlineOffset+=2;
- if(deco & UNDERLINE)
+ if(deco & UNDERLINE){
+ //fprintf (stderr, "UNDERLINE (%d, %d) to (%d, %d)\n", _tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
+ }
if(deco & OVERLINE)
pt->drawLine(_tx, _ty, _tx + width, _ty );
if(deco & LINE_THROUGH)
diff --git a/WebCore/src/kwq/KWQFontMetrics.mm b/WebCore/src/kwq/KWQFontMetrics.mm
index 56b0bdf..01d4c69 100644
--- a/WebCore/src/kwq/KWQFontMetrics.mm
+++ b/WebCore/src/kwq/KWQFontMetrics.mm
@@ -29,6 +29,53 @@
#define ROUND_TO_INT(f) ((int)rint((f)))
+struct QFontMetricsPrivate {
+friend class QFontMetrics;
+public:
+ QFontMetricsPrivate() :
+ font(0),
+ textContainer(0),
+ layoutManager(0),
+ attributes(0),
+ boundingRectCache(0),
+ lastLength(0)
+ {
+ }
+
+ ~QFontMetricsPrivate()
+ {
+ if (font){
+ [font release];
+ font = 0;
+ }
+ if (textContainer){
+ [textContainer release];
+ textContainer = 0;
+ }
+ if (layoutManager){
+ [layoutManager release];
+ layoutManager = 0;
+ }
+ if (attributes){
+ [attributes release];
+ attributes = 0;
+ }
+ if (boundingRectCache){
+ [boundingRectCache release];
+ boundingRectCache = 0;
+ }
+ }
+
+private:
+ NSFont *font;
+ NSTextContainer *textContainer;
+ NSLayoutManager *layoutManager;
+ NSDictionary *attributes;
+ NSMutableDictionary *boundingRectCache;
+ int lastLength;
+};
+
+
QFontMetrics::QFontMetrics()
{
_initialize();
@@ -37,43 +84,46 @@ QFontMetrics::QFontMetrics()
QFontMetrics::QFontMetrics(const QFont &withFont)
{
- _initializeWithFont (withFont.font);
+ _initializeWithData (0);
+ data->font = [withFont.font retain];
}
QFontMetrics::QFontMetrics(const QFontMetrics ©From)
{
- struct KWQFontMetricsData *oldData = data;
- _initializeWithFont(copyFrom.data->font);
- _freeWithData (oldData);
+ _initializeWithData(copyFrom.data);
}
void QFontMetrics::_initialize()
{
- _initializeWithFont (0);
+ _initializeWithData (0);
}
-void QFontMetrics::_initializeWithFont (NSFont *withFont)
+void QFontMetrics::_initializeWithData (QFontMetricsPrivate *withData)
{
- data = (struct KWQFontMetricsData *)calloc (1, sizeof (struct KWQFontMetricsData));
- if (withFont == 0)
+ data = new QFontMetricsPrivate();
+
+ if (withData == 0){
data->font = [QFont::defaultNSFont() retain];
- else
- data->font = [withFont retain];
+ data->textContainer = 0;
+ data->layoutManager = 0;
+ data->attributes = 0;
+ data->boundingRectCache = 0;
+ }
+ else {
+ data->font = [withData->font retain];
+ data->textContainer = [withData->textContainer retain];
+ data->layoutManager = [withData->layoutManager retain];
+ data->attributes = [withData->attributes retain];
+ data->boundingRectCache = [withData->boundingRectCache retain];
+ }
}
void QFontMetrics::_free(){
- _freeWithData (data);
+ delete data;
}
-void QFontMetrics::_freeWithData(struct KWQFontMetricsData *freeData){
- if (freeData != 0){
- //[freeData->font release];
- //free (freeData);
- }
-}
-
QFontMetrics::~QFontMetrics()
{
_free();
@@ -97,19 +147,73 @@ int QFontMetrics::height() const
return ROUND_TO_INT([data->font defaultLineHeightForFont]);
}
+const float LargeNumberForText = 1.0e7;
+
+NSRect QFontMetrics::_rectOfString(NSString *string) const
+ {
+ NSValue *cachedValue;
+ NSTextStorage *textStorage;
+
+ if (data->boundingRectCache == nil){
+ data->boundingRectCache = [[NSMutableDictionary alloc] init];
+ }
+
+ cachedValue = [data->boundingRectCache objectForKey: string];
+ if (cachedValue != nil){
+ return [cachedValue rectValue];
+ }
+
+ if (data->textContainer == nil){
+ data->textContainer = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)];
+ data->layoutManager = [[NSLayoutManager alloc] init];
+ // data->textStorage = [[NSTextStorage alloc] initWithString:string attributes:[NSDictionary dictionaryWithObjectsAndKeys:data->font, NSFontAttributeName, nil]];
+ [data->layoutManager addTextContainer: data->textContainer];
+// [data->textStorage addLayoutManager: data->layoutManager];
+ data->attributes = [[NSDictionary dictionaryWithObjectsAndKeys:data->font, NSFontAttributeName, nil] retain];
+ }
+// else {
+// [data->textStorage beginEditing];
+// [data->textStorage replaceCharactersInRange: NSMakeRange (0,[data->textStorage length]) withString: string];
+// [data->textStorage endEditing];
+// }
+
+ textStorage = [[NSTextStorage alloc] initWithString:string attributes: data->attributes];
+ [textStorage addLayoutManager: data->layoutManager];
+
+ //[data->layoutManager addTextContainer: data->textContainer];
+ //[data->textStorage addLayoutManager: data->layoutManager];
+
+ unsigned numberOfGlyphs = [data->layoutManager numberOfGlyphs];
+ NSRect glyphRect = [data->layoutManager boundingRectForGlyphRange: NSMakeRange (0, numberOfGlyphs) inTextContainer: data->textContainer];
+
+ [textStorage removeLayoutManager: data->layoutManager];
+ [textStorage release];
+
+ //[data->layoutManager removeTextContainerAtIndex: 0];
+
+ [data->boundingRectCache setObject: [NSValue valueWithRect: glyphRect] forKey: string];
+
+ return glyphRect;
+}
+
+
+
int QFontMetrics::width(QChar qc) const
{
ushort c = qc.unicode();
NSString *string = [NSString stringWithCharacters: (const unichar *)&c length: 1];
- return ROUND_TO_INT([data->font widthOfString: string]);
+ int stringWidth = ROUND_TO_INT(_rectOfString(string).size.width);
+ return stringWidth;
}
+
int QFontMetrics::width(char c) const
{
NSString *string = [NSString stringWithCString: &c length: 1];
- return ROUND_TO_INT([data->font widthOfString: string]);
+ int stringWidth = ROUND_TO_INT(_rectOfString(string).size.width);
+ return stringWidth;
}
@@ -121,7 +225,8 @@ int QFontMetrics::width(const QString &qstring, int len) const
string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
else
string = QSTRING_TO_NSSTRING (qstring);
- return ROUND_TO_INT([data->font widthOfString: string]);
+ int stringWidth = ROUND_TO_INT(_rectOfString(string).size.width);
+ return stringWidth;
}
@@ -131,17 +236,33 @@ int QFontMetrics::descent() const
}
-QRect QFontMetrics::boundingRect(const QString &, int len=-1) const
+QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
{
- _logNotYetImplemented();
- return QRect();
+ NSString *string;
+
+ if (len != -1)
+ string = QSTRING_TO_NSSTRING_LENGTH (qstring, len);
+ else
+ string = QSTRING_TO_NSSTRING (qstring);
+ NSRect rect = _rectOfString(string);
+
+ return QRect(ROUND_TO_INT(rect.origin.x),
+ ROUND_TO_INT(rect.origin.y),
+ ROUND_TO_INT(rect.size.width),
+ ROUND_TO_INT(rect.size.height));
}
-QRect QFontMetrics::boundingRect(QChar) const
+QRect QFontMetrics::boundingRect(QChar qc) const
{
- _logNotYetImplemented();
- return QRect();
+ ushort c = qc.unicode();
+ NSString *string = [NSString stringWithCharacters: (const unichar *)&c length: 1];
+ NSRect rect = _rectOfString(string);
+
+ return QRect(ROUND_TO_INT(rect.origin.x),
+ ROUND_TO_INT(rect.origin.y),
+ ROUND_TO_INT(rect.size.width),
+ ROUND_TO_INT(rect.size.height));
}
@@ -184,7 +305,7 @@ int QFontMetrics::leftBearing(QChar) const
QFontMetrics &QFontMetrics::operator=(const QFontMetrics &assignFrom)
{
_free();
- _initializeWithFont(assignFrom.data->font);
+ _initializeWithData(assignFrom.data);
return *this;
}
diff --git a/WebCore/src/kwq/KWQPaintDeviceMetrics.mm b/WebCore/src/kwq/KWQPaintDeviceMetrics.mm
index 6ef92bf..7f70afc 100644
--- a/WebCore/src/kwq/KWQPaintDeviceMetrics.mm
+++ b/WebCore/src/kwq/KWQPaintDeviceMetrics.mm
@@ -35,7 +35,7 @@ QPaintDeviceMetrics::QPaintDeviceMetrics(const QPaintDevice *)
int QPaintDeviceMetrics::logicalDpiY() const
{
//_logPartiallyImplemented();
- return 72;
+ return 96;
}
diff --git a/WebCore/src/kwq/KWQPainter.mm b/WebCore/src/kwq/KWQPainter.mm
index b4dd9cd..fa5b8fd 100644
--- a/WebCore/src/kwq/KWQPainter.mm
+++ b/WebCore/src/kwq/KWQPainter.mm
@@ -245,16 +245,28 @@ void QPainter::drawLine(int x1, int y1, int x2, int y2)
{
NSBezierPath *path;
- [NSBezierPath setDefaultLineWidth:0];
-
_lockFocus();
_setColorFromPen();
- path = [NSBezierPath bezierPath];
- [path setLineWidth:0];
+
+ NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
+ BOOL flag = [graphicsContext shouldAntialias];
+
+ [graphicsContext setShouldAntialias: NO];
+
+#if 0
+ NSBezierPath *path = [NSBezierPath bezierPath];
+ [path setLineWidth:(float)0.1];
[path moveToPoint:NSMakePoint(x1, y1)];
[path lineToPoint:NSMakePoint(x2, y2)];
[path closePath];
[path stroke];
+#endif
+
+ [NSBezierPath setDefaultLineWidth:1.0f];
+ [NSBezierPath strokeLineFromPoint: NSMakePoint (x1,y1-0.5f) toPoint: NSMakePoint (x2,y2-0.5f)];
+
+ [graphicsContext setShouldAntialias: flag];
+
_unlockFocus();
}
@@ -616,7 +628,9 @@ QPaintDevice *QPainter::device() const
return (QPaintDevice *)data->bufferDevice;
}
-void QPainter::_lockFocus(){
+void QPainter::_lockFocus()
+{
+#if 0
if (data->isFocusLocked == 0){
if (data->bufferDevice != 0L){
const QPixmap *pixmap = (QPixmap *)(data->bufferDevice);
@@ -627,9 +641,12 @@ void QPainter::_lockFocus(){
}
data->isFocusLocked = 1;
}
+#endif
}
-void QPainter::_unlockFocus(){
+void QPainter::_unlockFocus()
+{
+#if 0
if (data->isFocusLocked == 1){
if (data->bufferDevice != 0L){
const QPixmap *pixmap = (QPixmap *)(data->bufferDevice);
@@ -640,6 +657,7 @@ void QPainter::_unlockFocus(){
}
data->isFocusLocked = 0;
}
+#endif
}
diff --git a/WebCore/src/kwq/KWQView.mm b/WebCore/src/kwq/KWQView.mm
index 0496286..f4aa132 100644
--- a/WebCore/src/kwq/KWQView.mm
+++ b/WebCore/src/kwq/KWQView.mm
@@ -136,11 +136,14 @@
[self layout];
- QPainter p(widget);
+ QPainter p(widget);
+
+ [self lockFocus];
((KHTMLView *)widget)->drawContents( &p, (int)rect.origin.x,
(int)rect.origin.y,
(int)rect.size.width,
(int)rect.size.height );
+ [self unlockFocus];
}
}
diff --git a/WebCore/src/kwq/qt/qfontmetrics.h b/WebCore/src/kwq/qt/qfontmetrics.h
index 5c0ad3e..925daa8 100644
--- a/WebCore/src/kwq/qt/qfontmetrics.h
+++ b/WebCore/src/kwq/qt/qfontmetrics.h
@@ -39,6 +39,9 @@
#import <Cocoa/Cocoa.h>
#endif
+class QFontMetricsPrivate;
+
+
// class QFontMetrics ==========================================================
class QFontMetrics {
@@ -80,19 +83,15 @@ public:
#ifdef _KWQ_
void _initialize();
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- void _initializeWithFont(NSFont *);
+ void _initializeWithData(QFontMetricsPrivate *);
+ NSRect _rectOfString(NSString *) const;
#else
- void _initializeWithFont(void *);
+ void _initializeWithData(void *);
+// int _rectOfString(void *) const;
#endif
void _free();
- struct KWQFontMetricsData {
-#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
- NSFont *font;
-#else
- void *font;
-#endif
- } *data;
+ QFontMetricsPrivate *data;
#endif
void _freeWithData(struct KWQFontMetricsData *);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list