| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
| 7 | 7 |
| 8 #include <gdk/gdk.h> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/gfx/native_widget_types.h" | 11 #include "base/gfx/native_widget_types.h" |
| 11 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 12 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 12 #include "chrome/common/owned_widget_gtk.h" | 13 #include "chrome/common/owned_widget_gtk.h" |
| 14 #include "chrome/common/render_messages.h" |
| 13 #include "webkit/glue/webcursor.h" | 15 #include "webkit/glue/webcursor.h" |
| 14 | 16 |
| 15 class RenderWidgetHost; | 17 class RenderWidgetHost; |
| 16 | 18 |
| 17 typedef struct _GtkClipboard GtkClipboard; | 19 typedef struct _GtkClipboard GtkClipboard; |
| 20 typedef struct _GtkSelectionData GtkSelectionData; |
| 18 | 21 |
| 19 // ----------------------------------------------------------------------------- | 22 // ----------------------------------------------------------------------------- |
| 20 // See comments in render_widget_host_view.h about this class and its members. | 23 // See comments in render_widget_host_view.h about this class and its members. |
| 21 // ----------------------------------------------------------------------------- | 24 // ----------------------------------------------------------------------------- |
| 22 class RenderWidgetHostViewGtk : public RenderWidgetHostView { | 25 class RenderWidgetHostViewGtk : public RenderWidgetHostView { |
| 23 public: | 26 public: |
| 24 RenderWidgetHostViewGtk(RenderWidgetHost* widget); | 27 RenderWidgetHostViewGtk(RenderWidgetHost* widget); |
| 25 ~RenderWidgetHostViewGtk(); | 28 ~RenderWidgetHostViewGtk(); |
| 26 | 29 |
| 27 // Initialize this object for use as a drawing area. | 30 // Initialize this object for use as a drawing area. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 gfx::Rect GetViewBounds() const; | 54 gfx::Rect GetViewBounds() const; |
| 52 void UpdateCursor(const WebCursor& cursor); | 55 void UpdateCursor(const WebCursor& cursor); |
| 53 void SetIsLoading(bool is_loading); | 56 void SetIsLoading(bool is_loading); |
| 54 void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); | 57 void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); |
| 55 void DidPaintRect(const gfx::Rect& rect); | 58 void DidPaintRect(const gfx::Rect& rect); |
| 56 void DidScrollRect( | 59 void DidScrollRect( |
| 57 const gfx::Rect& rect, int dx, int dy); | 60 const gfx::Rect& rect, int dx, int dy); |
| 58 void RenderViewGone(); | 61 void RenderViewGone(); |
| 59 void Destroy(); | 62 void Destroy(); |
| 60 void SetTooltipText(const std::wstring& tooltip_text); | 63 void SetTooltipText(const std::wstring& tooltip_text); |
| 64 void SelectionChanged(); |
| 65 void SetSelectionText(const std::string& text); |
| 61 void PasteFromSelectionClipboard(); | 66 void PasteFromSelectionClipboard(); |
| 62 BackingStore* AllocBackingStore(const gfx::Size& size); | 67 BackingStore* AllocBackingStore(const gfx::Size& size); |
| 63 // --------------------------------------------------------------------------- | 68 // --------------------------------------------------------------------------- |
| 64 | 69 |
| 65 gfx::NativeView native_view() const { return view_.get(); } | 70 gfx::NativeView native_view() const { return view_.get(); } |
| 66 | 71 |
| 67 void Paint(const gfx::Rect&); | 72 void Paint(const gfx::Rect&); |
| 68 | 73 |
| 69 private: | 74 private: |
| 75 friend class RenderWidgetHostViewGtkWidget; |
| 76 |
| 77 void set_event_selection(GdkEventSelection* event_selection) { |
| 78 event_selection_ = *event_selection; |
| 79 event_selection_active_ = true; |
| 80 } |
| 81 |
| 70 // Update the display cursor for the render view. | 82 // Update the display cursor for the render view. |
| 71 void ShowCurrentCursor(); | 83 void ShowCurrentCursor(); |
| 72 | 84 |
| 85 void RequestSelectionText(); |
| 86 |
| 87 // When we've requested the text from the X clipboard, GTK returns it to us |
| 88 // through this callback. |
| 73 static void ReceivedSelectionText(GtkClipboard* clipboard, | 89 static void ReceivedSelectionText(GtkClipboard* clipboard, |
| 74 const gchar* text, | 90 const gchar* text, |
| 75 gpointer userdata); | 91 gpointer userdata); |
| 76 | 92 |
| 77 // The model object. | 93 // The model object. |
| 78 RenderWidgetHost *const host_; | 94 RenderWidgetHost *const host_; |
| 79 // The native UI widget. | 95 // The native UI widget. |
| 80 OwnedWidgetGtk view_; | 96 OwnedWidgetGtk view_; |
| 81 // Variables used only for popups -------------------------------------------- | 97 // Variables used only for popups -------------------------------------------- |
| 82 // Our parent widget. | 98 // Our parent widget. |
| 83 RenderWidgetHostView* parent_host_view_; | 99 RenderWidgetHostView* parent_host_view_; |
| 84 // The native view of our parent, equivalent to | 100 // The native view of our parent, equivalent to |
| 85 // parent_host_view_->GetPluginNativeView(). | 101 // parent_host_view_->GetPluginNativeView(). |
| 86 GtkWidget* parent_; | 102 GtkWidget* parent_; |
| 87 // We connect to the parent's focus out event. When we are destroyed, we need | 103 // We connect to the parent's focus out event. When we are destroyed, we need |
| 88 // to remove this handler, so we must keep track of its id. | 104 // to remove this handler, so we must keep track of its id. |
| 89 gulong popup_signal_id_; | 105 gulong popup_signal_id_; |
| 90 // This variable determines our degree of control over user input. If we are | 106 // This variable determines our degree of control over user input. If we are |
| 91 // activatable, we must grab and handle all user input. If we are not | 107 // activatable, we must grab and handle all user input. If we are not |
| 92 // activatable, then our parent render view retains more control. Example of | 108 // activatable, then our parent render view retains more control. Example of |
| 93 // activatable popup: <select> dropdown. Example of non-activatable popup: | 109 // activatable popup: <select> dropdown. Example of non-activatable popup: |
| 94 // form autocomplete. | 110 // form autocomplete. |
| 95 bool activatable_; | 111 bool activatable_; |
| 96 | 112 |
| 97 // Whether we are currently loading. | 113 // Whether we are currently loading. |
| 98 bool is_loading_; | 114 bool is_loading_; |
| 99 | 115 |
| 100 // The cursor for the page. This is passed up from the renderer. | 116 // The cursor for the page. This is passed up from the renderer. |
| 101 WebCursor current_cursor_; | 117 WebCursor current_cursor_; |
| 118 |
| 119 // We cache the text that is selected on the page. This is used for copying to |
| 120 // the X clipboard. We update |selection_text_| whenever X asks us for it and |
| 121 // the cache is empty. We invalidate it (set it to empty) whenever the |
| 122 // renderer sends a SelectionChanged message. |
| 123 std::string selection_text_; |
| 124 |
| 125 // A struct that keeps state for the XSelectionEvent we are handling (if any). |
| 126 GdkEventSelection event_selection_; |
| 127 // Tracks whether we are currently handling an XSelectionEvent. |
| 128 bool event_selection_active_; |
| 102 }; | 129 }; |
| 103 | 130 |
| 104 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 131 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
| OLD | NEW |