[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 06:36:54 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 979d267652d1726c03253dd78e5a8ac1da07e817
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Sep 6 23:22:59 2002 +0000

            Added support for khtml's justified text drawing.  Additional padding is distributed
            to space widths.  (Sites like www.osnews.com now render correctly.)
    
            Change word end rounding hack to use ceil of word width.  I'm still noticing a spacing anomaly
            that is fixed by a reload.  Occasionally text runs are still crammed together, but a reload uses
            correct spacing.  This anomaly is often visible on www.arstechnica.com.  Still investigating.
    
            * WebCoreSupport.subproj/WebTextRenderer.m:
            (-[WebTextRenderer drawGlyphs:numGlyphs:fromGlyphPosition:toGlyphPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
            (-[WebTextRenderer slowDrawCharacters:length:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:attemptFontSubstitution:]):
            (-[WebTextRenderer _drawCharacters:length:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
            (-[WebTextRenderer drawCharacters:stringLength:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
            (-[WebTextRenderer slowFloatWidthForCharacters:stringLength:fromCharacterPostion:numberOfCharacters:applyRounding:]):
            (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:applyRounding:attemptFontSubstitution:]):
    
            Tweaks to dragged image.
    
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView mouseDragged:]):
    
            Start using khtml's 'toAdd' parameter to justify text.
    
            * khtml/rendering/font.cpp:
            (Font::drawText):
    
            Normalize all calls to get width to minimize use of
            ObjC.  Will make it easier to use IMPL cache later.
    
            * kwq/KWQFontMetrics.mm:
            (QFontMetrics::width):
            (QFontMetrics::floatWidth):
            (QFontMetrics::floatCharacterWidth):
    
            Pass additional 'toAdd' parameter.
    
            * kwq/KWQPainter.mm:
            (QPainter::drawText):
            * kwq/qt/qpainter.h:
    
            Remove methods now that width calls are normalized to single
            method.
            * kwq/WebCoreTextRenderer.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1989 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 44e19b7..29fb304 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,29 @@
+2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
+
+        Start using khtml's 'toAdd' parameter to justify text.
+        
+        * khtml/rendering/font.cpp:
+        (Font::drawText):
+        
+        Normalize all calls to get width to minimize use of
+        ObjC.  Will make it easier to use IMPL cache later.
+        
+        * kwq/KWQFontMetrics.mm:
+        (QFontMetrics::width):
+        (QFontMetrics::floatWidth):
+        (QFontMetrics::floatCharacterWidth):
+        
+        Pass additional 'toAdd' parameter.
+        
+        * kwq/KWQPainter.mm:
+        (QPainter::drawText):
+        * kwq/qt/qpainter.h:
+        
+        Remove methods now that width calls are normalized to single
+        method.
+        * kwq/WebCoreTextRenderer.h:
+
+
 === Alexander-22 ===
 
 2002-09-05  Richard Williamson (Local)  <rjw at apple.com>
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 44e19b7..29fb304 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,29 @@
+2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
+
+        Start using khtml's 'toAdd' parameter to justify text.
+        
+        * khtml/rendering/font.cpp:
+        (Font::drawText):
+        
+        Normalize all calls to get width to minimize use of
+        ObjC.  Will make it easier to use IMPL cache later.
+        
+        * kwq/KWQFontMetrics.mm:
+        (QFontMetrics::width):
+        (QFontMetrics::floatWidth):
+        (QFontMetrics::floatCharacterWidth):
+        
+        Pass additional 'toAdd' parameter.
+        
+        * kwq/KWQPainter.mm:
+        (QPainter::drawText):
+        * kwq/qt/qpainter.h:
+        
+        Remove methods now that width calls are normalized to single
+        method.
+        * kwq/WebCoreTextRenderer.h:
+
+
 === Alexander-22 ===
 
 2002-09-05  Richard Williamson (Local)  <rjw at apple.com>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 44e19b7..29fb304 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,29 @@
+2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
+
+        Start using khtml's 'toAdd' parameter to justify text.
+        
+        * khtml/rendering/font.cpp:
+        (Font::drawText):
+        
+        Normalize all calls to get width to minimize use of
+        ObjC.  Will make it easier to use IMPL cache later.
+        
+        * kwq/KWQFontMetrics.mm:
+        (QFontMetrics::width):
+        (QFontMetrics::floatWidth):
+        (QFontMetrics::floatCharacterWidth):
+        
+        Pass additional 'toAdd' parameter.
+        
+        * kwq/KWQPainter.mm:
+        (QPainter::drawText):
+        * kwq/qt/qpainter.h:
+        
+        Remove methods now that width calls are normalized to single
+        method.
+        * kwq/WebCoreTextRenderer.h:
+
+
 === Alexander-22 ===
 
 2002-09-05  Richard Williamson (Local)  <rjw at apple.com>
diff --git a/WebCore/khtml/rendering/font.cpp b/WebCore/khtml/rendering/font.cpp
index d0fafd5..6029105 100644
--- a/WebCore/khtml/rendering/font.cpp
+++ b/WebCore/khtml/rendering/font.cpp
@@ -41,7 +41,7 @@ void Font::drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, i
         int toAdd, QPainter::TextDirection d, int from, int to, QColor bg ) const
 {
 #ifdef APPLE_CHANGES
-    p->drawText(x, y, str + pos, std::min(slen - pos, len), from, to, bg);
+    p->drawText(x, y, str + pos, std::min(slen - pos, len), from, to, toAdd, bg);
 #else
     QString qstr = QConstString(str, slen).string();
 
diff --git a/WebCore/kwq/KWQFontMetrics.mm b/WebCore/kwq/KWQFontMetrics.mm
index a168e8a..d00481c 100644
--- a/WebCore/kwq/KWQFontMetrics.mm
+++ b/WebCore/kwq/KWQFontMetrics.mm
@@ -112,7 +112,7 @@ float QFontMetrics::xHeight() const
 int QFontMetrics::width(QChar qc) const
 {
     UniChar c = qc.unicode();
-    return [data->getRenderer() widthForCharacters:&c length:1];
+    return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:&c stringLength:1 fromCharacterPosition:0 numberOfCharacters:1 applyRounding:YES attemptFontSubstitution: YES]);
 }
 
 int QFontMetrics::charWidth(const QString &s, int pos) const
@@ -123,32 +123,27 @@ int QFontMetrics::charWidth(const QString &s, int pos) const
 int QFontMetrics::width(char c) const
 {
     UniChar ch = (uchar) c;
-    return [data->getRenderer() widthForCharacters:&ch length:1];
+    return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:&ch stringLength:1 fromCharacterPosition:0 numberOfCharacters:1 applyRounding:YES attemptFontSubstitution: YES]);
 }
 
 int QFontMetrics::width(const QString &qstring, int len) const
 {
-    NSString *string;
-
-    string = qstring.getNSString();
-    if (len != -1)
-        string = [string substringToIndex:len];
-    return [data->getRenderer() widthForString:string];
+    return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)qstring.unicode() stringLength:len fromCharacterPosition:0 numberOfCharacters:len applyRounding:YES attemptFontSubstitution: YES]);
 }
 
 int QFontMetrics::width(const QChar *uchars, int len) const
 {
-    return [data->getRenderer() widthForCharacters:(const UniChar *)uchars length:len];
+    return ROUND_TO_INT([data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:len fromCharacterPosition:0 numberOfCharacters:len applyRounding:YES attemptFontSubstitution: YES]);
 }
 
 float QFontMetrics::floatWidth(const QChar *uchars, int slen, int pos, int len) const
 {
-    return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len];
+    return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:len applyRounding: YES attemptFontSubstitution: YES];
 }
 
 float QFontMetrics::floatCharacterWidth(const QChar *uchars, int slen, int pos) const
 {
-    return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen characterPosition:pos];
+    return [data->getRenderer() floatWidthForCharacters:(const UniChar *)uchars stringLength:slen fromCharacterPosition:pos numberOfCharacters:1 applyRounding: YES attemptFontSubstitution: YES];
 }
 
 QRect QFontMetrics::boundingRect(const QString &qstring, int len) const
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index d2a7c53..84096d4 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -91,7 +91,7 @@ public:
     void setRasterOp(RasterOp);
 
     void drawText(int x, int y, int, int, int alignmentFlags, const QString &);
