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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 8918022: Print preview: Prevent a crash when zooming with the scroll wheel. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years 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 | « no previous file | 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) 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 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/tab_contents/tab_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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 TabContents* tab_contents) { 47 TabContents* tab_contents) {
48 if (tab_contents->delegate()) 48 if (tab_contents->delegate())
49 tab_contents->delegate()->ContentsMouseEvent( 49 tab_contents->delegate()->ContentsMouseEvent(
50 tab_contents, gfx::Point(event->x_root, event->y_root), true); 50 tab_contents, gfx::Point(event->x_root, event->y_root), true);
51 return FALSE; 51 return FALSE;
52 } 52 }
53 53
54 // See tab_contents_view_views.cc for discussion of mouse scroll zooming. 54 // See tab_contents_view_views.cc for discussion of mouse scroll zooming.
55 gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event, 55 gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event,
56 TabContents* tab_contents) { 56 TabContents* tab_contents) {
57 if ((event->state & gtk_accelerator_get_default_mod_mask()) == 57 if ((event->state & gtk_accelerator_get_default_mod_mask()) !=
58 GDK_CONTROL_MASK) { 58 GDK_CONTROL_MASK) {
59 if (event->direction == GDK_SCROLL_DOWN) { 59 return FALSE;
60 tab_contents->delegate()->ContentsZoomChange(false);
61 return TRUE;
62 } else if (event->direction == GDK_SCROLL_UP) {
63 tab_contents->delegate()->ContentsZoomChange(true);
64 return TRUE;
65 }
66 } 60 }
67 61
68 return FALSE; 62 TabContentsDelegate* delegate = tab_contents->delegate();
63 if (!delegate)
64 return FALSE;
65
66 if (!(event->direction == GDK_SCROLL_DOWN ||
67 event->direction == GDK_SCROLL_UP)) {
68 return FALSE;
69 }
70
71 delegate->ContentsZoomChange(event->direction == GDK_SCROLL_UP);
72 return TRUE;
69 } 73 }
70 74
71 } // namespace 75 } // namespace
72 76
73 TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents, 77 TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents,
74 TabContentsViewWrapperGtk* view_wrapper) 78 TabContentsViewWrapperGtk* view_wrapper)
75 : tab_contents_(tab_contents), 79 : tab_contents_(tab_contents),
76 expanded_(gtk_expanded_container_new()), 80 expanded_(gtk_expanded_container_new()),
77 view_wrapper_(view_wrapper), 81 view_wrapper_(view_wrapper),
78 overlaid_view_(NULL) { 82 overlaid_view_(NULL) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 requested_size_ = size; 418 requested_size_ = size;
415 419
416 // We manually tell our RWHV to resize the renderer content. This avoids 420 // We manually tell our RWHV to resize the renderer content. This avoids
417 // spurious resizes from GTK+. 421 // spurious resizes from GTK+.
418 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); 422 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
419 if (rwhv) 423 if (rwhv)
420 rwhv->SetSize(size); 424 rwhv->SetSize(size);
421 if (tab_contents_->interstitial_page()) 425 if (tab_contents_->interstitial_page())
422 tab_contents_->interstitial_page()->SetSize(size); 426 tab_contents_->interstitial_page()->SetSize(size);
423 } 427 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698