Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_gtk.h

Issue 7669040: content: Move render_widget_host_view_gtk to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos fix. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_
7 #pragma once
8
9 #include <gdk/gdk.h>
10
11 #include <string>
12 #include <vector>
13
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time.h"
16 #include "chrome/browser/ui/gtk/owned_widget_gtk.h"
17 #include "content/browser/renderer_host/render_widget_host_view.h"
18 #include "ui/base/animation/animation_delegate.h"
19 #include "ui/base/animation/slide_animation.h"
20 #include "ui/base/gtk/gtk_signal.h"
21 #include "ui/gfx/native_widget_types.h"
22 #include "ui/gfx/rect.h"
23 #include "webkit/glue/webcursor.h"
24 #include "webkit/plugins/npapi/gtk_plugin_container_manager.h"
25
26 class RenderWidgetHost;
27 class GtkIMContextWrapper;
28 #if !defined(TOOLKIT_VIEWS)
29 class MenuGtk;
30 #endif
31 struct NativeWebKeyboardEvent;
32
33 #if defined(OS_CHROMEOS)
34 namespace views {
35 class TooltipWindowGtk;
36 }
37 #else
38 class GtkKeyBindingsHandler;
39 #endif // defined(OS_CHROMEOS)
40
41 typedef struct _GtkClipboard GtkClipboard;
42 typedef struct _GtkSelectionData GtkSelectionData;
43
44 // -----------------------------------------------------------------------------
45 // See comments in render_widget_host_view.h about this class and its members.
46 // -----------------------------------------------------------------------------
47 class RenderWidgetHostViewGtk : public RenderWidgetHostView,
48 public ui::AnimationDelegate {
49 public:
50 explicit RenderWidgetHostViewGtk(RenderWidgetHost* widget);
51 virtual ~RenderWidgetHostViewGtk();
52
53 // Initialize this object for use as a drawing area.
54 void InitAsChild();
55
56 // RenderWidgetHostView implementation.
57 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
58 const gfx::Rect& pos) OVERRIDE;
59 virtual void InitAsFullscreen(
60 RenderWidgetHostView* reference_host_view) OVERRIDE;
61 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
62 virtual void DidBecomeSelected() OVERRIDE;
63 virtual void WasHidden() OVERRIDE;
64 virtual void SetSize(const gfx::Size& size) OVERRIDE;
65 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
66 virtual gfx::NativeView GetNativeView() OVERRIDE;
67 virtual void MovePluginWindows(
68 const std::vector<webkit::npapi::WebPluginGeometry>& moves) OVERRIDE;
69 virtual void Focus() OVERRIDE;
70 virtual void Blur() OVERRIDE;
71 virtual bool HasFocus() OVERRIDE;
72 virtual void Show() OVERRIDE;
73 virtual void Hide() OVERRIDE;
74 virtual bool IsShowing() OVERRIDE;
75 virtual gfx::Rect GetViewBounds() const OVERRIDE;
76 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE;
77 virtual void SetIsLoading(bool is_loading) OVERRIDE;
78 virtual void ImeUpdateTextInputState(ui::TextInputType type,
79 bool can_compose_inline,
80 const gfx::Rect& caret_rect) OVERRIDE;
81 virtual void ImeCancelComposition() OVERRIDE;
82 virtual void DidUpdateBackingStore(
83 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy,
84 const std::vector<gfx::Rect>& copy_rects) OVERRIDE;
85 virtual void RenderViewGone(base::TerminationStatus status,
86 int error_code) OVERRIDE;
87 virtual void Destroy() OVERRIDE;
88 virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) {}
89 virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE;
90 virtual void SelectionChanged(const std::string& text,
91 const ui::Range& range,
92 const gfx::Point& start,
93 const gfx::Point& end) OVERRIDE;
94 virtual void ShowingContextMenu(bool showing) OVERRIDE;
95 virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE;
96 virtual void SetBackground(const SkBitmap& background) OVERRIDE;
97 virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE;
98 virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE;
99 virtual void SetVisuallyDeemphasized(const SkColor* color,
100 bool animate) OVERRIDE;
101 virtual void UnhandledWheelEvent(
102 const WebKit::WebMouseWheelEvent& event) OVERRIDE;
103 virtual void SetHasHorizontalScrollbar(
104 bool has_horizontal_scrollbar) OVERRIDE;
105 virtual void SetScrollOffsetPinning(
106 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
107 virtual void AcceleratedCompositingActivated(bool activated) OVERRIDE;
108 virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE;
109
110 // ui::AnimationDelegate implementation.
111 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
112 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
113 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE;
114
115 gfx::NativeView native_view() const { return view_.get(); }
116
117 // If the widget is aligned with an edge of the monitor its on and the user
118 // attempts to drag past that edge we track the number of times it has
119 // occurred, so that we can force the widget to scroll when it otherwise
120 // would be unable to.
121 void ModifyEventForEdgeDragging(GtkWidget* widget, GdkEventMotion* event);
122 void Paint(const gfx::Rect&);
123
124 // Called by GtkIMContextWrapper to forward a keyboard event to renderer.
125 // On Linux (not ChromeOS):
126 // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method
127 // calls GtkKeyBindingsHandler::Match() against the event and send matched
128 // edit commands to renderer by calling
129 // RenderWidgetHost::ForwardEditCommandsForNextKeyEvent().
130 void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event);
131
132 GdkEventButton* last_mouse_down() const {
133 return last_mouse_down_;
134 }
135
136 #if !defined(TOOLKIT_VIEWS)
137 // Appends the input methods context menu to the specified |menu| object as a
138 // submenu.
139 void AppendInputMethodsContextMenu(MenuGtk* menu);
140 #endif
141
142 private:
143 friend class RenderWidgetHostViewGtkWidget;
144
145 CHROMEGTK_CALLBACK_1(RenderWidgetHostViewGtk,
146 gboolean,
147 OnWindowStateEvent,
148 GdkEventWindowState*);
149
150 CHROMEGTK_CALLBACK_0(RenderWidgetHostViewGtk,
151 void,
152 OnDestroy);
153
154 // Returns whether the widget needs an input grab (GTK+ and X) to work
155 // properly.
156 bool NeedsInputGrab();
157
158 // Returns whether this render view is a popup (<select> dropdown or
159 // autocomplete window).
160 bool IsPopup() const;
161
162 // Do initialization needed by all InitAs*() methods.
163 void DoSharedInit();
164
165 // Do initialization needed just by InitAsPopup() and InitAsFullscreen().
166 // We move and resize |window| to |bounds| and show it and its contents.
167 void DoPopupOrFullscreenInit(GtkWindow* window, const gfx::Rect& bounds);
168
169 // Update the display cursor for the render view.
170 void ShowCurrentCursor();
171
172 void set_last_mouse_down(GdkEventButton* event);
173
174 // The model object.
175 RenderWidgetHost* host_;
176
177 // The native UI widget.
178 OwnedWidgetGtk view_;
179
180 // This is true when we are currently painting and thus should handle extra
181 // paint requests by expanding the invalid rect rather than actually
182 // painting.
183 bool about_to_validate_and_paint_;
184
185 // This is the rectangle which we'll paint.
186 gfx::Rect invalid_rect_;
187
188 // Whether or not this widget is hidden.
189 bool is_hidden_;
190
191 // Whether we are currently loading.
192 bool is_loading_;
193
194 // The cursor for the page. This is passed up from the renderer.
195 WebCursor current_cursor_;
196
197 // Whether we are showing a context menu.
198 bool is_showing_context_menu_;
199
200 // The time at which this view started displaying white pixels as a result of
201 // not having anything to paint (empty backing store from renderer). This
202 // value returns true for is_null() if we are not recording whiteout times.
203 base::TimeTicks whiteout_start_time_;
204
205 // The time it took after this view was selected for it to be fully painted.
206 base::TimeTicks tab_switch_paint_time_;
207
208 // A color we use to shade the entire render view. If 100% transparent, we do
209 // not shade the render view.
210 SkColor overlay_color_;
211
212 // The animation used for the abovementioned shade effect. The animation's
213 // value affects the alpha we use for |overlay_color_|.
214 ui::SlideAnimation overlay_animation_;
215
216 // The native view of our parent widget. Used only for popups.
217 GtkWidget* parent_;
218
219 // We ignore the first mouse release on popups so the popup will remain open.
220 bool is_popup_first_mouse_release_;
221
222 // Whether or not this widget's input context was focused before being
223 // shadowed by another widget. Used in OnGrabNotify() handler to track the
224 // focused state correctly.
225 bool was_imcontext_focused_before_grab_;
226
227 // True if we are responsible for creating an X grab. This will only be used
228 // for <select> dropdowns. It should be true for most such cases, but false
229 // for extension popups.
230 bool do_x_grab_;
231
232 // Is the widget fullscreen?
233 bool is_fullscreen_;
234
235 // For full-screen windows we have a OnDestroy handler that we need to remove,
236 // so we keep it ID here.
237 unsigned long destroy_handler_id_;
238
239 // A convenience wrapper object for GtkIMContext;
240 scoped_ptr<GtkIMContextWrapper> im_context_;
241
242 #if !defined(OS_CHROMEOS)
243 // A convenience object for handling editor key bindings defined in gtk
244 // keyboard theme.
245 scoped_ptr<GtkKeyBindingsHandler> key_bindings_handler_;
246 #endif
247
248 // Helper class that lets us allocate plugin containers and move them.
249 webkit::npapi::GtkPluginContainerManager plugin_container_manager_;
250
251 // The size that we want the renderer to be. We keep this in a separate
252 // variable because resizing in GTK+ is async.
253 gfx::Size requested_size_;
254
255 // The number of times the user has dragged against horizontal edge of the
256 // monitor (if the widget is aligned with that edge). Negative values
257 // indicate the left edge, positive the right.
258 int dragged_at_horizontal_edge_;
259
260 // The number of times the user has dragged against vertical edge of the
261 // monitor (if the widget is aligned with that edge). Negative values
262 // indicate the top edge, positive the bottom.
263 int dragged_at_vertical_edge_;
264
265 gfx::PluginWindowHandle compositing_surface_;
266
267 // The event for the last mouse down we handled. We need this for context
268 // menus and drags.
269 GdkEventButton* last_mouse_down_;
270
271 #if defined(OS_CHROMEOS)
272 // Custimized tooltip window.
273 scoped_ptr<views::TooltipWindowGtk> tooltip_window_;
274 #endif // defined(OS_CHROMEOS)
275 };
276
277 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698