Changeset 159016 in webkit


Ignore:
Timestamp:
Nov 9, 2013 10:49:13 PM (10 years ago)
Author:
mitz@apple.com
Message:

Use createCFURLFromBuffer when converting a String to a CFURL
https://bugs.webkit.org/show_bug.cgi?id=124113

Reviewed by Anders Carlsson.

  • Shared/API/c/cf/WKURLCF.mm:

(WKURLCopyCFURL): Replaced some code with a call to createCFURLFromBuffer(), which does the
same thing.

  • Shared/Cocoa/WKNSURLExtras.h: Added.
  • Shared/Cocoa/WKNSURLExtras.mm: Added.

(+[NSURL _web_URLWithWTFString:relativeToURL:]): Added. Returns nil for the null String,
otherwise returns the result of createCFURLFromBuffer().

  • UIProcess/API/Cocoa/WKBackForwardListItem.mm:

(-[WKBackForwardListItem URL]): Changed to use +_web_URLWithWTFString:relativeToURL:.
(-[WKBackForwardListItem originalURL]): Ditto.

  • UIProcess/API/Cocoa/WKNavigationData.mm:

(-[WKNavigationData destinationURL]): Ditto.

  • UIProcess/API/mac/WKBrowsingContextController.mm:

(-[WKBrowsingContextController unreachableURL]): Ditto.

  • WebKit2.xcodeproj/project.pbxproj: Added references to new files.
