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

David harrison at opensource.apple.com
Mon Oct 24 12:40:08 PDT 2005


harrison    05/10/24 12:40:08

  Modified:    .        ChangeLog
               WebCoreSupport.subproj WebTextRenderer.m
  Log:
          Reviewed by Darin.  Committed by David Harrison.
  
          http://bugzilla.opendarwin.org/show_bug.cgi?id=5415
          "Left border of selection highlight leaves behind a trail"
  
          * manual-tests/drag_select_highlighting.html: Added.
          (this test case was added to WebCore)
  
          * WebCoreSupport.subproj/WebTextRenderer.m:
          (overrideLayoutOperation):
          (-[WebTextRenderer CG_drawHighlightForRun:style:geometry:]):
          (-[WebTextRenderer ATSU_drawHighlightForRun:style:geometry:]):
          (advanceWidthIterator):
  
  Revision  Changes    Path
  1.3361    +17 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3360
  retrieving revision 1.3361
  diff -u -r1.3360 -r1.3361
  --- ChangeLog	24 Oct 2005 02:13:11 -0000	1.3360
  +++ ChangeLog	24 Oct 2005 19:40:00 -0000	1.3361
  @@ -1,3 +1,20 @@
  +2005-10-24  Mitz Pettel  <opendarwin.org at mitzpettel.com>
  +
  +        Reviewed by Darin.  Committed by David Harrison.
  +
  +        http://bugzilla.opendarwin.org/show_bug.cgi?id=5415
  +        "Left border of selection highlight leaves behind a trail"
  +        
  +        * manual-tests/drag_select_highlighting.html: Added.
  +        (this test case was added to WebCore)
  +   
  +        * WebCoreSupport.subproj/WebTextRenderer.m:
  +        (overrideLayoutOperation):
  +        (-[WebTextRenderer CG_drawHighlightForRun:style:geometry:]):
  +        (-[WebTextRenderer ATSU_drawHighlightForRun:style:geometry:]):
  +        (advanceWidthIterator):
  +
  +
   2005-10-23  Tim Omernick  <tomernick at apple.com>
   
           Reviewed by Dave Hyatt.
  
  
  
  1.200     +18 -8     WebKit/WebCoreSupport.subproj/WebTextRenderer.m
  
  Index: WebTextRenderer.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebTextRenderer.m,v
  retrieving revision 1.199
  retrieving revision 1.200
  diff -u -r1.199 -r1.200
  --- WebTextRenderer.m	21 Oct 2005 16:35:25 -0000	1.199
  +++ WebTextRenderer.m	24 Oct 2005 19:40:07 -0000	1.200
  @@ -251,7 +251,7 @@
               lastAdjustedPos = lastAdjustedPos + width;
               if (isRoundingHackCharacter(nextCh))
                   if (!isLastChar
  -                        || (style->applyRunRounding && (run->length == 1 || run->to - run->from > 1))
  +                        || style->applyRunRounding
                           || (run->to < (int)run->length && isRoundingHackCharacter(characters[run->to])))
                       lastAdjustedPos = ceilf(lastAdjustedPos);
               layoutRecords[i].realPos = FloatToFixed(lastAdjustedPos);
  @@ -865,14 +865,20 @@
       
       advanceWidthIterator(&it, run->from, 0, 0, 0);
       float beforeWidth = it.runWidthSoFar;
  +    // apply rounding as if this is the end of the run, since that's how RenderText::selectionRect() works
  +    if ((style->applyWordRounding && isRoundingHackCharacter(run->characters[run->from]))
  +            || style->applyRunRounding)
  +        beforeWidth = ceilf(beforeWidth);
       advanceWidthIterator(&it, run->to, 0, 0, 0);
       float backgroundWidth = it.runWidthSoFar - beforeWidth;
       if (style->rtl) {
           advanceWidthIterator(&it, run->length, 0, 0, 0);
  -        float afterWidth = it.runWidthSoFar;
  -        [NSBezierPath fillRect:NSMakeRect(geometry->point.x + afterWidth, yPos, backgroundWidth, height)];
  +        float totalWidth = it.runWidthSoFar;
  +        if (style->applyRunRounding)
  +            totalWidth = ceilf(totalWidth);
  +        [NSBezierPath fillRect:NSMakeRect(geometry->point.x + roundf(totalWidth - backgroundWidth - beforeWidth), yPos, roundf(backgroundWidth), height)];
       } else {
  -        [NSBezierPath fillRect:NSMakeRect(geometry->point.x + beforeWidth, yPos, backgroundWidth, height)];
  +        [NSBezierPath fillRect:NSMakeRect(geometry->point.x + roundf(beforeWidth), yPos, roundf(backgroundWidth), height)];
       }
   }
   
  @@ -1391,15 +1397,19 @@
       else while (j < count - 1 && layoutRecords[j].originalOffset >= sizeof(UniChar) * aRun->from)
               j++;
       
  -    float backgroundWidth = FixedToFloat(layoutRecords[j].realPos - layoutRecords[i].realPos);
  +    float beforeWidth = FixedToFloat(layoutRecords[i].realPos);
  +    if ((style->applyWordRounding && isRoundingHackCharacter(run->characters[run->from])) || style->applyRunRounding)
  +        beforeWidth = ceilf(beforeWidth);
  +    float afterWidth = FixedToFloat(layoutRecords[j].realPos);
  +    float backgroundWidth = afterWidth - beforeWidth;
   
  -    selectedLeftX = geometry->point.x + FixedToFloat(layoutRecords[i].realPos);
  +    selectedLeftX = geometry->point.x + beforeWidth;
       
       [style->backgroundColor set];
   
       float yPos = geometry->useFontMetricsForSelectionYAndHeight ? geometry->point.y - [self ascent] : geometry->selectionY;
       float height = geometry->useFontMetricsForSelectionYAndHeight ? [self lineSpacing] : geometry->selectionHeight;
  -    [NSBezierPath fillRect:NSMakeRect(selectedLeftX, yPos, backgroundWidth, height)];
  +    [NSBezierPath fillRect:NSMakeRect(roundf(selectedLeftX), yPos, roundf(backgroundWidth), height)];
   
       disposeATSULayoutParameters(&params);
   
  @@ -1847,7 +1857,7 @@
           // Check to see if the next character is a "rounding hack character", if so, adjust
           // width so that the total run width will be on an integer boundary.
           if ((style->applyWordRounding && currentCharacter < run->length && isRoundingHackCharacter(*cp))
  -                || (style->applyRunRounding && currentCharacter >= (unsigned)run->to && (run->length == 1 || run->to - run->from > 1))) {
  +                || (style->applyRunRounding && currentCharacter >= (unsigned)run->to)) {
               float totalWidth = iterator->widthToStart + runWidthSoFar + width;
               width += ceilf(totalWidth) - totalWidth;
           }
  
  
  



More information about the webkit-changes mailing list