[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 07:50:55 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 39b8717ad0b48b623fbb2d9712f3f1125bcf9b98
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Aug 9 01:00:37 2003 +0000

    	Lots of healthy cleanup.  Introduced width and shaping iterators
    	to simplify code and remove allocations for large text runs.  Should
    	go further and make more use of these in the future (post panther).
    
    	Fixed 3369608.  Crash in -[WebTextRenderer _CG_drawRun:style:atPoint:] at lovepucca.net
    	Fixed 3118050.  Crash selecting text at http://www.faqs.org/rfcs/rfc2849.html (SELECTION)
    	Fixed 3371115.  Can't correctly select text that contains surrogate pairs
    
            Reviewed by darin.
    
            * Misc.subproj/WebUnicode.h:
            * Misc.subproj/WebUnicode.m:
            (prevChar):
            (nextChar):
            (prevLogicalCharJoins):
            (nextLogicalCharJoins):
            (glyphVariantLogical):
            (hasShapeForNextCharacter):
            (shapeForNextCharacter):
            (initializeCharacterShapeIterator):
            (shapedString):
            * WebCoreSupport.subproj/WebTextRenderer.h:
            * WebCoreSupport.subproj/WebTextRenderer.m:
            (initializeCharacterWidthIterator):
            (widthAndGlyphForSurrogate):
            (widthForNextCharacter):
            (-[WebTextRenderer _CG_floatWidthForRun:style:widths:fonts:glyphs:startGlyph:endGlyph:numGlyphs:]):
            (-[WebTextRenderer _CG_pointToOffset:style:position:reversed:]):
    
    	Just formatting changed here
            * WebView.subproj/WebHTMLViewPrivate.m:
            (-[WebHTMLView _dragImageForLinkElement:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4801 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 81b4bd6..112d838 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,38 @@
+2003-08-08  Richard Williamson  <rjw at apple.com>
+	
+	Lots of healthy cleanup.  Introduced width and shaping iterators
+	to simplify code and remove allocations for large text runs.  Should
+	go further and make more use of these in the future (post panther).
+
+	Fixed 3369608.  Crash in -[WebTextRenderer _CG_drawRun:style:atPoint:] at lovepucca.net
+	Fixed 3118050.  Crash selecting text at http://www.faqs.org/rfcs/rfc2849.html (SELECTION)
+	Fixed 3371115.  Can't correctly select text that contains surrogate pairs
+
+        Reviewed by darin.
+
+        * Misc.subproj/WebUnicode.h:
+        * Misc.subproj/WebUnicode.m:
+        (prevChar):
+        (nextChar):
+        (prevLogicalCharJoins):
+        (nextLogicalCharJoins):
+        (glyphVariantLogical):
+        (hasShapeForNextCharacter):
+        (shapeForNextCharacter):
+        (initializeCharacterShapeIterator):
+        (shapedString):
+        * WebCoreSupport.subproj/WebTextRenderer.h:
+        * WebCoreSupport.subproj/WebTextRenderer.m:
+        (initializeCharacterWidthIterator):
+        (widthAndGlyphForSurrogate):
+        (widthForNextCharacter):
+        (-[WebTextRenderer _CG_floatWidthForRun:style:widths:fonts:glyphs:startGlyph:endGlyph:numGlyphs:]):
+        (-[WebTextRenderer _CG_pointToOffset:style:position:reversed:]):
+
+	Just formatting changed here
+        * WebView.subproj/WebHTMLViewPrivate.m:
+        (-[WebHTMLView _dragImageForLinkElement:]):
+
 2003-08-08  Darin Adler  <darin at apple.com>
 
         Reviewed by Maciej.
diff --git a/WebKit/Misc.subproj/WebUnicode.h b/WebKit/Misc.subproj/WebUnicode.h
index 558a9c0..a3d5adf 100644
--- a/WebKit/Misc.subproj/WebUnicode.h
+++ b/WebKit/Misc.subproj/WebUnicode.h
@@ -4,6 +4,8 @@
 
     Private header file.
 */
+#import <WebCore/WebCoreTextRenderer.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -20,7 +22,8 @@ extern int symmetricPairsSize;
 extern const unsigned short * const case_info[];
 extern const unsigned short * const ligature_info[];
 extern const unsigned short ligature_map[];
-extern UniChar *shapedString(UniChar *uc, int stringLength, int from, int len, int dir, int *lengthOut);
+extern UniChar *shapedString(const WebCoreTextRun *run, int dir, int *lengthOut);
+
 #ifdef __cplusplus
 }
 #endif
@@ -42,3 +45,12 @@ enum {
 #define IsHighSurrogatePair(c)  (( c & 0xFC00 ) == HighSurrogateRangeStart )
 #define IsLowSurrogatePair(c)  (( c & 0xFC00 ) == LowSurrogateRangeStart )
 
+typedef struct CharacterShapeIterator CharacterShapeIterator;
+struct CharacterShapeIterator
+{
+    const WebCoreTextRun *run;
+    const UniChar *currentCharacter;
+};
+extern bool initializeCharacterShapeIterator (CharacterShapeIterator *iterator, const WebCoreTextRun *run);
+extern UniChar shapeForNextCharacter (CharacterShapeIterator *iterator);
+extern bool hasShapeForNextCharacter (const CharacterShapeIterator *iterator);
diff --git a/WebKit/Misc.subproj/WebUnicode.m b/WebKit/Misc.subproj/WebUnicode.m
index f82bccf..02dc4e2 100644
--- a/WebKit/Misc.subproj/WebUnicode.m
+++ b/WebKit/Misc.subproj/WebUnicode.m
@@ -433,10 +433,10 @@ enum CursiveShape {
 
 UniChar replacementUniChar = 0xfffd;
 
-static inline UniChar *prevChar( UniChar *str, int stringLength, int pos )
+static inline const UniChar *prevChar( const UniChar *str, int stringLength, int pos )
 {
     pos--;
-    UniChar *ch = str + pos;
+    const UniChar *ch = str + pos;
     while( pos > -1 ) {
 	if( !_unicodeIsMark(*ch) )
 	    return ch;
@@ -446,11 +446,11 @@ static inline UniChar *prevChar( UniChar *str, int stringLength, int pos )
     return &replacementUniChar;
 }
 
-static inline UniChar *nextChar( UniChar *str, int stringLength, int pos)
+static inline const UniChar *nextChar( const UniChar *str, int stringLength, int pos)
 {
     pos++;
     int len = stringLength;
-    UniChar *ch = str + pos;
+    const UniChar *ch = str + pos;
     while( pos < len ) {
 	if( !_unicodeIsMark(*ch) )
 	    return ch;
@@ -460,18 +460,18 @@ static inline UniChar *nextChar( UniChar *str, int stringLength, int pos)
     return &replacementUniChar;
 }
 
-static inline bool prevLogicalCharJoins( UniChar *str, int stringLength, int pos)
+static inline bool prevLogicalCharJoins( const UniChar *str, int stringLength, int pos)
 {
     return ( _unicodeJoining(*nextChar( str, stringLength, pos )) != JoiningOther );
 }
 
-static inline bool nextLogicalCharJoins( UniChar *str, int stringLength, int pos)
+static inline bool nextLogicalCharJoins( const UniChar *str, int stringLength, int pos)
 {
     int join = _unicodeJoining(*prevChar( str, stringLength, pos ));
     return ( join == JoiningDual || join == JoiningCausing );
 }
 
-static int glyphVariantLogical( UniChar *str, int stringLength, int pos)
+static int glyphVariantLogical( const UniChar *str, int stringLength, int pos)
 {
     int joining = _unicodeJoining(str[pos]);
     switch ( joining ) {
@@ -495,13 +495,93 @@ static int shapeBufSize = 0;
 #define LTR 0
 #define RTL 1
 
+bool hasShapeForNextCharacter (const CharacterShapeIterator *iterator)
+{
+    if (iterator->currentCharacter - iterator->run->characters >= iterator->run->to)
+        return false;
+    return true;
+}
+
+UniChar shapeForNextCharacter (CharacterShapeIterator *iterator)
+{
+    const WebCoreTextRun *run = iterator->run;
+    int stringLength = run->length;
+    UniChar shapedCharacter = 0;
+    int pos = iterator->currentCharacter - run->characters;
+    
+    if (!hasShapeForNextCharacter(iterator))
+        return 0;
+    
+    UniChar currentCharacter = *iterator->currentCharacter;
+    UniChar r = WK_ROW(currentCharacter);
+    UniChar c = WK_CELL(currentCharacter);
+    if ( r != 0x06 ) {
+        if ( r == 0x20 ) {
+            switch ( c ) {
+                case 0x0C:
+                case 0x0D:
+                    goto skip;
+                default:
+                    break;
+            }
+        }
+        if (_unicodeMirrored(currentCharacter))
+            shapedCharacter = _unicodeMirroredChar(currentCharacter);
+        else
+            shapedCharacter = currentCharacter;
+    } else {
+        int shape = glyphVariantLogical( run->characters, stringLength, pos );
+        ushort map;
+        switch ( c ) {
+            case 0x44: {
+                const UniChar *pch = nextChar( run->characters, stringLength, pos );
+                if ( WK_ROW(*pch) == 0x06 ) {
+                    switch ( WK_CELL(*pch) ) {
+                        case 0x22:
+                        case 0x23:
+                        case 0x25:
+                        case 0x27:
+                            map = arabicUnicodeLamAlefMapping[WK_CELL(*pch) - 0x22][shape];
+                            goto next;
+                        default:
+                            break;
+                    }
+                }
+                break;
+            }
+            case 0x22: 
+            case 0x23: 
+            case 0x25: 
+            case 0x27: 
+                if ( *prevChar( run->characters, stringLength, pos ) == 0x0644 ) {
+                    goto skip;
+                }
+            default:
+                break;
+        }
+        map = getShape( c, shape );
+    next:
+        shapedCharacter = map;
+    }
+    
+skip:
+    iterator->currentCharacter++;
+
+    return shapedCharacter;
+}
 
-UniChar *shapedString(UniChar *uc, int stringLength, int from, int len, int dir, int *lengthOut)
+// Assumes input characters are logically ordered.
+bool initializeCharacterShapeIterator (CharacterShapeIterator *iterator, const WebCoreTextRun *run)
 {
+    int len = run->to - run->from;
+    int from = run->from;
+    int stringLength = run->length;
+    const UniChar *uc = run->characters;
+    
     if( len < 0 ) {
 	len = stringLength - from;
     } else if( len == 0 ) {
-	return 0;
+	return false;
     }
 
     int i;
@@ -510,10 +590,60 @@ UniChar *shapedString(UniChar *uc, int stringLength, int from, int len, int dir,
             break;
     }
     if (i == from+len)
+        return false;
+    
+    int num = stringLength - from - len;
+    iterator->currentCharacter = uc + from + len;
+    while ( num > 0 && _unicodeCombiningClass(*iterator->currentCharacter) != 0 ) {
+	iterator->currentCharacter++;
+	num--;
+	len++;
+    }
+
+    iterator->currentCharacter = uc + from;
+    while ( len > 0 && _unicodeCombiningClass(*iterator->currentCharacter) != 0 ) {
+	iterator->currentCharacter++;
+	len--;
+	from++;
+    }
+    if ( len == 0 )
+        return false;
+
+    if( !shapeBuffer || len > shapeBufSize ) {
+        if( shapeBuffer )
+            free( (void *) shapeBuffer );
+        shapeBuffer = (UniChar *) malloc( len*sizeof( UniChar ) );
+        shapeBufSize = len;
+    }
+    
+    iterator->run = run;
+    
+    return true;
+}
+
+UniChar *shapedString(const WebCoreTextRun *run, int dir, int *lengthOut)
+{
+    int len = run->to - run->from;
+    int from = run->from;
+    int stringLength = run->length;
+    const UniChar *uc = run->characters;
+
+    if( len < 0 ) {
+	len = stringLength - from;
+    } else if( len == 0 ) {
+	return 0;
+    }
+
+    int i;
+    for (i = from; i < from+len; i++){
+        if (uc[i] >= 0x600 && uc[i] <= 0x700)
+            break;
+    }
+    if (i == from+len)
         return 0;
     
     int num = stringLength - from - len;
-    UniChar *ch = uc + from + len;
+    const UniChar *ch = uc + from + len;
     while ( num > 0 && _unicodeCombiningClass(*ch) != 0 ) {
 	ch++;
 	num--;
@@ -568,7 +698,7 @@ UniChar *shapedString(UniChar *uc, int stringLength, int from, int len, int dir,
 	    ushort map;
 	    switch ( c ) {
 		case 0x44: {
-		    UniChar *pch = nextChar( uc, stringLength, pos );
+		    const UniChar *pch = nextChar( uc, stringLength, pos );
 		    if ( WK_ROW(*pch) == 0x06 ) {
 			switch ( WK_CELL(*pch) ) {
 			    case 0x22:
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
index ed88ed0..39ce16f 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.h
@@ -11,6 +11,7 @@ typedef struct GlyphMap GlyphMap;
 typedef struct GlyphEntry GlyphEntry;
 typedef struct UnicodeGlyphMap UnicodeGlyphMap;
 typedef struct SubstituteFontWidthMap SubstituteFontWidthMap;
+typedef struct CharacterWidthIterator CharacterWidthIterator;
 
 /// Should be more than enough for normal usage.
 #define NUM_SUBSTITUTE_FONT_MAPS	10
@@ -37,12 +38,11 @@ typedef struct SubstituteFontWidthMap SubstituteFontWidthMap;
     int numSubstituteFontWidthMaps;
     int maxSubstituteFontWidthMaps;
     SubstituteFontWidthMap *substituteFontWidthMaps;
+    BOOL usingPrinterFont;
     
 @private
     ATSUStyle _ATSUSstyle;
     BOOL ATSUStyleInitialized;
-
-    BOOL usingPrinterFont;
 }
 
 + (BOOL)shouldBufferTextDrawing;
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
index 553d01f..0d95a6b 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRenderer.m
@@ -93,6 +93,18 @@ struct SubstituteFontWidthMap {
     WidthMap *map;
 };
 
+struct CharacterWidthIterator
+{
+    WebTextRenderer *renderer;
+    const WebCoreTextRun *run;
+    const WebCoreTextStyle *style;
+    unsigned currentCharacter;
+    CharacterShapeIterator shapeIterator;
+    unsigned int needsShaping;
+};
+
+static void initializeCharacterWidthIterator (CharacterWidthIterator *iterator, WebTextRenderer *renderer, const WebCoreTextRun *run , const WebCoreTextStyle *style);
+static float widthForNextCharacter (CharacterWidthIterator *iterator);
 
 // These somewhat cryptically named constants were 'borrowed' from
 // some example carbon code.
@@ -166,6 +178,9 @@ static CFCharacterSetRef nonBaseChars = NULL;
 
 
 @interface WebTextRenderer (WebPrivate)
+
+- (NSFont *)substituteFontForCharacters: (const unichar *)characters length: (int)numCharacters families: (NSString **)families;
+
 - (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID font:(NSFont *)font;
 - (ATSGlyphRef)extendCharacterToGlyphMapToInclude:(UniChar) c;
 - (ATSGlyphRef)extendUnicodeCharacterToGlyphMapToInclude: (UnicodeChar)c;
@@ -331,10 +346,96 @@ static inline WebGlyphWidth widthForGlyph (WebTextRenderer *renderer, ATSGlyphRe
     return widthFromMap (renderer, map, glyph, font);
 }
 
-static inline  WebGlyphWidth widthForCharacter (WebTextRenderer *renderer, UniChar c, NSFont **font)
+
+void initializeCharacterWidthIterator (CharacterWidthIterator *iterator, WebTextRenderer *renderer, const WebCoreTextRun *run , const WebCoreTextStyle *style) 
+{
+    iterator->needsShaping = initializeCharacterShapeIterator (&iterator->shapeIterator, run);
+    iterator->renderer = renderer;
+    iterator->run = run;
+    iterator->style = style;
+    iterator->currentCharacter = run->from;
+}
+
+static float widthAndGlyphForSurrogate (WebTextRenderer *renderer, UniChar high, UniChar low, ATSGlyphRef *glyphID, NSString **families)
+{
+    UnicodeChar uc = UnicodeValueForSurrogatePair(high, low);
+    NSFont *font = renderer->font;
+
+    *glyphID = glyphForUnicodeCharacter(renderer->unicodeCharacterToGlyphMap, uc, &font);
+    if (*glyphID == nonGlyphID) {
+        *glyphID = [renderer extendUnicodeCharacterToGlyphMapToInclude: uc];
+    }
+
+    if (*glyphID == 0){
+        UniChar surrogates[2];
+        unsigned int clusterLength;
+        
+        clusterLength = 2;
+        surrogates[0] = high;
+        surrogates[1] = low;
+        NSFont *substituteFont = [renderer substituteFontForCharacters:&surrogates[0] length: clusterLength families: families];
+        if (substituteFont){
+            WebTextRenderer *substituteRenderer = [[WebTextRendererFactory sharedFactory] rendererWithFont:substituteFont usingPrinterFont:renderer->usingPrinterFont];
+            *glyphID = glyphForUnicodeCharacter(substituteRenderer->unicodeCharacterToGlyphMap, uc, &font);
+            if (*glyphID == nonGlyphID)
+                *glyphID = [substituteRenderer extendUnicodeCharacterToGlyphMapToInclude: uc];
+            return widthForGlyph (substituteRenderer, *glyphID, substituteFont);
+       }
+    }
+    return widthForGlyph (renderer, *glyphID, font);
+}
+
+static float widthForNextCharacter (CharacterWidthIterator *iterator)
 {
-    ATSGlyphRef glyphID = glyphForCharacter(renderer->characterToGlyphMap, c, font);
-    return widthForGlyph (renderer, glyphID, *font);
+    WebTextRenderer *renderer = iterator->renderer;
+    const WebCoreTextRun *run = iterator->run;
+    NSFont *font = renderer->font;
+    UniChar c;
+    unsigned int offset = iterator->currentCharacter;
+
+    if (offset >= run->length)
+        // Error!  Offset specified beyond end of run.
+        return 0;
+        
+    // Determine if the string requires any shaping, i.e. Arabic.
+    if (iterator->needsShaping)
+        c = shapeForNextCharacter(&iterator->shapeIterator);
+    else
+        c = run->characters[offset];
+    iterator->currentCharacter++;
+    
+    // It's legit to sometimes get 0 from the shape iterator, return a zero width.
+    if (c == 0)
+        return 0;
+
+
+    // Get a glyph for the next characters.  Somewhat complicated by surrogate
+    // pairs.
+    ATSGlyphRef glyphID;
+
+    // Do we have a surrogate pair?  If so, determine the full Unicode (32bit)
+    // code point before glyph lookup.  We only provide a width when the offset
+    // specifies the first component of the surrogate pair.
+    if (c >= HighSurrogateRangeStart && c <= HighSurrogateRangeEnd) {
+        UniChar high = c, low;
+
+        // Make sure we have another character and it's a low surrogate.
+        if (offset+1 >= run->length || !IsLowSurrogatePair((low = run->characters[offset+1]))) {
+            // Error!  The second component of the surrogate pair is missing.
+            return 0;
+        }
+
+        return widthAndGlyphForSurrogate (renderer, high, low, &glyphID, iterator->style->families);
+    }
+    else if (c >= LowSurrogateRangeStart && c <= LowSurrogateRangeEnd) {
+        // Return 0 width for second component of the surrogate pair.
+        return 0;
+    }
+    else
+        glyphID = glyphForCharacter(renderer->characterToGlyphMap, c, &font);
+    
+    // Now that we have glyph get it's width.
+    return widthForGlyph (renderer, glyphID, font);
 }
 
 
@@ -910,7 +1011,6 @@ static void _drawGlyphs(NSFont *font, NSColor *color, CGGlyph *glyphs, CGSize *a
     }
 }
 
-
 - (void)drawRun:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style atPoint:(NSPoint)point
 {
     if (shouldUseATSU(run))
@@ -1187,10 +1287,9 @@ static const char *joiningNames[] = {
     {
         UniChar *shaped;
         int lengthOut;
-        shaped = shapedString ((UniChar *)characters, stringLength,
-                               from,
-                               len,
-                               0, &lengthOut);
+
+        // FIXME:  Change to use the new CharacterShapeIterator internal API.
+        shaped = shapedString (run, 0, &lengthOut);        
         if (shaped){
              if (run->length < LOCAL_BUFFER_SIZE)
                  munged = &_localMunged[0];
@@ -1330,7 +1429,7 @@ static const char *joiningNames[] = {
                 
                 int j;
                 if (glyphBuffer){
-                    if (i == (unsigned int)run->from && startGlyph)
+                    if (i-1 == (unsigned int)run->from && startGlyph)
                         *startGlyph = numGlyphs;
                     for (j = 0; j < cNumGlyphs; j++){
                         glyphBuffer[numGlyphs+j] = localGlyphBuffer[j];
@@ -1429,7 +1528,7 @@ static const char *joiningNames[] = {
 #ifdef DEBUG_COMBINING        
         printf ("Character 0x%04x, joining attribute %d(%s), combining class %d, direction %d(%s)\n", c, WebCoreUnicodeJoiningFunction(c), joiningNames[WebCoreUnicodeJoiningFunction(c)], WebCoreUnicodeCombiningClassFunction(c), WebCoreUnicodeDirectionFunction(c), directionNames[WebCoreUnicodeDirectionFunction(c)]);
 #endif
-
+        
         if (i >= (unsigned int)pos)
             totalWidth += lastWidth;       
     }
@@ -1899,53 +1998,48 @@ static const char *joiningNames[] = {
     return offset;
 }
 
-
 #define LOCAL_WIDTH_BUF_SIZE 1024
 
 - (int)_CG_pointToOffset:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style position:(int)x reversed:(BOOL)reversed
 {
-    // FIXME.  This algorimth is the original KTHML algorithm.  We need to update it to
-    // be more savvy about unicode.
     float delta = (float)x;
-    float _widths[LOCAL_WIDTH_BUF_SIZE]; 
-    float *widths = 0, width;
-    unsigned int offset = 0;
-
-    if (run->length > LOCAL_WIDTH_BUF_SIZE)
-        widths = (float *)malloc(run->length * sizeof(float));
-    else
-        widths = &_widths[0];
-    width = [self floatWidthForRun:run style:style widths:widths];
+    float width;
+    unsigned int offset = run->from;
+    CharacterWidthIterator widthIterator;
+    
+    initializeCharacterWidthIterator(&widthIterator, self, run, style);
 
-    if ( reversed ) {
+    if (reversed) {
+        width = [self floatWidthForRun:run style:style widths:nil];
         delta -= width;
         while(offset < run->length) {
-            float w = widths[offset+run->from];
-            float w2 = w/2;
-            w -= w2;
-            delta += w2;
-            if(delta >= 0)
-                break;
+            float w = widthForNextCharacter(&widthIterator);
+            if (w){
+                float w2 = w/2;
+                w -= w2;
+                delta += w2;
+                if(delta >= 0)
+                    break;
+                delta += w;
+            }
             offset++;
-            delta += w;
         }
     } else {
         while(offset < run->length) {
-            float w = widths[offset+run->from];
-            float w2 = w/2;
-            w -= w2;
-            delta -= w2;
-            if(delta <= 0) 
-                break;
+            float w = widthForNextCharacter(&widthIterator);
+            if (w){
+                float w2 = w/2;
+                w -= w2;
+                delta -= w2;
+                if(delta <= 0) 
+                    break;
+                delta -= w;
+            }
             offset++;
-            delta -= w;
         }
     }
     
-    if (widths != _widths)
-        free (widths);
-        
-    return offset;
+    return offset - run->from;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index 7b03ea3..1862555 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -436,7 +436,7 @@ static WebHTMLView *lastHitView = nil;
 
     if (clipLabelString)
 	    label = [WebStringTruncator rightTruncateString: label toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2) withFont:labelFont];
-    [label _web_drawDoubledAtPoint:NSMakePoint (DRAG_LABEL_BORDER_X, imageSize.height - DRAG_LABEL_BORDER_Y_OFFSET - [labelFont ascender])
+    [label _web_drawDoubledAtPoint:NSMakePoint (DRAG_LABEL_BORDER_X, imageSize.height - DRAG_LABEL_BORDER_Y_OFFSET - [labelFont pointSize])
              withTopColor:topColor bottomColor:bottomColor font:labelFont];
     
     [dragImage unlockFocus];

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list