mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 13:45:27 +00:00
Fixing bug 346782, bookmark toggle behavior is broken. Patch by froodian (stridey@gmail.com) r=smorgan, sr=pink.
This commit is contained in:
parent
b18e0ce2f8
commit
ab0481a4ba
@ -466,6 +466,7 @@ enum BWCOpenDest {
|
||||
- (void)openNewTabWithDescriptor:(nsISupports*)aDesc displayType:(PRUint32)aDisplayType loadInBackground:(BOOL)aLoadInBG;
|
||||
- (BOOL)isPageTextFieldFocused;
|
||||
- (void)performSearch:(SearchTextField *)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
|
||||
- (int)historyIndexOfPageBeforeBookmarkManager;
|
||||
- (void)goToLocationFromToolbarURLField:(AutoCompleteTextField *)inURLField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
|
||||
|
||||
- (BrowserTabViewItem*)tabForBrowser:(BrowserWrapper*)inWrapper;
|
||||
@ -1413,7 +1414,7 @@ enum BWCOpenDest {
|
||||
return enable;
|
||||
}
|
||||
else if (action == @selector(manageBookmarks:))
|
||||
return [[mBrowserView getBrowserView] canGoBack] || (![self bookmarkManagerIsVisible]);
|
||||
return ![self bookmarkManagerIsVisible] || [self canHideBookmarks];
|
||||
else if (action == @selector(reload:))
|
||||
return [[self getBrowserWrapper] canReload];
|
||||
else if (action == @selector(stop:))
|
||||
@ -1974,8 +1975,11 @@ enum BWCOpenDest {
|
||||
//
|
||||
-(IBAction)manageBookmarks:(id)aSender
|
||||
{
|
||||
if ([self bookmarkManagerIsVisible])
|
||||
[self back:aSender];
|
||||
if ([self bookmarkManagerIsVisible]) {
|
||||
int previousPage = [self historyIndexOfPageBeforeBookmarkManager];
|
||||
if (previousPage != -1)
|
||||
[[[self getBrowserWrapper] getBrowserView] goToSessionHistoryIndex:previousPage];
|
||||
}
|
||||
else
|
||||
[self loadURL:@"about:bookmarks"];
|
||||
|
||||
@ -2008,6 +2012,45 @@ enum BWCOpenDest {
|
||||
// to reveal...
|
||||
}
|
||||
|
||||
//
|
||||
// historyIndexOfPageBeforeBookmarkManager
|
||||
//
|
||||
// Returns the index in session history of the last page visited before viewing the bookmarks manager
|
||||
//
|
||||
- (int)historyIndexOfPageBeforeBookmarkManager
|
||||
{
|
||||
if (![self bookmarkManagerIsVisible])
|
||||
return -1;
|
||||
|
||||
nsIWebNavigation* webNav = [self currentWebNavigation];
|
||||
if (!webNav)
|
||||
return -1;
|
||||
|
||||
nsCOMPtr<nsISHistory> sessionHistory;
|
||||
webNav->GetSessionHistory(getter_AddRefs(sessionHistory));
|
||||
if (!sessionHistory)
|
||||
return -1;
|
||||
|
||||
PRInt32 curEntryIndex;
|
||||
sessionHistory->GetIndex(&curEntryIndex);
|
||||
|
||||
for (int i = curEntryIndex - 1; i >= 0; --i) {
|
||||
nsCOMPtr<nsIHistoryEntry> entry;
|
||||
sessionHistory->GetEntryAtIndex(i, PR_FALSE, getter_AddRefs(entry));
|
||||
|
||||
nsCAutoString uriSpec;
|
||||
nsCOMPtr<nsIURI> entryURI;
|
||||
entry->GetURI(getter_AddRefs(entryURI));
|
||||
if (entryURI)
|
||||
entryURI->GetSpec(uriSpec);
|
||||
|
||||
if (!(uriSpec.EqualsLiteral("about:bookmarks") || uriSpec.EqualsLiteral("about:history")))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (IBAction)goToLocationFromToolbarURLField:(id)sender
|
||||
{
|
||||
if ([sender isKindOfClass:[AutoCompleteTextField class]])
|
||||
@ -2416,7 +2459,7 @@ enum BWCOpenDest {
|
||||
|
||||
- (BOOL)canHideBookmarks
|
||||
{
|
||||
return [self bookmarkManagerIsVisible] && [[mBrowserView getBrowserView] canGoBack];
|
||||
return [self historyIndexOfPageBeforeBookmarkManager] != -1;
|
||||
}
|
||||
|
||||
- (BOOL)singleBookmarkIsSelected
|
||||
|
Loading…
Reference in New Issue
Block a user