Title: [225679] trunk/Source/WebKitLegacy/mac
Revision
225679
Author
da...@apple.com
Date
2017-12-08 09:26:27 -0800 (Fri, 08 Dec 2017)

Log Message

Remove some unused code from WebKitLegacy
https://bugs.webkit.org/show_bug.cgi?id=180567

Reviewed by Anders Carlsson.

* Misc/WebKitNSStringExtras.h: Researched which of these functions are used in
macOS (back a few versions) and iOS and removed unused
_web_drawAtPoint:font:textColor:allowingFontSmoothing:,
_web_drawDoubledAtPoint:withTopColor:bottomColor:font:,
_web_stringByStrippingReturnCharacters, _webkit_hasCaseInsensitiveSubstring:,
_webkit_stringByCollapsingNonPrintingCharacters,
_webkit_stringByCollapsingWhitespaceCharacters,
_web_stringWithData:textEncodingName:, and
_webkit_localStorageDirectoryWithBundleIdentifier:.

* Misc/WebKitNSStringExtras.mm: Made WebKitLocalCacheDefaultsKey private to
this source file.
(canUseFastRenderer): Made this faster by not calling u_charDirection for
Latin-1 characters, and also added special cases for U_DIR_NON_SPACING_MARK
and U_BOUNDARY_NEUTRAL, which should not prevent use of the fast renderer.
(-[NSString _web_drawAtPoint:font:textColor:allowingFontSmoothing:]): Deleted.
(-[NSString _web_drawAtPoint:font:textColor:]): Removed unneeded code to
handle font smoothing options.
(-[NSString _web_drawDoubledAtPoint:withTopColor:bottomColor:font:]): Deleted.
(-[NSString _web_stringByAbbreviatingWithTildeInPath]): Moved comment here
from header and made it a little clearer.
(-[NSString _web_stringByStrippingReturnCharacters]): Deleted.
(-[NSString _webkit_hasCaseInsensitiveSubstring:]): Deleted.
(-[NSString _webkit_stringByCollapsingNonPrintingCharacters]): Deleted.
(-[NSString _webkit_stringByCollapsingWhitespaceCharacters]): Deleted.
(+[NSString _web_stringWithData:textEncodingName:]): Deleted.
(+[NSString _webkit_localCacheDirectoryWithBundleIdentifier:]): Streamlined
implementation a bit and used whole words instead of abbreviations.
(+[NSString _webkit_localStorageDirectoryWithBundleIdentifier:]): Deleted.

* Misc/WebNSFileManagerExtras.mm:
(-[NSFileManager _webkit_pathWithUniqueFilenameForPath:]): Use the
filenameByFixingIllegalCharacters function from WebCore directly instead of
indirectly through the method _webkit_filenameByFixingIllegalCharacters.

* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView URLWithCString:]): Rewrote to use simple
string replacements instead of _web_stringByStrippingReturnCharacters
and to use NSString methods instead of CFString functions.

Modified Paths

