Closed Bug 385484 Opened 19 years ago Closed 19 years ago

Refactor bookmark creation APIs

Categories

(Camino Graveyard :: Bookmarks, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Camino1.6

People

(Reporter: stuart.morgan+bugzilla, Assigned: stuart.morgan+bugzilla)

Details

(Keywords: fixed1.8.1.5)

Attachments

(2 files, 1 obsolete file)

Attached patch refactoring (obsolete) — — Splinter Review
The current bookmark creation APIs all live on BookmarkFolder, which doesn't make a whole lot of sense. It also results in most bookmarks being created as blank bookmarks in the bookmark hierarchy, with the title and url set immediately after, which means three bookmark update notifications instead of one. This patch makes a few related changes: - Moves bookmark creation APIs to Bookmark - Changes the load-from-file API to a creation method, rather than having to create a blank bookmark and then read the dictionary representation into it, since that seems much more logical - Suppresses the change notifications for bookmarks that haven't yet been added to the hierarchy, since that's now the common case. (Folder addition APIs could use similar changes, but that will be another bug.)
Attachment #269398 - Flags: review?
Attachment #269398 - Flags: review? → review?(nick.kreeger)
Comment on attachment 269398 [details] [diff] [review] refactoring Looks pretty good, this code definitely needed some loving. Here are a few nits: ++ (Bookmark*)bookmarkWithTitle:(NSString *)aTitle url:(NSString *)aURL ++ (Bookmark*)bookmarkWithNativeDictionary:(NSDictionary *)aDict ++ (Bookmark*)bookmarkWithSafariDictionary:(NSDictionary *)aDict Could you be a bit more consistent with pointer spacing? Personally, I've recently have fallen in love with |foo *| but I see that most of the Camino code uses |foo*|. - (void)insertChild:(BookmarkItem *)aChild atIndex:(unsigned)aPosition isMove:(BOOL)inIsMove { + // Ensure that only folders are added to the root. + if ([self isRoot] && ![aChild isKindOfClass:[BookmarkFolder class]]) { + NSLog(@"Attempting to insert a bookmark into the bookmark root"); + return; + } Is this a known issue, if so, is that why you are NSLog'ing? // adding from native plist - (BOOL)addBookmarkFromNativeDict:(NSDictionary *)aDict { - return [[self addBookmark] readNativeDictionary:aDict]; -} + Bookmark* theBookmark = [Bookmark bookmarkWithNativeDictionary:aDict]; + if (!theBookmark || [self isRoot]) + return NO; -- (BOOL)addBookmarkFromSafariDict:(NSDictionary *)aDict -{ - return [[self addBookmark] readSafariDictionary:aDict]; + [self appendChild:theBookmark]; + return YES; } Even though |theBookmark| is in a autorelease pool, it seems awkward to allocate an instance and return early. Perhaps (even if it is no the most elegant way) check for |[self isRoot]| first, then allocate. +- (BOOL)addBookmarkFromSafariDict:(NSDictionary *)aDict ..... + Bookmark* theBookmark = [Bookmark bookmarkWithSafariDictionary:aDict]; + if (!theBookmark || [self isRoot]) + return NO; + + [self appendChild:theBookmark]; + return YES; } Ditto here. r=me
Attachment #269398 - Flags: review?(nick.kreeger) → review+
Attached patch v2 — — Splinter Review
All comments addressed.
Attachment #269398 - Attachment is obsolete: true
Attachment #270436 - Flags: superreview?(joshmoz)
Attachment #270436 - Flags: superreview?(joshmoz) → superreview+
Attached patch missed file — — Splinter Review
I missed a file in the last patch; this is the BWC change.
Checked in on trunk and MOZILLA_1_8_BRANCH.
Status: NEW → RESOLVED
Closed: 19 years ago
Keywords: fixed1.8.1.5
Resolution: --- → FIXED
Whiteboard: [needs checkin]
Target Milestone: --- → Camino1.6
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: