Changeset 158538 in webkit


Ignore:
Timestamp:
Nov 3, 2013 12:41:01 PM (10 years ago)
Author:
mitz@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r158500 r158538  
     12013-11-03  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Wrappers' -copyWithZone: should copy if the collection is mutable
     4        https://bugs.webkit.org/show_bug.cgi?id=123707
     5
     6        Reviewed by Geoff Garen.
     7
     8        * Shared/Cocoa/WKNSArray.mm:
     9        (-[WKNSArray copyWithZone:]): If the array is mutable, make a copy.
     10        * Shared/Cocoa/WKNSDictionary.mm:
     11        (-[WKNSDictionary copyWithZone:]): If the dictionary is mutable, make a copy.
     12        * Shared/ImmutableArray.h:
     13        (WebKit::ImmutableArray::entries): Added this accessor.
     14
    1152013-11-02  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/Source/WebKit2/Shared/Cocoa/WKNSArray.mm

    r158500 r158538  
    5959- (id)copyWithZone:(NSZone *)zone
    6060{
    61     return [self retain];
     61    if (!reinterpret_cast<ImmutableArray*>(&_array)->isMutable())
     62        return [self retain];
     63
     64    auto entries = reinterpret_cast<ImmutableArray*>(&_array)->entries();
     65    return ImmutableArray::adopt(entries).leakRef()->wrapper();
    6266}
    6367
  • trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm

    r158500 r158538  
    7979- (id)copyWithZone:(NSZone *)zone
    8080{
    81     return [self retain];
     81    if (!reinterpret_cast<ImmutableDictionary*>(&_dictionary)->isMutable())
     82        return [self retain];
     83
     84    auto map = reinterpret_cast<ImmutableDictionary*>(&_dictionary)->map();
     85    return ImmutableDictionary::adopt(map).leakRef()->wrapper();
    8286}
    8387
  • trunk/Source/WebKit2/Shared/ImmutableArray.h

    r155262 r158538  
    6666    virtual bool isMutable() { return false; }
    6767
     68    const Vector<RefPtr<APIObject>>& entries() { return m_entries; }
     69
    6870protected:
    6971    ImmutableArray();
Note: See TracChangeset for help on using the changeset viewer.