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

Side by Side Diff: content/browser/web_contents/web_contents_view_gtk.cc

Issue 169093002: Scroll zooming Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/browser/web_contents/web_contents_view_gtk.h" 5 #include "content/browser/web_contents/web_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Called when the mouse moves within the widget. We notify our delegate. 47 // Called when the mouse moves within the widget. We notify our delegate.
48 gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event, 48 gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event,
49 WebContentsImpl* web_contents) { 49 WebContentsImpl* web_contents) {
50 if (web_contents->GetDelegate()) 50 if (web_contents->GetDelegate())
51 web_contents->GetDelegate()->ContentsMouseEvent( 51 web_contents->GetDelegate()->ContentsMouseEvent(
52 web_contents, gfx::Point(event->x_root, event->y_root), true); 52 web_contents, gfx::Point(event->x_root, event->y_root), true);
53 return FALSE; 53 return FALSE;
54 } 54 }
55 55
56 // See tab_contents_view_views.cc for discussion of mouse scroll zooming.
57 gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event,
58 WebContentsImpl* web_contents) {
59 if ((event->state & gtk_accelerator_get_default_mod_mask()) !=
60 GDK_CONTROL_MASK) {
61 return FALSE;
62 }
63
64 WebContentsDelegate* delegate = web_contents->GetDelegate();
65 if (!delegate)
66 return FALSE;
67
68 if (!(event->direction == GDK_SCROLL_DOWN ||
69 event->direction == GDK_SCROLL_UP)) {
70 return FALSE;
71 }
72
73 delegate->ContentsZoomChange(event->direction == GDK_SCROLL_UP);
74 return TRUE;
75 }
76
77 } // namespace 56 } // namespace
78 57
79 WebContentsViewPort* CreateWebContentsView( 58 WebContentsViewPort* CreateWebContentsView(
80 WebContentsImpl* web_contents, 59 WebContentsImpl* web_contents,
81 WebContentsViewDelegate* delegate, 60 WebContentsViewDelegate* delegate,
82 RenderViewHostDelegateView** render_view_host_delegate_view) { 61 RenderViewHostDelegateView** render_view_host_delegate_view) {
83 WebContentsViewGtk* rv = new WebContentsViewGtk(web_contents, delegate); 62 WebContentsViewGtk* rv = new WebContentsViewGtk(web_contents, delegate);
84 *render_view_host_delegate_view = rv; 63 *render_view_host_delegate_view = rv;
85 return rv; 64 return rv;
86 } 65 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 191
213 RenderWidgetHostView* view = 192 RenderWidgetHostView* view =
214 RenderWidgetHostView::CreateViewForWidget(render_widget_host); 193 RenderWidgetHostView::CreateViewForWidget(render_widget_host);
215 view->InitAsChild(NULL); 194 view->InitAsChild(NULL);
216 gfx::NativeView content_view = view->GetNativeView(); 195 gfx::NativeView content_view = view->GetNativeView();
217 g_signal_connect(content_view, "focus", G_CALLBACK(OnFocusThunk), this); 196 g_signal_connect(content_view, "focus", G_CALLBACK(OnFocusThunk), this);
218 g_signal_connect(content_view, "leave-notify-event", 197 g_signal_connect(content_view, "leave-notify-event",
219 G_CALLBACK(OnLeaveNotify), web_contents_); 198 G_CALLBACK(OnLeaveNotify), web_contents_);
220 g_signal_connect(content_view, "motion-notify-event", 199 g_signal_connect(content_view, "motion-notify-event",
221 G_CALLBACK(OnMouseMove), web_contents_); 200 G_CALLBACK(OnMouseMove), web_contents_);
222 g_signal_connect(content_view, "scroll-event",
223 G_CALLBACK(OnMouseScroll), web_contents_);
224 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | 201 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK |
225 GDK_POINTER_MOTION_MASK); 202 GDK_POINTER_MOTION_MASK);
226 InsertIntoContentArea(content_view); 203 InsertIntoContentArea(content_view);
227 204
228 if (render_widget_host->IsRenderView()) { 205 if (render_widget_host->IsRenderView()) {
229 RenderViewHost* rvh = RenderViewHost::From(render_widget_host); 206 RenderViewHost* rvh = RenderViewHost::From(render_widget_host);
230 // If |rvh| is already the current render view host for the web contents, we 207 // If |rvh| is already the current render view host for the web contents, we
231 // need to initialize |drag_dest_| for drags to be properly handled. 208 // need to initialize |drag_dest_| for drags to be properly handled.
232 // Otherwise, |drag_dest_| will be updated in RenderViewSwappedIn. The 209 // Otherwise, |drag_dest_| will be updated in RenderViewSwappedIn. The
233 // reason we can't simply check that this isn't a swapped-out view is 210 // reason we can't simply check that this isn't a swapped-out view is
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // We manually tell our RWHV to resize the renderer content. This avoids 399 // We manually tell our RWHV to resize the renderer content. This avoids
423 // spurious resizes from GTK+. 400 // spurious resizes from GTK+.
424 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 401 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
425 if (rwhv) 402 if (rwhv)
426 rwhv->SetSize(size); 403 rwhv->SetSize(size);
427 if (web_contents_->GetInterstitialPage()) 404 if (web_contents_->GetInterstitialPage())
428 web_contents_->GetInterstitialPage()->SetSize(size); 405 web_contents_->GetInterstitialPage()->SetSize(size);
429 } 406 }
430 407
431 } // namespace content 408 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698