Changeset 165118 in webkit


Ignore:
Timestamp:
Mar 5, 2014 12:16:10 PM (10 years ago)
Author:
Simon Fraser
Message:

ObjC exception when dropping files into a WKView: drag and drop uses code from WebKit.framework
https://bugs.webkit.org/show_bug.cgi?id=129752

Source/WebCore:

Reviewed by Enrica Casucci.

Add C functions for NSURL-related functionality required by WebKit2

  • WebCore.exp.in:
  • platform/mac/WebCoreNSURLExtras.h:
  • platform/mac/WebCoreNSURLExtras.mm:

(WebCore::URLByCanonicalizingURL):
(WebCore::rangeOfURLScheme):
(WebCore::looksLikeAbsoluteURL):

Source/WebKit/mac:

Reviewed by Enrica Casucci.

Call URLByCanonicalizingURL() which is implemented in WebCore.

  • Misc/WebNSURLExtras.mm:

(-[NSURL _webkit_canonicalize]):

Source/WebKit2:

Reviewed by Enrica Casucci.

Get WebDragClientMac off of all WebKit headers, and WebEditorClientMac off
all but one by using C functions from WebCoreNSURLExtras.h rather than
the NSURL category.

  • WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:

(WebKit::WebDragClient::declareAndWriteDragImage):

  • WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:

(WebKit::WebEditorClient::userVisibleString):
(WebKit::WebEditorClient::canonicalizeURL):
(WebKit::WebEditorClient::canonicalizeURLString):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r165117 r165118  
     12014-03-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        ObjC exception when dropping files into a WKView: drag and drop uses code from WebKit.framework
     4        https://bugs.webkit.org/show_bug.cgi?id=129752
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Add C functions for NSURL-related functionality required by WebKit2
     9
     10        * WebCore.exp.in:
     11        * platform/mac/WebCoreNSURLExtras.h:
     12        * platform/mac/WebCoreNSURLExtras.mm:
     13        (WebCore::URLByCanonicalizingURL):
     14        (WebCore::rangeOfURLScheme):
     15        (WebCore::looksLikeAbsoluteURL):
     16
    1172014-03-05  Martin Hock  <mhock@apple.com>
    218
  • trunk/Source/WebCore/WebCore.exp.in

    r165117 r165118  
    7676__ZN7WebCore10FontGlyphs15releaseFontDataEv
    7777__ZN7WebCore10JSDocument6s_infoE
     78__ZN7WebCore10LayoutRectC1ERKNS_9FloatRectE
    7879__ZN7WebCore10MouseEvent6createERKN3WTF12AtomicStringENS1_10PassRefPtrINS_9DOMWindowEEERKNS_18PlatformMouseEventEiNS5_INS_4NodeEEE
    7980__ZN7WebCore10MouseEvent6createERKN3WTF12AtomicStringEbbdNS1_10PassRefPtrINS_9DOMWindowEEEiiiiibbbbtNS5_INS_11EventTargetEEENS5_INS_9ClipboardEEEb
     
    834835__ZN7WebCore20UserGestureIndicatorD1Ev
    835836__ZN7WebCore20deleteEmptyDirectoryERKN3WTF6StringE
     837__ZN7WebCore20looksLikeAbsoluteURLEP8NSString
    836838__ZN7WebCore20makeRGBA32FromFloatsEffff
    837839__ZN7WebCore20previousLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
     
    895897__ZN7WebCore22ScriptExecutionContext2vmEv
    896898__ZN7WebCore22StorageEventDispatcher34dispatchLocalStorageEventsToFramesERNS_9PageGroupERKN3WTF6VectorINS3_6RefPtrINS_5FrameEEELm0ENS3_15CrashOnOverflowEEERKNS3_6StringESE_SE_SE_PNS_14SecurityOriginE
     899__ZN7WebCore22URLByCanonicalizingURLEP5NSURL
    897900__ZN7WebCore22URLWithUserTypedStringEP8NSStringP5NSURL
    898901__ZN7WebCore22WheelEventDeltaTracker17endTrackingDeltasEv
     
    19331936__ZTVN7WebCore31BasicColorMatrixFilterOperationE
    19341937__ZTVN7WebCore37BasicComponentTransferFilterOperationE
    1935 __ZN7WebCore10LayoutRectC1ERKNS_9FloatRectE
    19361938__ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_9FloatRectE
    19371939__ZThn???_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
     
    23152317#endif
    23162318
     2319#if PLATFORM(MAC) || PLATFORM(IOS_SIMULATOR)
     2320_wkSetCrashReportApplicationSpecificInformation
     2321#endif
     2322
    23172323#if PLATFORM(IOS)
    23182324.objc_class_name_NSCursor
     
    24472453__ZN7WebCore15GraphicsContext15drawLineForTextERKNS_10FloatPointEfbb
    24482454__ZN7WebCore15GraphicsContext15drawNativeImageEP7CGImageRKNS_9FloatSizeENS_10ColorSpaceERKNS_9FloatRectES9_fNS_17CompositeOperatorENS_9BlendModeENS_16ImageOrientationE
    2449 __ZN7WebCore15GraphicsContext15drawLineForTextERKNS_10FloatPointEfbb
    24502455__ZN7WebCore15GraphicsContext22setEmojiDrawingEnabledEb
    24512456__ZN7WebCore15GraphicsContext23setIsAcceleratedContextEb
     
    26862691#endif
    26872692
    2688 #if PLATFORM(MAC) || PLATFORM(IOS_SIMULATOR)
    2689 _wkSetCrashReportApplicationSpecificInformation
    2690 #endif
    2691 
    26922693#if ENABLE(3D_RENDERING)
    26932694_WebCoreHas3DRendering
  • trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h

    r132925 r165118  
    4040
    4141NSString *userVisibleString(NSURL *);
     42NSURL *URLByCanonicalizingURL(NSURL *);
    4243NSURL *URLWithUserTypedString(NSString *, NSURL *);
    4344NSURL *URLByRemovingUserInfo(NSURL *);
     
    5253NSData *originalURLData(NSURL *);
    5354NSData *dataForURLComponentType(NSURL *, CFIndex);
     55
     56NSRange rangeOfURLScheme(NSString *);
    5457BOOL isUserVisibleURL(NSString *);
    55    
     58BOOL looksLikeAbsoluteURL(NSString *);
     59
    5660} // namespace WebCore
  • trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm

    r154963 r165118  
    4848static pthread_once_t IDNScriptWhiteListFileRead = PTHREAD_ONCE_INIT;
    4949static uint32_t IDNScriptWhiteList[(USCRIPT_CODE_LIMIT + 31) / 32];
     50
     51
     52@interface NSURLProtocol (WKNSURLProtocolInternal)
     53+ (Class)_protocolClassForRequest:(NSURLRequest *)request;
     54@end
    5055
    5156namespace WebCore {
     
    713718}
    714719
     720NSURL *URLByCanonicalizingURL(NSURL *URL)
     721{
     722    RetainPtr<NSURLRequest> request = adoptNS([[NSURLRequest alloc] initWithURL:URL]);
     723    Class concreteClass = [NSURLProtocol _protocolClassForRequest:request.get()];
     724    if (!concreteClass) {
     725        return URL;
     726    }
     727   
     728    // This applies NSURL's concept of canonicalization, but not URL's concept. It would
     729    // make sense to apply both, but when we tried that it caused a performance degradation
     730    // (see 5315926). It might make sense to apply only the URL concept and not the NSURL
     731    // concept, but it's too risky to make that change for WebKit 3.0.
     732    NSURLRequest *newRequest = [concreteClass canonicalRequestForRequest:request.get()];
     733    NSURL *newURL = [newRequest URL];
     734    return [[newURL retain] autorelease];
     735}
     736
    715737NSData *originalURLData(NSURL *URL)
    716738{
     
    881903}
    882904
     905NSRange rangeOfURLScheme(NSString *string)
     906{
     907    NSRange colon = [string rangeOfString:@":"];
     908    if (colon.location != NSNotFound && colon.location > 0) {
     909        NSRange scheme = {0, colon.location};
     910        static NSCharacterSet *InverseSchemeCharacterSet = nil;
     911        if (!InverseSchemeCharacterSet) {
     912            /*
     913             This stuff is very expensive.  10-15 msec on a 2x1.2GHz.  If not cached it swamps
     914             everything else when adding items to the autocomplete DB.  Makes me wonder if we
     915             even need to enforce the character set here.
     916            */
     917            NSString *acceptableCharacters = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+.-";
     918            InverseSchemeCharacterSet = [[[NSCharacterSet characterSetWithCharactersInString:acceptableCharacters] invertedSet] retain];
     919        }
     920        NSRange illegals = [string rangeOfCharacterFromSet:InverseSchemeCharacterSet options:0 range:scheme];
     921        if (illegals.location == NSNotFound)
     922            return scheme;
     923    }
     924    return NSMakeRange(NSNotFound, 0);
     925}
     926
     927BOOL looksLikeAbsoluteURL(NSString *string)
     928{
     929    // Trim whitespace because _web_URLWithString allows whitespace.
     930    return rangeOfURLScheme(stringByTrimmingWhitespace(string)).location != NSNotFound;
     931}
     932
    883933} // namespace WebCore
  • trunk/Source/WebKit/mac/ChangeLog

    r165094 r165118  
     12014-03-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        ObjC exception when dropping files into a WKView: drag and drop uses code from WebKit.framework
     4        https://bugs.webkit.org/show_bug.cgi?id=129752
     5
     6        Reviewed by Enrica Casucci.
     7       
     8        Call URLByCanonicalizingURL() which is implemented in WebCore.
     9
     10        * Misc/WebNSURLExtras.mm:
     11        (-[NSURL _webkit_canonicalize]):
     12
    1132014-03-04  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm

    r161185 r165118  
    129129
    130130- (NSURL *)_webkit_canonicalize
    131 {   
    132     NSURLRequest *request = [[NSURLRequest alloc] initWithURL:self];
    133     Class concreteClass = WKNSURLProtocolClassForRequest(request);
    134     if (!concreteClass) {
    135         [request release];
    136         return self;
    137     }
    138    
    139     // This applies NSURL's concept of canonicalization, but not URL's concept. It would
    140     // make sense to apply both, but when we tried that it caused a performance degradation
    141     // (see 5315926). It might make sense to apply only the URL concept and not the NSURL
    142     // concept, but it's too risky to make that change for WebKit 3.0.
    143     NSURLRequest *newRequest = [concreteClass canonicalRequestForRequest:request];
    144     NSURL *newURL = [newRequest URL];
    145     NSURL *result = [[newURL retain] autorelease];
    146     [request release];
    147    
    148     return result;
     131{
     132    return URLByCanonicalizingURL(self);
    149133}
    150134
  • trunk/Source/WebKit2/ChangeLog

    r165117 r165118  
     12014-03-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        ObjC exception when dropping files into a WKView: drag and drop uses code from WebKit.framework
     4        https://bugs.webkit.org/show_bug.cgi?id=129752
     5
     6        Reviewed by Enrica Casucci.
     7       
     8        Get WebDragClientMac off of all WebKit headers, and WebEditorClientMac off
     9        all but one by using C functions from WebCoreNSURLExtras.h rather than
     10        the NSURL category.
     11
     12        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
     13        (WebKit::WebDragClient::declareAndWriteDragImage):
     14        * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
     15        (WebKit::WebEditorClient::userVisibleString):
     16        (WebKit::WebEditorClient::canonicalizeURL):
     17        (WebKit::WebEditorClient::canonicalizeURLString):
     18
    1192014-03-05  Martin Hock  <mhock@apple.com>
    220
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm

    r162505 r165118  
    4242#import <WebCore/GraphicsContext.h>
    4343#import <WebCore/LegacyWebArchive.h>
     44#import <WebCore/WebCoreNSURLExtras.h>
    4445#import <WebCore/Page.h>
    4546#import <WebCore/RenderImage.h>
     
    4748#import <WebCore/StringTruncator.h>
    4849#import <WebKit/WebArchive.h>
    49 #import <WebKit/WebKitNSStringExtras.h>
    50 #import <WebKit/WebNSFileManagerExtras.h>
    51 #import <WebKit/WebNSPasteboardExtras.h>
    52 #import <WebKit/WebNSURLExtras.h>
    5350#import <WebKitSystemInterface.h>
    5451#import <wtf/StdLibExtras.h>
     
    119116        title = url.lastPathComponent();
    120117        if (title.isEmpty())
    121             title = [(NSURL *)url _web_userVisibleString];
     118            title = userVisibleString((NSURL *)url);
    122119    }
    123120
     
    144141        sharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly);           
    145142    }
    146     m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), String([(NSURL *)url _web_userVisibleString]), archiveHandle, archiveSize));
     143    m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
    147144}
    148145
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm

    r164776 r165118  
    4747#import <WebCore/NotImplemented.h>
    4848#import <WebCore/Page.h>
    49 #import <WebKit/WebResource.h>
    50 #import <WebKit/WebNSURLExtras.h>
     49#import <WebCore/WebCoreNSURLExtras.h>
     50#import <WebKit/WebResource.h> // FIXME: WebKit2 should not include WebKit headers.
    5151
    5252using namespace WebCore;
     
    7676NSString *WebEditorClient::userVisibleString(NSURL *url)
    7777{
    78     return [url _web_userVisibleString];
     78    return userVisibleString(url);
    7979}
    8080
    8181NSURL *WebEditorClient::canonicalizeURL(NSURL *url)
    8282{
    83     return [url _webkit_canonicalize];
     83    return URLByCanonicalizingURL(url);
    8484}
    8585
     
    8787{
    8888    NSURL *URL = nil;
    89     if ([URLString _webkit_looksLikeAbsoluteURL])
    90         URL = [[NSURL _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
     89    if (looksLikeAbsoluteURL(URLString))
     90        URL = URLByCanonicalizingURL(URLWithUserTypedString(URLString, nil));
    9191    return URL;
    9292}
Note: See TracChangeset for help on using the changeset viewer.