Diff

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (225678 => 225679)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-12-08 16:45:51 UTC (rev 225678)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-12-08 17:26:27 UTC (rev 225679)
@@ -1,3 +1,50 @@
+2017-12-07  Darin Adler  <da...@apple.com>
+
+        Remove some unused code from WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=180567
+
+        Reviewed by Anders Carlsson.
+
+        * Misc/WebKitNSStringExtras.h: Researched which of these functions are used in
+        macOS (back a few versions) and iOS and removed unused
+        _web_drawAtPoint:font:textColor:allowingFontSmoothing:,
+        _web_drawDoubledAtPoint:withTopColor:bottomColor:font:,
+        _web_stringByStrippingReturnCharacters, _webkit_hasCaseInsensitiveSubstring:,
+        _webkit_stringByCollapsingNonPrintingCharacters,
+        _webkit_stringByCollapsingWhitespaceCharacters,
+        _web_stringWithData:textEncodingName:, and
+        _webkit_localStorageDirectoryWithBundleIdentifier:.
+
+        * Misc/WebKitNSStringExtras.mm: Made WebKitLocalCacheDefaultsKey private to
+        this source file.
+        (canUseFastRenderer): Made this faster by not calling u_charDirection for
+        Latin-1 characters, and also added special cases for U_DIR_NON_SPACING_MARK
+        and U_BOUNDARY_NEUTRAL, which should not prevent use of the fast renderer.
+        (-[NSString _web_drawAtPoint:font:textColor:allowingFontSmoothing:]): Deleted.
+        (-[NSString _web_drawAtPoint:font:textColor:]): Removed unneeded code to
+        handle font smoothing options.
+        (-[NSString _web_drawDoubledAtPoint:withTopColor:bottomColor:font:]): Deleted.
+        (-[NSString _web_stringByAbbreviatingWithTildeInPath]): Moved comment here
+        from header and made it a little clearer.
+        (-[NSString _web_stringByStrippingReturnCharacters]): Deleted.
+        (-[NSString _webkit_hasCaseInsensitiveSubstring:]): Deleted.
+        (-[NSString _webkit_stringByCollapsingNonPrintingCharacters]): Deleted.
+        (-[NSString _webkit_stringByCollapsingWhitespaceCharacters]): Deleted.
+        (+[NSString _web_stringWithData:textEncodingName:]): Deleted.
+        (+[NSString _webkit_localCacheDirectoryWithBundleIdentifier:]): Streamlined
+        implementation a bit and used whole words instead of abbreviations.
+        (+[NSString _webkit_localStorageDirectoryWithBundleIdentifier:]): Deleted.
+
+        * Misc/WebNSFileManagerExtras.mm:
+        (-[NSFileManager _webkit_pathWithUniqueFilenameForPath:]): Use the
+        filenameByFixingIllegalCharacters function from WebCore directly instead of
+        indirectly through the method _webkit_filenameByFixingIllegalCharacters.
+
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView URLWithCString:]): Rewrote to use simple
+        string replacements instead of _web_stringByStrippingReturnCharacters
+        and to use NSString methods instead of CFString functions.
+
 2017-12-07  Jessie Berlin  <jber...@webkit.org>
 
         Ignore deprecation warnings.

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.h (225678 => 225679)


--- trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.h	2017-12-08 16:45:51 UTC (rev 225678)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.h	2017-12-08 17:26:27 UTC (rev 225679)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Apple Inc.  All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,34 +38,19 @@
 @interface NSString (WebKitExtras)
 
 #if !TARGET_OS_IPHONE
-- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor allowingFontSmoothing:(BOOL)fontSmoothingIsAllowed;
 - (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor;
-- (void)_web_drawDoubledAtPoint:(NSPoint)textPoint withTopColor:(NSColor *)topColor bottomColor:(NSColor *)bottomColor font:(NSFont *)font;
-
 - (float)_web_widthWithFont:(NSFont *)font;
 #endif
 
-// Handles home directories that have symlinks in their paths.
-// This works around 2774250.
 - (NSString *)_web_stringByAbbreviatingWithTildeInPath;
 
-- (NSString *)_web_stringByStrippingReturnCharacters;
-
 - (BOOL)_webkit_isCaseInsensitiveEqualToString:(NSString *)string;
 - (BOOL)_webkit_hasCaseInsensitivePrefix:(NSString *)suffix;
 - (BOOL)_webkit_hasCaseInsensitiveSuffix:(NSString *)suffix;
-- (BOOL)_webkit_hasCaseInsensitiveSubstring:(NSString *)substring;
 - (NSString *)_webkit_filenameByFixingIllegalCharacters;
 
 - (NSString *)_webkit_stringByTrimmingWhitespace;
-- (NSString *)_webkit_stringByCollapsingNonPrintingCharacters;
-- (NSString *)_webkit_stringByCollapsingWhitespaceCharacters;
 
-#if TARGET_OS_IPHONE
-+ (NSString *)_web_stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
-#endif
-
 + (NSString *)_webkit_localCacheDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier;
-+ (NSString *)_webkit_localStorageDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier;
 
 @end

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm (225678 => 225679)


--- trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm	2017-12-08 16:45:51 UTC (rev 225678)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebKitNSStringExtras.mm	2017-12-08 17:26:27 UTC (rev 225679)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,19 +32,10 @@
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/LoaderNSURLExtras.h>
 #import <WebCore/TextRun.h>
-#import <WebKitLegacy/WebNSFileManagerExtras.h>
-#import <WebKitLegacy/WebNSObjectExtras.h>
 #import <pal/spi/cg/CoreGraphicsSPI.h>
 #import <sys/param.h>
 #import <unicode/uchar.h>
 
-#if PLATFORM(IOS)
-#import <WebKitLegacy/DOM.h>
-#import <WebKitLegacy/WebFrame.h>
-#import <WebKitLegacy/WebFrameView.h>
-#import <WebKitLegacy/WebViewPrivate.h>
-#endif
-
 NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
 NSString *WebKitResourceLoadStatisticsDirectoryDefaultsKey = @"WebKitResourceLoadStatisticsDirectory";
 
@@ -52,52 +43,47 @@
 
 @implementation NSString (WebKitExtras)
 
-#if !PLATFORM(IOS)
-static BOOL canUseFastRenderer(const UniChar *buffer, unsigned length)
+#if PLATFORM(MAC)
+
+static bool canUseFastRenderer(const UniChar* buffer, unsigned length)
 {
-    unsigned i;
-    for (i = 0; i < length; i++) {
-        UCharDirection direction = u_charDirection(buffer[i]);
-        if (direction == U_RIGHT_TO_LEFT || direction > U_OTHER_NEUTRAL)
-            return NO;
+    for (unsigned i = 0; i < length; i++) {
+        if (buffer[i] > 0xFF) {
+            auto direction = u_charDirection(buffer[i]);
+            if (direction == U_RIGHT_TO_LEFT || (direction > U_OTHER_NEUTRAL && direction != U_DIR_NON_SPACING_MARK && direction != U_BOUNDARY_NEUTRAL))
+                return false;
+        }
     }
-    return YES;
+    return true;
 }
 
 - (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor
 {
-    [self _web_drawAtPoint:point font:font textColor:textColor allowingFontSmoothing:YES];
-}
-
-- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor allowingFontSmoothing:(BOOL)fontSmoothingIsAllowed
-{
     if (!font)
         return;
 
     unsigned length = [self length];
     Vector<UniChar, 2048> buffer(length);
-
     [self getCharacters:buffer.data()];
 
     if (canUseFastRenderer(buffer.data(), length)) {
+        FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]));
+        TextRun run(StringView(buffer.data(), length));
+
         // The following is a half-assed attempt to match AppKit's rounding rules for drawAtPoint.
-        // It's probably incorrect for high DPI.
-        // If you change this, be sure to test all the text drawn this way in Safari, including
+        // If you change it, be sure to test all the text drawn this way in Safari, including
         // the status bar, bookmarks bar, tab bar, and activity window.
         point.y = CGCeiling(point.y);
 
         NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
         CGContextRef cgContext = static_cast<CGContextRef>([nsContext graphicsPort]);
-        GraphicsContext graphicsContext(cgContext);    
+        GraphicsContext graphicsContext { cgContext };
 
-        // Safari doesn't flip the NSGraphicsContext before calling WebKit, yet WebCore requires a flipped graphics context.
-        BOOL flipped = [nsContext isFlipped];
+        // WebCore requires a flipped graphics context.
+        bool flipped = [nsContext isFlipped];
         if (!flipped)
             CGContextScaleCTM(cgContext, 1, -1);
 
-        FontCascade webCoreFont(FontPlatformData(reinterpret_cast<CTFontRef>(font), [font pointSize]), fontSmoothingIsAllowed ? AutoSmoothing : Antialiased);
-        TextRun run(StringView(buffer.data(), length));
-
         CGFloat red;
         CGFloat green;
         CGFloat blue;
@@ -104,9 +90,8 @@
         CGFloat alpha;
         [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
         graphicsContext.setFillColor(Color(static_cast<float>(red * 255), static_cast<float>(green * 255.0f), static_cast<float>(blue * 255.0f), static_cast<float>(alpha * 255.0f)));
+        webCoreFont.drawText(graphicsContext, run, FloatPoint(point.x, flipped ? point.y : -point.y));
 
-        webCoreFont.drawText(graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1 * point.y))));
-
         if (!flipped)
             CGContextScaleCTM(cgContext, 1, -1);
     } else {
@@ -120,23 +105,10 @@
     }
 }
 
