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

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

Issue 7840035: Update call sites to account for new WebTouchEvent API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | « 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/renderer_host/render_widget_host_view_views.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" 8 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h"
9 #include "content/browser/renderer_host/render_widget_host.h" 9 #include "content/browser/renderer_host/render_widget_host.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact ory.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact ory.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 if (!host_) 81 if (!host_)
82 return ui::TOUCH_STATUS_UNKNOWN; 82 return ui::TOUCH_STATUS_UNKNOWN;
83 83
84 // Update the list of touch points first. 84 // Update the list of touch points first.
85 WebKit::WebTouchPoint* point = NULL; 85 WebKit::WebTouchPoint* point = NULL;
86 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; 86 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
87 87
88 switch (event.type()) { 88 switch (event.type()) {
89 case ui::ET_TOUCH_PRESSED: 89 case ui::ET_TOUCH_PRESSED:
90 // Add a new touch point. 90 // Add a new touch point.
91 if (touch_event_.touchPointsLength < 91 if (touch_event_.touchesLength <
92 WebTouchEvent::touchPointsLengthCap) { 92 WebTouchEvent::touchesLengthCap) {
93 point = &touch_event_.touchPoints[touch_event_.touchPointsLength++]; 93 point = &touch_event_.touches[touch_event_.touchesLength++];
94 point->id = event.identity(); 94 point->id = event.identity();
95 95
96 if (touch_event_.touchPointsLength == 1) { 96 if (touch_event_.touchesLength == 1) {
97 // A new touch sequence has started. 97 // A new touch sequence has started.
98 status = ui::TOUCH_STATUS_START; 98 status = ui::TOUCH_STATUS_START;
99 99
100 // We also want the focus. 100 // We also want the focus.
101 RequestFocus(); 101 RequestFocus();
102 102
103 // Confirm existing composition text on touch press events, to make 103 // Confirm existing composition text on touch press events, to make
104 // sure the input caret won't be moved with an ongoing composition 104 // sure the input caret won't be moved with an ongoing composition
105 // text. 105 // text.
106 FinishImeCompositionSession(); 106 FinishImeCompositionSession();
107 } 107 }
108 } 108 }
109 break; 109 break;
110 case ui::ET_TOUCH_RELEASED: 110 case ui::ET_TOUCH_RELEASED:
111 case ui::ET_TOUCH_CANCELLED: 111 case ui::ET_TOUCH_CANCELLED:
112 case ui::ET_TOUCH_MOVED: { 112 case ui::ET_TOUCH_MOVED: {
113 // The touch point should have been added to the event from an earlier 113 // The touch point should have been added to the event from an earlier
114 // _PRESSED event. So find that. 114 // _PRESSED event. So find that.
115 // At the moment, only a maximum of 4 touch-points are allowed. So a 115 // At the moment, only a maximum of 4 touch-points are allowed. So a
116 // simple loop should be sufficient. 116 // simple loop should be sufficient.
117 for (int i = 0; i < touch_event_.touchPointsLength; ++i) { 117 for (int i = 0; i < touch_event_.touchesLength; ++i) {
118 point = touch_event_.touchPoints + i; 118 point = touch_event_.touches + i;
119 if (point->id == event.identity()) { 119 if (point->id == event.identity()) {
120 break; 120 break;
121 } 121 }
122 point = NULL; 122 point = NULL;
123 } 123 }
124 break; 124 break;
125 } 125 }
126 default: 126 default:
127 DLOG(WARNING) << "Unknown touch event " << event.type(); 127 DLOG(WARNING) << "Unknown touch event " << event.type();
128 break; 128 break;
(...skipping 13 matching lines...) Expand all
142 // It is possible for badly written touch drivers to emit Move events even 142 // It is possible for badly written touch drivers to emit Move events even
143 // when the touch location hasn't changed. In such cases, consume the event 143 // when the touch location hasn't changed. In such cases, consume the event
144 // and pretend nothing happened. 144 // and pretend nothing happened.
145 if (point->position.x == event.x() && point->position.y == event.y()) { 145 if (point->position.x == event.x() && point->position.y == event.y()) {
146 return status; 146 return status;
147 } 147 }
148 } 148 }
149 UpdateTouchPointPosition(&event, GetMirroredPosition(), point); 149 UpdateTouchPointPosition(&event, GetMirroredPosition(), point);
150 150
151 // Mark the rest of the points as stationary. 151 // Mark the rest of the points as stationary.
152 for (int i = 0; i < touch_event_.touchPointsLength; ++i) { 152 for (int i = 0; i < touch_event_.touchesLength; ++i) {
153 WebKit::WebTouchPoint* iter = touch_event_.touchPoints + i; 153 WebKit::WebTouchPoint* iter = touch_event_.touches + i;
154 if (iter != point) { 154 if (iter != point) {
155 iter->state = WebKit::WebTouchPoint::StateStationary; 155 iter->state = WebKit::WebTouchPoint::StateStationary;
156 } 156 }
157 } 157 }
158 158
159 // Update the type of the touch event. 159 // Update the type of the touch event.
160 touch_event_.type = TouchEventTypeFromEvent(&event); 160 touch_event_.type = TouchEventTypeFromEvent(&event);
161 touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT(); 161 touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT();
162 162
163 // The event and all the touches have been updated. Dispatch. 163 // The event and all the touches have been updated. Dispatch.
164 host_->ForwardTouchEvent(touch_event_); 164 host_->ForwardTouchEvent(touch_event_);
165 165
166 // If the touch was released, then remove it from the list of touch points. 166 // If the touch was released, then remove it from the list of touch points.
167 if (event.type() == ui::ET_TOUCH_RELEASED) { 167 if (event.type() == ui::ET_TOUCH_RELEASED) {
168 --touch_event_.touchPointsLength; 168 --touch_event_.touchesLength;
169 for (int i = point - touch_event_.touchPoints; 169 for (int i = point - touch_event_.touches;
170 i < touch_event_.touchPointsLength; 170 i < touch_event_.touchesLength;
171 ++i) { 171 ++i) {
172 touch_event_.touchPoints[i] = touch_event_.touchPoints[i + 1]; 172 touch_event_.touches[i] = touch_event_.touches[i + 1];
173 } 173 }
174 if (touch_event_.touchPointsLength == 0) 174 if (touch_event_.touchesLength == 0)
175 status = ui::TOUCH_STATUS_END; 175 status = ui::TOUCH_STATUS_END;
176 } else if (event.type() == ui::ET_TOUCH_CANCELLED) { 176 } else if (event.type() == ui::ET_TOUCH_CANCELLED) {
177 status = ui::TOUCH_STATUS_CANCEL; 177 status = ui::TOUCH_STATUS_CANCEL;
178 } 178 }
179 179
180 return status; 180 return status;
181 } 181 }
182 182
183 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() { 183 gfx::PluginWindowHandle RenderWidgetHostViewViews::GetCompositingSurface() {
184 // On TOUCH_UI builds, the GPU process renders to an offscreen surface 184 // On TOUCH_UI builds, the GPU process renders to an offscreen surface
(...skipping 12 matching lines...) Expand all
197 197
198 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) { 198 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) {
199 accelerated_surface_containers_.erase(surface_id); 199 accelerated_surface_containers_.erase(surface_id);
200 } 200 }
201 201
202 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped( 202 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped(
203 uint64 surface_id) { 203 uint64 surface_id) {
204 SetExternalTexture(accelerated_surface_containers_[surface_id].get()); 204 SetExternalTexture(accelerated_surface_containers_[surface_id].get());
205 glFlush(); 205 glFlush();
206 } 206 }
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