Fix bug 160008: make autocomplete work in the Location sheet.

This commit is contained in:
smfr%smfr.org 2005-08-02 20:28:45 +00:00
Родитель e4270a6e72
Коммит 80bbacfa81
6 изменённых файлов: 87 добавлений и 58 удалений

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

@ -21,7 +21,7 @@
<key>463</key>
<string>348 489 213 275 0 0 1600 1002 </string>
<key>56</key>
<string>419 485 314 64 0 0 1152 746 </string>
<string>622 636 314 64 0 0 1600 1002 </string>
<key>654</key>
<string>1011 366 198 149 0 0 1280 938 </string>
<key>801</key>
@ -30,18 +30,14 @@
<string>124 551 213 61 0 0 1600 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>439.0</string>
<string>437.0</string>
<key>IBLockedObjects</key>
<array>
<integer>748</integer>
<integer>910</integer>
<integer>889</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>10</integer>
</array>
<key>IBSystem Version</key>
<string>8B15</string>
<string>8C46</string>
</dict>
</plist>

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

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

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

@ -48,20 +48,20 @@
@interface AutoCompleteTextField : NSTextField
{
IBOutlet PageProxyIcon *mProxyIcon;
NSWindow *mPopupWin;
NSTableView *mTableView;
IBOutlet PageProxyIcon* mProxyIcon;
NSWindow* mPopupWin;
NSTableView* mTableView;
NSImageView* mLock; // STRONG, lock that shows when a page is secure, hidden otherwise
NSColor* mSecureBackgroundColor; // STRONG, yellow color for bg when on a secure page, cached for perf
AutoCompleteDataSource *mDataSource;
AutoCompleteDataSource* mDataSource;
NSString* mSearchString;
NSTimer* mOpenTimer;
nsIAutoCompleteSession *mSession;
nsIAutoCompleteResults *mResults;
nsIAutoCompleteListener *mListener;
NSString *mSearchString;
nsIAutoCompleteSession* mSession; // owned
nsIAutoCompleteResults* mResults; // owned
nsIAutoCompleteListener* mListener; // owned
// used to remember if backspace was pressed in complete: so we can check this in controlTextDidChange
BOOL mBackspaced;
@ -70,8 +70,6 @@
// should the autocomplete fill in the default completion into the text field? The default
// is no, but this can be set with a user default pref.
BOOL mCompleteWhileTyping;
NSTimer *mOpenTimer;
}
- (void) setSession:(NSString *)aSession;

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