-- (void)_web_drawDoubledAtPoint:(NSPoint)textPoint
-             withTopColor:(NSColor *)topColor
-              bottomColor:(NSColor *)bottomColor
-                     font:(NSFont *)font
-{
-    // turn off font smoothing so translucent text draws correctly (Radar 3118455)
-    [self _web_drawAtPoint:textPoint font:font textColor:bottomColor allowingFontSmoothing:NO];
-
-    textPoint.y += 1;
-    [self _web_drawAtPoint:textPoint font:font textColor:topColor allowingFontSmoothing:NO];
-}
-
 - (float)_web_widthWithFont:(NSFont *)font
 {
     unsigned length = [self length];
     Vector<UniChar, 2048> buffer(length);
-
     [self getCharacters:buffer.data()];
 
     if (canUseFastRenderer(buffer.data(), length)) {
@@ -147,13 +119,17 @@
 
     return [self sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]].width;
 }
-#endif // !PLATFORM(IOS)
 
+#endif // PLATFORM(MAC)
+
 - (NSString *)_web_stringByAbbreviatingWithTildeInPath
 {
+    // Handles home directories that have symlinks in their paths as well as what stringByAbbreviatingWithTildeInPath handles.
+    // This works around Radar bug 2774250.
+
     NSString *resolvedHomeDirectory = [NSHomeDirectory() stringByResolvingSymlinksInPath];
     NSString *path;
-    
+
     if ([self hasPrefix:resolvedHomeDirectory]) {
         NSString *relativePath = [self substringFromIndex:[resolvedHomeDirectory length]];
         path = [NSHomeDirectory() stringByAppendingPathComponent:relativePath];
@@ -160,18 +136,10 @@
     } else {
         path = self;
     }
-        
+
     return [path stringByAbbreviatingWithTildeInPath];
 }
 
-- (NSString *)_web_stringByStrippingReturnCharacters
-{
-    NSMutableString *newString = [[self mutableCopy] autorelease];
-    [newString replaceOccurrencesOfString:@"\r" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
-    [newString replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [newString length])];
-    return newString;
-}
-
 - (BOOL)_webkit_isCaseInsensitiveEqualToString:(NSString *)string
 {
     return [self compare:string options:(NSCaseInsensitiveSearch | NSLiteralSearch)] == NSOrderedSame;
@@ -187,11 +155,6 @@
     return [self rangeOfString:suffix options:(NSCaseInsensitiveSearch | NSBackwardsSearch | NSAnchoredSearch)].location != NSNotFound;
 }
 
--(BOOL)_webkit_hasCaseInsensitiveSubstring:(NSString *)substring
-{
-    return [self rangeOfString:substring options:NSCaseInsensitiveSearch].location != NSNotFound;
-}
-
 -(NSString *)_webkit_filenameByFixingIllegalCharacters
 {
     return filenameByFixingIllegalCharacters(self);
@@ -204,131 +167,33 @@
     return trimmed;
 }
 
-- (NSString *)_webkit_stringByCollapsingNonPrintingCharacters
-{
-    NSMutableString *result = [NSMutableString string];
-    static NSCharacterSet *charactersToTurnIntoSpaces = nil;
-    static NSCharacterSet *charactersToNotTurnIntoSpaces = nil;
-    
-    if (charactersToTurnIntoSpaces == nil) {
-        NSMutableCharacterSet *set = [[NSMutableCharacterSet alloc] init];
-        [set addCharactersInRange:NSMakeRange(0x00, 0x21)];
-        [set addCharactersInRange:NSMakeRange(0x7F, 0x01)];
-        charactersToTurnIntoSpaces = [set copy];
-        [set release];
-        charactersToNotTurnIntoSpaces = [[charactersToTurnIntoSpaces invertedSet] retain];
-    }
-    
-    unsigned length = [self length];
-    unsigned position = 0;
-    while (position != length) {
-        NSRange nonSpace = [self rangeOfCharacterFromSet:charactersToNotTurnIntoSpaces
-            options:0 range:NSMakeRange(position, length - position)];
-        if (nonSpace.location == NSNotFound) {
-            break;
-        }
+#if PLATFORM(MAC)
 
-        NSRange space = [self rangeOfCharacterFromSet:charactersToTurnIntoSpaces
-            options:0 range:NSMakeRange(nonSpace.location, length - nonSpace.location)];
-        if (space.location == NSNotFound) {
-            space.location = length;
-        }
-
-        if (space.location > nonSpace.location) {
-            if (position != 0) {
-                [result appendString:@" "];
-            }
-            [result appendString:[self substringWithRange:
-                NSMakeRange(nonSpace.location, space.location - nonSpace.location)]];
-        }
-
-        position = space.location;
-    }
-    
-    return result;
-}
-
-- (NSString *)_webkit_stringByCollapsingWhitespaceCharacters
-{
-    NSMutableString *result = [[NSMutableString alloc] initWithCapacity:[self length]];
-    NSCharacterSet *spaces = [NSCharacterSet whitespaceAndNewlineCharacterSet];
-    static NSCharacterSet *notSpaces = nil;
-
-    if (notSpaces == nil)
-        notSpaces = [[spaces invertedSet] retain];
-
-    unsigned length = [self length];
-    unsigned position = 0;
-    while (position != length) {
-        NSRange nonSpace = [self rangeOfCharacterFromSet:notSpaces options:0 range:NSMakeRange(position, length - position)];
-        if (nonSpace.location == NSNotFound)
-            break;
-
-        NSRange space = [self rangeOfCharacterFromSet:spaces options:0 range:NSMakeRange(nonSpace.location, length - nonSpace.location)];
-        if (space.location == NSNotFound)
-            space.location = length;
-
-        if (space.location > nonSpace.location) {
-            if (position != 0)
-                [result appendString:@" "];
-            [result appendString:[self substringWithRange:NSMakeRange(nonSpace.location, space.location - nonSpace.location)]];
-        }
-
-        position = space.location;
-    }
-
-    return [result autorelease];
-}
-
-#if PLATFORM(MAC)
 // FIXME: This is here only for binary compatibility with Safari 8 and earlier.
+// Remove it once we don't have to support that any more.
 -(NSString *)_webkit_fixedCarbonPOSIXPath
 {
     return self;
 }
-#endif
 
-#if PLATFORM(IOS)
-+ (NSString *)_web_stringWithData:(NSData *)data textEncodingName:(NSString *)textEncodingName
-{
-    return [WebFrame stringWithData:data textEncodingName:textEncodingName];
-}
 #endif
 
 + (NSString *)_webkit_localCacheDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier
 {
-    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    NSString *cacheDir = [defaults objectForKey:WebKitLocalCacheDefaultsKey];
+    NSString *cacheDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebKitLocalCacheDefaultsKey];
 
