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

Darin darin at opensource.apple.com
Tue Nov 29 09:52:58 PST 2005


darin       05/11/29 09:52:57

  Modified:    .        ChangeLog
               kwq      KWQKURL.h KWQKURL.mm
  Log:
          Reviewed by Maciej.
  
          - fixed http://bugzilla.opendarwin.org/show_bug.cgi?5683
            add code so we can use CFURL instead of NSURL for speed
  
          * kwq/KWQKURL.h: Added declaration of createCFURL function.
          * kwq/KWQKURL.mm:
          (KURL::createCFURL): Moved body of getNSURL in here.
          (KURL::getNSURL): Changed to createCFURL.
  
  Revision  Changes    Path
  1.428     +12 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.427
  retrieving revision 1.428
  diff -u -r1.427 -r1.428
  --- ChangeLog	29 Nov 2005 17:44:00 -0000	1.427
  +++ ChangeLog	29 Nov 2005 17:52:53 -0000	1.428
  @@ -1,5 +1,17 @@
   2005-11-29  Darin Adler  <darin at apple.com>
   
  +        Reviewed by Maciej.
  +
  +        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?5683
  +          add code so we can use CFURL instead of NSURL for speed
  +
  +        * kwq/KWQKURL.h: Added declaration of createCFURL function.
  +        * kwq/KWQKURL.mm:
  +        (KURL::createCFURL): Moved body of getNSURL in here.
  +        (KURL::getNSURL): Changed to createCFURL.
  +
  +2005-11-29  Darin Adler  <darin at apple.com>
  +
           - fixed broken tree (from my last check-in)
   
           * kwq/DOM-CSS.mm: Added "using namespace DOM" and an import of "dom_docimpl.h".
  
  
  
  1.40      +1 -1      WebCore/kwq/KWQKURL.h
  
  Index: KWQKURL.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKURL.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- KWQKURL.h	17 Feb 2005 01:34:06 -0000	1.39
  +++ KWQKURL.h	29 Nov 2005 17:52:57 -0000	1.40
  @@ -77,8 +77,8 @@
   
       QString prettyURL() const;
       
  +    CFURLRef createCFURL() const;
       NSURL *getNSURL() const;
  -    NSData *getNSData() const;
   
       bool isLocalFile() const;
   
  
  
  
  1.96      +11 -20    WebCore/kwq/KWQKURL.mm
  
  Index: KWQKURL.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQKURL.mm,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- KWQKURL.mm	1 Nov 2005 17:21:42 -0000	1.95
  +++ KWQKURL.mm	29 Nov 2005 17:52:57 -0000	1.96
  @@ -1475,31 +1475,22 @@
       return result;
   }
   
  -NSURL *KURL::getNSURL() const
  +CFURLRef KURL::createCFURL() const
   {
  -    const UInt8 *bytes = (const UInt8 *)(urlString.latin1());
  -    NSURL *result = nil;
  -    if (urlString.length() > 0) {
  -        // NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components
  -        // (e.g calls to NSURL -path). However, this function is not tolerant of illegal UTF-8 sequences, which
  -        // could either be a malformed string or bytes in a different encoding, like shift-jis, so we fall back
  -        // onto using ISO Latin 1 in those cases.
  -        result = KWQCFAutorelease(CFURLCreateAbsoluteURLWithBytes(NULL, bytes, urlString.length(), kCFStringEncodingUTF8, NULL, TRUE));
  -        if (!result) {
  -            result = KWQCFAutorelease(CFURLCreateAbsoluteURLWithBytes(NULL, bytes, urlString.length(), kCFStringEncodingISOLatin1, NULL, TRUE));
  -        }
  -    }
  -    else {
  -        result = [NSURL URLWithString:@""];
  -    }
  -    
  +    const UInt8 *bytes = (const UInt8 *)urlString.latin1();
  +    // NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components
  +    // (e.g calls to NSURL -path). However, this function is not tolerant of illegal UTF-8 sequences, which
  +    // could either be a malformed string or bytes in a different encoding, like Shift-JIS, so we fall back
  +    // onto using ISO Latin-1 in those cases.
  +    CFURLRef result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingUTF8, 0, TRUE);
  +    if (!result)
  +        result = CFURLCreateAbsoluteURLWithBytes(0, bytes, urlString.length(), kCFStringEncodingISOLatin1, 0, TRUE);
       return result;
   }
   
  -NSData *KURL::getNSData() const
  +NSURL *KURL::getNSURL() const
   {
  -    const UInt8 *bytes = (const UInt8 *)(urlString.latin1());
  -    return [NSData dataWithBytes:bytes length:urlString.length()];
  +    return KWQCFAutorelease(createCFURL());
   }
   
   static QString encodeHostname(const QString &s)
  
  
  



More information about the webkit-changes mailing list