Location:
trunk/Source/WebKit2
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r159004 r159016  
     12013-11-09  Dan Bernstein  <mitz@apple.com>
     2
     3        Use createCFURLFromBuffer when converting a String to a CFURL
     4        https://bugs.webkit.org/show_bug.cgi?id=124113
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/API/c/cf/WKURLCF.mm:
     9        (WKURLCopyCFURL): Replaced some code with a call to createCFURLFromBuffer(), which does the
     10        same thing.
     11
     12        * Shared/Cocoa/WKNSURLExtras.h: Added.
     13        * Shared/Cocoa/WKNSURLExtras.mm: Added.
     14        (+[NSURL _web_URLWithWTFString:relativeToURL:]): Added. Returns nil for the null String,
     15        otherwise returns the result of createCFURLFromBuffer().
     16
     17        * UIProcess/API/Cocoa/WKBackForwardListItem.mm:
     18        (-[WKBackForwardListItem URL]): Changed to use +_web_URLWithWTFString:relativeToURL:.
     19        (-[WKBackForwardListItem originalURL]): Ditto.
     20
     21        * UIProcess/API/Cocoa/WKNavigationData.mm:
     22        (-[WKNavigationData destinationURL]): Ditto.
     23
     24        * UIProcess/API/mac/WKBrowsingContextController.mm:
     25        (-[WKBrowsingContextController unreachableURL]): Ditto.
     26
     27        * WebKit2.xcodeproj/project.pbxproj: Added references to new files.
     28
    1292013-11-09  Anders Carlsson  <andersca@apple.com>
    230
  • trunk/Source/WebKit2/Shared/API/c/cf/WKURLCF.mm

    r158456 r159016  
    3131#import <WebCore/CFURLExtras.h>
    3232#import <objc/runtime.h>
    33 #import <wtf/PassRefPtr.h>
    34 #import <wtf/RefPtr.h>
    3533#import <wtf/text/CString.h>
    36 #import <wtf/text/WTFString.h>
    3734
    3835using namespace WebCore;
     
    7673    // UTF-8 which uses less memory and is what WebKit clients might expect.
    7774
    78     // This pattern of using UTF-8 and then falling back to Latin1 on failure matches URL::createCFString with the
    79     // major differnce being that URL does not do a UTF-8 conversion and instead chops off the high bits of the UTF-16
    80     // character sequence.
    81 
    8275    CString buffer = toImpl(URLRef)->string().utf8();
    83     CFURLRef result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingUTF8, 0, true);
    84     if (!result)
    85         result = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingISOLatin1, 0, true);
    86     return result;
     76    return createCFURLFromBuffer(buffer.data(), buffer.length(), 0).leakRef();
    8777}
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKBackForwardListItem.mm

    r158324 r159016  
    2929#if WK_API_ENABLED
    3030
    31 #import "WebString.h"
     31#import "WKNSURLExtras.h"
    3232
    3333using namespace WebKit;
     
    4646- (NSURL *)URL
    4747{
    48     if (!reinterpret_cast<WebBackForwardListItem*>(&_item)->url())
    49         return nil;
    50 
    51     return [NSURL URLWithString:reinterpret_cast<WebBackForwardListItem*>(&_item)->url()];
     48    return [NSURL _web_URLWithWTFString:reinterpret_cast<WebBackForwardListItem*>(&_item)->url() relativeToURL:nil];
    5249}
    5350
     
    6259- (NSURL *)originalURL
    6360{
    64     if (!reinterpret_cast<WebBackForwardListItem*>(&_item)->originalURL())
    65         return nil;
    66 
    67     return [NSURL URLWithString:reinterpret_cast<WebBackForwardListItem*>(&_item)->originalURL()];
     61    return [NSURL _web_URLWithWTFString:reinterpret_cast<WebBackForwardListItem*>(&_item)->originalURL() relativeToURL:nil];
    6862}
    6963
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationData.mm

    r158779 r159016  
    2929#if WK_API_ENABLED
    3030
     31#import "WKNSURLExtras.h"
    3132#import <WebCore/ResourceRequest.h>
    3233#import <WebCore/ResourceResponse.h>
     
    5758- (NSURL *)destinationURL
    5859{
    59     return [NSURL URLWithString:reinterpret_cast<WebNavigationData*>(&_data)->url()];
     60    return [NSURL _web_URLWithWTFString:reinterpret_cast<WebNavigationData*>(&_data)->url() relativeToURL:nil];
    6061}
    6162
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm

    r158949 r159016  
    3434#import "WKFramePolicyListener.h"
    3535#import "WKNSArray.h"
     36#import "WKNSURLExtras.h"
    3637#import "WKPagePrivate.h"
    3738#import "WKRetainPtr.h"
     
    333334- (NSURL *)unreachableURL
    334335{
    335     const String& unreachableURL = toImpl(_data->_pageRef.get())->unreachableURL();
    336     if (!unreachableURL)
    337         return nil;
    338 
    339     return !unreachableURL ? nil : [NSURL URLWithString:unreachableURL];
     336    return [NSURL _web_URLWithWTFString:toImpl(_data->_pageRef.get())->unreachableURL() relativeToURL:nil];
    340337}
    341338
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r158971 r159016  
    408408                370F34A51829BEA3009027C8 /* WKNavigationDataInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 370F34A41829BEA3009027C8 /* WKNavigationDataInternal.h */; };
    409409                370F34A71829CFF3009027C8 /* WKBrowsingContextHistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 370F34A61829CFF3009027C8 /* WKBrowsingContextHistoryDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     410                37183D56182F4E700080C811 /* WKNSURLExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37183D54182F4E700080C811 /* WKNSURLExtras.mm */; };
     411                37183D57182F4E700080C811 /* WKNSURLExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 37183D55182F4E700080C811 /* WKNSURLExtras.h */; };
    410412                371A19411824D29300F32A5E /* WKNSDictionary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 371A193F1824D29300F32A5E /* WKNSDictionary.mm */; };
    411413                371A19421824D29300F32A5E /* WKNSDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 371A19401824D29300F32A5E /* WKNSDictionary.h */; };
     
    19131915                370F34A41829BEA3009027C8 /* WKNavigationDataInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationDataInternal.h; sourceTree = "<group>"; };
    19141916                370F34A61829CFF3009027C8 /* WKBrowsingContextHistoryDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextHistoryDelegate.h; sourceTree = "<group>"; };
     1917                37183D54182F4E700080C811 /* WKNSURLExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSURLExtras.mm; sourceTree = "<group>"; };
     1918                37183D55182F4E700080C811 /* WKNSURLExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLExtras.h; sourceTree = "<group>"; };
    19151919                371A193F1824D29300F32A5E /* WKNSDictionary.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSDictionary.mm; sourceTree = "<group>"; };
    19161920                371A19401824D29300F32A5E /* WKNSDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSDictionary.h; sourceTree = "<group>"; };
     
    37183722                                378E1A4C18208D700031007A /* WKNSURL.h */,
    37193723                                378E1A4B18208D700031007A /* WKNSURL.mm */,
     3724                                37183D55182F4E700080C811 /* WKNSURLExtras.h */,
     3725                                37183D54182F4E700080C811 /* WKNSURLExtras.mm */,
    37203726                                378E1A3F181EDA010031007A /* WKObject.h */,
    37213727                                374436871820E7240049579F /* WKObject.mm */,
     
    59135919                                51A555F6128C6C47009ABCEC /* WKContextMenuItem.h in Headers */,
    59145920                                51A55601128C6D92009ABCEC /* WKContextMenuItemTypes.h in Headers */,
     5921                                37183D57182F4E700080C811 /* WKNSURLExtras.h in Headers */,
    59155922                                BCC938E11180DE440085E5FE /* WKContextPrivate.h in Headers */,
    59165923                                9FB5F395169E6A80002C25BF /* WKContextPrivateMac.h in Headers */,
     
    70077014                                1AF05D8614688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm in Sources */,
    70087015                                1A64245F12DE29A100CAAE2C /* UpdateInfo.cpp in Sources */,
     7016                                37183D56182F4E700080C811 /* WKNSURLExtras.mm in Sources */,
    70097017                                374436881820E7240049579F /* WKObject.mm in Sources */,
    70107018                                1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.