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