Title: [165118] trunk/Source
Revision
165118
Author
[email protected]
Date
2014-03-05 12:16:10 -0800 (Wed, 05 Mar 2014)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (165117 => 165118)


--- trunk/Source/WebCore/ChangeLog	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebCore/ChangeLog	2014-03-05 20:16:10 UTC (rev 165118)
@@ -1,3 +1,19 @@
+2014-03-05  Simon Fraser  <[email protected]>
+
+        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
+
+        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):
+
 2014-03-05  Martin Hock  <[email protected]>
 
         Add support for sessions to MemoryCache.

Modified: trunk/Source/WebCore/WebCore.exp.in (165117 => 165118)


--- trunk/Source/WebCore/WebCore.exp.in	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-03-05 20:16:10 UTC (rev 165118)
@@ -75,6 +75,7 @@
 __ZN7WebCore10FloatPointC1ERKNS_8IntPointE
 __ZN7WebCore10FontGlyphs15releaseFontDataEv
 __ZN7WebCore10JSDocument6s_infoE
+__ZN7WebCore10LayoutRectC1ERKNS_9FloatRectE
 __ZN7WebCore10MouseEvent6createERKN3WTF12AtomicStringENS1_10PassRefPtrINS_9DOMWindowEEERKNS_18PlatformMouseEventEiNS5_INS_4NodeEEE
 __ZN7WebCore10MouseEvent6createERKN3WTF12AtomicStringEbbdNS1_10PassRefPtrINS_9DOMWindowEEEiiiiibbbbtNS5_INS_11EventTargetEEENS5_INS_9ClipboardEEEb
 __ZN7WebCore10Pasteboard14writePlainTextERKN3WTF6StringENS0_18SmartReplaceOptionE
@@ -833,6 +834,7 @@
 __ZN7WebCore20UserGestureIndicatorC1ENS_26ProcessingUserGestureStateE
 __ZN7WebCore20UserGestureIndicatorD1Ev
 __ZN7WebCore20deleteEmptyDirectoryERKN3WTF6StringE
+__ZN7WebCore20looksLikeAbsoluteURLEP8NSString
 __ZN7WebCore20makeRGBA32FromFloatsEffff
 __ZN7WebCore20previousLinePositionERKNS_15VisiblePositionEiNS_12EditableTypeE
 __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
@@ -894,6 +896,7 @@
 __ZN7WebCore22ScriptExecutionContext26canSuspendActiveDOMObjectsEv
 __ZN7WebCore22ScriptExecutionContext2vmEv
 __ZN7WebCore22StorageEventDispatcher34dispatchLocalStorageEventsToFramesERNS_9PageGroupERKN3WTF6VectorINS3_6RefPtrINS_5FrameEEELm0ENS3_15CrashOnOverflowEEERKNS3_6StringESE_SE_SE_PNS_14SecurityOriginE
+__ZN7WebCore22URLByCanonicalizingURLEP5NSURL
 __ZN7WebCore22URLWithUserTypedStringEP8NSStringP5NSURL
 __ZN7WebCore22WheelEventDeltaTracker17endTrackingDeltasEv
 __ZN7WebCore22WheelEventDeltaTracker19beginTrackingDeltasEv
@@ -1932,7 +1935,6 @@
 __ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
 __ZTVN7WebCore31BasicColorMatrixFilterOperationE
 __ZTVN7WebCore37BasicComponentTransferFilterOperationE
-__ZN7WebCore10LayoutRectC1ERKNS_9FloatRectE
 __ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_9FloatRectE
 __ZThn???_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
 __ZThn???_N7WebCore15GraphicsLayerCA40platformCALayerSetNeedsToRevalidateTilesEv
@@ -2314,6 +2316,10 @@
 _wkCreateMemoryStatusPressureCriticalDispatchOnMainQueue
 #endif
 
+#if PLATFORM(MAC) || PLATFORM(IOS_SIMULATOR)
+_wkSetCrashReportApplicationSpecificInformation
+#endif
+
 #if PLATFORM(IOS)
 .objc_class_name_NSCursor
 .objc_class_name_WAKClipView
@@ -2446,7 +2452,6 @@
 __ZN7WebCore15GraphicsContext12drawBidiTextERKNS_4FontERKNS_7TextRunERKNS_10FloatPointENS1_24CustomFontNotReadyActionEPNS_10BidiStatusEi
 __ZN7WebCore15GraphicsContext15drawLineForTextERKNS_10FloatPointEfbb
 __ZN7WebCore15GraphicsContext15drawNativeImageEP7CGImageRKNS_9FloatSizeENS_10ColorSpaceERKNS_9FloatRectES9_fNS_17CompositeOperatorENS_9BlendModeENS_16ImageOrientationE
-__ZN7WebCore15GraphicsContext15drawLineForTextERKNS_10FloatPointEfbb
 __ZN7WebCore15GraphicsContext22setEmojiDrawingEnabledEb
 __ZN7WebCore15GraphicsContext23setIsAcceleratedContextEb
 __ZN7WebCore15GraphicsContextC1EP9CGContextb
