[webkit-changes] cvs commit: WebCore/kwq WebCoreBridge.mm

Justin justing at opensource.apple.com
Tue Dec 20 18:05:13 PST 2005


justing     05/12/20 18:05:13

  Modified:    .        ChangeLog
               khtml/editing visible_text.cpp
               kwq      WebCoreBridge.mm
  Log:
          Reviewed by justin
  
          <http://bugzilla.opendarwin.org/show_bug.cgi?id=4682>
          -[WebHTMLView firstRectForCharacterRange:] is using _selectedRange instead of the given range if no marked text
  
          Added layout tests:
          * editing/input/firstrectforcharacterrange-styled
          * editing/input/firstrectforcharacterrange-plain
  
          * khtml/editing/visible_text.cpp:
          (khtml::TextIterator::rangeFromLocationAndLength):
          Return null if the range isn't found, instead of a startless/endless
          range.  Set the end if the requested location+length is out of bounds.
          * kwq/WebCoreBridge.mm:
          (-[WebCoreBridge convertToDOMRange:]): Handle larged unsigned values
          before calling rangeWithLocationAndLength, which expects signed ints.
  
  Revision  Changes    Path
  1.17      +19 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ChangeLog	21 Dec 2005 00:48:55 -0000	1.16
  +++ ChangeLog	21 Dec 2005 02:05:11 -0000	1.17
  @@ -1,3 +1,22 @@
  +2005-12-20  Alexey Proskuryakov  <ap at nypop.com>
  +
  +        Reviewed by justin
  +        
  +        <http://bugzilla.opendarwin.org/show_bug.cgi?id=4682>
  +        -[WebHTMLView firstRectForCharacterRange:] is using _selectedRange instead of the given range if no marked text
  +
  +        Added layout tests:
  +        * editing/input/firstrectforcharacterrange-styled
  +        * editing/input/firstrectforcharacterrange-plain
  +
  +        * khtml/editing/visible_text.cpp:
  +        (khtml::TextIterator::rangeFromLocationAndLength): 
  +        Return null if the range isn't found, instead of a startless/endless 
  +        range.  Set the end if the requested location+length is out of bounds.
  +        * kwq/WebCoreBridge.mm:
  +        (-[WebCoreBridge convertToDOMRange:]): Handle larged unsigned values 
  +        before calling rangeWithLocationAndLength, which expects signed ints.
  +
   2005-12-20  Adele Peterson  <adele at apple.com>
   
           Reviewed by Darin.
  
  
  
  1.44      +21 -5     WebCore/khtml/editing/visible_text.cpp
  
  Index: visible_text.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/editing/visible_text.cpp,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- visible_text.cpp	10 Dec 2005 20:34:42 -0000	1.43
  +++ visible_text.cpp	21 Dec 2005 02:05:11 -0000	1.44
  @@ -990,11 +990,16 @@
   
       int docTextPosition = 0;
       int rangeEnd = rangeLocation + rangeLength;
  +    bool startRangeFound = false;
  +
  +    RefPtr<RangeImpl> textRunRange;
   
       for (TextIterator it(rangeOfContents(doc).get()); !it.atEnd(); it.advance()) {
           int len = it.length();
  +        textRunRange = it.range();
  +
           if (rangeLocation >= docTextPosition && rangeLocation <= docTextPosition + len) {
  -            RefPtr<RangeImpl> textRunRange = it.range();
  +            startRangeFound = true;
               int exception = 0;
               if (textRunRange->startContainer(exception)->isTextNode()) {
                   int offset = rangeLocation - docTextPosition;
  @@ -1007,8 +1012,8 @@
                   }
               }
           }
  +
           if (rangeEnd >= docTextPosition && rangeEnd <= docTextPosition + len) {
  -            RefPtr<RangeImpl> textRunRange = it.range();
               int exception = 0;
               if (textRunRange->startContainer(exception)->isTextNode()) {
                   int offset = rangeEnd - docTextPosition;
  @@ -1020,13 +1025,24 @@
                       resultRange->setEnd(textRunRange->endContainer(exception), textRunRange->endOffset(exception), exception);
                   }
               }
  -            if ( !(rangeLength == 0 && rangeEnd == docTextPosition + len) ) {
  +            if (!(rangeLength == 0 && rangeEnd == docTextPosition + len)) {
  +                docTextPosition += len;
                   break;
               }
           }
  -        docTextPosition += it.length();
  +        docTextPosition += len;
       }
  -
  +    
  +    if (!startRangeFound) {
  +        delete resultRange;
  +        return 0;
  +    }
  +    
  +    if (rangeLength != 0 && rangeEnd > docTextPosition) { // rangeEnd is out of bounds
  +        int exception = 0;
  +        resultRange->setEnd(textRunRange->endContainer(exception), textRunRange->endOffset(exception), exception);
  +    }
  +    
       return resultRange;
   }
   
  
  
  
  1.444     +5 -0      WebCore/kwq/WebCoreBridge.mm
  
  Index: WebCoreBridge.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
  retrieving revision 1.443
  retrieving revision 1.444
  diff -u -r1.443 -r1.444
  --- WebCoreBridge.mm	14 Dec 2005 23:32:02 -0000	1.443
  +++ WebCoreBridge.mm	21 Dec 2005 02:05:12 -0000	1.444
  @@ -1679,6 +1679,11 @@
   
   - (RangeImpl *)convertToDOMRange:(NSRange)nsrange
   {
  +    if (nsrange.location > INT_MAX)
  +        return 0;
  +    if (nsrange.length > INT_MAX || nsrange.location + nsrange.length > INT_MAX)
  +        nsrange.length = INT_MAX - nsrange.location;
  +
       return TextIterator::rangeFromLocationAndLength(_part->xmlDocImpl(), nsrange.location, nsrange.length);
   }
   
  
  
  



More information about the webkit-changes mailing list