Title: [202118] trunk/Source/WebKit/mac
- Revision
- 202118
- Author
- [email protected]
- Date
- 2016-06-15 18:22:54 -0700 (Wed, 15 Jun 2016)
Log Message
+[WebHTMLRepresentation supportedMIMETypes] leaks
https://bugs.webkit.org/show_bug.cgi?id=158683
Reviewed by Darin Adler.
The problem occurred when chaining newArrayByConcatenatingArrays calls.
Also refactored the code to avoid returning NSMutableArrays disguised as NSArrays,
and removed __unsafe_unretained modifiers that were added in http://trac.webkit.org/r149453
for no apparent reason.
* WebView/WebHTMLRepresentation.mm:
(newArrayWithStrings):
(+[WebHTMLRepresentation supportedMIMETypes]):
(+[WebHTMLRepresentation supportedMediaMIMETypes]):
(+[WebHTMLRepresentation supportedNonImageMIMETypes]):
(+[WebHTMLRepresentation supportedImageMIMETypes]):
(+[WebHTMLRepresentation unsupportedTextMIMETypes]):
(newArrayByConcatenatingArrays): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (202117 => 202118)
--- trunk/Source/WebKit/mac/ChangeLog 2016-06-16 01:14:02 UTC (rev 202117)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-06-16 01:22:54 UTC (rev 202118)
@@ -1,3 +1,25 @@
+2016-06-15 Alexey Proskuryakov <[email protected]>
+
+ +[WebHTMLRepresentation supportedMIMETypes] leaks
+ https://bugs.webkit.org/show_bug.cgi?id=158683
+
+ Reviewed by Darin Adler.
+
+ The problem occurred when chaining newArrayByConcatenatingArrays calls.
+
+ Also refactored the code to avoid returning NSMutableArrays disguised as NSArrays,
+ and removed __unsafe_unretained modifiers that were added in http://trac.webkit.org/r149453
+ for no apparent reason.
+
+ * WebView/WebHTMLRepresentation.mm:
+ (newArrayWithStrings):
+ (+[WebHTMLRepresentation supportedMIMETypes]):
+ (+[WebHTMLRepresentation supportedMediaMIMETypes]):
+ (+[WebHTMLRepresentation supportedNonImageMIMETypes]):
+ (+[WebHTMLRepresentation supportedImageMIMETypes]):
+ (+[WebHTMLRepresentation unsupportedTextMIMETypes]):
+ (newArrayByConcatenatingArrays): Deleted.
+
2016-06-15 Dean Jackson <[email protected]>
RTL <select> forms are misplaced
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm (202117 => 202118)
--- trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm 2016-06-16 01:14:02 UTC (rev 202117)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm 2016-06-16 01:22:54 UTC (rev 202118)
@@ -87,51 +87,42 @@
@implementation WebHTMLRepresentation
-static NSMutableArray *newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>&) NS_RETURNS_RETAINED;
-static NSMutableArray *newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>& set)
+static RetainPtr<NSArray> newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>& set)
{
- NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:set.size()];
- for (auto& string : set)
- [array addObject:(NSString *)string];
- return array;
+ Vector<NSString *> vector;
+ copyToVector(set, vector);
+ return adoptNS([[NSArray alloc] initWithObjects:vector.data() count:vector.size()]);
}
-static NSMutableArray *newArrayByConcatenatingArrays(NSArray *first, NSArray *second) NS_RETURNS_RETAINED;
-static NSMutableArray *newArrayByConcatenatingArrays(NSArray *first, NSArray *second)
-{
- NSMutableArray *result = [first mutableCopy];
- [result addObjectsFromArray:second];
- return result;
-}
-
+ (NSArray *)supportedMIMETypes
{
- static __unsafe_unretained NSArray *staticSupportedMIMETypes = newArrayByConcatenatingArrays([self supportedNonImageMIMETypes],
- newArrayByConcatenatingArrays([self supportedImageMIMETypes], [self supportedMediaMIMETypes]));
+ static NSArray *staticSupportedMIMETypes = [[[[self supportedNonImageMIMETypes] arrayByAddingObjectsFromArray:
+ [self supportedImageMIMETypes]] arrayByAddingObjectsFromArray:
+ [self supportedMediaMIMETypes]] retain];
return staticSupportedMIMETypes;
}
+ (NSArray *)supportedMediaMIMETypes
{
- static __unsafe_unretained NSArray *staticSupportedMediaMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedMediaMIMETypes());
+ static NSArray *staticSupportedMediaMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedMediaMIMETypes()).leakRef();
return staticSupportedMediaMIMETypes;
}
+ (NSArray *)supportedNonImageMIMETypes
{
- static __unsafe_unretained NSArray *staticSupportedNonImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedNonImageMIMETypes());
+ static NSArray *staticSupportedNonImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedNonImageMIMETypes()).leakRef();
return staticSupportedNonImageMIMETypes;
}
+ (NSArray *)supportedImageMIMETypes
{
- static __unsafe_unretained NSArray *staticSupportedImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedImageMIMETypes());
+ static NSArray *staticSupportedImageMIMETypes = newArrayWithStrings(MIMETypeRegistry::getSupportedImageMIMETypes()).leakRef();
return staticSupportedImageMIMETypes;
}
+ (NSArray *)unsupportedTextMIMETypes
{
- static __unsafe_unretained NSArray *staticUnsupportedTextMIMETypes = newArrayWithStrings(MIMETypeRegistry::getUnsupportedTextMIMETypes());
+ static NSArray *staticUnsupportedTextMIMETypes = newArrayWithStrings(MIMETypeRegistry::getUnsupportedTextMIMETypes()).leakRef();
return staticUnsupportedTextMIMETypes;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes