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

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: Tweak include for moved synthetic_web_input_event_builders.h Created 7 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 | « content/renderer/render_widget.h ('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/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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 if (WebInputEvent::isGestureEventType(input_event->type)) { 1099 if (WebInputEvent::isGestureEventType(input_event->type)) {
1099 const WebGestureEvent& gesture_event = 1100 const WebGestureEvent& gesture_event =
1100 *static_cast<const WebGestureEvent*>(input_event); 1101 *static_cast<const WebGestureEvent*>(input_event);
1101 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); 1102 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event);
1102 } 1103 }
1103 1104
1104 if (input_event->type == WebInputEvent::GestureTap || 1105 if (input_event->type == WebInputEvent::GestureTap ||
1105 input_event->type == WebInputEvent::GestureLongPress) 1106 input_event->type == WebInputEvent::GestureLongPress)
1106 resetInputMethod(); 1107 resetInputMethod();
1107 1108
1109 if (input_event->type == WebInputEvent::TouchStart)
1110 handling_touchstart_event_ = true;
1111
1108 bool processed = prevent_default; 1112 bool processed = prevent_default;
1109 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { 1113 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) {
1110 suppress_next_char_events_ = false; 1114 suppress_next_char_events_ = false;
1111 if (!processed && webwidget_) 1115 if (!processed && webwidget_)
1112 processed = webwidget_->handleInputEvent(*input_event); 1116 processed = webwidget_->handleInputEvent(*input_event);
1113 } 1117 }
1114 1118
1119 handling_touchstart_event_ = false;
1120
1115 // If this RawKeyDown event corresponds to a browser keyboard shortcut and 1121 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
1116 // it's not processed by webkit, then we need to suppress the upcoming Char 1122 // it's not processed by webkit, then we need to suppress the upcoming Char
1117 // events. 1123 // events.
1118 if (!processed && is_keyboard_shortcut) 1124 if (!processed && is_keyboard_shortcut)
1119 suppress_next_char_events_ = true; 1125 suppress_next_char_events_ = true;
1120 1126
1121 InputEventAckState ack_result = processed ? 1127 InputEventAckState ack_result = processed ?
1122 INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1128 INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1123 if (!processed && input_event->type == WebInputEvent::TouchStart) { 1129 if (!processed && input_event->type == WebInputEvent::TouchStart) {
1124 const WebTouchEvent& touch_event = 1130 const WebTouchEvent& touch_event =
(...skipping 1651 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698