Title: [158538] trunk/Source/WebKit2
- Revision
- 158538
- Author
- m...@apple.com
- Date
- 2013-11-03 12:41:01 -0800 (Sun, 03 Nov 2013)
Log Message
[Cocoa] Wrappers' -copyWithZone: should copy if the collection is mutable
https://bugs.webkit.org/show_bug.cgi?id=123707
Reviewed by Geoff Garen.
* Shared/Cocoa/WKNSArray.mm:
(-[WKNSArray copyWithZone:]): If the array is mutable, make a copy.
* Shared/Cocoa/WKNSDictionary.mm:
(-[WKNSDictionary copyWithZone:]): If the dictionary is mutable, make a copy.
* Shared/ImmutableArray.h:
(WebKit::ImmutableArray::entries): Added this accessor.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (158537 => 158538)
--- trunk/Source/WebKit2/ChangeLog 2013-11-03 20:19:52 UTC (rev 158537)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-03 20:41:01 UTC (rev 158538)
@@ -1,3 +1,17 @@
+2013-11-03 Dan Bernstein <m...@apple.com>
+
+ [Cocoa] Wrappers' -copyWithZone: should copy if the collection is mutable
+ https://bugs.webkit.org/show_bug.cgi?id=123707
+
+ Reviewed by Geoff Garen.
+
+ * Shared/Cocoa/WKNSArray.mm:
+ (-[WKNSArray copyWithZone:]): If the array is mutable, make a copy.
+ * Shared/Cocoa/WKNSDictionary.mm:
+ (-[WKNSDictionary copyWithZone:]): If the dictionary is mutable, make a copy.
+ * Shared/ImmutableArray.h:
+ (WebKit::ImmutableArray::entries): Added this accessor.
+
2013-11-02 Dan Bernstein <m...@apple.com>
[Cocoa] Wrappers mishandle NULL values in arrays and dictionaries
Modified: trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm (158537 => 158538)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm 2013-11-03 20:19:52 UTC (rev 158537)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm 2013-11-03 20:41:01 UTC (rev 158538)
@@ -58,7 +58,11 @@
- (id)copyWithZone:(NSZone *)zone
{
- return [self retain];
+ if (!reinterpret_cast<ImmutableArray*>(&_array)->isMutable())
+ return [self retain];
+
+ auto entries = reinterpret_cast<ImmutableArray*>(&_array)->entries();
+ return ImmutableArray::adopt(entries).leakRef()->wrapper();
}
#pragma mark WKObject protocol implementation
Modified: trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm (158537 => 158538)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm 2013-11-03 20:19:52 UTC (rev 158537)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm 2013-11-03 20:41:01 UTC (rev 158538)
@@ -78,7 +78,11 @@
- (id)copyWithZone:(NSZone *)zone
{
- return [self retain];
+ if (!reinterpret_cast<ImmutableDictionary*>(&_dictionary)->isMutable())
+ return [self retain];
+
+ auto map = reinterpret_cast<ImmutableDictionary*>(&_dictionary)->map();
+ return ImmutableDictionary::adopt(map).leakRef()->wrapper();
}
#pragma mark WKObject protocol implementation
Modified: trunk/Source/WebKit2/Shared/ImmutableArray.h (158537 => 158538)
--- trunk/Source/WebKit2/Shared/ImmutableArray.h 2013-11-03 20:19:52 UTC (rev 158537)
+++ trunk/Source/WebKit2/Shared/ImmutableArray.h 2013-11-03 20:41:01 UTC (rev 158538)
@@ -65,6 +65,8 @@
virtual bool isMutable() { return false; }
+ const Vector<RefPtr<APIObject>>& entries() { return m_entries; }
+
protected:
ImmutableArray();
ImmutableArray(AdoptTag, APIObject** entries, size_t);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes