| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/location_bar/autocomplete_text_field.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #import "base/mac/sdk_forward_declarations.h" | 9 #import "base/mac/sdk_forward_declarations.h" |
| 10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // If the event is to the right of the editing area, scroll the | 189 // If the event is to the right of the editing area, scroll the |
| 190 // field editor to the end of the content so that the selection | 190 // field editor to the end of the content so that the selection |
| 191 // doesn't initiate from somewhere in the middle of the text. | 191 // doesn't initiate from somewhere in the middle of the text. |
| 192 if (location.x > NSMaxX(textFrame)) { | 192 if (location.x > NSMaxX(textFrame)) { |
| 193 [editor scrollRangeToVisible:NSMakeRange([[self stringValue] length], 0)]; | 193 [editor scrollRangeToVisible:NSMakeRange([[self stringValue] length], 0)]; |
| 194 } | 194 } |
| 195 | 195 |
| 196 [editor mouseDown:theEvent]; | 196 [editor mouseDown:theEvent]; |
| 197 } | 197 } |
| 198 | 198 |
| 199 - (void)mouseUp:(NSEvent*)theEvent { |
| 200 const NSRect bounds([self bounds]); |
| 201 AutocompleteTextFieldCell* cell = [self cell]; |
| 202 [cell mouseUp:theEvent inRect:bounds ofView:self]; |
| 203 } |
| 204 |
| 199 - (void)rightMouseDown:(NSEvent*)event { | 205 - (void)rightMouseDown:(NSEvent*)event { |
| 200 if (observer_) | 206 if (observer_) |
| 201 observer_->OnMouseDown([event buttonNumber]); | 207 observer_->OnMouseDown([event buttonNumber]); |
| 202 [super rightMouseDown:event]; | 208 [super rightMouseDown:event]; |
| 203 } | 209 } |
| 204 | 210 |
| 205 - (void)otherMouseDown:(NSEvent *)event { | 211 - (void)otherMouseDown:(NSEvent *)event { |
| 206 if (observer_) | 212 if (observer_) |
| 207 observer_->OnMouseDown([event buttonNumber]); | 213 observer_->OnMouseDown([event buttonNumber]); |
| 208 [super otherMouseDown:event]; | 214 [super otherMouseDown:event]; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // directly. | 315 // directly. |
| 310 [[self window] invalidateCursorRectsForView:self]; | 316 [[self window] invalidateCursorRectsForView:self]; |
| 311 | 317 |
| 312 // |removeAllToolTips| only removes those set on the current NSView, not any | 318 // |removeAllToolTips| only removes those set on the current NSView, not any |
| 313 // subviews. Unless more tooltips are added to this view, this should suffice | 319 // subviews. Unless more tooltips are added to this view, this should suffice |
| 314 // in place of managing a set of NSToolTipTag objects. | 320 // in place of managing a set of NSToolTipTag objects. |
| 315 [self removeAllToolTips]; | 321 [self removeAllToolTips]; |
| 316 | 322 |
| 317 // Reload the decoration tooltips. | 323 // Reload the decoration tooltips. |
| 318 [currentToolTips_ removeAllObjects]; | 324 [currentToolTips_ removeAllObjects]; |
| 319 [[self cell] updateToolTipsInRect:[self bounds] ofView:self]; | 325 [[self cell] updateMouseTrackingAndToolTipsInRect:[self bounds] ofView:self]; |
| 320 } | 326 } |
| 321 | 327 |
| 322 // NOTE(shess): http://crbug.com/19116 describes a weird bug which | 328 // NOTE(shess): http://crbug.com/19116 describes a weird bug which |
| 323 // happens when the user runs a Print panel on Leopard. After that, | 329 // happens when the user runs a Print panel on Leopard. After that, |
| 324 // spurious -controlTextDidBeginEditing notifications are sent when an | 330 // spurious -controlTextDidBeginEditing notifications are sent when an |
| 325 // NSTextField is firstResponder, even though -currentEditor on that | 331 // NSTextField is firstResponder, even though -currentEditor on that |
| 326 // field returns nil. That notification caused significant problems | 332 // field returns nil. That notification caused significant problems |
| 327 // in OmniboxViewMac. -textDidBeginEditing: was NOT being | 333 // in OmniboxViewMac. -textDidBeginEditing: was NOT being |
| 328 // sent in those cases, so this approach doesn't have the problem. | 334 // sent in those cases, so this approach doesn't have the problem. |
| 329 - (void)textDidBeginEditing:(NSNotification*)aNotification { | 335 - (void)textDidBeginEditing:(NSNotification*)aNotification { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 NSMinY(frame), | 595 NSMinY(frame), |
| 590 suggestWidth, | 596 suggestWidth, |
| 591 NSHeight(frame)); | 597 NSHeight(frame)); |
| 592 | 598 |
| 593 gfx::ScopedNSGraphicsContextSaveGState saveGState; | 599 gfx::ScopedNSGraphicsContextSaveGState saveGState; |
| 594 NSRectClip(suggestRect); | 600 NSRectClip(suggestRect); |
| 595 [cell drawInteriorWithFrame:frame inView:controlView]; | 601 [cell drawInteriorWithFrame:frame inView:controlView]; |
| 596 } | 602 } |
| 597 | 603 |
| 598 } // namespace autocomplete_text_field | 604 } // namespace autocomplete_text_field |
| OLD | NEW |