Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: chrome/browser/cocoa/autocomplete_text_field.mm

Issue 501135: Revert 34998, more stabbing in the dark to find a perf regression - Mac: impl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/autocomplete_text_field.h" 5 #import "chrome/browser/cocoa/autocomplete_text_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" 8 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
9 #import "chrome/browser/cocoa/browser_window_controller.h"
10 #import "chrome/browser/cocoa/toolbar_controller.h"
11 #import "chrome/browser/cocoa/url_drop_target.h"
12 9
13 @implementation AutocompleteTextField 10 @implementation AutocompleteTextField
14 11
15 @synthesize observer = observer_; 12 @synthesize observer = observer_;
16 13
17 + (Class)cellClass { 14 + (Class)cellClass {
18 return [AutocompleteTextFieldCell class]; 15 return [AutocompleteTextFieldCell class];
19 } 16 }
20 17
21 - (void)dealloc { 18 - (void)dealloc {
22 [[NSNotificationCenter defaultCenter] removeObserver:self]; 19 [[NSNotificationCenter defaultCenter] removeObserver:self];
23 [super dealloc]; 20 [super dealloc];
24 } 21 }
25 22
26 - (void)awakeFromNib { 23 - (void)awakeFromNib {
27 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]); 24 DCHECK([[self cell] isKindOfClass:[AutocompleteTextFieldCell class]]);
28 dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]);
29 } 25 }
30 26
31 - (void)flagsChanged:(NSEvent*)theEvent { 27 - (void)flagsChanged:(NSEvent*)theEvent {
32 if (observer_) { 28 if (observer_) {
33 const bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; 29 const bool controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0;
34 observer_->OnControlKeyChanged(controlFlag); 30 observer_->OnControlKeyChanged(controlFlag);
35 } 31 }
36 } 32 }
37 33
38 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell { 34 - (AutocompleteTextFieldCell*)autocompleteTextFieldCell {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 - (void)viewDidMoveToWindow { 245 - (void)viewDidMoveToWindow {
250 if ([self window]) { 246 if ([self window]) {
251 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; 247 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
252 [nc addObserver:self 248 [nc addObserver:self
253 selector:@selector(windowDidResignKey:) 249 selector:@selector(windowDidResignKey:)
254 name:NSWindowDidResignKeyNotification 250 name:NSWindowDidResignKeyNotification
255 object:[self window]]; 251 object:[self window]];
256 } 252 }
257 } 253 }
258 254
259 // (URLDropTarget protocol)
260 - (id<URLDropTargetController>)urlDropController {
261 BrowserWindowController* windowController = [[self window] windowController];
262 DCHECK([windowController isKindOfClass:[BrowserWindowController class]]);
263 return [windowController toolbarController];
264 }
265
266 // (URLDropTarget protocol)
267 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
268 // Make ourself the first responder, which will select the text to indicate
269 // that our contents would be replaced by a drop.
270 // TODO(viettrungluu): crbug.com/30809 -- this is a hack since it steals focus
271 // and doesn't return it.
272 [[self window] makeFirstResponder:self];
273 return [dropHandler_ draggingEntered:sender];
274 }
275
276 // (URLDropTarget protocol)
277 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
278 return [dropHandler_ draggingUpdated:sender];
279 }
280
281 // (URLDropTarget protocol)
282 - (void)draggingExited:(id<NSDraggingInfo>)sender {
283 return [dropHandler_ draggingExited:sender];
284 }
285
286 // (URLDropTarget protocol)
287 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
288 return [dropHandler_ performDragOperation:sender];
289 }
290
291 @end 255 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field.h ('k') | chrome/browser/cocoa/autocomplete_text_field_editor.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698