-    void drawText(int x, int y, const QChar *, int length, int from, int to, const QColor& backgroundColor);
+    void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd, const QColor& backgroundColor);
     void drawUnderlineForText(int x, int y, const QChar *, int length);
     static QColor selectedTextBackgroundColor();
     
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 86d0134..e8fe59e 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -359,14 +359,18 @@ void QPainter::drawText(int x, int y, int, int, int alignmentFlags, const QStrin
 
     const UniChar* str = (const UniChar*)qstring.unicode();
     if (alignmentFlags & Qt::AlignRight)
-	x -= [renderer widthForCharacters: str length: qstring.length()];
+    	x -= ROUND_TO_INT([renderer floatWidthForCharacters:(const UniChar *)str stringLength:qstring.length() fromCharacterPosition:0 numberOfCharacters:qstring.length() applyRounding:YES attemptFontSubstitution: YES]);
      
     [renderer drawCharacters:str stringLength:qstring.length()
-        fromCharacterPosition:0 toCharacterPosition:qstring.length() atPoint:NSMakePoint(x, y)
-        withTextColor:data->state.pen.color().getNSColor() backgroundColor:nil];
+        fromCharacterPosition:0 
+        toCharacterPosition:qstring.length() 
+        atPoint:NSMakePoint(x, y)
+        withPadding: 0
+        withTextColor:data->state.pen.color().getNSColor() 
+        backgroundColor:nil];
 }
 
