OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_VIEWS_COCOA_BRIDGED_CONTENT_VIEW_H_ | 5 #ifndef UI_VIEWS_COCOA_BRIDGED_CONTENT_VIEW_H_ |
6 #define UI_VIEWS_COCOA_BRIDGED_CONTENT_VIEW_H_ | 6 #define UI_VIEWS_COCOA_BRIDGED_CONTENT_VIEW_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
| 10 #include "base/strings/string16.h" |
| 11 #import "ui/base/cocoa/tool_tip_base_view.h" |
10 #import "ui/base/cocoa/tracking_area.h" | 12 #import "ui/base/cocoa/tracking_area.h" |
11 | 13 |
12 namespace ui { | 14 namespace ui { |
13 class TextInputClient; | 15 class TextInputClient; |
14 } | 16 } |
15 | 17 |
16 namespace views { | 18 namespace views { |
17 class View; | 19 class View; |
18 } | 20 } |
19 | 21 |
20 // The NSView that sits as the root contentView of the NSWindow, whilst it has | 22 // The NSView that sits as the root contentView of the NSWindow, whilst it has |
21 // a views::RootView present. Bridges requests from Cocoa to the hosted | 23 // a views::RootView present. Bridges requests from Cocoa to the hosted |
22 // views::View. | 24 // views::View. |
23 @interface BridgedContentView | 25 @interface BridgedContentView |
24 : NSView<NSTextInputClient, NSUserInterfaceValidations> { | 26 : ToolTipBaseView<NSTextInputClient, NSUserInterfaceValidations> { |
25 @private | 27 @private |
26 // Weak. The hosted RootView, owned by hostedView_->GetWidget(). | 28 // Weak. The hosted RootView, owned by hostedView_->GetWidget(). |
27 views::View* hostedView_; | 29 views::View* hostedView_; |
28 | 30 |
29 // Weak. If non-null the TextInputClient of the currently focused View in the | 31 // Weak. If non-null the TextInputClient of the currently focused View in the |
30 // hierarchy rooted at |hostedView_|. Owned by the focused View. | 32 // hierarchy rooted at |hostedView_|. Owned by the focused View. |
31 ui::TextInputClient* textInputClient_; | 33 ui::TextInputClient* textInputClient_; |
32 | 34 |
33 // A tracking area installed to enable mouseMoved events. | 35 // A tracking area installed to enable mouseMoved events. |
34 ui::ScopedCrTrackingArea trackingArea_; | 36 ui::ScopedCrTrackingArea cursorTrackingArea_; |
35 | 37 |
36 // Whether the view is reacting to a keyDown event on the view. | 38 // Whether the view is reacting to a keyDown event on the view. |
37 BOOL inKeyDown_; | 39 BOOL inKeyDown_; |
| 40 |
| 41 // The last tooltip text, used to limit updates. |
| 42 base::string16 lastTooltipText_; |
38 } | 43 } |
39 | 44 |
40 @property(readonly, nonatomic) views::View* hostedView; | 45 @property(readonly, nonatomic) views::View* hostedView; |
41 @property(assign, nonatomic) ui::TextInputClient* textInputClient; | 46 @property(assign, nonatomic) ui::TextInputClient* textInputClient; |
42 | 47 |
43 // Initialize the NSView -> views::View bridge. |viewToHost| must be non-NULL. | 48 // Initialize the NSView -> views::View bridge. |viewToHost| must be non-NULL. |
44 - (id)initWithView:(views::View*)viewToHost; | 49 - (id)initWithView:(views::View*)viewToHost; |
45 | 50 |
46 // Clear the hosted view. For example, if it is about to be destroyed. | 51 // Clear the hosted view. For example, if it is about to be destroyed. |
47 - (void)clearView; | 52 - (void)clearView; |
48 | 53 |
49 // Process a mouse event captured while the widget had global mouse capture. | 54 // Process a mouse event captured while the widget had global mouse capture. |
50 - (void)processCapturedMouseEvent:(NSEvent*)theEvent; | 55 - (void)processCapturedMouseEvent:(NSEvent*)theEvent; |
51 | 56 |
| 57 // Mac's version of views::corewm::TooltipController::UpdateIfRequired(). |
| 58 // Updates the tooltip on the ToolTipBaseView if the text needs to change. |
| 59 // |locationInContent| is the position from the top left of the window's |
| 60 // contentRect (also this NSView's frame), as given by a ui::LocatedEvent. |
| 61 - (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent; |
| 62 |
52 @end | 63 @end |
53 | 64 |
54 #endif // UI_VIEWS_COCOA_BRIDGED_CONTENT_VIEW_H_ | 65 #endif // UI_VIEWS_COCOA_BRIDGED_CONTENT_VIEW_H_ |
OLD | NEW |