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

Side by Side Diff: content/renderer/render_widget.cc

Issue 67383002: Initial browser-side implementation for touch-action (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for new blink API - no touch ID for now Created 7 years, 1 month 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
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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 need_update_rect_for_auto_resize_(false), 349 need_update_rect_for_auto_resize_(false),
350 using_asynchronous_swapbuffers_(false), 350 using_asynchronous_swapbuffers_(false),
351 num_swapbuffers_complete_pending_(0), 351 num_swapbuffers_complete_pending_(0),
352 did_show_(false), 352 did_show_(false),
353 is_hidden_(hidden), 353 is_hidden_(hidden),
354 is_fullscreen_(false), 354 is_fullscreen_(false),
355 needs_repainting_on_restore_(false), 355 needs_repainting_on_restore_(false),
356 has_focus_(false), 356 has_focus_(false),
357 handling_input_event_(false), 357 handling_input_event_(false),
358 handling_ime_event_(false), 358 handling_ime_event_(false),
359 handling_touchstart_event_(false),
359 closing_(false), 360 closing_(false),
360 is_swapped_out_(swapped_out), 361 is_swapped_out_(swapped_out),
361 input_method_is_active_(false), 362 input_method_is_active_(false),
362 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 363 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
363 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 364 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
364 can_compose_inline_(true), 365 can_compose_inline_(true),
365 popup_type_(popup_type), 366 popup_type_(popup_type),
366 pending_window_rect_count_(0), 367 pending_window_rect_count_(0),
367 suppress_next_char_events_(false), 368 suppress_next_char_events_(false),
368 is_accelerated_compositing_active_(false), 369 is_accelerated_compositing_active_(false),
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 if (WebInputEvent::isGestureEventType(input_event->type)) { 1110 if (WebInputEvent::isGestureEventType(input_event->type)) {
1110 const WebGestureEvent& gesture_event = 1111 const WebGestureEvent& gesture_event =
1111 *static_cast<const WebGestureEvent*>(input_event); 1112 *static_cast<const WebGestureEvent*>(input_event);
1112 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); 1113 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
1113 } 1114 }
1114 1115
1115 if (input_event->type == WebInputEvent::GestureTap || 1116 if (input_event->type == WebInputEvent::GestureTap ||
1116 input_event->type == WebInputEvent::GestureLongPress) 1117 input_event->type == WebInputEvent::GestureLongPress)
1117 resetInputMethod(); 1118 resetInputMethod();
1118 1119
1120 if (input_event->type == WebInputEvent::TouchStart)
1121 handling_touchstart_event_ = true;
1122
1119 bool processed = prevent_default; 1123 bool processed = prevent_default;
1120 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { 1124 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
1121 suppress_next_char_events_ = false; 1125 suppress_next_char_events_ = false;
1122 if (!processed && webwidget_) 1126 if (!processed && webwidget_)
1123 processed = webwidget_->handleInputEvent(*input_event); 1127 processed = webwidget_->handleInputEvent(*input_event);
1124 } 1128 }
1125 1129
1130 handling_touchstart_event_ = false;
1131
1126 // If this RawKeyDown event corresponds to a browser keyboard shortcut and 1132 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
1127 // it's not processed by webkit, then we need to suppress the upcoming Char 1133 // it's not processed by webkit, then we need to suppress the upcoming Char
1128 // events. 1134 // events.
1129 if (!processed && is_keyboard_shortcut) 1135 if (!processed && is_keyboard_shortcut)
1130 suppress_next_char_events_ = true; 1136 suppress_next_char_events_ = true;
1131 1137
1132 InputEventAckState ack_result = processed ? 1138 InputEventAckState ack_result = processed ?
1133 INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1139 INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1134 if (!processed && input_event->type == WebInputEvent::TouchStart) { 1140 if (!processed && input_event->type == WebInputEvent::TouchStart) {
1135 const WebTouchEvent& touch_event = 1141 const WebTouchEvent& touch_event =
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 2782
2777 bool RenderWidget::WillHandleGestureEvent( 2783 bool RenderWidget::WillHandleGestureEvent(
2778 const blink::WebGestureEvent& event) { 2784 const blink::WebGestureEvent& event) {
2779 return false; 2785 return false;
2780 } 2786 }
2781 2787
2782 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { 2788 void RenderWidget::hasTouchEventHandlers(bool has_handlers) {
2783 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); 2789 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers));
2784 } 2790 }
2785 2791
2792 void RenderWidget::setTouchAction(
2793 blink::WebTouchAction web_touch_action) {
2794
2795 // Ignore setTouchAction calls that result from synthetic touch events (eg.
2796 // when blink is emulating touch with mouse).
2797 if (!handling_touchstart_event_)
2798 return;
2799
2800 content::TouchAction content_touch_action;
2801 switch(web_touch_action) {
2802 case blink::WebTouchActionNone:
2803 content_touch_action = content::TOUCH_ACTION_NONE;
2804 break;
2805 case blink::WebTouchActionAuto:
2806 content_touch_action = content::TOUCH_ACTION_AUTO;
2807 break;
2808 default:
2809 NOTREACHED();
2810 }
2811 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action));
2812 }
2813
2786 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 2814 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
2787 return true; 2815 return true;
2788 } 2816 }
2789 2817
2790 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 2818 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
2791 RenderWidget::CreateGraphicsContext3D( 2819 RenderWidget::CreateGraphicsContext3D(
2792 const blink::WebGraphicsContext3D::Attributes& attributes) { 2820 const blink::WebGraphicsContext3D::Attributes& attributes) {
2793 if (!webwidget_) 2821 if (!webwidget_)
2794 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2822 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2795 if (CommandLine::ForCurrentProcess()->HasSwitch( 2823 if (CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 GetURLForGraphicsContext3D(), 2870 GetURLForGraphicsContext3D(),
2843 gpu_channel_host.get(), 2871 gpu_channel_host.get(),
2844 use_echo_for_swap_ack, 2872 use_echo_for_swap_ack,
2845 attributes, 2873 attributes,
2846 false /* bind generates resources */, 2874 false /* bind generates resources */,
2847 limits)); 2875 limits));
2848 return context.Pass(); 2876 return context.Pass();
2849 } 2877 }
2850 2878
2851 } // namespace content 2879 } // namespace content
OLDNEW
« content/common/input/touch_action.h ('K') | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698