| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GTK_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
| 7 | 7 |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "content/browser/accessibility/browser_accessibility_manager.h" | 15 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 16 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 #include "ui/base/animation/animation_delegate.h" | 18 #include "ui/base/animation/animation_delegate.h" |
| 19 #include "ui/base/animation/slide_animation.h" | 19 #include "ui/base/animation/slide_animation.h" |
| 20 #include "ui/base/gtk/gtk_signal.h" | 20 #include "ui/base/gtk/gtk_signal.h" |
| 21 #include "ui/base/gtk/gtk_signal_registrar.h" | 21 #include "ui/base/gtk/gtk_signal_registrar.h" |
| 22 #include "ui/base/gtk/owned_widget_gtk.h" | 22 #include "ui/base/gtk/owned_widget_gtk.h" |
| 23 #include "ui/base/x/active_window_watcher_x_observer.h" | 23 #include "ui/base/x/active_window_watcher_x_observer.h" |
| 24 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
| 25 #include "ui/gfx/point.h" | 25 #include "ui/gfx/point.h" |
| 26 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
| 27 #include "webkit/glue/webcursor.h" | 27 #include "webkit/glue/webcursor.h" |
| 28 #include "webkit/plugins/npapi/gtk_plugin_container_manager.h" | 28 #include "webkit/plugins/npapi/gtk_plugin_container_manager.h" |
| 29 | 29 |
| 30 class GtkIMContextWrapper; | |
| 31 | |
| 32 namespace content { | |
| 33 class RenderWidgetHost; | |
| 34 class RenderWidgetHostImpl; | |
| 35 struct NativeWebKeyboardEvent; | |
| 36 } | |
| 37 | |
| 38 class GtkKeyBindingsHandler; | 30 class GtkKeyBindingsHandler; |
| 39 | 31 |
| 40 typedef struct _GtkClipboard GtkClipboard; | 32 typedef struct _GtkClipboard GtkClipboard; |
| 41 typedef struct _GtkSelectionData GtkSelectionData; | 33 typedef struct _GtkSelectionData GtkSelectionData; |
| 42 | 34 |
| 35 namespace content { |
| 36 class GtkIMContextWrapper; |
| 37 class RenderWidgetHost; |
| 38 class RenderWidgetHostImpl; |
| 39 struct NativeWebKeyboardEvent; |
| 40 |
| 43 // ----------------------------------------------------------------------------- | 41 // ----------------------------------------------------------------------------- |
| 44 // See comments in render_widget_host_view.h about this class and its members. | 42 // See comments in render_widget_host_view.h about this class and its members. |
| 45 // ----------------------------------------------------------------------------- | 43 // ----------------------------------------------------------------------------- |
| 46 class CONTENT_EXPORT RenderWidgetHostViewGtk | 44 class CONTENT_EXPORT RenderWidgetHostViewGtk |
| 47 : public content::RenderWidgetHostViewBase, | 45 : public RenderWidgetHostViewBase, |
| 48 public BrowserAccessibilityDelegate, | 46 public BrowserAccessibilityDelegate, |
| 49 public ui::ActiveWindowWatcherXObserver { | 47 public ui::ActiveWindowWatcherXObserver { |
| 50 public: | 48 public: |
| 51 virtual ~RenderWidgetHostViewGtk(); | 49 virtual ~RenderWidgetHostViewGtk(); |
| 52 | 50 |
| 53 // RenderWidgetHostView implementation. | 51 // RenderWidgetHostView implementation. |
| 54 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; | 52 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; |
| 55 virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; | 53 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; |
| 56 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 54 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
| 57 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; | 55 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; |
| 58 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 56 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 59 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; | 57 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; |
| 60 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | 58 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
| 61 virtual bool HasFocus() const OVERRIDE; | 59 virtual bool HasFocus() const OVERRIDE; |
| 62 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; | 60 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; |
| 63 virtual void Show() OVERRIDE; | 61 virtual void Show() OVERRIDE; |
| 64 virtual void Hide() OVERRIDE; | 62 virtual void Hide() OVERRIDE; |
| 65 virtual bool IsShowing() OVERRIDE; | 63 virtual bool IsShowing() OVERRIDE; |
| 66 virtual gfx::Rect GetViewBounds() const OVERRIDE; | 64 virtual gfx::Rect GetViewBounds() const OVERRIDE; |
| 67 virtual GdkEventButton* GetLastMouseDown() OVERRIDE; | 65 virtual GdkEventButton* GetLastMouseDown() OVERRIDE; |
| 68 virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; | 66 virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; |
| 69 virtual void SetBackground(const SkBitmap& background) OVERRIDE; | 67 virtual void SetBackground(const SkBitmap& background) OVERRIDE; |
| 70 | 68 |
| 71 // RenderWidgetHostViewPort implementation. | 69 // RenderWidgetHostViewPort implementation. |
| 72 virtual void InitAsPopup(content::RenderWidgetHostView* parent_host_view, | 70 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
| 73 const gfx::Rect& pos) OVERRIDE; | 71 const gfx::Rect& pos) OVERRIDE; |
| 74 virtual void InitAsFullscreen( | 72 virtual void InitAsFullscreen( |
| 75 content::RenderWidgetHostView* reference_host_view) OVERRIDE; | 73 RenderWidgetHostView* reference_host_view) OVERRIDE; |
| 76 virtual void WasRestored() OVERRIDE; | 74 virtual void WasRestored() OVERRIDE; |
| 77 virtual void WasHidden() OVERRIDE; | 75 virtual void WasHidden() OVERRIDE; |
| 78 virtual void MovePluginWindows( | 76 virtual void MovePluginWindows( |
| 79 const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; | 77 const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE; |
| 80 virtual void Focus() OVERRIDE; | 78 virtual void Focus() OVERRIDE; |
| 81 virtual void Blur() OVERRIDE; | 79 virtual void Blur() OVERRIDE; |
| 82 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; | 80 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; |
| 83 virtual void SetIsLoading(bool is_loading) OVERRIDE; | 81 virtual void SetIsLoading(bool is_loading) OVERRIDE; |
| 84 virtual void TextInputStateChanged(ui::TextInputType type, | 82 virtual void TextInputStateChanged(ui::TextInputType type, |
| 85 bool can_compose_inline) OVERRIDE; | 83 bool can_compose_inline) OVERRIDE; |
| 86 virtual void ImeCancelComposition() OVERRIDE; | 84 virtual void ImeCancelComposition() OVERRIDE; |
| 87 virtual void DidUpdateBackingStore( | 85 virtual void DidUpdateBackingStore( |
| 88 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, | 86 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, |
| 89 const std::vector<gfx::Rect>& copy_rects) OVERRIDE; | 87 const std::vector<gfx::Rect>& copy_rects) OVERRIDE; |
| 90 virtual void RenderViewGone(base::TerminationStatus status, | 88 virtual void RenderViewGone(base::TerminationStatus status, |
| 91 int error_code) OVERRIDE; | 89 int error_code) OVERRIDE; |
| 92 virtual void Destroy() OVERRIDE; | 90 virtual void Destroy() OVERRIDE; |
| 93 virtual void WillDestroyRenderWidget(content::RenderWidgetHost* rwh) {} | 91 virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) {} |
| 94 virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; | 92 virtual void SetTooltipText(const string16& tooltip_text) OVERRIDE; |
| 95 virtual void SelectionChanged(const string16& text, | 93 virtual void SelectionChanged(const string16& text, |
| 96 size_t offset, | 94 size_t offset, |
| 97 const ui::Range& range) OVERRIDE; | 95 const ui::Range& range) OVERRIDE; |
| 98 virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, | 96 virtual void SelectionBoundsChanged(const gfx::Rect& start_rect, |
| 99 const gfx::Rect& end_rect) OVERRIDE; | 97 const gfx::Rect& end_rect) OVERRIDE; |
| 100 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; | 98 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; |
| 101 virtual void CopyFromCompositingSurface( | 99 virtual void CopyFromCompositingSurface( |
| 102 const gfx::Size& size, | 100 const gfx::Size& size, |
| 103 const base::Callback<void(bool)>& callback, | 101 const base::Callback<void(bool)>& callback, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); | 141 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); |
| 144 | 142 |
| 145 void Paint(const gfx::Rect&); | 143 void Paint(const gfx::Rect&); |
| 146 | 144 |
| 147 // Called by GtkIMContextWrapper to forward a keyboard event to renderer. | 145 // Called by GtkIMContextWrapper to forward a keyboard event to renderer. |
| 148 // On Linux (not ChromeOS): | 146 // On Linux (not ChromeOS): |
| 149 // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method | 147 // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method |
| 150 // calls GtkKeyBindingsHandler::Match() against the event and send matched | 148 // calls GtkKeyBindingsHandler::Match() against the event and send matched |
| 151 // edit commands to renderer by calling | 149 // edit commands to renderer by calling |
| 152 // RenderWidgetHost::ForwardEditCommandsForNextKeyEvent(). | 150 // RenderWidgetHost::ForwardEditCommandsForNextKeyEvent(). |
| 153 void ForwardKeyboardEvent(const content::NativeWebKeyboardEvent& event); | 151 void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event); |
| 154 | 152 |
| 155 bool RetrieveSurrounding(std::string* text, size_t* cursor_index); | 153 bool RetrieveSurrounding(std::string* text, size_t* cursor_index); |
| 156 | 154 |
| 157 // BrowserAccessibilityDelegate implementation. | 155 // BrowserAccessibilityDelegate implementation. |
| 158 virtual void SetAccessibilityFocus(int acc_obj_id) OVERRIDE; | 156 virtual void SetAccessibilityFocus(int acc_obj_id) OVERRIDE; |
| 159 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; | 157 virtual void AccessibilityDoDefaultAction(int acc_obj_id) OVERRIDE; |
| 160 virtual void AccessibilityScrollToMakeVisible( | 158 virtual void AccessibilityScrollToMakeVisible( |
| 161 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; | 159 int acc_obj_id, gfx::Rect subfocus) OVERRIDE; |
| 162 virtual void AccessibilityScrollToPoint( | 160 virtual void AccessibilityScrollToPoint( |
| 163 int acc_obj_id, gfx::Point point) OVERRIDE; | 161 int acc_obj_id, gfx::Point point) OVERRIDE; |
| 164 virtual void AccessibilitySetTextSelection( | 162 virtual void AccessibilitySetTextSelection( |
| 165 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; | 163 int acc_obj_id, int start_offset, int end_offset) OVERRIDE; |
| 166 | 164 |
| 167 // Get the root of the AtkObject* tree for accessibility. | 165 // Get the root of the AtkObject* tree for accessibility. |
| 168 AtkObject* GetAccessible(); | 166 AtkObject* GetAccessible(); |
| 169 | 167 |
| 170 protected: | 168 protected: |
| 171 friend class content::RenderWidgetHostView; | 169 friend class RenderWidgetHostView; |
| 172 | 170 |
| 173 // Should construct only via RenderWidgetHostView::CreateViewForWidget. | 171 // Should construct only via RenderWidgetHostView::CreateViewForWidget. |
| 174 explicit RenderWidgetHostViewGtk(content::RenderWidgetHost* widget); | 172 explicit RenderWidgetHostViewGtk(RenderWidgetHost* widget); |
| 175 | 173 |
| 176 private: | 174 private: |
| 177 friend class RenderWidgetHostViewGtkWidget; | 175 friend class RenderWidgetHostViewGtkWidget; |
| 178 | 176 |
| 179 CHROMEGTK_CALLBACK_0(RenderWidgetHostViewGtk, | 177 CHROMEGTK_CALLBACK_0(RenderWidgetHostViewGtk, |
| 180 void, | 178 void, |
| 181 OnDestroy); | 179 OnDestroy); |
| 182 | 180 |
| 183 // Returns whether the widget needs an input grab (GTK+ and X) to work | 181 // Returns whether the widget needs an input grab (GTK+ and X) to work |
| 184 // properly. | 182 // properly. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 199 void ShowCurrentCursor(); | 197 void ShowCurrentCursor(); |
| 200 | 198 |
| 201 void set_last_mouse_down(GdkEventButton* event); | 199 void set_last_mouse_down(GdkEventButton* event); |
| 202 | 200 |
| 203 // Cause the next query for the widget center to recompute the cached value. | 201 // Cause the next query for the widget center to recompute the cached value. |
| 204 void MarkCachedWidgetCenterStale(); | 202 void MarkCachedWidgetCenterStale(); |
| 205 | 203 |
| 206 gfx::Point GetWidgetCenter(); | 204 gfx::Point GetWidgetCenter(); |
| 207 | 205 |
| 208 // The model object. | 206 // The model object. |
| 209 content::RenderWidgetHostImpl* host_; | 207 RenderWidgetHostImpl* host_; |
| 210 | 208 |
| 211 // The native UI widget. | 209 // The native UI widget. |
| 212 ui::OwnedWidgetGtk view_; | 210 ui::OwnedWidgetGtk view_; |
| 213 | 211 |
| 214 // This is true when we are currently painting and thus should handle extra | 212 // This is true when we are currently painting and thus should handle extra |
| 215 // paint requests by expanding the invalid rect rather than actually | 213 // paint requests by expanding the invalid rect rather than actually |
| 216 // painting. | 214 // painting. |
| 217 bool about_to_validate_and_paint_; | 215 bool about_to_validate_and_paint_; |
| 218 | 216 |
| 219 // This is the rectangle which we'll paint. | 217 // This is the rectangle which we'll paint. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 // menus and drags. | 308 // menus and drags. |
| 311 GdkEventButton* last_mouse_down_; | 309 GdkEventButton* last_mouse_down_; |
| 312 | 310 |
| 313 // Instance of accessibility information for the root of the AtkObject | 311 // Instance of accessibility information for the root of the AtkObject |
| 314 // tree representation of the WebKit render tree. | 312 // tree representation of the WebKit render tree. |
| 315 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; | 313 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
| 316 | 314 |
| 317 ui::GtkSignalRegistrar signals_; | 315 ui::GtkSignalRegistrar signals_; |
| 318 }; | 316 }; |
| 319 | 317 |
| 318 } // namespace content |
| 319 |
| 320 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 320 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
| OLD | NEW |