OLD | NEW |
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" | 9 #import "chrome/browser/cocoa/browser_window_controller.h" |
10 #import "chrome/browser/cocoa/toolbar_controller.h" | 10 #import "chrome/browser/cocoa/toolbar_controller.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 - (NSUndoManager*)undoManagerForTextView:(NSTextView*)textView { | 188 - (NSUndoManager*)undoManagerForTextView:(NSTextView*)textView { |
189 if (!undoManager_.get()) | 189 if (!undoManager_.get()) |
190 undoManager_.reset([[NSUndoManager alloc] init]); | 190 undoManager_.reset([[NSUndoManager alloc] init]); |
191 return undoManager_.get(); | 191 return undoManager_.get(); |
192 } | 192 } |
193 | 193 |
194 - (void)clearUndoChain { | 194 - (void)clearUndoChain { |
195 [undoManager_ removeAllActions]; | 195 [undoManager_ removeAllActions]; |
196 } | 196 } |
197 | 197 |
198 // Any image within the field (Page Actions or the security icon) should have | 198 // Show the I-beam cursor unless the mouse is over an image within the field |
199 // the arrow cursor shown instead of the I-beam. | 199 // (Page Actions or the security icon) in which case show the arrow cursor. |
200 - (void)resetCursorRects { | 200 - (void)resetCursorRects { |
| 201 NSRect fieldBounds = [self bounds]; |
| 202 [self addCursorRect:fieldBounds cursor:[NSCursor IBeamCursor]]; |
| 203 |
201 AutocompleteTextFieldCell* cell = [self autocompleteTextFieldCell]; | 204 AutocompleteTextFieldCell* cell = [self autocompleteTextFieldCell]; |
202 NSRect iconRect = [cell securityImageFrameForFrame:[self bounds]]; | 205 NSRect iconRect = [cell securityImageFrameForFrame:fieldBounds]; |
203 [self addCursorRect:iconRect cursor:[NSCursor arrowCursor]]; | 206 [self addCursorRect:iconRect cursor:[NSCursor arrowCursor]]; |
204 | 207 |
205 const size_t pageActionCount = [cell pageActionCount]; | 208 const size_t pageActionCount = [cell pageActionCount]; |
206 for (size_t i = 0; i < pageActionCount; ++i) { | 209 for (size_t i = 0; i < pageActionCount; ++i) { |
207 iconRect = [cell pageActionFrameForIndex:i inFrame:[self bounds]]; | 210 iconRect = [cell pageActionFrameForIndex:i inFrame:fieldBounds]; |
208 [self addCursorRect:iconRect cursor:[NSCursor arrowCursor]]; | 211 [self addCursorRect:iconRect cursor:[NSCursor arrowCursor]]; |
209 } | 212 } |
210 } | 213 } |
211 | 214 |
212 - (void)updateCursorAndToolTipRects { | 215 - (void)updateCursorAndToolTipRects { |
213 // This will force |resetCursorRects| to be called, as it is not to be called | 216 // This will force |resetCursorRects| to be called, as it is not to be called |
214 // directly. | 217 // directly. |
215 [[self window] invalidateCursorRectsForView:self]; | 218 [[self window] invalidateCursorRectsForView:self]; |
216 | 219 |
217 // |removeAllToolTips| only removes those set on the current NSView, not any | 220 // |removeAllToolTips| only removes those set on the current NSView, not any |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 - (void)draggingExited:(id<NSDraggingInfo>)sender { | 323 - (void)draggingExited:(id<NSDraggingInfo>)sender { |
321 return [dropHandler_ draggingExited:sender]; | 324 return [dropHandler_ draggingExited:sender]; |
322 } | 325 } |
323 | 326 |
324 // (URLDropTarget protocol) | 327 // (URLDropTarget protocol) |
325 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { | 328 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
326 return [dropHandler_ performDragOperation:sender]; | 329 return [dropHandler_ performDragOperation:sender]; |
327 } | 330 } |
328 | 331 |
329 @end | 332 @end |
OLD | NEW |