[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:17:45 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c2024f4b65fa34fe55232bfe25441df3409e83e7
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jun 10 05:32:54 2002 +0000

    	WebKit part of fix for 2949646 (Can't drag & drop bookmarks
    	into auto-expanded folder). To get this to work right, I gave
    	each bookmark a unique (per-session) identifier.
    
    	While working on this, I found and fixed some leaks of bookmarks.
    
    	* Bookmarks.subproj/IFBookmark.h:
    	New -[identifier] method and _identifier ivar.
    
    	* Bookmarks.subproj/IFBookmark.m:
    	(+[IFBookmark _generateUniqueIdentifier]):
    	(-[IFBookmark init]):
    	(-[IFBookmark dealloc]):
    	Remember unique identifier in each bookmark as it is created;
    	delete when dealloc'd.
    
    	(-[IFBookmark identifier]): Return unique identifier.
    
    	(-[IFBookmark _setParent:]): Don't retain parent, to avoid
    	circular ownership.
    
    	(-[IFBookmark _setGroup:]): Tell coming and going group.
    
    	* Bookmarks.subproj/IFBookmarkGroup.h:
    	New +[bookmarkForIdentifier] method and _bookmarksByID ivar.
    
    	* Bookmarks.subproj/IFBookmarkGroup_Private.h:
    	Declarations of _removedBookmark: and _addedBookmark:
    	* Bookmarks.subproj/IFBookmarkGroup.m:
    	(-[IFBookmarkGroup initWithFile:]): alloc _bookmarksByID.
    	(-[IFBookmarkGroup dealloc]): release _bookmarksByID.
    	(-[IFBookmarkGroup _setTopBookmark:]): Don't bail out early;
    	would now cause leak.
    	(-[IFBookmarkGroup _removedBookmark:]): New method, removes
    	bookmark from _bookmarksByID.
    	(-[IFBookmarkGroup _addedBookmark:]): New method, adds bookmark to
    	_bookmarksByID.
    	(-[IFBookmarkGroup bookmarkForIdentifier:]): Looks up bookmark from
    	_bookmarksByID dictionary.
    	(-[IFBookmarkGroup _loadBookmarkGroupGuts]): autorelease newTopbookmark;
    	this had been leaking.
    
    	* Bookmarks.subproj/IFBookmarkList.m:
    	(-[IFBookmarkList _initFromDictionaryRepresentation:withGroup:]):
    	autorelease children before adding them to parent; this had been leaking.
    
    	WebBrowser part of fix for 2949646 (Can't drag & drop bookmarks into
    	auto-expanded folder).
    
    	While working on this, I found and fixed some other unreported bugs, including
    	leaks of bookmarks.
    
    	* BookmarksController.m:
    	(-[BookmarksController windowDidLoad]): Use BookmarkIDListPboardType rather than
    	RowListPboardType.
    
    	(-[BookmarksController _endEditing]),
    	(-[BookmarksController _toggleEdit:]): Broke _endEditing out of _toggleEdit so
    	it could be called by itself.
    
    	(-[BookmarksController _safeRemoveBookmark:]): Workaround for NSOutlineView bug
    	where removing expanded items leaks.
    
    	(-[BookmarksController removeSelectedBookmarks:]),
    	(-[BookmarksController _redoRemoveBookmarks:]): Call _endEditing to avoid problem
    	when removing a bookmark that's being edited; call _safeRemoveBookmark to prevent
    	leak.
    
    	(-[BookmarksController _anyAncestorOfRow:inArray:]): removed.
    	(-[BookmarksController _identifierOfBookmarkOrAnyAncestor:inArray:]):
    	Changed name from _rowOrAnyAncestor:inArray:, now deals with array of bookmark
    	identifiers rather than array of row numbers.
    
    	(-[BookmarksController outlineView:writeItems:toPasteboard:]),
    	(-[BookmarksController outlineView:validateDrop:proposedItem:proposedChildIndex:]),
    	(-[BookmarksController outlineView:acceptDrop:item:childIndex:]): Reworked to use
    	array of bookmark identifiers rather than array of row numbers.
    
    	* Preferences.subproj/English.lproj/ActiveContentPreferences.nib: Added 2nd sentence
    	to "allow JavaScript to open windows automatically" preference at Maciej's wise
    	suggestion.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1316 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/Bookmarks.subproj/IFBookmark.h b/WebKit/Bookmarks.subproj/IFBookmark.h
index a32f1ed..048e0b2 100644
--- a/WebKit/Bookmarks.subproj/IFBookmark.h
+++ b/WebKit/Bookmarks.subproj/IFBookmark.h
@@ -19,6 +19,7 @@ typedef enum {
 @interface IFBookmark : NSObject <NSCopying> {
     IFBookmark *_parent;
     IFBookmarkGroup *_group;
+    NSString *_identifier;
 }
 
 - (NSString *)title;
@@ -56,5 +57,8 @@ typedef enum {
 // The group that this bookmark belongs to.
 - (IFBookmarkGroup *)group;
 
+// An NSString that can be used to uniquely identify this bookmark; use with +[IFBookmarkGroup bookmarkForIdentifier];
+- (NSString *)identifier;
+
 
 @end
diff --git a/WebKit/Bookmarks.subproj/IFBookmark.m b/WebKit/Bookmarks.subproj/IFBookmark.m
index 47cdc5c..dd227ad 100644
--- a/WebKit/Bookmarks.subproj/IFBookmark.m
+++ b/WebKit/Bookmarks.subproj/IFBookmark.m
@@ -8,20 +8,42 @@
 
 #import <WebKit/IFBookmark.h>
 #import <WebKit/IFBookmarkGroup.h>
+#import <WebKit/IFBookmarkGroup_Private.h>
+#import <WebKit/WebKitDebug.h>
 
 // to get NSRequestConcreteImplementation
 #import <Foundation/NSPrivateDecls.h>
 
 @implementation IFBookmark
 
+static unsigned _highestUsedID = 0;
+
++ (NSString *)_generateUniqueIdentifier
+{
+    return [[NSNumber numberWithInt:_highestUsedID++] stringValue];
+}
+
+- (id)init
+{
+    [super init];
+    _identifier = [[IFBookmark _generateUniqueIdentifier] retain];
+    return self;
+}
+
 - (void)dealloc
 {
-    [_parent release];
-    [_group release];
-    
+    WEBKIT_ASSERT (_group == nil);
+
+    [_identifier release];    
     [super dealloc];
 }
 
+- (NSString *)identifier
+{
+    WEBKIT_ASSERT(_identifier != nil);
+    return [[_identifier retain] autorelease];
+}
+
 - (id)copyWithZone:(NSZone *)zone
 {
     NSRequestConcreteImplementation(self, _cmd, [self class]);
@@ -121,8 +143,8 @@
 
 - (void)_setParent:(IFBookmark *)parent
 {
-    [parent retain];
-    [_parent release];
+    // Don't retain parent, to avoid circular ownership that prevents dealloc'ing
+    // when a parent with children is removed from a group and has no other references.
     _parent = parent;
 }
 
@@ -133,9 +155,15 @@
 
 - (void)_setGroup:(IFBookmarkGroup *)group
 {
-    [group retain];
+    if (group == _group) {
+        return;
+    }
+
+    [_group _removedBookmark:self];
     [_group release];
-    _group = group;
+
+    _group = [group retain];
+    [group _addedBookmark:self];
 }
 
 - (id)_initFromDictionaryRepresentation:(NSDictionary *)dict withGroup:(IFBookmarkGroup *)group
diff --git a/WebKit/Bookmarks.subproj/IFBookmarkGroup.h b/WebKit/Bookmarks.subproj/IFBookmarkGroup.h
index a294afc..2a02463 100644
--- a/WebKit/Bookmarks.subproj/IFBookmarkGroup.h
+++ b/WebKit/Bookmarks.subproj/IFBookmarkGroup.h
@@ -25,6 +25,7 @@
 {
     NSString *_file;
     IFBookmark *_topBookmark;
+    NSMutableDictionary *_bookmarksByID;
     BOOL _loading;
 }
 
@@ -33,6 +34,7 @@
 
 // examining contents
 - (IFBookmark *)topBookmark;
+- (IFBookmark *)bookmarkForIdentifier:(NSString *)identifier;
 
 // modifying contents
 - (void)removeBookmark:(IFBookmark *)bookmark;
diff --git a/WebKit/Bookmarks.subproj/IFBookmarkGroup.m b/WebKit/Bookmarks.subproj/IFBookmarkGroup.m
index 38e24e8..85522ff 100644
--- a/WebKit/Bookmarks.subproj/IFBookmarkGroup.m
+++ b/WebKit/Bookmarks.subproj/IFBookmarkGroup.m
@@ -31,6 +31,8 @@
         return nil;
     }
 
+    _bookmarksByID = [[NSMutableDictionary dictionary] retain];
+
     _file = [file retain];
     [self _setTopBookmark:nil];
 
@@ -44,6 +46,7 @@
 {
     [_topBookmark release];
     [_file release];
+    [_bookmarksByID release];
     [super dealloc];
 }
 
@@ -76,31 +79,19 @@
 
 - (void)_setTopBookmark:(IFBookmark *)newTopBookmark
 {
-    BOOL hadChildren, hasChildrenNow;
-
     WEBKIT_ASSERT_VALID_ARG (newTopBookmark, newTopBookmark == nil ||
                              [newTopBookmark bookmarkType] == IFBookmarkTypeList);
-
-    hadChildren = [_topBookmark numberOfChildren] > 0;
-    hasChildrenNow = newTopBookmark != nil && [newTopBookmark numberOfChildren] > 0;
     
-    // bail out early if nothing needs resetting
-    if (!hadChildren && _topBookmark != nil && !hasChildrenNow) {
-        return;
-    }
-
     [_topBookmark _setGroup:nil];
     [_topBookmark autorelease];
 
     if (newTopBookmark) {
         _topBookmark = [newTopBookmark retain];
     } else {
-        _topBookmark = [[[IFBookmarkList alloc] initWithTitle:nil image:nil group:self] retain];
+        _topBookmark = [[IFBookmarkList alloc] initWithTitle:nil image:nil group:self];
     }
 
-    if (hadChildren || hasChildrenNow) {
-        [self _sendChangeNotificationForBookmark:_topBookmark childrenChanged:YES];
-    }
+    [self _sendChangeNotificationForBookmark:_topBookmark childrenChanged:YES];
 }
 
 - (void)_bookmarkDidChange:(IFBookmark *)bookmark
@@ -115,6 +106,23 @@
     [self _sendChangeNotificationForBookmark:bookmark childrenChanged:YES];
 }
 
+- (void)_removedBookmark:(IFBookmark *)bookmark
+{
+    WEBKIT_ASSERT ([_bookmarksByID objectForKey:[bookmark identifier]] == bookmark);
+    [_bookmarksByID removeObjectForKey:[bookmark identifier]];
+}
+
+- (void)_addedBookmark:(IFBookmark *)bookmark
+{
+    WEBKIT_ASSERT ([_bookmarksByID objectForKey:[bookmark identifier]] == nil);
+    [_bookmarksByID setObject:bookmark forKey:[bookmark identifier]];
+}
+
+- (IFBookmark *)bookmarkForIdentifier:(NSString *)identifier
+{
+    return [_bookmarksByID objectForKey:identifier];
+}
+
 - (void)removeBookmark:(IFBookmark *)bookmark
 {
     WEBKIT_ASSERT_VALID_ARG (bookmark, [bookmark group] == self);
@@ -203,7 +211,7 @@
     }
 
     _loading = YES;
-    newTopBookmark = [[IFBookmarkList alloc] _initFromDictionaryRepresentation:dictionary withGroup:self];
+    newTopBookmark = [[[IFBookmarkList alloc] _initFromDictionaryRepresentation:dictionary withGroup:self] autorelease];
     [self _setTopBookmark:newTopBookmark];
     _loading = NO;
 
diff --git a/WebKit/Bookmarks.subproj/IFBookmarkGroup_Private.h b/WebKit/Bookmarks.subproj/IFBookmarkGroup_Private.h
index 0d6c275..a437fd1 100644
--- a/WebKit/Bookmarks.subproj/IFBookmarkGroup_Private.h
+++ b/WebKit/Bookmarks.subproj/IFBookmarkGroup_Private.h
@@ -14,5 +14,8 @@
 - (void)_bookmarkDidChange:(IFBookmark *)bookmark;
 - (void)_bookmarkChildrenDidChange:(IFBookmark *)bookmark;
 
+- (void)_removedBookmark:(IFBookmark *)bookmark;
+- (void)_addedBookmark:(IFBookmark *)bookmark;
+
 @end
 
diff --git a/WebKit/Bookmarks.subproj/IFBookmarkList.m b/WebKit/Bookmarks.subproj/IFBookmarkList.m
index e51df5c..0dbdcf5 100644
--- a/WebKit/Bookmarks.subproj/IFBookmarkList.m
+++ b/WebKit/Bookmarks.subproj/IFBookmarkList.m
@@ -61,14 +61,14 @@
             
             typeString = [childAsDictionary objectForKey:IFBookmarkTypeKey];
             if ([typeString isEqualToString:IFBookmarkTypeListValue]) {
-                child = [[IFBookmarkList alloc] _initFromDictionaryRepresentation:childAsDictionary
-                                                                        withGroup:group];
+                child = [[[IFBookmarkList alloc] _initFromDictionaryRepresentation:childAsDictionary
+                                                                        withGroup:group] autorelease];
             } else if ([typeString isEqualToString:IFBookmarkTypeLeafValue]) {
-                child = [[IFBookmarkLeaf alloc] _initFromDictionaryRepresentation:childAsDictionary
-                                                                        withGroup:group];
+                child = [[[IFBookmarkLeaf alloc] _initFromDictionaryRepresentation:childAsDictionary
+                                                                        withGroup:group] autorelease];
             } else if ([typeString isEqualToString:IFBookmarkTypeSeparatorValue]) {
-                child = [[IFBookmarkSeparator alloc] _initFromDictionaryRepresentation:childAsDictionary
-                                                                             withGroup:group];
+                child = [[[IFBookmarkSeparator alloc] _initFromDictionaryRepresentation:childAsDictionary
+                                                                             withGroup:group] autorelease];
             }
 
             if (child != nil) {
@@ -241,12 +241,12 @@
 {
     WEBKIT_ASSERT_VALID_ARG (bookmark, [bookmark parent] == nil);
     WEBKIT_ASSERT_VALID_ARG (bookmark, ![_list containsObject:bookmark]);
-    
+
     [_list insertObject:bookmark atIndex:index];
     [bookmark _setParent:self];
     [bookmark _setGroup:[self group]];
     
-    [[self group] _bookmarkChildrenDidChange:self]; 
+    [[self group] _bookmarkChildrenDidChange:self];
 }
 
 - (void)_setGroup:(IFBookmarkGroup *)group
diff --git a/WebKit/Bookmarks.subproj/WebBookmark.h b/WebKit/Bookmarks.subproj/WebBookmark.h
index a32f1ed..048e0b2 100644
--- a/WebKit/Bookmarks.subproj/WebBookmark.h
+++ b/WebKit/Bookmarks.subproj/WebBookmark.h
@@ -19,6 +19,7 @@ typedef enum {
 @interface IFBookmark : NSObject <NSCopying> {
     IFBookmark *_parent;
     IFBookmarkGroup *_group;
+    NSString *_identifier;
 }
 
 - (NSString *)title;
@@ -56,5 +57,8 @@ typedef enum {
 // The group that this bookmark belongs to.
 - (IFBookmarkGroup *)group;
 
+// An NSString that can be used to uniquely identify this bookmark; use with +[IFBookmarkGroup bookmarkForIdentifier];
+- (NSString *)identifier;
+
 
 @end
diff --git a/WebKit/Bookmarks.subproj/WebBookmark.m b/WebKit/Bookmarks.subproj/WebBookmark.m
index 47cdc5c..dd227ad 100644
--- a/WebKit/Bookmarks.subproj/WebBookmark.m
+++ b/WebKit/Bookmarks.subproj/WebBookmark.m
@@ -8,20 +8,42 @@
 
 #import <WebKit/IFBookmark.h>
 #import <WebKit/IFBookmarkGroup.h>
+#import <WebKit/IFBookmarkGroup_Private.h>
+#import <WebKit/WebKitDebug.h>
 
 // to get NSRequestConcreteImplementation
 #import <Foundation/NSPrivateDecls.h>
 
 @implementation IFBookmark
 
+static unsigned _highestUsedID = 0;
+
++ (NSString *)_generateUniqueIdentifier
+{
+    return [[NSNumber numberWithInt:_highestUsedID++] stringValue];
+}
+
+- (id)init
+{
+    [super init];
+    _identifier = [[IFBookmark _generateUniqueIdentifier] retain];
+    return self;
+}
+
 - (void)dealloc
 {
-    [_parent release];
-    [_group release];
-    
+    WEBKIT_ASSERT (_group == nil);
+
+    [_identifier release];    
     [super dealloc];
 }
 
+- (NSString *)identifier
+{
+    WEBKIT_ASSERT(_identifier != nil);
+    return [[_identifier retain] autorelease];
+}
+
 - (id)copyWithZone:(NSZone *)zone
 {
     NSRequestConcreteImplementation(self, _cmd, [self class]);
@@ -121,8 +143,8 @@
 
 - (void)_setParent:(IFBookmark *)parent
 {
-    [parent retain];
-    [_parent release];
+    // Don't retain parent, to avoid circular ownership that prevents dealloc'ing
+    // when a parent with children is removed from a group and has no other references.
     _parent = parent;
 }
 
@@ -133,9 +155,15 @@
 
 - (void)_setGroup:(IFBookmarkGroup *)group
 {
-    [group retain];
+    if (group == _group) {
+        return;
+    }
+
+    [_group _removedBookmark:self];
     [_group release];
-    _group = group;
+
+    _group = [group retain];
+    [group _addedBookmark:self];
 }
 
 - (id)_initFromDictionaryRepresentation:(NSDictionary *)dict withGroup:(IFBookmarkGroup *)group
diff --git a/WebKit/Bookmarks.subproj/WebBookmarkGroup.h b/WebKit/Bookmarks.subproj/WebBookmarkGroup.h
index a294afc..2a02463 100644
--- a/WebKit/Bookmarks.subproj/WebBookmarkGroup.h
+++ b/WebKit/Bookmarks.subproj/WebBookmarkGroup.h
@@ -25,6 +25,7 @@
 {
     NSString *_file;
     IFBookmark *_topBookmark;
+    NSMutableDictionary *_bookmarksByID;
     BOOL _loading;
 }
 
@@ -33,6 +34,7 @@
 
 // examining contents
 - (IFBookmark *)topBookmark;
+- (IFBookmark *)bookmarkForIdentifier:(NSString *)identifier;
 
 // modifying contents
 - (void)removeBookmark:(IFBookmark *)bookmark;
diff --git a/WebKit/Bookmarks.subproj/WebBookmarkGroup.m b/WebKit/Bookmarks.subproj/WebBookmarkGroup.m
index 38e24e8..85522ff 100644
--- a/WebKit/Bookmarks.subproj/WebBookmarkGroup.m
+++ b/WebKit/Bookmarks.subproj/WebBookmarkGroup.m
@@ -31,6 +31,8 @@
         return nil;
     }
 
+    _bookmarksByID = [[NSMutableDictionary dictionary] retain];
+
     _file = [file retain];
     [self _setTopBookmark:nil];
 
@@ -44,6 +46,7 @@
 {
     [_topBookmark release];
     [_file release];
+    [_bookmarksByID release];
     [super dealloc];
 }
 
@@ -76,31 +79,19 @@
 
 - (void)_setTopBookmark:(IFBookmark *)newTopBookmark
 {
-    BOOL hadChildren, hasChildrenNow;
-
     WEBKIT_ASSERT_VALID_ARG (newTopBookmark, newTopBookmark == nil ||
                              [newTopBookmark bookmarkType] == IFBookmarkTypeList);
-
-    hadChildren = [_topBookmark numberOfChildren] > 0;
-    hasChildrenNow = newTopBookmark != nil && [newTopBookmark numberOfChildren] > 0;
     
-    // bail out early if nothing needs resetting
-    if (!hadChildren && _topBookmark != nil && !hasChildrenNow) {
-        return;
-    }
-
     [_topBookmark _setGroup:nil];
     [_topBookmark autorelease];
 
     if (newTopBookmark) {
         _topBookmark = [newTopBookmark retain];
     } else {
-        _topBookmark = [[[IFBookmarkList alloc] initWithTitle:nil image:nil group:self] retain];
+        _topBookmark = [[IFBookmarkList alloc] initWithTitle:nil image:nil group:self];
     }
 
-    if (hadChildren || hasChildrenNow) {
-        [self _sendChangeNotificationForBookmark:_topBookmark childrenChanged:YES];
-    }
+    [self _sendChangeNotificationForBookmark:_topBookmark childrenChanged:YES];
 }
 
 - (void)_bookmarkDidChange:(IFBookmark *)bookmark
@@ -115,6 +106,23 @@
     [self _sendChangeNotificationForBookmark:bookmark childrenChanged:YES];
 }
 
+- (void)_removedBookmark:(IFBookmark *)bookmark
+{
+    WEBKIT_ASSERT ([_bookmarksByID objectForKey:[bookmark identifier]] == bookmark);
+    [_bookmarksByID removeObjectForKey:[bookmark identifier]];
+}
+
+- (void)_addedBookmark:(IFBookmark *)bookmark
+{
+    WEBKIT_ASSERT ([_bookmarksByID objectForKey:[bookmark identifier]] == nil);
+    [_bookmarksByID setObject:bookmark forKey:[bookmark identifier]];
+}
+
+- (IFBookmark *)bookmarkForIdentifier:(NSString *)identifier
+{
+    return [_bookmarksByID objectForKey:identifier];
+}
+
 - (void)removeBookmark:(IFBookmark *)bookmark
 {
     WEBKIT_ASSERT_VALID_ARG (bookmark, [bookmark group] == self);
@@ -203,7 +211,7 @@
     }
 
     _loading = YES;
-    newTopBookmark = [[IFBookmarkList alloc] _initFromDictionaryRepresentation:dictionary withGroup:self];
+    newTopBookmark = [[[IFBookmarkList alloc] _initFromDictionaryRepresentation:dictionary withGroup:self] autorelease];
     [self _setTopBookmark:newTopBookmark];
     _loading = NO;
 
diff --git a/WebKit/Bookmarks.subproj/WebBookmarkGroupPrivate.h b/WebKit/Bookmarks.subproj/WebBookmarkGroupPrivate.h
index 0d6c275..a437fd1 100644
--- a/WebKit/Bookmarks.subproj/WebBookmarkGroupPrivate.h
+++ b/WebKit/Bookmarks.subproj/WebBookmarkGroupPrivate.h
@@ -14,5 +14,8 @@
 - (void)_bookmarkDidChange:(IFBookmark *)bookmark;
 - (void)_bookmarkChildrenDidChange:(IFBookmark *)bookmark;
 
+- (void)_removedBookmark:(IFBookmark *)bookmark;
+- (void)_addedBookmark:(IFBookmark *)bookmark;
+
 @end
 
diff --git a/WebKit/Bookmarks.subproj/WebBookmarkList.m b/WebKit/Bookmarks.subproj/WebBookmarkList.m
index e51df5c..0dbdcf5 100644
--- a/WebKit/Bookmarks.subproj/WebBookmarkList.m
+++ b/WebKit/Bookmarks.subproj/WebBookmarkList.m
@@ -61,14 +61,14 @@
             
             typeString = [childAsDictionary objectForKey:IFBookmarkTypeKey];
             if ([typeString isEqualToString:IFBookmarkTypeListValue]) {
-                child = [[IFBookmarkList alloc] _initFromDictionaryRepresentation:childAsDictionary
-                                                                        withGroup:group];
+                child = [[[IFBookmarkList alloc] _initFromDictionaryRepresentation:childAsDictionary
+                                                                        withGroup:group] autorelease];
             } else if ([typeString isEqualToString:IFBookmarkTypeLeafValue]) {
-                child = [[IFBookmarkLeaf alloc] _initFromDictionaryRepresentation:childAsDictionary
-                                                                        withGroup:group];
+                child = [[[IFBookmarkLeaf alloc] _initFromDictionaryRepresentation:childAsDictionary
+                                                                        withGroup:group] autorelease];
             } else if ([typeString isEqualToString:IFBookmarkTypeSeparatorValue]) {
-                child = [[IFBookmarkSeparator alloc] _initFromDictionaryRepresentation:childAsDictionary
-                                                                             withGroup:group];
+                child = [[[IFBookmarkSeparator alloc] _initFromDictionaryRepresentation:childAsDictionary
+                                                                             withGroup:group] autorelease];
             }
 
             if (child != nil) {
@@ -241,12 +241,12 @@
 {
     WEBKIT_ASSERT_VALID_ARG (bookmark, [bookmark parent] == nil);
     WEBKIT_ASSERT_VALID_ARG (bookmark, ![_list containsObject:bookmark]);
-    
+
     [_list insertObject:bookmark atIndex:index];
     [bookmark _setParent:self];
     [bookmark _setGroup:[self group]];
     
-    [[self group] _bookmarkChildrenDidChange:self]; 
+    [[self group] _bookmarkChildrenDidChange:self];
 }
 
 - (void)_setGroup:(IFBookmarkGroup *)group
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 4eee3ae..48318fa 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,51 @@
+2002-06-09  John Sullivan  <sullivan at apple.com>
+
+	WebKit part of fix for 2949646 (Can't drag & drop bookmarks
+	into auto-expanded folder). To get this to work right, I gave
+	each bookmark a unique (per-session) identifier.
+
+	While working on this, I found and fixed some leaks of bookmarks.
+
+	* Bookmarks.subproj/IFBookmark.h:
+	New -[identifier] method and _identifier ivar.
+
+	* Bookmarks.subproj/IFBookmark.m:
+	(+[IFBookmark _generateUniqueIdentifier]):
+	(-[IFBookmark init]):
+	(-[IFBookmark dealloc]):
+	Remember unique identifier in each bookmark as it is created;
+	delete when dealloc'd.
+
+	(-[IFBookmark identifier]): Return unique identifier.
+
+	(-[IFBookmark _setParent:]): Don't retain parent, to avoid
+	circular ownership.
+
+	(-[IFBookmark _setGroup:]): Tell coming and going group.
+
+	* Bookmarks.subproj/IFBookmarkGroup.h:
+	New +[bookmarkForIdentifier] method and _bookmarksByID ivar.
+
+	* Bookmarks.subproj/IFBookmarkGroup_Private.h:
+	Declarations of _removedBookmark: and _addedBookmark:
+	* Bookmarks.subproj/IFBookmarkGroup.m:
+	(-[IFBookmarkGroup initWithFile:]): alloc _bookmarksByID.
+	(-[IFBookmarkGroup dealloc]): release _bookmarksByID.
+	(-[IFBookmarkGroup _setTopBookmark:]): Don't bail out early;
+	would now cause leak.
+	(-[IFBookmarkGroup _removedBookmark:]): New method, removes
+	bookmark from _bookmarksByID.
+	(-[IFBookmarkGroup _addedBookmark:]): New method, adds bookmark to
+	_bookmarksByID.
+	(-[IFBookmarkGroup bookmarkForIdentifier:]): Looks up bookmark from
+	_bookmarksByID dictionary.
+	(-[IFBookmarkGroup _loadBookmarkGroupGuts]): autorelease newTopbookmark; 
+	this had been leaking.
+
+	* Bookmarks.subproj/IFBookmarkList.m:
+	(-[IFBookmarkList _initFromDictionaryRepresentation:withGroup:]):
+	autorelease children before adding them to parent; this had been leaking.
+
 2002-06-09  Darin Adler  <darin at apple.com>
 
 	* WebCoreSupport.subproj/IFTextRenderer.m:
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 4eee3ae..48318fa 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,51 @@
+2002-06-09  John Sullivan  <sullivan at apple.com>
+
+	WebKit part of fix for 2949646 (Can't drag & drop bookmarks
+	into auto-expanded folder). To get this to work right, I gave
+	each bookmark a unique (per-session) identifier.
+
+	While working on this, I found and fixed some leaks of bookmarks.
+
+	* Bookmarks.subproj/IFBookmark.h:
+	New -[identifier] method and _identifier ivar.
+
+	* Bookmarks.subproj/IFBookmark.m:
+	(+[IFBookmark _generateUniqueIdentifier]):
+	(-[IFBookmark init]):
+	(-[IFBookmark dealloc]):
+	Remember unique identifier in each bookmark as it is created;
+	delete when dealloc'd.
+
+	(-[IFBookmark identifier]): Return unique identifier.
+
+	(-[IFBookmark _setParent:]): Don't retain parent, to avoid
+	circular ownership.
+
+	(-[IFBookmark _setGroup:]): Tell coming and going group.
+
+	* Bookmarks.subproj/IFBookmarkGroup.h:
+	New +[bookmarkForIdentifier] method and _bookmarksByID ivar.
+
+	* Bookmarks.subproj/IFBookmarkGroup_Private.h:
+	Declarations of _removedBookmark: and _addedBookmark:
+	* Bookmarks.subproj/IFBookmarkGroup.m:
+	(-[IFBookmarkGroup initWithFile:]): alloc _bookmarksByID.
+	(-[IFBookmarkGroup dealloc]): release _bookmarksByID.
+	(-[IFBookmarkGroup _setTopBookmark:]): Don't bail out early;
+	would now cause leak.
+	(-[IFBookmarkGroup _removedBookmark:]): New method, removes
+	bookmark from _bookmarksByID.
+	(-[IFBookmarkGroup _addedBookmark:]): New method, adds bookmark to
+	_bookmarksByID.
+	(-[IFBookmarkGroup bookmarkForIdentifier:]): Looks up bookmark from
+	_bookmarksByID dictionary.
+	(-[IFBookmarkGroup _loadBookmarkGroupGuts]): autorelease newTopbookmark; 
+	this had been leaking.
+
+	* Bookmarks.subproj/IFBookmarkList.m:
+	(-[IFBookmarkList _initFromDictionaryRepresentation:withGroup:]):
+	autorelease children before adding them to parent; this had been leaking.
+
 2002-06-09  Darin Adler  <darin at apple.com>
 
 	* WebCoreSupport.subproj/IFTextRenderer.m:

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list