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

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

Issue 6488012: Revert 74518 - Refactor TOUCH_UI to match other refactor.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « chrome/browser/dom_ui/keyboard_ui.cc ('k') | chrome/browser/ui/views/dropdown_bar_host_gtk.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_view_views.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 if (event.IsAltDown()) 52 if (event.IsAltDown())
53 modifiers |= WebKit::WebInputEvent::AltKey; 53 modifiers |= WebKit::WebInputEvent::AltKey;
54 if (event.IsCapsLockDown()) 54 if (event.IsCapsLockDown())
55 modifiers |= WebKit::WebInputEvent::CapsLockOn; 55 modifiers |= WebKit::WebInputEvent::CapsLockOn;
56 56
57 return modifiers; 57 return modifiers;
58 } 58 }
59 59
60 WebKit::WebTouchPoint::State TouchPointStateFromEvent( 60 WebKit::WebTouchPoint::State TouchPointStateFromEvent(
61 const views::TouchEvent* event) { 61 const views::TouchEvent* event) {
62 switch (event->type()) { 62 switch (event->GetType()) {
63 case ui::ET_TOUCH_PRESSED: 63 case ui::ET_TOUCH_PRESSED:
64 return WebKit::WebTouchPoint::StatePressed; 64 return WebKit::WebTouchPoint::StatePressed;
65 case ui::ET_TOUCH_RELEASED: 65 case ui::ET_TOUCH_RELEASED:
66 return WebKit::WebTouchPoint::StateReleased; 66 return WebKit::WebTouchPoint::StateReleased;
67 case ui::ET_TOUCH_MOVED: 67 case ui::ET_TOUCH_MOVED:
68 return WebKit::WebTouchPoint::StateMoved; 68 return WebKit::WebTouchPoint::StateMoved;
69 case ui::ET_TOUCH_CANCELLED: 69 case ui::ET_TOUCH_CANCELLED:
70 return WebKit::WebTouchPoint::StateCancelled; 70 return WebKit::WebTouchPoint::StateCancelled;
71 default: 71 default:
72 return WebKit::WebTouchPoint::StateUndefined; 72 return WebKit::WebTouchPoint::StateUndefined;
73 } 73 }
74 } 74 }
75 75
76 WebKit::WebInputEvent::Type TouchEventTypeFromEvent( 76 WebKit::WebInputEvent::Type TouchEventTypeFromEvent(
77 const views::TouchEvent* event) { 77 const views::TouchEvent* event) {
78 switch (event->type()) { 78 switch (event->GetType()) {
79 case ui::ET_TOUCH_PRESSED: 79 case ui::ET_TOUCH_PRESSED:
80 return WebKit::WebInputEvent::TouchStart; 80 return WebKit::WebInputEvent::TouchStart;
81 case ui::ET_TOUCH_RELEASED: 81 case ui::ET_TOUCH_RELEASED:
82 return WebKit::WebInputEvent::TouchEnd; 82 return WebKit::WebInputEvent::TouchEnd;
83 case ui::ET_TOUCH_MOVED: 83 case ui::ET_TOUCH_MOVED:
84 return WebKit::WebInputEvent::TouchMove; 84 return WebKit::WebInputEvent::TouchMove;
85 case ui::ET_TOUCH_CANCELLED: 85 case ui::ET_TOUCH_CANCELLED:
86 return WebKit::WebInputEvent::TouchCancel; 86 return WebKit::WebInputEvent::TouchCancel;
87 default: 87 default:
88 return WebKit::WebInputEvent::Undefined; 88 return WebKit::WebInputEvent::Undefined;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 496 }
497 497
498 bool RenderWidgetHostViewViews::OnMouseWheel(const views::MouseWheelEvent& e) { 498 bool RenderWidgetHostViewViews::OnMouseWheel(const views::MouseWheelEvent& e) {
499 WebMouseWheelEvent wmwe; 499 WebMouseWheelEvent wmwe;
500 InitializeWebMouseEventFromViewsEvent(e, GetMirroredPosition(), &wmwe); 500 InitializeWebMouseEventFromViewsEvent(e, GetMirroredPosition(), &wmwe);
501 501
502 wmwe.type = WebKit::WebInputEvent::MouseWheel; 502 wmwe.type = WebKit::WebInputEvent::MouseWheel;
503 wmwe.button = WebKit::WebMouseEvent::ButtonNone; 503 wmwe.button = WebKit::WebMouseEvent::ButtonNone;
504 504
505 // TODO(sadrul): How do we determine if it's a horizontal scroll? 505 // TODO(sadrul): How do we determine if it's a horizontal scroll?
506 wmwe.deltaY = e.offset(); 506 wmwe.deltaY = e.GetOffset();
507 wmwe.wheelTicksY = wmwe.deltaY > 0 ? 1 : -1; 507 wmwe.wheelTicksY = wmwe.deltaY > 0 ? 1 : -1;
508 508
509 GetRenderWidgetHost()->ForwardWheelEvent(wmwe); 509 GetRenderWidgetHost()->ForwardWheelEvent(wmwe);
510 return true; 510 return true;
511 } 511 }
512 512
513 bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent &e) { 513 bool RenderWidgetHostViewViews::OnKeyPressed(const views::KeyEvent &e) {
514 // Send key event to input method. 514 // Send key event to input method.
515 // TODO host_view->im_context_->ProcessKeyEvent(event); 515 // TODO host_view->im_context_->ProcessKeyEvent(event);
516 516
517 // This is how it works: 517 // This is how it works:
518 // (1) If a RawKeyDown event is an accelerator for a reserved command (see 518 // (1) If a RawKeyDown event is an accelerator for a reserved command (see
519 // Browser::IsReservedCommand), then the command is executed. Otherwise, 519 // Browser::IsReservedCommand), then the command is executed. Otherwise,
520 // the event is first sent off to the renderer. The renderer is also 520 // the event is first sent off to the renderer. The renderer is also
521 // notified whether the event would trigger an accelerator in the browser. 521 // notified whether the event would trigger an accelerator in the browser.
522 // (2) A Char event is then sent to the renderer. 522 // (2) A Char event is then sent to the renderer.
523 // (3) If the renderer does not process the event in step (1), and the event 523 // (3) If the renderer does not process the event in step (1), and the event
524 // triggers an accelerator, then it will ignore the event in step (2). The 524 // triggers an accelerator, then it will ignore the event in step (2). The
525 // renderer also sends back notification to the browser for both steps (1) 525 // renderer also sends back notification to the browser for both steps (1)
526 // and (2) about whether the events were processed or not. If the event 526 // and (2) about whether the events were processed or not. If the event
527 // for (1) is not processed by the renderer, then it is processed by the 527 // for (1) is not processed by the renderer, then it is processed by the
528 // browser, and (2) is ignored. 528 // browser, and (2) is ignored.
529 529
530 NativeWebKeyboardEvent wke; 530 NativeWebKeyboardEvent wke;
531 wke.type = WebKit::WebInputEvent::RawKeyDown; 531 wke.type = WebKit::WebInputEvent::RawKeyDown;
532 wke.windowsKeyCode = e.key_code(); 532 wke.windowsKeyCode = e.GetKeyCode();
533 wke.setKeyIdentifierFromWindowsKeyCode(); 533 wke.setKeyIdentifierFromWindowsKeyCode();
534 534
535 wke.text[0] = wke.unmodifiedText[0] = 535 wke.text[0] = wke.unmodifiedText[0] =
536 static_cast<unsigned short>(gdk_keyval_to_unicode( 536 static_cast<unsigned short>(gdk_keyval_to_unicode(
537 ui::GdkKeyCodeForWindowsKeyCode(e.key_code(), 537 ui::GdkKeyCodeForWindowsKeyCode(e.GetKeyCode(),
538 e.IsShiftDown() ^ e.IsCapsLockDown()))); 538 e.IsShiftDown() ^ e.IsCapsLockDown())));
539 539
540 wke.modifiers = WebInputEventFlagsFromViewsEvent(e); 540 wke.modifiers = WebInputEventFlagsFromViewsEvent(e);
541 ForwardKeyboardEvent(wke); 541 ForwardKeyboardEvent(wke);
542 542
543 // send the keypress event 543 // send the keypress event
544 wke.type = WebKit::WebInputEvent::Char; 544 wke.type = WebKit::WebInputEvent::Char;
545 ForwardKeyboardEvent(wke); 545 ForwardKeyboardEvent(wke);
546 546
547 return TRUE; 547 return TRUE;
548 } 548 }
549 549
550 bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent &e) { 550 bool RenderWidgetHostViewViews::OnKeyReleased(const views::KeyEvent &e) {
551 // TODO(bryeung): deal with input methods 551 // TODO(bryeung): deal with input methods
552 NativeWebKeyboardEvent wke; 552 NativeWebKeyboardEvent wke;
553 553
554 wke.type = WebKit::WebInputEvent::KeyUp; 554 wke.type = WebKit::WebInputEvent::KeyUp;
555 wke.windowsKeyCode = e.key_code(); 555 wke.windowsKeyCode = e.GetKeyCode();
556 wke.setKeyIdentifierFromWindowsKeyCode(); 556 wke.setKeyIdentifierFromWindowsKeyCode();
557 557
558 ForwardKeyboardEvent(wke); 558 ForwardKeyboardEvent(wke);
559 559
560 return TRUE; 560 return TRUE;
561 } 561 }
562 562
563 void RenderWidgetHostViewViews::DidGainFocus() { 563 void RenderWidgetHostViewViews::DidGainFocus() {
564 #if 0 564 #if 0
565 // TODO(anicolao): - is this needed/replicable? 565 // TODO(anicolao): - is this needed/replicable?
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 #endif 676 #endif
677 host_->ForwardKeyboardEvent(event); 677 host_->ForwardKeyboardEvent(event);
678 } 678 }
679 679
680 views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent( 680 views::View::TouchStatus RenderWidgetHostViewViews::OnTouchEvent(
681 const views::TouchEvent& e) { 681 const views::TouchEvent& e) {
682 // Update the list of touch points first. 682 // Update the list of touch points first.
683 WebKit::WebTouchPoint* point = NULL; 683 WebKit::WebTouchPoint* point = NULL;
684 TouchStatus status = TOUCH_STATUS_UNKNOWN; 684 TouchStatus status = TOUCH_STATUS_UNKNOWN;
685 685
686 switch (e.type()) { 686 switch (e.GetType()) {
687 case ui::ET_TOUCH_PRESSED: 687 case ui::ET_TOUCH_PRESSED:
688 // Add a new touch point. 688 // Add a new touch point.
689 if (touch_event_.touchPointsLength < 689 if (touch_event_.touchPointsLength <
690 WebTouchEvent::touchPointsLengthCap) { 690 WebTouchEvent::touchPointsLengthCap) {
691 point = &touch_event_.touchPoints[touch_event_.touchPointsLength++]; 691 point = &touch_event_.touchPoints[touch_event_.touchPointsLength++];
692 point->id = e.identity(); 692 point->id = e.identity();
693 693
694 if (touch_event_.touchPointsLength == 1) { 694 if (touch_event_.touchPointsLength == 1) {
695 // A new touch sequence has started. 695 // A new touch sequence has started.
696 status = TOUCH_STATUS_START; 696 status = TOUCH_STATUS_START;
(...skipping 13 matching lines...) Expand all
710 for (int i = 0; i < touch_event_.touchPointsLength; ++i) { 710 for (int i = 0; i < touch_event_.touchPointsLength; ++i) {
711 point = touch_event_.touchPoints + i; 711 point = touch_event_.touchPoints + i;
712 if (point->id == e.identity()) { 712 if (point->id == e.identity()) {
713 break; 713 break;
714 } 714 }
715 point = NULL; 715 point = NULL;
716 } 716 }
717 break; 717 break;
718 } 718 }
719 default: 719 default:
720 DLOG(WARNING) << "Unknown touch event " << e.type(); 720 DLOG(WARNING) << "Unknown touch event " << e.GetType();
721 break; 721 break;
722 } 722 }
723 723
724 if (!point) 724 if (!point)
725 return TOUCH_STATUS_UNKNOWN; 725 return TOUCH_STATUS_UNKNOWN;
726 726
727 if (status != TOUCH_STATUS_START) 727 if (status != TOUCH_STATUS_START)
728 status = TOUCH_STATUS_CONTINUE; 728 status = TOUCH_STATUS_CONTINUE;
729 729
730 // Update the location and state of the point. 730 // Update the location and state of the point.
(...skipping 17 matching lines...) Expand all
748 } 748 }
749 749
750 // Update the type of the touch event. 750 // Update the type of the touch event.
751 touch_event_.type = TouchEventTypeFromEvent(&e); 751 touch_event_.type = TouchEventTypeFromEvent(&e);
752 touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT(); 752 touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT();
753 753
754 // The event and all the touches have been updated. Dispatch. 754 // The event and all the touches have been updated. Dispatch.
755 host_->ForwardTouchEvent(touch_event_); 755 host_->ForwardTouchEvent(touch_event_);
756 756
757 // If the touch was released, then remove it from the list of touch points. 757 // If the touch was released, then remove it from the list of touch points.
758 if (e.type() == ui::ET_TOUCH_RELEASED) { 758 if (e.GetType() == ui::ET_TOUCH_RELEASED) {
759 --touch_event_.touchPointsLength; 759 --touch_event_.touchPointsLength;
760 for (int i = point - touch_event_.touchPoints; 760 for (int i = point - touch_event_.touchPoints;
761 i < touch_event_.touchPointsLength; 761 i < touch_event_.touchPointsLength;
762 ++i) { 762 ++i) {
763 touch_event_.touchPoints[i] = touch_event_.touchPoints[i + 1]; 763 touch_event_.touchPoints[i] = touch_event_.touchPoints[i + 1];
764 } 764 }
765 if (touch_event_.touchPointsLength == 0) 765 if (touch_event_.touchPointsLength == 0)
766 status = TOUCH_STATUS_END; 766 status = TOUCH_STATUS_END;
767 } else if (e.type() == ui::ET_TOUCH_CANCELLED) { 767 } else if (e.GetType() == ui::ET_TOUCH_CANCELLED) {
768 status = TOUCH_STATUS_CANCEL; 768 status = TOUCH_STATUS_CANCEL;
769 } 769 }
770 770
771 return status; 771 return status;
772 } 772 }
773 773
774 std::string RenderWidgetHostViewViews::GetClassName() const { 774 std::string RenderWidgetHostViewViews::GetClassName() const {
775 return kViewClassName; 775 return kViewClassName;
776 } 776 }
777 777
778 // static 778 // static
779 RenderWidgetHostView* 779 RenderWidgetHostView*
780 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 780 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
781 gfx::NativeView widget) { 781 gfx::NativeView widget) {
782 gpointer user_data = g_object_get_data(G_OBJECT(widget), 782 gpointer user_data = g_object_get_data(G_OBJECT(widget),
783 kRenderWidgetHostViewKey); 783 kRenderWidgetHostViewKey);
784 return reinterpret_cast<RenderWidgetHostView*>(user_data); 784 return reinterpret_cast<RenderWidgetHostView*>(user_data);
785 } 785 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/keyboard_ui.cc ('k') | chrome/browser/ui/views/dropdown_bar_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698