Camino only - Bug 241100: Make the 'load in background' pref only apply to tabs, clarify its description (bug 356204), and update the Tabs pref class name from Chimera to Camino (bug 381356). r/sr=mento

This commit is contained in:
stuart.morgan%alumni.case.edu 2008-01-19 00:10:20 +00:00
Родитель b5a9f9470d
Коммит abe1e59792
14 изменённых файлов: 95 добавлений и 71 удалений

Просмотреть файл

@ -23,6 +23,6 @@
<key>NSMainNibFile</key>
<string>Tabs</string>
<key>NSPrincipalClass</key>
<string>OrgMozillaChimeraPreferenceTabs</string>
<string>OrgMozillaCaminoPreferenceTabs</string>
</dict>
</plist>

Просмотреть файл

@ -14,7 +14,7 @@
},
{
ACTIONS = {checkboxClicked = id; };
CLASS = OrgMozillaChimeraPreferenceTabs;
CLASS = OrgMozillaCaminoPreferenceTabs;
LANGUAGE = ObjC;
OUTLETS = {
mCheckboxLoadTabsInBackground = NSButton;

Просмотреть файл

@ -11,6 +11,6 @@
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>
<string>8S2167</string>
</dict>
</plist>

Двоичные данные
camino/PreferencePanes/Tabs/English.lproj/Tabs.nib/keyedobjects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -41,7 +41,7 @@
#import <Cocoa/Cocoa.h>
#import <PreferencePaneBase.h>
@interface OrgMozillaChimeraPreferenceTabs : PreferencePaneBase
@interface OrgMozillaCaminoPreferenceTabs : PreferencePaneBase
{
IBOutlet NSButton* mCheckboxOpenTabsForCommand;
IBOutlet NSButton* mCheckboxOpenTabsForExternalLinks;

Просмотреть файл

@ -44,7 +44,7 @@
const int kOpenExternalLinksInNewWindow = 0;
const int kOpenExternalLinksInNewTab = 1;
@implementation OrgMozillaChimeraPreferenceTabs
@implementation OrgMozillaCaminoPreferenceTabs
- (id)initWithBundle:(NSBundle *)bundle
{

Просмотреть файл

@ -798,7 +798,7 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
}
else {
openInNewWindow = YES;
if (loadNewTabsInBackgroundPref)
if (reverseBackgroundPref)
behindWindow = [browserWindowController window];
}
break;
@ -816,7 +816,7 @@ NSString* const kPreviousSessionTerminatedNormallyKey = @"PreviousSessionTermina
case eBookmarkOpenBehavior_NewWindow:
openInNewWindow = YES;
if (loadNewTabsInBackgroundPref)
if (reverseBackgroundPref)
behindWindow = [browserWindowController window];
break;

Просмотреть файл

@ -588,13 +588,7 @@ const int kOutlineViewLeftMargin = 19; // determined empirically, since it doesn
}
// make new window
BOOL loadNewTabsInBackgroundPref = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
NSWindow* behindWindow = nil;
if (loadNewTabsInBackgroundPref)
behindWindow = [mBrowserWindowController window];
[[NSApp delegate] openBrowserWindowWithURLs:urlArray behind:behindWindow allowPopups:NO];
[[NSApp delegate] openBrowserWindowWithURLs:urlArray behind:nil allowPopups:NO];
}
- (IBAction)openBookmarkInNewWindow:(id)aSender

Просмотреть файл

@ -461,14 +461,16 @@ NSString* const kTabBarBackgroundDoubleClickedNotification = @"kTabBarBackground
{
if ([urls count] == 1) {
NSString* url = [urls objectAtIndex:0];
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:eDestinationNewTab
sender:nil];
if (targetTab) {
[[targetTab view] loadURI:url referrer:nil flags:NSLoadFlagsNone focusContent:YES allowPopups:NO];
if (![BrowserWindowController shouldLoadInBackground:nil])
if (!loadInBackground)
[self selectTabViewItem:targetTab];
}
else {
[self addTabForURL:url referrer:nil inBackground:[BrowserWindowController shouldLoadInBackground:nil]];
[self addTabForURL:url referrer:nil inBackground:loadInBackground];
}
}
else {

Просмотреть файл

@ -96,6 +96,12 @@ typedef enum
} ETabOpenPolicy;
typedef enum {
eDestinationNewWindow = 0,
eDestinationNewTab,
eDestinationCurrentView
} EOpenDestination;
@class CHBrowserView;
@class BookmarkViewController;
@class BookmarkToolbar;
@ -361,10 +367,13 @@ typedef enum
// cache the toolbar defaults we parse from a plist
+ (NSArray*) toolbarDefaults;
// Get the load-in-background pref. If possible, aSender's keyEquivalentModifierMask
// is used to determine the shift key's state. Otherwise (if aSender doesn't respond to
// keyEquivalentModifierMask or aSender is nil) uses the current event's modifier flags.
+ (BOOL)shouldLoadInBackground:(id)aSender;
// Get the correct load-in-background behvaior for the given destination based
// on prefs and the state of the shift key. If possible, aSender's
// keyEquivalentModifierMask is used to determine the shift key's state.
// Otherwise (if aSender doesn't respond to keyEquivalentModifierMask is nil)
// it uses the current event's modifier flags.
+ (BOOL)shouldLoadInBackgroundForDestination:(EOpenDestination)destination
sender:(id)sender;
// Accessor to get the proxy icon view
- (PageProxyIcon *)proxyIconView;

Просмотреть файл

@ -526,12 +526,6 @@ public:
#pragma mark -
enum BWCOpenDest {
kDestinationNewWindow = 0,
kDestinationNewTab,
kDestinationCurrentView
};
@interface BrowserWindowController(Private)
// open a new window or tab, but doesn't load anything into them. Must be matched
// with a call to do that.
@ -546,9 +540,9 @@ enum BWCOpenDest {
- (void)transformFormatString:(NSMutableString*)inFormat domain:(NSString*)inDomain search:(NSString*)inSearch;
- (void)openNewWindowWithDescriptor:(nsISupports*)aDesc displayType:(PRUint32)aDisplayType loadInBackground:(BOOL)aLoadInBG;
- (void)openNewTabWithDescriptor:(nsISupports*)aDesc displayType:(PRUint32)aDisplayType loadInBackground:(BOOL)aLoadInBG;
- (void)performSearch:(WebSearchField*)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
- (void)performSearch:(WebSearchField*)inSearchField inView:(EOpenDestination)inDest inBackground:(BOOL)inLoadInBG;
- (int)historyIndexOfPageBeforeBookmarkManager;
- (void)goToLocationFromToolbarURLField:(AutoCompleteTextField *)inURLField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG;
- (void)goToLocationFromToolbarURLField:(AutoCompleteTextField *)inURLField inView:(EOpenDestination)inDest inBackground:(BOOL)inLoadInBG;
- (BrowserTabViewItem*)tabForBrowser:(BrowserWrapper*)inWrapper;
- (void)closeTab:(NSTabViewItem *)tab;
@ -1261,16 +1255,18 @@ enum BWCOpenDest {
return sToolbarDefaults;
}
// +shouldLoadInBackground
//
// gets the foreground/background tab loading pref
//
+ (BOOL)shouldLoadInBackground:(id)aSender
+ (BOOL)shouldLoadInBackgroundForDestination:(EOpenDestination)destination
sender:(id)sender;
{
BOOL loadInBackground = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
BOOL loadInBackground = NO;
if (destination == eDestinationNewTab) {
loadInBackground =
[[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground"
withSuccess:NULL];
}
if ([aSender respondsToSelector:@selector(keyEquivalentModifierMask)]) {
if ([aSender keyEquivalentModifierMask] & NSShiftKeyMask)
if ([sender respondsToSelector:@selector(keyEquivalentModifierMask)]) {
if ([sender keyEquivalentModifierMask] & NSShiftKeyMask)
loadInBackground = !loadInBackground;
}
else {
@ -2317,7 +2313,7 @@ enum BWCOpenDest {
{
[mSearchSheetWindow orderOut:self];
[NSApp endSheet:mSearchSheetWindow returnCode:1];
[self performSearch:mSearchSheetTextField inView:kDestinationCurrentView inBackground:NO];
[self performSearch:mSearchSheetTextField inView:eDestinationCurrentView inBackground:NO];
}
- (IBAction)cancelSearchSheet:(id)sender
@ -2416,11 +2412,11 @@ enum BWCOpenDest {
{
if ([sender isKindOfClass:[AutoCompleteTextField class]])
[self goToLocationFromToolbarURLField:(AutoCompleteTextField *)sender
inView:kDestinationCurrentView inBackground:NO];
inView:eDestinationCurrentView inBackground:NO];
}
- (void)goToLocationFromToolbarURLField:(AutoCompleteTextField *)inURLField
inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG
inView:(EOpenDestination)inDest inBackground:(BOOL)inLoadInBG
{
// trim off any whitespace around url
NSString *theURL = [[inURLField stringValue] stringByTrimmingWhitespace];
@ -2441,15 +2437,15 @@ enum BWCOpenDest {
if (!resolvedURLs || [resolvedURLs count] == 1) {
targetURL = resolvedURLs ? [resolvedURLs lastObject] : theURL;
BOOL allowPopups = resolvedURLs ? YES : NO; //Allow popups if it's a bookmark shortcut
if (inDest == kDestinationNewTab)
if (inDest == eDestinationNewTab)
[self openNewTabWithURL:targetURL referrer:nil loadInBackground:inLoadInBG allowPopups:allowPopups setJumpback:NO];
else if (inDest == kDestinationNewWindow)
else if (inDest == eDestinationNewWindow)
[self openNewWindowWithURL:targetURL referrer:nil loadInBackground:inLoadInBG allowPopups:allowPopups];
else // if it's not a new window or a new tab, load into the current view
[self loadURL:targetURL referrer:nil focusContent:YES allowPopups:allowPopups];
}
else {
if (inDest == kDestinationNewTab || inDest == kDestinationNewWindow)
if (inDest == eDestinationNewTab || inDest == eDestinationNewWindow)
[self openURLArray:resolvedURLs tabOpenPolicy:eAppendTabs allowPopups:YES];
else
[self openURLArray:resolvedURLs tabOpenPolicy:eReplaceTabs allowPopups:YES];
@ -2606,7 +2602,7 @@ enum BWCOpenDest {
[mSearchSheetWindow orderOut:self];
[NSApp endSheet:mSearchSheetWindow returnCode:1];
}
[self performSearch:aSender inView:kDestinationCurrentView inBackground:NO];
[self performSearch:aSender inView:eDestinationCurrentView inBackground:NO];
}
}
@ -2626,14 +2622,17 @@ enum BWCOpenDest {
unsigned int modifiers = [[NSApp currentEvent] modifierFlags];
EOpenDestination destination = eDestinationCurrentView;
BOOL loadInBackground = NO;
// do search in a new window/tab if Command is held down
if (modifiers & NSCommandKeyMask) {
BOOL loadInTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BWCOpenDest destination = loadInTab ? kDestinationNewTab : kDestinationNewWindow;
[self performSearch:mSearchBar inView:destination inBackground:[BrowserWindowController shouldLoadInBackground:nil]];
destination = loadInTab ? eDestinationNewTab : eDestinationNewWindow;
loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:destination
sender:nil];
}
else
[self performSearch:mSearchBar inView:kDestinationCurrentView inBackground:NO];
[self performSearch:mSearchBar inView:destination inBackground:loadInBackground];
}
//
@ -2642,7 +2641,7 @@ enum BWCOpenDest {
// performs a search using searchField and opens either in the current view, a new tab, or a new
// window. If it's a new tab or window, loadInBG determines whether the window/tab is opened in the background
//
-(void)performSearch:(WebSearchField*)inSearchField inView:(BWCOpenDest)inDest inBackground:(BOOL)inLoadInBG
-(void)performSearch:(WebSearchField*)inSearchField inView:(EOpenDestination)inDest inBackground:(BOOL)inLoadInBG
{
NSString *searchString = [inSearchField stringValue];
NSMutableString *searchURL = [[[inSearchField currentSearchURL] mutableCopy] autorelease];
@ -2672,9 +2671,9 @@ enum BWCOpenDest {
NSString *searchDomain = [NSString stringWithUTF8String:spec.get()];
if (inDest == kDestinationNewTab)
if (inDest == eDestinationNewTab)
[self openNewTabWithURL:searchDomain referrer:nil loadInBackground:inLoadInBG allowPopups:NO setJumpback:NO];
else if (inDest == kDestinationNewWindow)
else if (inDest == eDestinationNewWindow)
[self openNewWindowWithURL:searchDomain referrer:nil loadInBackground:inLoadInBG allowPopups:NO];
else // if it's not a new window or a new tab, load into the current view
[self loadURL:searchDomain];
@ -2700,9 +2699,9 @@ enum BWCOpenDest {
[self transformFormatString:searchURL domain:currentDomain search:escapedSearchString];
[escapedSearchString release];
if (inDest == kDestinationNewTab)
if (inDest == eDestinationNewTab)
[self openNewTabWithURL:searchURL referrer:nil loadInBackground:inLoadInBG allowPopups:NO setJumpback:NO];
else if (inDest == kDestinationNewWindow)
else if (inDest == eDestinationNewWindow)
[self openNewWindowWithURL:searchURL referrer:nil loadInBackground:inLoadInBG allowPopups:NO];
else // if it's not a new window or a new tab, load into the current view
[self loadURL:searchURL];
@ -3565,7 +3564,8 @@ enum BWCOpenDest {
BrowserTabViewItem* tabViewItem = [mTabBrowser itemWithTag:[sender tag]];
if (tabViewItem) {
NSString* url = [[tabViewItem view] currentURI];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackground:nil];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackgroundForDestination:eDestinationNewWindow
sender:nil];
[self openNewWindowWithURL:url referrer:nil loadInBackground:backgroundLoad allowPopups:NO];
@ -3788,7 +3788,9 @@ enum BWCOpenDest {
// if we replace all tabs (because we opened a tab group), or we open additional tabs
// with the "focus new tab"-pref on, focus the first new tab.
if (!((tabPolicy == eAppendTabs) && [BrowserWindowController shouldLoadInBackground:nil]))
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:eDestinationNewTab
sender:nil];
if (!((tabPolicy == eAppendTabs) && loadInBackground))
[mTabBrowser selectTabViewItem:tabViewToSelect];
}
@ -4508,7 +4510,9 @@ enum BWCOpenDest {
if ([hrefStr length] == 0)
return;
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackground:nil];
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:(aUseWindow ? eDestinationNewWindow
: eDestinationNewTab)
sender:nil];
NSString* referrer = [[mBrowserView browserView] focusedURLString];
@ -4598,7 +4602,9 @@ enum BWCOpenDest {
if (modifiers & NSCommandKeyMask) {
BOOL loadInTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BOOL loadInBG = [BrowserWindowController shouldLoadInBackground:nil];
BOOL loadInBG = [BrowserWindowController shouldLoadInBackgroundForDestination:(loadInTab ? eDestinationNewTab
: eDestinationNewWindow)
sender:nil];
if (loadInTab)
[self openNewTabWithURL:urlStr referrer:referrer loadInBackground:loadInBG allowPopups:NO setJumpback:NO];
else
@ -4927,15 +4933,17 @@ enum BWCOpenDest {
//
- (BOOL)handleCommandReturn:(BOOL)aShiftIsDown
{
// determine whether to load in background
BOOL loadInBG = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
if (aShiftIsDown) // if shift is being held down, do the opposite of the pref
loadInBG = !loadInBG;
// determine whether to load in tab or window
BOOL loadInTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BWCOpenDest destination = loadInTab ? kDestinationNewTab : kDestinationNewWindow;
// determine whether to load in background
BOOL loadInBG = NO;
if (loadInTab)
loadInBG = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.loadInBackground" withSuccess:NULL];
if (aShiftIsDown) // if shift is being held down, do the opposite of the pref
loadInBG = !loadInBG;
EOpenDestination destination = loadInTab ? eDestinationNewTab : eDestinationNewWindow;
// see if command-return came in the url bar
BOOL handled = NO;

Просмотреть файл

@ -115,7 +115,9 @@ ContentClickListener::MouseClick(nsIDOMEvent* aEvent)
// Open the link in a new window or tab if it's an internally handled, non-Javascript link.
if (![hrefScheme isEqualToString:@"javascript"] && GeckoUtils::isProtocolInternal([hrefScheme UTF8String])) {
BOOL useTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackground:nil];
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:(useTab ? eDestinationNewTab
: eDestinationNewWindow)
sender:nil];
if (useTab)
[mBrowserController openNewTabWithURL:hrefStr referrer:referrer loadInBackground:loadInBackground allowPopups:NO setJumpback:YES];

Просмотреть файл

@ -450,8 +450,12 @@ static const unsigned int kMaxTitleLength = 50;
{
if ([sender keyEquivalentModifierMask] & NSCommandKeyMask)
{
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackground:sender];
if ([[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL])
BOOL openInTab = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick"
withSuccess:NULL];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackgroundForDestination:(openInTab ? eDestinationNewTab
: eDestinationNewWindow)
sender:sender];
if (openInTab)
[bwc openNewTabWithURL:itemURL referrer:nil loadInBackground:backgroundLoad allowPopups:NO setJumpback:NO];
else
[bwc openNewWindowWithURL:itemURL referrer:nil loadInBackground:backgroundLoad allowPopups:NO];

Просмотреть файл

@ -203,8 +203,10 @@ static NSString* const kExpandedHistoryStatesDefaultsKey = @"history_expand_stat
return;
}
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackground:sender];
BOOL openInTabs = [[PreferenceManager sharedInstance] getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:NULL];
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:(openInTabs ? eDestinationNewTab
: eDestinationNewWindow)
sender:sender];
BOOL cmdKeyDown = (([[NSApp currentEvent] modifierFlags] & NSCommandKeyMask) != 0);
NSEnumerator* itemEnum = [selectedHistoryItems objectEnumerator];
@ -265,7 +267,8 @@ static NSString* const kExpandedHistoryStatesDefaultsKey = @"history_expand_stat
{
NSArray* itemsArray = [mHistoryOutlineView selectedItems];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackground:aSender];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackgroundForDestination:eDestinationNewWindow
sender:aSender];
NSEnumerator* itemsEnum = [itemsArray objectEnumerator];
HistoryItem* curItem;
@ -281,7 +284,8 @@ static NSString* const kExpandedHistoryStatesDefaultsKey = @"history_expand_stat
{
NSArray* itemsArray = [mHistoryOutlineView selectedItems];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackground:aSender];
BOOL backgroundLoad = [BrowserWindowController shouldLoadInBackgroundForDestination:eDestinationNewTab
sender:aSender];
NSEnumerator* itemsEnum = [itemsArray objectEnumerator];
HistoryItem* curItem;
@ -307,7 +311,8 @@ static NSString* const kExpandedHistoryStatesDefaultsKey = @"history_expand_stat
}
// make new window
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackground:aSender];
BOOL loadInBackground = [BrowserWindowController shouldLoadInBackgroundForDestination:eDestinationNewWindow
sender:aSender];
NSWindow* behindWindow = nil;
if (loadInBackground)
behindWindow = [mBrowserWindowController window];