@@ -2685,10 +2690,6 @@
 _wkIOSurfaceContextCreateImage
 #endif
 
-#if PLATFORM(MAC) || PLATFORM(IOS_SIMULATOR)
-_wkSetCrashReportApplicationSpecificInformation
-#endif
-
 #if ENABLE(3D_RENDERING)
 _WebCoreHas3DRendering
 #endif

Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h (165117 => 165118)


--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.h	2014-03-05 20:16:10 UTC (rev 165118)
@@ -39,6 +39,7 @@
 namespace WebCore {
 
 NSString *userVisibleString(NSURL *);
+NSURL *URLByCanonicalizingURL(NSURL *);
 NSURL *URLWithUserTypedString(NSString *, NSURL *);
 NSURL *URLByRemovingUserInfo(NSURL *);
 BOOL hostNameNeedsDecodingWithRange(NSString *, NSRange);
@@ -51,6 +52,9 @@
 NSURL *URLWithData(NSData *, NSURL *baseURL);
 NSData *originalURLData(NSURL *);
 NSData *dataForURLComponentType(NSURL *, CFIndex);
+
+NSRange rangeOfURLScheme(NSString *);
 BOOL isUserVisibleURL(NSString *);
-    
+BOOL looksLikeAbsoluteURL(NSString *);
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm (165117 => 165118)


--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm	2014-03-05 20:16:10 UTC (rev 165118)
@@ -48,6 +48,11 @@
 static pthread_once_t IDNScriptWhiteListFileRead = PTHREAD_ONCE_INIT;
 static uint32_t IDNScriptWhiteList[(USCRIPT_CODE_LIMIT + 31) / 32];
 
+
+@interface NSURLProtocol (WKNSURLProtocolInternal)
++ (Class)_protocolClassForRequest:(NSURLRequest *)request;
+@end
+
 namespace WebCore {
 
 static inline BOOL isLookalikeCharacter(int charCode)
@@ -712,6 +717,23 @@
     return URLByRemovingComponentAndSubsequentCharacter(URL, kCFURLComponentUserInfo);
 }
 
+NSURL *URLByCanonicalizingURL(NSURL *URL)
+{
+    RetainPtr<NSURLRequest> request = adoptNS([[NSURLRequest alloc] initWithURL:URL]);
+    Class concreteClass = [NSURLProtocol _protocolClassForRequest:request.get()];
+    if (!concreteClass) {
+        return URL;
+    }
+    
+    // This applies NSURL's concept of canonicalization, but not URL's concept. It would
+    // make sense to apply both, but when we tried that it caused a performance degradation
+    // (see 5315926). It might make sense to apply only the URL concept and not the NSURL
+    // concept, but it's too risky to make that change for WebKit 3.0.
+    NSURLRequest *newRequest = [concreteClass canonicalRequestForRequest:request.get()];
+    NSURL *newURL = [newRequest URL]; 
+    return [[newURL retain] autorelease];
+}
+
 NSData *originalURLData(NSURL *URL)
 {
     UInt8 *buffer = (UInt8 *)malloc(URL_BYTES_BUFFER_LENGTH);
@@ -880,4 +902,32 @@
     return valid;
 }
 
+NSRange rangeOfURLScheme(NSString *string)
+{
+    NSRange colon = [string rangeOfString:@":"];
+    if (colon.location != NSNotFound && colon.location > 0) {
+        NSRange scheme = {0, colon.location};
+        static NSCharacterSet *InverseSchemeCharacterSet = nil;
+        if (!InverseSchemeCharacterSet) {
+            /*
+             This stuff is very expensive.  10-15 msec on a 2x1.2GHz.  If not cached it swamps
+             everything else when adding items to the autocomplete DB.  Makes me wonder if we
+             even need to enforce the character set here.
+            */
+            NSString *acceptableCharacters = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+.-";
+            InverseSchemeCharacterSet = [[[NSCharacterSet characterSetWithCharactersInString:acceptableCharacters] invertedSet] retain];
+        }
+        NSRange illegals = [string rangeOfCharacterFromSet:InverseSchemeCharacterSet options:0 range:scheme];
+        if (illegals.location == NSNotFound)
+            return scheme;
+    }
+    return NSMakeRange(NSNotFound, 0);
+}
+
+BOOL looksLikeAbsoluteURL(NSString *string)
+{
+    // Trim whitespace because _web_URLWithString allows whitespace.
+    return rangeOfURLScheme(stringByTrimmingWhitespace(string)).location != NSNotFound;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebKit/mac/ChangeLog (165117 => 165118)


--- trunk/Source/WebKit/mac/ChangeLog	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-03-05 20:16:10 UTC (rev 165118)
@@ -1,3 +1,15 @@
+2014-03-05  Simon Fraser  <[email protected]>
+
+        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
+
+        Reviewed by Enrica Casucci.
+        
+        Call URLByCanonicalizingURL() which is implemented in WebCore.
+
+        * Misc/WebNSURLExtras.mm:
+        (-[NSURL _webkit_canonicalize]):
+
 2014-03-04  Zalan Bujtas  <[email protected]>
 
         Enable device pixel repaint rect tracking.

Modified: trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm (165117 => 165118)


--- trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm	2014-03-05 20:16:10 UTC (rev 165118)
@@ -128,24 +128,8 @@
  }
 
 - (NSURL *)_webkit_canonicalize
-{    
-    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:self];
-    Class concreteClass = WKNSURLProtocolClassForRequest(request);
-    if (!concreteClass) {
-        [request release];
-        return self;
-    }
-    
-    // This applies NSURL's concept of canonicalization, but not URL's concept. It would
-    // make sense to apply both, but when we tried that it caused a performance degradation
-    // (see 5315926). It might make sense to apply only the URL concept and not the NSURL
-    // concept, but it's too risky to make that change for WebKit 3.0.
-    NSURLRequest *newRequest = [concreteClass canonicalRequestForRequest:request];
-    NSURL *newURL = [newRequest URL]; 
-    NSURL *result = [[newURL retain] autorelease]; 
-    [request release];
-    
-    return result;
+{
+    return URLByCanonicalizingURL(self);
 }
 
 - (NSURL *)_web_URLByTruncatingOneCharacterBeforeComponent:(CFURLComponentType)component

Modified: trunk/Source/WebKit2/ChangeLog (165117 => 165118)


--- trunk/Source/WebKit2/ChangeLog	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-05 20:16:10 UTC (rev 165118)
@@ -1,3 +1,21 @@
+2014-03-05  Simon Fraser  <[email protected]>
+
+        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
+
+        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):
+
 2014-03-05  Martin Hock  <[email protected]>
 
         Add support for sessions to MemoryCache.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (165117 => 165118)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2014-03-05 20:16:10 UTC (rev 165118)