-void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int to, const QColor &backgroundColor)
+void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int to, int toAdd, const QColor &backgroundColor)
 {
     if (data->state.paintingDisabled || len <= 0)
         return;
@@ -374,8 +378,12 @@ void QPainter::drawText(int x, int y, const QChar *str, int len, int from, int t
     [[[WebCoreTextRendererFactory sharedFactory]
         rendererWithFamily:data->state.font.getNSFamily() traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()]
     	drawCharacters:(const UniChar *)str stringLength:len
-        fromCharacterPosition:from toCharacterPosition:to atPoint:NSMakePoint(x, y)
-        withTextColor:data->state.pen.color().getNSColor() backgroundColor:backgroundColor.isValid() ? backgroundColor.getNSColor() : nil];
+        fromCharacterPosition:from 
+        toCharacterPosition:to 
+        atPoint:NSMakePoint(x, y)
+        withPadding: toAdd
+        withTextColor:data->state.pen.color().getNSColor() 
+        backgroundColor:backgroundColor.isValid() ? backgroundColor.getNSColor() : nil];
 }
 
 void QPainter::drawUnderlineForText(int x, int y, const QChar *str, int len)
diff --git a/WebCore/kwq/WebCoreTextRenderer.h b/WebCore/kwq/WebCoreTextRenderer.h
index 75f46a7..5469f58 100644
--- a/WebCore/kwq/WebCoreTextRenderer.h
+++ b/WebCore/kwq/WebCoreTextRenderer.h
@@ -25,6 +25,10 @@
 
 #import <Cocoa/Cocoa.h>
 
+#ifndef ROUND_TO_INT
+#define ROUND_TO_INT(x) (unsigned int)((x)+.5)
+#endif
+
 @protocol WebCoreTextRenderer <NSObject>
 
 // vertical metrics
@@ -34,13 +38,10 @@
 - (float)xHeight;
 
 // horizontal metrics