-    if (!cacheDir || ![cacheDir isKindOfClass:[NSString class]]) {
+    if (!cacheDirectory || ![cacheDirectory isKindOfClass:[NSString class]]) {
 #if PLATFORM(IOS)
-        cacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
-#else
-        char cacheDirectory[MAXPATHLEN];
-        size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
-    
-        if (cacheDirectoryLen)
-            cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
+        cacheDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
 #endif
+#if PLATFORM(MAC)
+        char buffer[MAXPATHLEN];
+        if (size_t length = confstr(_CS_DARWIN_USER_CACHE_DIR, buffer, MAXPATHLEN))
+            cacheDirectory = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:buffer length:length - 1];
+#endif
     }
 
-    return [cacheDir stringByAppendingPathComponent:bundleIdentifier];
+    return [cacheDirectory stringByAppendingPathComponent:bundleIdentifier];
 }
 
-+ (NSString *)_webkit_localStorageDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier
-{
-    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-    NSString *storageDirectory = [defaults objectForKey:WebKitResourceLoadStatisticsDirectoryDefaultsKey];
-
-    if (!storageDirectory || ![storageDirectory isKindOfClass:[NSString class]]) {
-        NSError *error;
-        NSString *storageDirectory = [[[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&error] path];
-        
-        if (!storageDirectory || ![storageDirectory isKindOfClass:[NSString class]])
-            storageDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support"];
-    }
-
-    return [storageDirectory stringByAppendingPathComponent:bundleIdentifier];
-}
-
 @end

Modified: trunk/Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm (225678 => 225679)


--- trunk/Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm	2017-12-08 16:45:51 UTC (rev 225678)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebNSFileManagerExtras.mm	2017-12-08 17:26:27 UTC (rev 225679)
@@ -31,6 +31,7 @@
 #import "WebKitNSStringExtras.h"
 #import "WebNSURLExtras.h"
 #import <WebCore/FileSystem.h>
+#import <WebCore/LoaderNSURLExtras.h>
 #import <sys/stat.h>
 #import <wtf/Assertions.h>
 #import <wtf/ObjcRuntimeExtras.h>
@@ -60,7 +61,7 @@
 - (NSString *)_webkit_pathWithUniqueFilenameForPath:(NSString *)path
 {
     // "Fix" the filename of the path.
-    NSString *filename = [[path lastPathComponent] _webkit_filenameByFixingIllegalCharacters];
+    NSString *filename = filenameByFixingIllegalCharacters([path lastPathComponent]);
     path = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:filename];
 
     if (fileExists(path)) {

Modified: trunk/Source/WebKitLegacy/mac/Plugins/WebBaseNetscapePluginView.mm (225678 => 225679)


--- trunk/Source/WebKitLegacy/mac/Plugins/WebBaseNetscapePluginView.mm	2017-12-08 16:45:51 UTC (rev 225678)
+++ trunk/Source/WebKitLegacy/mac/Plugins/WebBaseNetscapePluginView.mm	2017-12-08 17:26:27 UTC (rev 225679)
@@ -132,21 +132,15 @@
     return YES;
 }
 
-- (NSURL *)URLWithCString:(const char *)URLCString
+- (NSURL *)URLWithCString:(const char *)cString
 {
-    if (!URLCString)
+    if (!cString)
         return nil;
     
-    CFStringRef string = CFStringCreateWithCString(kCFAllocatorDefault, URLCString, kCFStringEncodingISOLatin1);
-    ASSERT(string); // All strings should be representable in ISO Latin 1
-    
-    NSString *URLString = [(NSString *)string _web_stringByStrippingReturnCharacters];
-    NSURL *URL = "" _web_URLWithDataAsString:URLString relativeToURL:_baseURL.get()];
-    CFRelease(string);
-    if (!URL)
-        return nil;
-    
-    return URL;
+    NSString *string = [NSString stringWithCString:cString encoding:NSISOLatin1StringEncoding];
+    string = [string stringByReplacingOccurrencesOfString:@"\r" withString:@""];
+    string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
+    return [NSURL _web_URLWithDataAsString:string relativeToURL:_baseURL.get()];
 }
 
 - (NSMutableURLRequest *)requestWithURLCString:(const char *)URLCString
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to