@@ -41,15 +41,12 @@
 #import <WebCore/FrameView.h>
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/LegacyWebArchive.h>
+#import <WebCore/WebCoreNSURLExtras.h>
 #import <WebCore/Page.h>
 #import <WebCore/RenderImage.h>
 #import <WebCore/ResourceHandle.h>
 #import <WebCore/StringTruncator.h>
 #import <WebKit/WebArchive.h>
-#import <WebKit/WebKitNSStringExtras.h>
-#import <WebKit/WebNSFileManagerExtras.h>
-#import <WebKit/WebNSPasteboardExtras.h>
-#import <WebKit/WebNSURLExtras.h>
 #import <WebKitSystemInterface.h>
 #import <wtf/StdLibExtras.h>
 
@@ -118,7 +115,7 @@
     if (title.isEmpty()) {
         title = url.lastPathComponent();
         if (title.isEmpty())
-            title = [(NSURL *)url _web_userVisibleString];
+            title = userVisibleString((NSURL *)url);
     }
 
     RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(&element);
@@ -143,7 +140,7 @@
         memcpy(sharedMemoryBuffer->data(), buffer->data(), archiveSize);
         sharedMemoryBuffer->createHandle(archiveHandle, SharedMemory::ReadOnly);            
     }
-    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));
+    m_page->send(Messages::WebPageProxy::SetPromisedData(pasteboardName, imageHandle, imageSize, String([response suggestedFilename]), extension, title, String([[response URL] absoluteString]), userVisibleString((NSURL *)url), archiveHandle, archiveSize));
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm (165117 => 165118)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm	2014-03-05 20:11:03 UTC (rev 165117)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm	2014-03-05 20:16:10 UTC (rev 165118)
@@ -46,8 +46,8 @@
 #import <WebCore/KeyboardEvent.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/Page.h>
-#import <WebKit/WebResource.h>
-#import <WebKit/WebNSURLExtras.h>
+#import <WebCore/WebCoreNSURLExtras.h>
+#import <WebKit/WebResource.h> // FIXME: WebKit2 should not include WebKit headers.
 
 using namespace WebCore;
 
@@ -75,19 +75,19 @@
     
 NSString *WebEditorClient::userVisibleString(NSURL *url)
 {
-    return [url _web_userVisibleString];
+    return userVisibleString(url);
 }
 
 NSURL *WebEditorClient::canonicalizeURL(NSURL *url)
 {
-    return [url _webkit_canonicalize];
+    return URLByCanonicalizingURL(url);
 }
 
 NSURL *WebEditorClient::canonicalizeURLString(NSString *URLString)
 {
     NSURL *URL = ""
-    if ([URLString _webkit_looksLikeAbsoluteURL])
-        URL = "" _web_URLWithUserTypedString:URLString] _webkit_canonicalize];
+    if (looksLikeAbsoluteURL(URLString))
+        URL = "" nil));
     return URL;
 }
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to