OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/location_bar/autocomplete_text_field.h" | 5 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "chrome/browser/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/cocoa/browser_window_controller.h" |
9 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" | 9 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" |
10 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" | 10 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 [undoManager_ removeAllActions]; | 204 [undoManager_ removeAllActions]; |
205 } | 205 } |
206 | 206 |
207 // Show the I-beam cursor unless the mouse is over an image within the field | 207 // Show the I-beam cursor unless the mouse is over an image within the field |
208 // (Page Actions or the security icon) in which case show the arrow cursor. | 208 // (Page Actions or the security icon) in which case show the arrow cursor. |
209 // TODO(rohitrao): Should default to the arrow cursor. http://crbug.com/41612 | 209 // TODO(rohitrao): Should default to the arrow cursor. http://crbug.com/41612 |
210 - (void)resetCursorRects { | 210 - (void)resetCursorRects { |
211 NSRect fieldBounds = [self bounds]; | 211 NSRect fieldBounds = [self bounds]; |
212 [self addCursorRect:fieldBounds cursor:[NSCursor IBeamCursor]]; | 212 [self addCursorRect:fieldBounds cursor:[NSCursor IBeamCursor]]; |
213 | 213 |
214 AutocompleteTextFieldCell* cell = [self cell]; | |
215 for (AutocompleteTextFieldIcon* icon in [cell layedOutIcons:fieldBounds]) | |
216 [self addCursorRect:[icon rect] cursor:[NSCursor arrowCursor]]; | |
217 | |
218 // TODO(shess): This needs to traverse the LocationBarDecorations | 214 // TODO(shess): This needs to traverse the LocationBarDecorations |
219 // and put up a cursor for them, too. Except for the keyword-search | 215 // and put up a cursor for them, too. Except for the keyword-search |
220 // stuff? Sigh. | 216 // stuff? Sigh. |
| 217 // http://crbug.com/48867 |
221 } | 218 } |
222 | 219 |
223 // TODO(shess): -resetFieldEditorFrameIfNeeded is the place where | 220 // TODO(shess): -resetFieldEditorFrameIfNeeded is the place where |
224 // changes to the cell layout should be flushed. LocationBarViewMac | 221 // changes to the cell layout should be flushed. LocationBarViewMac |
225 // and ToolbarController are calling this routine directly, and I | 222 // and ToolbarController are calling this routine directly, and I |
226 // think they are probably wrong. | 223 // think they are probably wrong. |
227 // http://crbug.com/40053 | 224 // http://crbug.com/40053 |
228 - (void)updateCursorAndToolTipRects { | 225 - (void)updateCursorAndToolTipRects { |
229 // This will force |resetCursorRects| to be called, as it is not to be called | 226 // This will force |resetCursorRects| to be called, as it is not to be called |
230 // directly. | 227 // directly. |
231 [[self window] invalidateCursorRectsForView:self]; | 228 [[self window] invalidateCursorRectsForView:self]; |
232 | 229 |
233 // |removeAllToolTips| only removes those set on the current NSView, not any | 230 // |removeAllToolTips| only removes those set on the current NSView, not any |
234 // subviews. Unless more tooltips are added to this view, this should suffice | 231 // subviews. Unless more tooltips are added to this view, this should suffice |
235 // in place of managing a set of NSToolTipTag objects. | 232 // in place of managing a set of NSToolTipTag objects. |
236 [self removeAllToolTips]; | 233 [self removeAllToolTips]; |
237 [currentToolTips_ removeAllObjects]; | 234 [currentToolTips_ removeAllObjects]; |
238 | 235 |
| 236 #if 0 |
| 237 // TODO(shess): Bring back tooltips. All the wiring is in there, |
| 238 // just need to hook it up. |
| 239 // http://crbug.com/49321 |
239 AutocompleteTextFieldCell* cell = [self cell]; | 240 AutocompleteTextFieldCell* cell = [self cell]; |
240 for (AutocompleteTextFieldIcon* icon in [cell layedOutIcons:[self bounds]]) { | 241 for (AutocompleteTextFieldIcon* icon in [cell layedOutIcons:[self bounds]]) { |
241 NSRect iconRect = [icon rect]; | 242 NSRect iconRect = [icon rect]; |
242 NSString* tooltip = [icon view]->GetToolTip(); | 243 NSString* tooltip = [icon view]->GetToolTip(); |
243 if (!tooltip) | 244 if (!tooltip) |
244 continue; | 245 continue; |
245 | 246 |
246 // -[NSView addToolTipRect:owner:userData] does _not_ retain its |owner:|. | 247 // -[NSView addToolTipRect:owner:userData] does _not_ retain its |owner:|. |
247 // Put the string in a collection so it can't be dealloced while in use. | 248 // Put the string in a collection so it can't be dealloced while in use. |
248 [currentToolTips_ addObject:tooltip]; | 249 [currentToolTips_ addObject:tooltip]; |
249 [self addToolTipRect:iconRect owner:tooltip userData:nil]; | 250 [self addToolTipRect:iconRect owner:tooltip userData:nil]; |
250 } | 251 } |
| 252 #endif |
251 } | 253 } |
252 | 254 |
253 // NOTE(shess): http://crbug.com/19116 describes a weird bug which | 255 // NOTE(shess): http://crbug.com/19116 describes a weird bug which |
254 // happens when the user runs a Print panel on Leopard. After that, | 256 // happens when the user runs a Print panel on Leopard. After that, |
255 // spurious -controlTextDidBeginEditing notifications are sent when an | 257 // spurious -controlTextDidBeginEditing notifications are sent when an |
256 // NSTextField is firstResponder, even though -currentEditor on that | 258 // NSTextField is firstResponder, even though -currentEditor on that |
257 // field returns nil. That notification caused significant problems | 259 // field returns nil. That notification caused significant problems |
258 // in AutocompleteEditViewMac. -textDidBeginEditing: was NOT being | 260 // in AutocompleteEditViewMac. -textDidBeginEditing: was NOT being |
259 // sent in those cases, so this approach doesn't have the problem. | 261 // sent in those cases, so this approach doesn't have the problem. |
260 - (void)textDidBeginEditing:(NSNotification*)aNotification { | 262 - (void)textDidBeginEditing:(NSNotification*)aNotification { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { | 405 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
404 return [dropHandler_ performDragOperation:sender]; | 406 return [dropHandler_ performDragOperation:sender]; |
405 } | 407 } |
406 | 408 |
407 - (NSMenu*)decorationMenuForEvent:(NSEvent*)event { | 409 - (NSMenu*)decorationMenuForEvent:(NSEvent*)event { |
408 AutocompleteTextFieldCell* cell = [self cell]; | 410 AutocompleteTextFieldCell* cell = [self cell]; |
409 return [cell decorationMenuForEvent:event inRect:[self bounds] ofView:self]; | 411 return [cell decorationMenuForEvent:event inRect:[self bounds] ofView:self]; |
410 } | 412 } |
411 | 413 |
412 @end | 414 @end |
OLD | NEW |