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