@ -202,13 +202,6 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
NSScrollView *scrollView;
NSCell *dataCell;
mSearchString = nil;
mBackspaced = NO;
mCompleteResult = NO;
mOpenTimer = nil;
mSession = nsnull;
mResults = nsnull;
mListener = (nsIAutoCompleteListener *)new AutoCompleteListener(self);
NS_IF_ADDREF(mListener);
@ -291,9 +284,10 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
name:NSUndoManagerDidUndoChangeNotification
object:[[self fieldEditor] undoManager]];
// register for embedding shutting down, to clean up history stuff
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(shutdown:)
name: XPCOMShutDownNotificationName
name: TermEmbeddingNotificationName
object: nil];
// read the user default on if we should auto-complete the text field as the user
@ -374,6 +368,9 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
{
return [[self window] fieldEditor:NO forObject:self];
}
#pragma mark -
// searching ////////////////////////////
- (void) startSearch:(NSString*)aString complete:(BOOL)aComplete
@ -394,6 +391,7 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
[mOpenTimer release];
}
// note that we've created a circular reference here
mOpenTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(searchTimer:)
userInfo:nil repeats:NO] retain];
}
@ -459,6 +457,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
[self closePopup];
}
#pragma mark -
// handling the popup /////////////////////////////////
- (void) openPopup
@ -475,32 +475,30 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
- (void) resizePopup
{
NSRect locationFrame, winFrame;
NSPoint locationOrigin;
int tableHeight;
if ([self visibleRows] == 0) {
[self closePopup];
return;
}
// get the origin of the location bar in coordinates of the root view
locationFrame = [[self superview] frame];
locationOrigin = [[[self superview] superview] convertPoint:locationFrame.origin
toView:[[[self window] contentView] superview]];
NSRect locationFrame = [self bounds];
NSPoint locationOrigin = locationFrame.origin;
locationOrigin.y += NSHeight(locationFrame); // we want bottom left
locationOrigin = [self convertPoint:locationOrigin toView:nil];
// get the height of the table view
winFrame = [[self window] frame];
tableHeight = (int)([mTableView rowHeight]+[mTableView intercellSpacing].height)*[self visibleRows];
NSRect winFrame = [[self window] frame];
int tableHeight = (int)([mTableView rowHeight] + [mTableView intercellSpacing].height) * [self visibleRows];
// make the columns split the width of the popup
[[mTableView tableColumnWithIdentifier:@"col1"] setWidth:locationFrame.size.width/2];
[[mTableView tableColumnWithIdentifier:@"col1"] setWidth:(locationFrame.size.width / 2.0f)];
// position the popup anchored to bottom/left of location bar (
[mPopupWin setFrame:NSMakeRect(winFrame.origin.x + locationOrigin.x + kFrameMargin,
// position the popup anchored to bottom/left of location bar
NSRect popupFrame = NSMakeRect(winFrame.origin.x + locationOrigin.x + kFrameMargin,
((winFrame.origin.y + locationOrigin.y) - tableHeight) - kFrameMargin,
locationFrame.size.width - (2*kFrameMargin),
tableHeight) display:NO];
locationFrame.size.width - (2 * kFrameMargin),
tableHeight);
[mPopupWin setFrame:popupFrame display:NO];
}
- (void) closePopup
@ -526,6 +524,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
return ( mSearchString != nil );
}
#pragma mark -
// url completion ////////////////////////////
- (void) completeDefaultResult
@ -601,15 +601,22 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
- (void) revertText
{
BrowserWindowController *controller = (BrowserWindowController *)[[self window] windowController];
NSString *url = [[controller getBrowserWrapper] getCurrentURI];
if (url) {
id parentWindowController = [[self window] windowController];
NSString* url = nil;
if ([parentWindowController isKindOfClass:[BrowserWindowController class]])
{
BrowserWindowController *controller = (BrowserWindowController*)parentWindowController;
url = [[controller getBrowserWrapper] getCurrentURI];
}
if (!url)
url = @"";
[self clearResults];
NSTextView *fieldEditor = [self fieldEditor];
[[fieldEditor undoManager] removeAllActionsWithTarget:self];
[fieldEditor setString:url];
[fieldEditor selectAll:self];
}
}
//
@ -716,6 +723,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
[fieldEditor setSelectedRange:range];
}
#pragma mark -
// selecting rows /////////////////////////////////////////
- (void) selectRowAt:(int)aRow
@ -763,6 +772,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
[self selectRowAt:row];
}
#pragma mark -
// event handlers ////////////////////////////////////////////
- (void) onRowClicked:(NSNotification *)aNote
@ -791,6 +802,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
[self clearResults];
}
#pragma mark -
// Drag & Drop Methods ///////////////////////////////////////
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
@ -828,6 +841,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
[self selectText:self];
}
#pragma mark -
// NSTextField delegate //////////////////////////////////
- (void)controlTextDidChange:(NSNotification *)aNote
{
@ -923,4 +938,15 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
return NO;
}
#pragma mark -
// NSWindow delegate methods. We're only the window's delegate when we're inside
// the open location sheet.
- (void)windowWillClose:(NSNotification *)aNotification
{
// make sure we hide the autocomplete popup when the Location sheet is dismissed
[self clearResults];
}
@end

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

@ -1465,6 +1465,9 @@ enum BWCOpenDest {
- (void)beginLocationSheet
{
[mLocationSheetURLField setStringValue:[mURLBar stringValue]];
[mLocationSheetURLField selectText:nil];
[NSApp beginSheet: mLocationSheetWindow
modalForWindow: [self window]
modalDelegate: nil
@ -1474,14 +1477,14 @@ enum BWCOpenDest {
- (IBAction)endLocationSheet:(id)sender
{
[mLocationSheetWindow orderOut:self];
[mLocationSheetWindow close]; // assumes it's not released on close
[NSApp endSheet:mLocationSheetWindow returnCode:1];
[self loadURL:[mLocationSheetURLField stringValue] referrer:nil activate:YES allowPopups:NO];
}
- (IBAction)cancelLocationSheet:(id)sender
{
[mLocationSheetWindow orderOut:self];
[mLocationSheetWindow close]; // assumes it's not released on close
[NSApp endSheet:mLocationSheetWindow returnCode:0];
}

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

@ -92,7 +92,13 @@
{
NSString* urlString = nil;
NSString* titleString = nil;
[[[[self window] windowController] getBrowserWrapper] getTitle:&titleString andHref:&urlString];
id parentWindowController = [[self window] windowController];
if ([parentWindowController isKindOfClass:[BrowserWindowController class]])
[[(BrowserWindowController*)parentWindowController getBrowserWrapper] getTitle:&titleString andHref:&urlString];
if (!urlString)
return;
NSString *cleanedTitle = [titleString stringByReplacingCharactersInSet:[NSCharacterSet controlCharacterSet] withString:@" "];