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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "content/browser/renderer_host/render_widget_host_view.h" | 11 #include "content/browser/renderer_host/render_widget_host_view.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "ui/aura/window_delegate.h" | 13 #include "ui/aura/window_delegate.h" |
| 14 #include "ui/base/ime/text_input_client.h" |
14 #include "ui/gfx/compositor/compositor_observer.h" | 15 #include "ui/gfx/compositor/compositor_observer.h" |
15 #include "webkit/glue/webcursor.h" | 16 #include "webkit/glue/webcursor.h" |
16 | 17 |
| 18 namespace ui { |
| 19 class InputMethod; |
| 20 } |
| 21 |
17 namespace WebKit { | 22 namespace WebKit { |
18 class WebTouchEvent; | 23 class WebTouchEvent; |
19 } | 24 } |
20 | 25 |
21 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 26 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
22 class AcceleratedSurfaceContainerLinux; | 27 class AcceleratedSurfaceContainerLinux; |
23 #endif | 28 #endif |
24 | 29 |
25 class CONTENT_EXPORT RenderWidgetHostViewAura | 30 class CONTENT_EXPORT RenderWidgetHostViewAura |
26 : NON_EXPORTED_BASE(public RenderWidgetHostView), | 31 : NON_EXPORTED_BASE(public RenderWidgetHostView), |
27 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 32 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
28 public ui::CompositorObserver, | 33 public ui::CompositorObserver, |
29 #endif | 34 #endif |
| 35 public ui::TextInputClient, |
30 public aura::WindowDelegate { | 36 public aura::WindowDelegate { |
31 public: | 37 public: |
32 explicit RenderWidgetHostViewAura(RenderWidgetHost* host); | 38 explicit RenderWidgetHostViewAura(RenderWidgetHost* host); |
33 virtual ~RenderWidgetHostViewAura(); | 39 virtual ~RenderWidgetHostViewAura(); |
34 | 40 |
35 // TODO(derat): Add an abstract RenderWidgetHostView::InitAsChild() method and | 41 // TODO(derat): Add an abstract RenderWidgetHostView::InitAsChild() method and |
36 // update callers: http://crbug.com/102450. | 42 // update callers: http://crbug.com/102450. |
37 void InitAsChild(); | 43 void InitAsChild(); |
38 | 44 |
39 // Overridden from RenderWidgetHostView: | 45 // Overridden from RenderWidgetHostView: |
(...skipping 22 matching lines...) Expand all Loading... |
62 virtual void TextInputStateChanged(ui::TextInputType type, | 68 virtual void TextInputStateChanged(ui::TextInputType type, |
63 bool can_compose_inline) OVERRIDE; | 69 bool can_compose_inline) OVERRIDE; |
64 virtual void ImeCancelComposition() OVERRIDE; | 70 virtual void ImeCancelComposition() OVERRIDE; |
65 virtual void DidUpdateBackingStore( | 71 virtual void DidUpdateBackingStore( |
66 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, | 72 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, |
67 const std::vector<gfx::Rect>& copy_rects) OVERRIDE; | 73 const std::vector<gfx::Rect>& copy_rects) OVERRIDE; |
68 virtual void RenderViewGone(base::TerminationStatus status, | 74 virtual void RenderViewGone(base::TerminationStatus status, |
69 int error_code) OVERRIDE; | 75 int error_code) OVERRIDE; |
70 virtual void Destroy() OVERRIDE; | 76 virtual void Destroy() OVERRIDE; |
71 virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; | 77 virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; |
| 78 virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, |
| 79 const gfx::Rect& end_rect) OVERRIDE; |
72 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; | 80 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; |
73 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; | 81 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; |
74 virtual void AcceleratedSurfaceBuffersSwapped( | 82 virtual void AcceleratedSurfaceBuffersSwapped( |
75 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 83 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
76 int gpu_host_id) OVERRIDE; | 84 int gpu_host_id) OVERRIDE; |
77 virtual void AcceleratedSurfacePostSubBuffer( | 85 virtual void AcceleratedSurfacePostSubBuffer( |
78 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 86 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
79 int gpu_host_id) OVERRIDE; | 87 int gpu_host_id) OVERRIDE; |
80 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 88 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
81 virtual void AcceleratedSurfaceNew( | 89 virtual void AcceleratedSurfaceNew( |
(...skipping 11 matching lines...) Expand all Loading... |
93 virtual void UnhandledWheelEvent( | 101 virtual void UnhandledWheelEvent( |
94 const WebKit::WebMouseWheelEvent& event) OVERRIDE; | 102 const WebKit::WebMouseWheelEvent& event) OVERRIDE; |
95 virtual void SetHasHorizontalScrollbar( | 103 virtual void SetHasHorizontalScrollbar( |
96 bool has_horizontal_scrollbar) OVERRIDE; | 104 bool has_horizontal_scrollbar) OVERRIDE; |
97 virtual void SetScrollOffsetPinning( | 105 virtual void SetScrollOffsetPinning( |
98 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; | 106 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; |
99 virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE; | 107 virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE; |
100 virtual bool LockMouse() OVERRIDE; | 108 virtual bool LockMouse() OVERRIDE; |
101 virtual void UnlockMouse() OVERRIDE; | 109 virtual void UnlockMouse() OVERRIDE; |
102 | 110 |
| 111 // Overridden from ui::TextInputClient: |
| 112 virtual void SetCompositionText( |
| 113 const ui::CompositionText& composition) OVERRIDE; |
| 114 virtual void ConfirmCompositionText() OVERRIDE; |
| 115 virtual void ClearCompositionText() OVERRIDE; |
| 116 virtual void InsertText(const string16& text) OVERRIDE; |
| 117 virtual void InsertChar(char16 ch, int flags) OVERRIDE; |
| 118 virtual ui::TextInputType GetTextInputType() const OVERRIDE; |
| 119 virtual gfx::Rect GetCaretBounds() OVERRIDE; |
| 120 virtual bool HasCompositionText() OVERRIDE; |
| 121 virtual bool GetTextRange(ui::Range* range) OVERRIDE; |
| 122 virtual bool GetCompositionTextRange(ui::Range* range) OVERRIDE; |
| 123 virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; |
| 124 virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; |
| 125 virtual bool DeleteRange(const ui::Range& range) OVERRIDE; |
| 126 virtual bool GetTextFromRange(const ui::Range& range, |
| 127 string16* text) OVERRIDE; |
| 128 virtual void OnInputMethodChanged() OVERRIDE; |
| 129 virtual bool ChangeTextDirectionAndLayoutAlignment( |
| 130 base::i18n::TextDirection direction) OVERRIDE; |
| 131 |
103 // Overridden from aura::WindowDelegate: | 132 // Overridden from aura::WindowDelegate: |
104 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 133 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
105 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | 134 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, |
106 const gfx::Rect& new_bounds) OVERRIDE; | 135 const gfx::Rect& new_bounds) OVERRIDE; |
107 virtual void OnFocus() OVERRIDE; | 136 virtual void OnFocus() OVERRIDE; |
108 virtual void OnBlur() OVERRIDE; | 137 virtual void OnBlur() OVERRIDE; |
109 virtual bool OnKeyEvent(aura::KeyEvent* event) OVERRIDE; | 138 virtual bool OnKeyEvent(aura::KeyEvent* event) OVERRIDE; |
110 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; | 139 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; |
111 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | 140 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; |
112 virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE; | 141 virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE; |
113 virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE; | 142 virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE; |
114 virtual bool ShouldActivate(aura::Event* event) OVERRIDE; | 143 virtual bool ShouldActivate(aura::Event* event) OVERRIDE; |
115 virtual void OnActivated() OVERRIDE; | 144 virtual void OnActivated() OVERRIDE; |
116 virtual void OnLostActive() OVERRIDE; | 145 virtual void OnLostActive() OVERRIDE; |
117 virtual void OnCaptureLost() OVERRIDE; | 146 virtual void OnCaptureLost() OVERRIDE; |
118 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 147 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
119 virtual void OnWindowDestroying() OVERRIDE; | 148 virtual void OnWindowDestroying() OVERRIDE; |
120 virtual void OnWindowDestroyed() OVERRIDE; | 149 virtual void OnWindowDestroyed() OVERRIDE; |
121 virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE; | 150 virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE; |
122 | 151 |
123 private: | 152 private: |
124 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 153 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
125 // Overridden from ui::CompositorObserver: | 154 // Overridden from ui::CompositorObserver: |
126 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; | 155 virtual void OnCompositingEnded(ui::Compositor* compositor) OVERRIDE; |
127 #endif | 156 #endif |
128 | 157 |
129 void UpdateCursorIfOverSelf(); | 158 void UpdateCursorIfOverSelf(); |
130 | 159 |
| 160 // Gets the input method which use the ui::TextInputClient interface in this |
| 161 // class. |
| 162 ui::InputMethod* GetInputMethod(); |
| 163 |
131 // The model object. | 164 // The model object. |
132 RenderWidgetHost* host_; | 165 RenderWidgetHost* host_; |
133 | 166 |
134 aura::Window* window_; | 167 aura::Window* window_; |
135 | 168 |
136 // Is this a fullscreen view? | 169 // Is this a fullscreen view? |
137 bool is_fullscreen_; | 170 bool is_fullscreen_; |
138 | 171 |
139 // Our parent host view, if this is a popup. NULL otherwise. | 172 // Our parent host view, if this is a popup. NULL otherwise. |
140 RenderWidgetHostViewAura* popup_parent_host_view_; | 173 RenderWidgetHostViewAura* popup_parent_host_view_; |
141 | 174 |
142 // True when content is being loaded. Used to show an hourglass cursor. | 175 // True when content is being loaded. Used to show an hourglass cursor. |
143 bool is_loading_; | 176 bool is_loading_; |
144 | 177 |
145 // The cursor for the page. This is passed up from the renderer. | 178 // The cursor for the page. This is passed up from the renderer. |
146 WebCursor current_cursor_; | 179 WebCursor current_cursor_; |
147 | 180 |
148 // The touch-event. Its touch-points are updated as necessary. A new | 181 // The touch-event. Its touch-points are updated as necessary. A new |
149 // touch-point is added from an ET_TOUCH_PRESSED event, and a touch-point is | 182 // touch-point is added from an ET_TOUCH_PRESSED event, and a touch-point is |
150 // removed from the list on an ET_TOUCH_RELEASED event. | 183 // removed from the list on an ET_TOUCH_RELEASED event. |
151 WebKit::WebTouchEvent touch_event_; | 184 WebKit::WebTouchEvent touch_event_; |
152 | 185 |
| 186 // The current text input type. |
| 187 ui::TextInputType text_input_type_; |
| 188 |
| 189 // Rectangles before and after the selection. |
| 190 gfx::Rect selection_start_rect_; |
| 191 gfx::Rect selection_end_rect_; |
| 192 |
| 193 // Indicates if there is onging composition text. |
| 194 bool has_composition_text_; |
| 195 |
153 // Current tooltip text. | 196 // Current tooltip text. |
154 string16 tooltip_; | 197 string16 tooltip_; |
155 | 198 |
156 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 199 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
157 std::vector< base::Callback<void(void)> > on_compositing_ended_callbacks_; | 200 std::vector< base::Callback<void(void)> > on_compositing_ended_callbacks_; |
158 | 201 |
159 std::map<uint64, scoped_refptr<AcceleratedSurfaceContainerLinux> > | 202 std::map<uint64, scoped_refptr<AcceleratedSurfaceContainerLinux> > |
160 accelerated_surface_containers_; | 203 accelerated_surface_containers_; |
161 #endif | 204 #endif |
162 | 205 |
163 bool skip_schedule_paint_; | 206 bool skip_schedule_paint_; |
164 | 207 |
165 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); | 208 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |
166 }; | 209 }; |
167 | 210 |
168 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ | 211 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_AURA_H_ |
OLD | NEW |