-- (int)widthForString:(NSString *)string;
-- (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length;
-- (float)floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength fromCharacterPosition:(int)pos numberOfCharacters:(int)len;
-- (float)floatWidthForCharacters:(const UniChar *)characters stringLength:(unsigned)stringLength characterPosition:(int)pos;
+- (float)floatWidthForCharacters:(const unichar *)characters stringLength:(unsigned)length fromCharacterPosition: (int)pos numberOfCharacters: (int)len applyRounding: (BOOL)applyRounding attemptFontSubstitution: (BOOL)attemptFontSubstitution;
 
 // drawing
-- (void)drawCharacters:(const UniChar *)characters stringLength:(unsigned)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withTextColor:(NSColor *)textColor backgroundColor:(NSColor *)backgroundColor;
+- (void)drawCharacters:(const UniChar *)characters stringLength:(unsigned)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor:(NSColor *)backgroundColor;
 - (void)drawUnderlineForCharacters:(const UniChar *)characters stringLength:(unsigned)length atPoint:(NSPoint)point withColor:(NSColor *)color;
 
 @end
diff --git a/WebCore/kwq/qt/qpainter.h b/WebCore/kwq/qt/qpainter.h
index d2a7c53..84096d4 100644
--- a/WebCore/kwq/qt/qpainter.h
+++ b/WebCore/kwq/qt/qpainter.h
@@ -91,7 +91,7 @@ public:
     void setRasterOp(RasterOp);
 
     void drawText(int x, int y, int, int, int alignmentFlags, const QString &);
-    void drawText(int x, int y, const QChar *, int length, int from, int to, const QColor& backgroundColor);
+    void drawText(int x, int y, const QChar *, int length, int from, int to, int toAdd, const QColor& backgroundColor);
     void drawUnderlineForText(int x, int y, const QChar *, int length);
     static QColor selectedTextBackgroundColor();
     
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index a6a644e..3538ae8 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,27 @@
 2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
 
+        Added support for khtml's justified text drawing.  Additional padding is distributed
+        to space widths.  (Sites like www.osnews.com now render correctly.)
+        
+        Change word end rounding hack to use ceil of word width.  I'm still noticing a spacing anomaly
+        that is fixed by a reload.  Occasionally text runs are still crammed together, but a reload uses
+        correct spacing.  This anomaly is often visible on www.arstechnica.com.  Still investigating.
+        
+        * WebCoreSupport.subproj/WebTextRenderer.m:
+        (-[WebTextRenderer drawGlyphs:numGlyphs:fromGlyphPosition:toGlyphPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
+        (-[WebTextRenderer slowDrawCharacters:length:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:attemptFontSubstitution:]):
+        (-[WebTextRenderer _drawCharacters:length:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
+        (-[WebTextRenderer drawCharacters:stringLength:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
+        (-[WebTextRenderer slowFloatWidthForCharacters:stringLength:fromCharacterPostion:numberOfCharacters:applyRounding:]):
+        (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:applyRounding:attemptFontSubstitution:]):
+        
+        Tweaks to dragged image.
+        
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView mouseDragged:]):
+
+2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
+
         Fixed symbol lookup problem.  NSLookupAndBindSymbol() dies horribly
         if symbol is missing.  Use NSIsSymbolNameDefined() first to check if
         symbol is present.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index a6a644e..3538ae8 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,5 +1,27 @@
 2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
 
+        Added support for khtml's justified text drawing.  Additional padding is distributed
+        to space widths.  (Sites like www.osnews.com now render correctly.)
+        
+        Change word end rounding hack to use ceil of word width.  I'm still noticing a spacing anomaly
+        that is fixed by a reload.  Occasionally text runs are still crammed together, but a reload uses
+        correct spacing.  This anomaly is often visible on www.arstechnica.com.  Still investigating.
+        
+        * WebCoreSupport.subproj/WebTextRenderer.m:
+        (-[WebTextRenderer drawGlyphs:numGlyphs:fromGlyphPosition:toGlyphPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
+        (-[WebTextRenderer slowDrawCharacters:length:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:attemptFontSubstitution:]):
+        (-[WebTextRenderer _drawCharacters:length:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
+        (-[WebTextRenderer drawCharacters:stringLength:fromCharacterPosition:toCharacterPosition:atPoint:withPadding:withTextColor:backgroundColor:]):
+        (-[WebTextRenderer slowFloatWidthForCharacters:stringLength:fromCharacterPostion:numberOfCharacters:applyRounding:]):
+        (-[WebTextRenderer floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:applyRounding:attemptFontSubstitution:]):
+        
+        Tweaks to dragged image.
+        
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView mouseDragged:]):
+
+2002-09-06  Richard Williamson (Home)  <rjw at apple.com>
+
         Fixed symbol lookup problem.  NSLookupAndBindSymbol() dies horribly
         if symbol is missing.  Use NSIsSymbolNameDefined() first to check if
         symbol is present.
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
index b5c0e9e..7965d9e 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
@@ -419,17 +419,30 @@ static BOOL bufferTextDrawing = NO;
 }
 
 
-- (NSPoint)drawGlyphs: (CGGlyph *)glyphs numGlyphs: (unsigned int)numGlyphs fromGlyphPosition: (int)from toGlyphPosition: (int)to atPoint: (NSPoint)point withTextColor: (NSColor *)textColor backgroundColor: (NSColor *)backgroundColor
+- (NSPoint)drawGlyphs: (CGGlyph *)glyphs numGlyphs: (unsigned int)numGlyphs fromGlyphPosition: (int)from toGlyphPosition: (int)to atPoint: (NSPoint)point withPadding: (int)padding withTextColor: (NSColor *)textColor backgroundColor: (NSColor *)backgroundColor
 {
     unsigned int i;
     CGSize *advances, localAdvanceBuffer[LOCAL_BUFFER_SIZE];
     CGContextRef cgContext;
     NSPoint advancePoint = point;
     float startX, backgroundWidth = 0.0;
+    float wordWidth = 0.0;
+    uint numSpaces = 0;
+    int padPerSpace = 0;
 
     if (numGlyphs == 0)
         return point;
         
+    // If the padding is non-zero, count the number of spaces in the string
+    // and divide that by the padding for per space addition.
+    if (padding > 0){
+        for (i = 0; i < (uint)numGlyphs; i++){
+            if (glyphs[i] == spaceGlyph)
+                numSpaces++;
+        }
+        padPerSpace = ceil ((((float)padding) / ((float)numSpaces)));
+    }
+    
     // Determine if we can use the local stack buffer, otherwise allocate.
     if (numGlyphs > LOCAL_BUFFER_SIZE) {
         advances = (CGSize *)malloc(numGlyphs * sizeof(CGSize));
@@ -439,15 +452,24 @@ static BOOL bufferTextDrawing = NO;
 
     // Calculate advances for the entire string taking into account.
     // 1.  Rounding of spaces.
-    // 2.  Rounding at the end of words.
+    // 2.  Ceil word widths to guarantee integer word widths.
     for (i = 0; i < numGlyphs; i++) {
         advances[i].width = widthForGlyph(self, glyphToWidthMap, glyphs[i]);
         if (glyphs[i] == spaceGlyph){
             if (i > 0){
-                advances[i-1].width = ROUND_TO_INT (advances[i-1].width);
+                //advances[i-1].width = ROUND_TO_INT (advances[i-1].width);
+                advances[i-1].width += ceil (wordWidth) - wordWidth;
+            }
+            if (padding > 0){
+                advances[i].width = ROUND_TO_INT(advances[i].width) + padPerSpace;
+                padding -= padPerSpace;
             }
-            advances[i].width = ROUND_TO_INT(advances[i].width);
+            else
+                advances[i].width = ROUND_TO_INT(advances[i].width);
+            wordWidth = 0;
         }
+        else
+            wordWidth += advances[i].width;
         advances[i].height = 0;
         advancePoint.x += advances[i].width;
     }
@@ -490,7 +512,7 @@ static BOOL bufferTextDrawing = NO;
 
 // Useful page for testing http://home.att.net/~jameskass
 
-- (NSPoint)slowDrawCharacters:(const UniChar *)characters length: (unsigned int)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor attemptFontSubstitution: (BOOL)attemptFontSubstitution
+- (NSPoint)slowDrawCharacters:(const UniChar *)characters length: (unsigned int)length fromCharacterPosition:(int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor attemptFontSubstitution: (BOOL)attemptFontSubstitution
 {
     unsigned int charPos = 0, lastDrawnGlyph = 0;
     unsigned int clusterLength, i, numGlyphs, fragmentLength;
@@ -527,17 +549,17 @@ static BOOL bufferTextDrawing = NO;
                 
                 if (_fromGlyph < 0)
                     _fromGlyph = 0;
-                point = [self drawGlyphs: &glyphs[lastDrawnGlyph] numGlyphs: fragmentLength fromGlyphPosition: _fromGlyph toGlyphPosition:MIN(toGlyph-lastDrawnGlyph,fragmentLength) atPoint: point withTextColor: textColor backgroundColor: backgroundColor];
+                point = [self drawGlyphs: &glyphs[lastDrawnGlyph] numGlyphs: fragmentLength fromGlyphPosition: _fromGlyph toGlyphPosition:MIN(toGlyph-lastDrawnGlyph,fragmentLength) atPoint: point withPadding: padding withTextColor: textColor backgroundColor: backgroundColor];
             }
             
             // Draw the character in the alternate font.
             substituteFont = [self substituteFontForCharacters: &characters[charPos] length: clusterLength];
             if (substituteFont){
-                point = [[[WebTextRendererFactory sharedFactory] rendererWithFont: substituteFont] slowDrawCharacters: &characters[charPos] length: clusterLength fromCharacterPosition: from - charPos toCharacterPosition:to - charPos atPoint: point withTextColor: textColor backgroundColor: backgroundColor attemptFontSubstitution: NO];
+                point = [[[WebTextRendererFactory sharedFactory] rendererWithFont: substituteFont] slowDrawCharacters: &characters[charPos] length: clusterLength fromCharacterPosition: from - charPos toCharacterPosition:to - charPos atPoint: point withPadding: 0 withTextColor: textColor backgroundColor: backgroundColor attemptFontSubstitution: NO];
             }
             // No substitute font, draw null glyph
             else
-                point = [self drawGlyphs: &glyphs[i] numGlyphs: 1 fromGlyphPosition: fromGlyph-i toGlyphPosition:MIN((toGlyph-(int)i), 1) atPoint: point withTextColor: textColor backgroundColor: backgroundColor];
+                point = [self drawGlyphs: &glyphs[i] numGlyphs: 1 fromGlyphPosition: fromGlyph-i toGlyphPosition:MIN((toGlyph-(int)i), 1) atPoint: point withPadding: 0 withTextColor: textColor backgroundColor: backgroundColor];
                 
             lastDrawnGlyph = i+1;
         }
@@ -551,7 +573,7 @@ static BOOL bufferTextDrawing = NO;
         
         if (_fromGlyph < 0)
             _fromGlyph = 0;
-        point = [self drawGlyphs: &glyphs[lastDrawnGlyph] numGlyphs: fragmentLength fromGlyphPosition: _fromGlyph toGlyphPosition:MIN(toGlyph-lastDrawnGlyph,fragmentLength) atPoint: point withTextColor: textColor backgroundColor: backgroundColor];
+        point = [self drawGlyphs: &glyphs[lastDrawnGlyph] numGlyphs: fragmentLength fromGlyphPosition: _fromGlyph toGlyphPosition:MIN(toGlyph-lastDrawnGlyph,fragmentLength) atPoint: point withPadding: 0 withTextColor: textColor backgroundColor: backgroundColor];
     }
     if (glyphs)
         free(glyphs);
@@ -566,7 +588,7 @@ typedef enum {
     _IFDrawSucceeded,
 } _IFFailedDrawReason;
 
-- (_IFFailedDrawReason)_drawCharacters:(const UniChar *)characters length: (unsigned int)length fromCharacterPosition: (int)from toCharacterPosition:(int)to atPoint:(NSPoint)point withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor
+- (_IFFailedDrawReason)_drawCharacters:(const UniChar *)characters length: (unsigned int)length fromCharacterPosition: (int)from toCharacterPosition:(int)to atPoint:(NSPoint)point  withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor
 {
     uint i, numGlyphs;
     CGGlyph *glyphs, localGlyphBuffer[LOCAL_BUFFER_SIZE];
@@ -626,7 +648,7 @@ typedef enum {
     if (to == -1)
         to = numGlyphs;
     
-    [self drawGlyphs:glyphs numGlyphs:numGlyphs fromGlyphPosition:from toGlyphPosition:to atPoint:point withTextColor:textColor backgroundColor:backgroundColor];
+    [self drawGlyphs:glyphs numGlyphs:numGlyphs fromGlyphPosition:from toGlyphPosition:to atPoint:point withPadding: padding withTextColor:textColor backgroundColor:backgroundColor];
 
 cleanup:
     if (glyphs != localGlyphBuffer) {
@@ -636,12 +658,12 @@ cleanup:
 }
 
 
-- (void)drawCharacters:(const UniChar *)characters stringLength: (unsigned int)length fromCharacterPosition: (int)from toCharacterPosition: (int)to atPoint:(NSPoint)point withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor
+- (void)drawCharacters:(const UniChar *)characters stringLength: (unsigned int)length fromCharacterPosition: (int)from toCharacterPosition: (int)to atPoint:(NSPoint)point withPadding: (int)padding withTextColor:(NSColor *)textColor backgroundColor: (NSColor *)backgroundColor
 {
     //printf("draw: font %s, size %.1f, text \"%s\"\n", [[font fontName] cString], [font pointSize], [[NSString stringWithCharacters:characters length:length] UTF8String]);
 
     NSFont *substituteFont;
-    _IFFailedDrawReason reason = [self _drawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition: to atPoint: point withTextColor: textColor backgroundColor: backgroundColor];
+    _IFFailedDrawReason reason = [self _drawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition: to atPoint: point withPadding: padding withTextColor: textColor backgroundColor: backgroundColor];
     
     // ASSUMPTION:  We normally fail because we're trying to render characters
     // that don't have glyphs in the specified fonts.  If we failed in this way
@@ -654,13 +676,13 @@ cleanup:
         clusterLength = findLengthOfCharacterCluster(characters, length);
         substituteFont = [self substituteFontForCharacters: characters length: clusterLength];
         if (substituteFont)
-            reason = [[[WebTextRendererFactory sharedFactory] rendererWithFont: substituteFont] _drawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition: to atPoint: point withTextColor: textColor backgroundColor: backgroundColor];
+            reason = [[[WebTextRendererFactory sharedFactory] rendererWithFont: substituteFont] _drawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition: to atPoint: point withPadding: padding withTextColor: textColor backgroundColor: backgroundColor];
          
          if (!substituteFont || reason != _IFDrawSucceeded)
-            [self slowDrawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition:to atPoint: point withTextColor: textColor backgroundColor: backgroundColor attemptFontSubstitution: YES];
+            [self slowDrawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition:to atPoint: point withPadding: padding withTextColor: textColor backgroundColor: backgroundColor attemptFontSubstitution: YES];
     }
     else if (reason == _IFNonBaseCharacter) {
-        [self slowDrawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition:to atPoint: point withTextColor: textColor backgroundColor: backgroundColor attemptFontSubstitution: YES];
+        [self slowDrawCharacters: characters length: length fromCharacterPosition: from toCharacterPosition:to atPoint: point withPadding: padding withTextColor: textColor backgroundColor: backgroundColor attemptFontSubstitution: YES];
     }
 }
 
@@ -719,8 +741,9 @@ cleanup:
         // fragment.
         if ((int)charPos - pos >= len){
             if (glyphID == spaceGlyph){
-                totalWidth -= lastWidth;
-                totalWidth += ROUND_TO_INT(lastWidth);
+                //totalWidth -= lastWidth;
+                //totalWidth += ROUND_TO_INT(lastWidth);
+                totalWidth += ceil(totalWidth) - totalWidth;
             }
             break;
         }
@@ -735,8 +758,9 @@ cleanup:
         glyphWidth = widthForGlyph(self, glyphToWidthMap, glyphID);
         if (glyphID == spaceGlyph && applyRounding){
             if (totalWidth > 0 && lastWidth > 0){
-                totalWidth -= lastWidth;
-                totalWidth += ROUND_TO_INT(lastWidth);
+                //totalWidth -= lastWidth;
+                //totalWidth += ROUND_TO_INT(lastWidth);
+                totalWidth += ceil(totalWidth) - totalWidth;
             }
             glyphWidth = ROUND_TO_INT(glyphWidth);
         }
@@ -749,6 +773,9 @@ cleanup:
     }
     ATSClearGlyphVector(&glyphVector);
     
+    if (applyRounding)
+        totalWidth += ceil(totalWidth) - totalWidth;
+        
     return totalWidth;
 }
 
@@ -793,9 +820,10 @@ cleanup:
         // fragment.
         if ((int)i - pos >= len) {
             // Check if next character is a space. If so, we have to apply rounding.
-            if (c == SPACE) {
-                totalWidth -= lastWidth;
-                totalWidth += ROUND_TO_INT(lastWidth);
+            if (c == SPACE && applyRounding) {
+                //totalWidth -= lastWidth;
+                //totalWidth += ROUND_TO_INT(lastWidth);
+                totalWidth += ceil(totalWidth) - totalWidth;
             }
             break;
         }
@@ -825,8 +853,9 @@ cleanup:
         if (glyphID > 0 || ((glyphID == 0) && substituteFont == nil)) {
             if (glyphID == spaceGlyph && applyRounding) {
                 if (lastWidth > 0){
-                    totalWidth -= lastWidth;
-                    totalWidth += ROUND_TO_INT(lastWidth);
+                    //totalWidth -= lastWidth;
+                    //totalWidth += ROUND_TO_INT(lastWidth);
+                    totalWidth += ceil(totalWidth) - totalWidth;
                 }   
                 lastWidth = ROUND_TO_INT(widthForGlyph(self, glyphToWidthMap, glyphID));
             }
@@ -837,6 +866,9 @@ cleanup:
         totalWidth += lastWidth;       
     }
 
+    if (applyRounding)
+        totalWidth += ceil(totalWidth) - totalWidth;
+        
     return totalWidth;
 }
 
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index e74dc62..aab5373 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -420,6 +420,8 @@
 #define DRAG_LABEL_BORDER_X		4.0
 #define DRAG_LABEL_BORDER_Y		2.0
 
+#define MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP	120.0
+
 - (void)mouseDragged:(NSEvent *)event
 {
     // Ensure that we're visible wrt the event location.
@@ -471,8 +473,8 @@
                     urlStringSize = [urlString sizeWithAttributes: urlAttributes];
                     imageSize.height += urlStringSize.height;
                     // Clip the url string to 2.5 times the width of the label.
-                    if (urlStringSize.width > 2.5 * labelSize.width){
-                        imageSize.width = (labelSize.width * 2.5) + DRAG_LABEL_BORDER_X * 2;
+                    if (urlStringSize.width > MAX(2.5 * labelSize.width, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP)){
+                        imageSize.width = MAX((labelSize.width * 2.5) + DRAG_LABEL_BORDER_X * 2, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
                         clipURLString = YES;
                     }
                     else
@@ -496,7 +498,7 @@
                 [WebURLsWithTitles writeURLs:[NSArray arrayWithObject:linkURL] andTitles:[NSArray arrayWithObject:label] toPasteboard:pasteboard];
 
                 NSPoint mousePoint = [self convertPoint:[event locationInWindow] fromView:nil];
-                NSSize centerOffset = NSMakeSize(imageSize.width / 2, -imageSize.height / 2);
+                NSSize centerOffset = NSMakeSize(imageSize.width / 2, 0);
                 NSPoint imagePoint = NSMakePoint(mousePoint.x - centerOffset.width, mousePoint.y - centerOffset.height);
 
                 [self dragImage:dragImage

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list