Closed
Bug 385484
Opened 19 years ago
Closed 19 years ago
Refactor bookmark creation APIs
Categories
(Camino Graveyard :: Bookmarks, defect)
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)
|
17.57 KB,
patch
|
jaas
:
superreview+
|
Details | Diff | Splinter Review |
|
1.29 KB,
patch
|
Details | Diff | 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?
| Assignee | ||
Updated•19 years ago
|
Attachment #269398 -
Flags: review? → review?(nick.kreeger)
Comment 1•19 years ago
|
||
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+
| Assignee | ||
Comment 2•19 years ago
|
||
All comments addressed.
Attachment #269398 -
Attachment is obsolete: true
Attachment #270436 -
Flags: superreview?(joshmoz)
Attachment #270436 -
Flags: superreview?(joshmoz) → superreview+
Whiteboard: [needs checkin]
| Assignee | ||
Comment 3•19 years ago
|
||
I missed a file in the last patch; this is the BWC change.
| Assignee | ||
Comment 4•19 years ago
|
||
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]
| Assignee | ||
Updated•19 years ago
|
Target Milestone: --- → Camino1.6
You need to log in
before you can comment on or make changes to this bug.
Description
•