Commit b4635089 authored by rjw's avatar rjw
Browse files

Fixed likely cause of 3099047 (and others). Width buffer could underrun in

        some situations.

        * WebCoreSupport.subproj/WebTextRenderer.m:
        (-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2645 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5b288376
2002-11-12 Richard Williamson <rjw@apple.com>
Fixed likely cause of 3099047 (and others). Width buffer could underrun in
some situations.
* WebCoreSupport.subproj/WebTextRenderer.m:
(-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:]):
2002-11-12 John Sullivan <sullivan@apple.com>
 
* Misc.subproj/WebNSViewExtras.h:
......
2002-11-12 Richard Williamson <rjw@apple.com>
Fixed likely cause of 3099047 (and others). Width buffer could underrun in
some situations.
* WebCoreSupport.subproj/WebTextRenderer.m:
(-[WebTextRenderer _floatWidthForCharacters:stringLength:fromCharacterPosition:numberOfCharacters:withPadding:applyRounding:attemptFontSubstitution:widths:fonts:glyphs:numGlyphs:letterSpacing:wordSpacing:]):
2002-11-12 John Sullivan <sullivan@apple.com>
 
* Misc.subproj/WebNSViewExtras.h:
......
......@@ -747,7 +747,7 @@ - (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsi
if (c == SPACE && applyRounding) {
float delta = CEIL_TO_INT(totalWidth) - totalWidth;
totalWidth += delta;
if (widthBuffer)
if (widthBuffer && numGlyphs > 0)
widthBuffer[numGlyphs - 1] += delta;
}
break;
......@@ -844,10 +844,12 @@ - (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsi
// should have zero width.
if (widthBuffer){
int ng = numGlyphs-1;
if (ng >= 0){
while (ng && widthBuffer[ng] == 0)
ng--;
widthBuffer[ng] += wordSpacing;
}
}
totalWidth += wordSpacing;
}
......@@ -863,12 +865,13 @@ - (float)_floatWidthForCharacters:(const UniChar *)characters stringLength:(unsi
totalWidth += lastWidth;
}
// Don't ever apply rounding for single character. Single character measurement
// intra word needs to be non-ceiled.
// Ceil the last glyph, but only if
// 1) The string is longer than one character
// 2) or the entire stringLength is one character
if ((len > 1 || stringLength == 1) && applyRounding){
float delta = CEIL_TO_INT(totalWidth) - totalWidth;
totalWidth += delta;
if (widthBuffer)
if (widthBuffer && numGlyphs > 0)
widthBuffer[numGlyphs-1] += delta;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment