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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host.cc

Issue 147246: Linux: middle-click to navigate (Closed)
Patch Set: ... Created 11 years, 5 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/renderer_host/render_widget_host.h" 5 #include "chrome/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/keyboard_codes.h" 9 #include "base/keyboard_codes.h"
10 #include "chrome/browser/renderer_host/backing_store.h" 10 #include "chrome/browser/renderer_host/backing_store.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (mouse_event.type == WebInputEvent::MouseMove) { 324 if (mouse_event.type == WebInputEvent::MouseMove) {
325 if (mouse_move_pending_) { 325 if (mouse_move_pending_) {
326 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); 326 next_mouse_move_.reset(new WebMouseEvent(mouse_event));
327 return; 327 return;
328 } 328 }
329 mouse_move_pending_ = true; 329 mouse_move_pending_ = true;
330 } else if (mouse_event.type == WebInputEvent::MouseDown) { 330 } else if (mouse_event.type == WebInputEvent::MouseDown) {
331 OnUserGesture(); 331 OnUserGesture();
332 } 332 }
333 333
334 if (mouse_event.type == WebInputEvent::MouseUp ||
335 mouse_event.type == WebInputEvent::MouseDown) {
336 // We keep track of these events in case the renderer doesn't handle them.
337 // In that case we can then implement some default behaviour.
338 mouse_button_queue_.push(new WebMouseEvent(mouse_event));
339 }
340
334 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent)); 341 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent));
335 } 342 }
336 343
337 void RenderWidgetHost::ForwardWheelEvent( 344 void RenderWidgetHost::ForwardWheelEvent(
338 const WebMouseWheelEvent& wheel_event) { 345 const WebMouseWheelEvent& wheel_event) {
339 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent)); 346 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent));
340 } 347 }
341 348
342 void RenderWidgetHost::ForwardKeyboardEvent( 349 void RenderWidgetHost::ForwardKeyboardEvent(
343 const NativeWebKeyboardEvent& key_event) { 350 const NativeWebKeyboardEvent& key_event) {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); 669 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta);
663 670
664 // Cancel pending hung renderer checks since the renderer is responsive. 671 // Cancel pending hung renderer checks since the renderer is responsive.
665 StopHangMonitorTimeout(); 672 StopHangMonitorTimeout();
666 673
667 void* iter = NULL; 674 void* iter = NULL;
668 int type = 0; 675 int type = 0;
669 bool r = message.ReadInt(&iter, &type); 676 bool r = message.ReadInt(&iter, &type);
670 DCHECK(r); 677 DCHECK(r);
671 678
679 bool processed = false;
680 r = message.ReadBool(&iter, &processed);
681 DCHECK(r);
682
672 if (type == WebInputEvent::MouseMove) { 683 if (type == WebInputEvent::MouseMove) {
673 mouse_move_pending_ = false; 684 mouse_move_pending_ = false;
674 685
675 // now, we can send the next mouse move event 686 // now, we can send the next mouse move event
676 if (next_mouse_move_.get()) { 687 if (next_mouse_move_.get()) {
677 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); 688 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove);
678 ForwardMouseEvent(*next_mouse_move_); 689 ForwardMouseEvent(*next_mouse_move_);
679 } 690 }
680 } 691 } else if (type == WebInputEvent::MouseDown ||
692 type == WebInputEvent::MouseUp) {
693 if (mouse_button_queue_.size() == 0 ||
694 mouse_button_queue_.front()->type != type) {
695 LOG(ERROR) << "We got a mouse event from the renderer, but we don't "
696 "remember sending it!";
697 } else {
698 const MouseButtonQueue::value_type front_item =
699 mouse_button_queue_.front();
700 mouse_button_queue_.pop();
681 701
682 if (WebInputEvent::isKeyboardEventType(type)) { 702 if (!processed)
703 UnhandledMouseButtonEvent(front_item);
704 delete front_item;
705 }
706 } else if (WebInputEvent::isKeyboardEventType(type)) {
683 if (key_queue_.size() == 0) { 707 if (key_queue_.size() == 0) {
684 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " 708 LOG(ERROR) << "Got a KeyEvent back from the renderer but we "
685 << "don't seem to have sent it to the renderer!"; 709 << "don't seem to have sent it to the renderer!";
686 } else if (key_queue_.front().type != type) { 710 } else if (key_queue_.front().type != type) {
687 LOG(ERROR) << "We seem to have a different key type sent from " 711 LOG(ERROR) << "We seem to have a different key type sent from "
688 << "the renderer. (" << key_queue_.front().type << " vs. " 712 << "the renderer. (" << key_queue_.front().type << " vs. "
689 << type << "). Ignoring event."; 713 << type << "). Ignoring event.";
690 } else { 714 } else {
691 bool processed = false;
692 r = message.ReadBool(&iter, &processed);
693 DCHECK(r);
694
695 KeyQueue::value_type front_item = key_queue_.front(); 715 KeyQueue::value_type front_item = key_queue_.front();
696 key_queue_.pop(); 716 key_queue_.pop();
697 717
698 if (!processed) { 718 if (!processed) {
699 UnhandledKeyboardEvent(front_item); 719 UnhandledKeyboardEvent(front_item);
700 720
701 // WARNING: This RenderWidgetHost can be deallocated at this point 721 // WARNING: This RenderWidgetHost can be deallocated at this point
702 // (i.e. in the case of Ctrl+W, where the call to 722 // (i.e. in the case of Ctrl+W, where the call to
703 // UnhandledKeyboardEvent destroys this RenderWidgetHost). 723 // UnhandledKeyboardEvent destroys this RenderWidgetHost).
704 } 724 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 812
793 // TODO(darin): do we need to do something else if our backing store is not 813 // TODO(darin): do we need to do something else if our backing store is not
794 // the same size as the advertised view? maybe we just assume there is a 814 // the same size as the advertised view? maybe we just assume there is a
795 // full paint on its way? 815 // full paint on its way?
796 BackingStore* backing_store = BackingStoreManager::Lookup(this); 816 BackingStore* backing_store = BackingStoreManager::Lookup(this);
797 if (!backing_store || (backing_store->size() != view_size)) 817 if (!backing_store || (backing_store->size() != view_size))
798 return; 818 return;
799 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, 819 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect,
800 dx, dy, clip_rect, view_size); 820 dx, dy, clip_rect, view_size);
801 } 821 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host.h ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698