[webkit-changes] cvs commit: WebKit/WebCoreSupport.subproj WebTextRendererFactory.m

John sullivan at opensource.apple.com
Tue Dec 20 17:16:48 PST 2005


sullivan    05/12/20 17:16:48

  Modified:    .        ChangeLog
               WebCoreSupport.subproj WebTextRendererFactory.m
  Log:
          Reviewed by Darin Adler.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=6146
            (REGRESSION: Bold font used for Google search result pages is too thick)
  
          This is a problem with a particular font that was installed by Microsoft Office X. Though the
          font and/or lower levels of font-handling code in the system are buggy, this bad symptom will
          occur for users of Safari and other WebKit clients who happen to have one of these bad fonts.
          This adds a workaround to avoid the problem.
  
          * WebCoreSupport.subproj/WebTextRendererFactory.m:
          (-[WebTextRendererFactory fontWithFamilies:traits:size:]):
          When we're going to synthesize bold or italic, yet the font we looked up was apparently a
          match for the traits, try to look up a font that without the to-be-synthesized traits.
          This way, instead of applying synthetic bold over Arial Bold, we'll apply synthetic
          bold over Arial Regular, which is uglier than just using Arial Bold, but far less ugly
          than using Arial Bold with synthetic bold too.
  
   2005-12-16  Justin Garcia  <justin.garcia at apple.com>
  
           <rdar://problem/4103393> Frequent Safari crash on lexisnexus.com (khtml::Selection::xPosForVerticalArrowNavigation)
           <rdar://problem/4330451> CrashTracer: [REGRESSION] 2235 crashes in Safari at com.apple.WebCore: khtml::Selection::xPosForVerticalArrowNavigation const  436
  
           Reviewed by darin
  
           WebCore will crash when a selection that starts or ends in a node
           that has been removed from the document is modify()d.  This can occur:
           (1) in non-editable regions (4103393 and 4330451), (2) in editable
           regions (4383146) as the result of arbitrary DOM operations, and (3) in
           Mail (4099739) as the result of an editing operation that sets a
           bad ending selection.
  
           Crashes of type (1) can occur when the user uses the arrow keys
           to interact with a web app, or when the user tries to use
           command-shift-arrow to switch tabs (this is a depricated
           combo that will work if no one else responds to it). The easiest
           way to fix these crashes is to disallow editing'ish selection changes
           like moveDown:, selectWord:, pageDown:, etc, when the selection
           is in a non-editable region.
  
           Crashes of type (2) will require a more complicated fix (but occur
           much less often than type (1)).  Crashes of type (3) must be
           fixed by tracking down the editing operation that sets bad selections.
  
           Added a layout-test:
           * editing/selection/selection-actions.html
  
           * WebView.subproj/WebHTMLView.m:
           (-[WebHTMLView _canAlterCurrentSelection]):
           (-[WebHTMLView _alterCurrentSelection:direction:granularity:]):
           (-[WebHTMLView _alterCurrentSelection:verticalDistance:]):
           (-[WebHTMLView _expandSelectionToGranularity:]):
           * WebView.subproj/WebHTMLViewPrivate.h:
  
  Revision  Changes    Path
  1.3422    +20 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3421
  retrieving revision 1.3422
  diff -u -r1.3421 -r1.3422
  --- ChangeLog	21 Dec 2005 00:22:55 -0000	1.3421
  +++ ChangeLog	21 Dec 2005 01:16:38 -0000	1.3422
  @@ -1,3 +1,23 @@
  +2005-12-20  John Sullivan  <sullivan at apple.com>
  +
  +        Reviewed by Darin Adler.
  +        
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=6146
  +          (REGRESSION: Bold font used for Google search result pages is too thick)
  +          
  +        This is a problem with a particular font that was installed by Microsoft Office X. Though the
  +        font and/or lower levels of font-handling code in the system are buggy, this bad symptom will
  +        occur for users of Safari and other WebKit clients who happen to have one of these bad fonts.
  +        This adds a workaround to avoid the problem.
  +
  +        * WebCoreSupport.subproj/WebTextRendererFactory.m:
  +        (-[WebTextRendererFactory fontWithFamilies:traits:size:]):
  +        When we're going to synthesize bold or italic, yet the font we looked up was apparently a
  +        match for the traits, try to look up a font that without the to-be-synthesized traits.
  +        This way, instead of applying synthetic bold over Arial Bold, we'll apply synthetic
  +        bold over Arial Regular, which is uglier than just using Arial Bold, but far less ugly
  +        than using Arial Bold with synthetic bold too.
  +
    2005-12-16  Justin Garcia  <justin.garcia at apple.com>
    
            <rdar://problem/4103393> Frequent Safari crash on lexisnexus.com (khtml::Selection::xPosForVerticalArrowNavigation)
  
  
  
  1.48      +30 -2     WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
  
  Index: WebTextRendererFactory.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- WebTextRendererFactory.m	6 Oct 2005 15:46:09 -0000	1.47
  +++ WebTextRendererFactory.m	21 Dec 2005 01:16:47 -0000	1.48
  @@ -278,12 +278,18 @@
   - (WebCoreFont)fontWithFamilies:(NSString **)families traits:(NSFontTraitMask)traits size:(float)size
   {
       NSFont *font = nil;
  +    NSString *matchedFamily = nil;
       
       int i = 0;
       while (families && families[i] != 0 && font == nil) {
           NSString *family = families[i++];
  -        if ([family length] != 0)
  +        if ([family length] != 0) {
               font = [self cachedFontFromFamily:family traits:traits size:size];
  +            if (font) {
  +                matchedFamily = family;
  +                break;
  +            }
  +        }
       }
   
       if (font == nil) {
  @@ -313,12 +319,34 @@
       NSFontTraitMask actualTraits = 0;
       if (traits & (NSItalicFontMask | NSBoldFontMask))
           actualTraits = [[NSFontManager sharedFontManager] traitsOfFont:font];
  -
  +    
       WebCoreFont result;
       result.font = font;
       result.syntheticBold = (traits & NSBoldFontMask) && !(actualTraits & NSBoldFontMask);
       result.syntheticOblique = (traits & NSItalicFontMask) && !(actualTraits & NSItalicFontMask);
       result.forPrinter = NO;
  +    
  +    // There are some malformed fonts that will be correctly returned by -cachedFontForFamily:traits:size: as a match for a particular trait,
  +    // though -[NSFontManager traitsOfFont:] incorrectly claims the font does not have the specified trait. This could result in applying 
  +    // synthetic bold on top of an already-bold font, as reported in <http://bugzilla.opendarwin.org/show_bug.cgi?id=6146>. To work around this
  +    // problem, if we got an apparent exact match, but the requested traits aren't present in the matched font, we'll try to get a font from 
  +    // the same family without those traits (to apply the synthetic traits to later).
  +    if (matchedFamily) {
  +        NSFontTraitMask nonSyntheticTraits = traits;
  +        
  +        if (result.syntheticBold)
  +            nonSyntheticTraits &= ~NSBoldFontMask;
  +        
  +        if (result.syntheticOblique)
  +            nonSyntheticTraits &= ~NSItalicFontMask;
  +        
  +        if (nonSyntheticTraits != traits) {
  +            NSFont *fontWithoutSyntheticTraits = [self cachedFontFromFamily:matchedFamily traits:nonSyntheticTraits size:size];
  +            if (fontWithoutSyntheticTraits)
  +                result.font = fontWithoutSyntheticTraits;
  +        }
  +    }
  +    
       return result;
   }
   
  
  
  



More information about the webkit-changes mailing list