[webkit-changes] cvs commit: WebCore/khtml/rendering font.h

Geoffrey ggaren at opensource.apple.com
Thu Dec 29 03:27:07 PST 2005


ggaren      05/12/29 03:27:07

  Modified:    .        ChangeLog
               WebCoreSupport.subproj WebTextRenderer.m
               .        ChangeLog
               khtml/rendering font.h
  Log:
  WebCore:
  
          Reviewed by darin
  
          - WebCore part of fix for
            http://bugzilla.opendarwin.org/show_bug.cgi?id=3922
            Variable word/letter spacing and full justification not supported for
            ATSUI-rendered text
  
          * khtml/rendering/font.h:
          (khtml::Font::checkSelectionPoint): Make sure the complete run, used for
          counting spaces and determining padding per space does not go beyond the
          text box.
  
  WebKit:
  
          Reviewed by darin
  
          Test: fast/text/atsui-spacing-features.html
  
          - WebKit part of fix for
            http://bugzilla.opendarwin.org/show_bug.cgi?id=3922
            Variable word/letter spacing and full justification not supported for
            ATSUI-rendered text
  
          * WebCoreSupport.subproj/WebTextRenderer.m:
          (overrideLayoutOperation): Add letter- and word-spacing and padding for
          justification.
          (createATSULayoutParameters): Compute padding per space.
  
  Revision  Changes    Path
  1.3431    +16 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3430
  retrieving revision 1.3431
  diff -u -r1.3430 -r1.3431
  --- ChangeLog	27 Dec 2005 19:06:38 -0000	1.3430
  +++ ChangeLog	29 Dec 2005 11:27:03 -0000	1.3431
  @@ -1,3 +1,19 @@
  +2005-12-29  Mitz Pettel  <opendarwin.org at mitzpettel.com>
  +
  +        Reviewed by darin 
  +        
  +        Test: fast/text/atsui-spacing-features.html
  +
  +        - WebKit part of fix for
  +          http://bugzilla.opendarwin.org/show_bug.cgi?id=3922
  +          Variable word/letter spacing and full justification not supported for
  +          ATSUI-rendered text
  +
  +        * WebCoreSupport.subproj/WebTextRenderer.m:
  +        (overrideLayoutOperation): Add letter- and word-spacing and padding for
  +        justification.
  +        (createATSULayoutParameters): Compute padding per space.
  +
   2005-12-27  Mitz Pettel  <opendarwin.org at mitzpettel.com>
   
           Reviewed by Maciej, landed by Darin.
  
  
  
  1.210     +38 -6     WebKit/WebCoreSupport.subproj/WebTextRenderer.m
  
  Index: WebTextRenderer.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebTextRenderer.m,v
  retrieving revision 1.209
  retrieving revision 1.210
  diff -u -r1.209 -r1.210
  --- WebTextRenderer.m	27 Dec 2005 19:06:46 -0000	1.209
  +++ WebTextRenderer.m	29 Dec 2005 11:27:06 -0000	1.210
  @@ -117,6 +117,7 @@
       UniChar *charBuffer;
       bool hasSyntheticBold;
       bool syntheticBoldPass;
  +    float padPerSpace;
   } ATSULayoutParameters;
   
   static WebTextRenderer *rendererForAlternateFont(WebTextRenderer *, WebCoreFont);
  @@ -245,6 +246,8 @@
           bool syntheticBoldPass = params->syntheticBoldPass;
           Fixed syntheticBoldOffset = 0;
           ATSGlyphRef spaceGlyph = 0;
  +        bool hasExtraSpacing = style->letterSpacing | style->wordSpacing | style->padding;
  +        float padding = style->padding;
           // In the CoreGraphics code path, the rounding hack is applied in logical order.
           // Here it is applied in visual left-to-right order, which may be better.
           ItemCount i;
  @@ -262,12 +265,6 @@
                       spaceGlyph = renderer->spaceGlyph;
                   }
               }
  -            ch = nextCh;
  -            offset = layoutRecords[i].originalOffset;
  -            // Use space for nextCh at the end of the loop so that we get inside the rounding hack code.
  -            // We won't actually round unless the other conditions are satisfied.
  -            nextCh = isLastChar ? ' ' : *(UniChar *)(((char *)characters)+offset);
  -
               float width = FixedToFloat(layoutRecords[i].realPos - lastNativePos);
               lastNativePos = layoutRecords[i].realPos;
               if (shouldRound)
  @@ -275,6 +272,31 @@
               width += renderer->syntheticBoldOffset;
               if (renderer->treatAsFixedPitch ? width == renderer->spaceWidth : (layoutRecords[i-1].flags & kATSGlyphInfoIsWhiteSpace))
                   width = renderer->adjustedSpaceWidth;
  +
  +            if (hasExtraSpacing) {
  +                if (width && style->letterSpacing)
  +                    width +=style->letterSpacing;
  +                if (isSpace(nextCh)) {
  +                    if (style->padding) {
  +                        if (padding < params->padPerSpace) {
  +                            width += padding;
  +                            padding = 0;
  +                        } else {
  +                            width += params->padPerSpace;
  +                            padding -= params->padPerSpace;
  +                        }
  +                    }
  +                    if (offset != 0 && !isSpace(ch) && style->wordSpacing)
  +                        width += style->wordSpacing;
  +                }
  +            }
  +
  +            ch = nextCh;
  +            offset = layoutRecords[i].originalOffset;
  +            // Use space for nextCh at the end of the loop so that we get inside the rounding hack code.
  +            // We won't actually round unless the other conditions are satisfied.
  +            nextCh = isLastChar ? ' ' : *(UniChar *)(((char *)characters)+offset);
  +
               if (isRoundingHackCharacter(ch))
                   width = ceilf(width);
               lastAdjustedPos = lastAdjustedPos + width;
  @@ -1352,6 +1374,16 @@
           }
           substituteOffset += substituteLength;
       }
  +    if (style->padding) {
  +        float numSpaces = 0;
  +        unsigned k;
  +        for (k = 0; k < totalLength; k++)
  +            if (isSpace(run->characters[k]))
  +                numSpaces++;
  +
  +        params->padPerSpace = ceilf((float)style->padding / numSpaces);
  +    } else
  +        params->padPerSpace = 0;
   }
   
   static void disposeATSULayoutParameters(ATSULayoutParameters *params)
  
  
  
  1.54      +14 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- ChangeLog	29 Dec 2005 10:36:22 -0000	1.53
  +++ ChangeLog	29 Dec 2005 11:27:06 -0000	1.54
  @@ -1,3 +1,17 @@
  +2005-12-29  Mitz Pettel  <opendarwin.org at mitzpettel.com>
  +
  +        Reviewed by darin
  +
  +        - WebCore part of fix for
  +          http://bugzilla.opendarwin.org/show_bug.cgi?id=3922
  +          Variable word/letter spacing and full justification not supported for
  +          ATSUI-rendered text
  +
  +        * khtml/rendering/font.h:
  +        (khtml::Font::checkSelectionPoint): Make sure the complete run, used for
  +        counting spaces and determining padding per space does not go beyond the
  +        text box.
  +
   2005-12-28  Geoffrey Garen  <ggaren at apple.com>
   
           Reviewed by mjs.
  
  
  
  1.37      +1 -1      WebCore/khtml/rendering/font.h
  
  Index: font.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/font.h,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- font.h	17 Dec 2005 18:10:26 -0000	1.36
  +++ font.h	29 Dec 2005 11:27:07 -0000	1.37
  @@ -129,7 +129,7 @@
   
   inline int Font::checkSelectionPoint(QChar *s, int slen, int pos, int len, int toAdd, int tabWidth, int xpos, int x, QPainter::TextDirection d, bool visuallyOrdered, bool includePartialGlyphs) const
   {
  -    return fm.checkSelectionPoint(s + pos, slen - pos, 0, len, toAdd, tabWidth, xpos, letterSpacing, wordSpacing, fontDef.smallCaps, x, d == QPainter::RTL, visuallyOrdered, includePartialGlyphs);
  +    return fm.checkSelectionPoint(s + pos, std::min(slen - pos, len), 0, len, toAdd, tabWidth, xpos, letterSpacing, wordSpacing, fontDef.smallCaps, x, d == QPainter::RTL, visuallyOrdered, includePartialGlyphs);
   }
   
   inline int Font::width(QChar *chs, int slen, int pos, int len, int tabWidth, int xpos) const
  
  
  



More information about the webkit-changes mailing list