| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/renderer_host/render_widget_host_input_event_router.h" | 5 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 6 | 6 |
| 7 #include "cc/quads/surface_draw_quad.h" | 7 #include "cc/quads/surface_draw_quad.h" |
| 8 #include "cc/surfaces/surface_id_allocator.h" | 8 #include "cc/surfaces/surface_id_allocator.h" |
| 9 #include "cc/surfaces/surface_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 11 #include "content/common/frame_messages.h" | 11 #include "content/common/frame_messages.h" |
| 12 #include "third_party/WebKit/public/web/WebInputEvent.h" | 12 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 13 | 13 |
| 14 namespace { |
| 15 |
| 16 void TransformEventTouchPositions(blink::WebTouchEvent* event, |
| 17 const gfx::Vector2d& delta) { |
| 18 for (unsigned i = 0; i < event->touchesLength; ++i) { |
| 19 event->touches[i].position.x += delta.x(); |
| 20 event->touches[i].position.y += delta.y(); |
| 21 } |
| 22 } |
| 23 |
| 24 } // anonymous namespace |
| 25 |
| 14 namespace content { | 26 namespace content { |
| 15 | 27 |
| 16 void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed( | 28 void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed( |
| 17 RenderWidgetHostViewBase* view) { | 29 RenderWidgetHostViewBase* view) { |
| 18 view->RemoveObserver(this); | 30 view->RemoveObserver(this); |
| 19 | 31 |
| 20 // Remove this view from the owner_map. | 32 // Remove this view from the owner_map. |
| 21 for (auto entry : owner_map_) { | 33 for (auto entry : owner_map_) { |
| 22 if (entry.second == view) { | 34 if (entry.second == view) { |
| 23 owner_map_.erase(entry.first); | 35 owner_map_.erase(entry.first); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Since this is the first touch, it defines the target for the rest | 154 // Since this is the first touch, it defines the target for the rest |
| 143 // of this sequence. | 155 // of this sequence. |
| 144 DCHECK(!current_touch_target_); | 156 DCHECK(!current_touch_target_); |
| 145 gfx::Point transformed_point; | 157 gfx::Point transformed_point; |
| 146 gfx::Point original_point(event->touches[0].position.x, | 158 gfx::Point original_point(event->touches[0].position.x, |
| 147 event->touches[0].position.y); | 159 event->touches[0].position.y); |
| 148 current_touch_target_ = | 160 current_touch_target_ = |
| 149 FindEventTarget(root_view, original_point, &transformed_point); | 161 FindEventTarget(root_view, original_point, &transformed_point); |
| 150 if (!current_touch_target_) | 162 if (!current_touch_target_) |
| 151 return; | 163 return; |
| 164 |
| 165 // TODO(wjmaclean): Instead of just computing a delta, we should extract |
| 166 // the complete transform. We assume it doesn't change for the duration |
| 167 // of the touch sequence, though this could be wrong; a better approach |
| 168 // might be to always transform each point to the current_touch_target_ |
| 169 // for the duration of the sequence. |
| 170 touch_delta_ = transformed_point - original_point; |
| 152 } | 171 } |
| 153 ++active_touches_; | 172 ++active_touches_; |
| 154 if (current_touch_target_) | 173 if (current_touch_target_) { |
| 174 TransformEventTouchPositions(event, touch_delta_); |
| 155 current_touch_target_->ProcessTouchEvent(*event, latency); | 175 current_touch_target_->ProcessTouchEvent(*event, latency); |
| 176 } |
| 156 break; | 177 break; |
| 157 } | 178 } |
| 158 case blink::WebInputEvent::TouchMove: | 179 case blink::WebInputEvent::TouchMove: |
| 159 if (current_touch_target_) | 180 if (current_touch_target_) { |
| 181 TransformEventTouchPositions(event, touch_delta_); |
| 160 current_touch_target_->ProcessTouchEvent(*event, latency); | 182 current_touch_target_->ProcessTouchEvent(*event, latency); |
| 183 } |
| 161 break; | 184 break; |
| 162 case blink::WebInputEvent::TouchEnd: | 185 case blink::WebInputEvent::TouchEnd: |
| 163 case blink::WebInputEvent::TouchCancel: | 186 case blink::WebInputEvent::TouchCancel: |
| 164 if (!current_touch_target_) | 187 if (!current_touch_target_) |
| 165 break; | 188 break; |
| 166 | 189 |
| 167 DCHECK(active_touches_); | 190 DCHECK(active_touches_); |
| 191 TransformEventTouchPositions(event, touch_delta_); |
| 168 current_touch_target_->ProcessTouchEvent(*event, latency); | 192 current_touch_target_->ProcessTouchEvent(*event, latency); |
| 169 --active_touches_; | 193 --active_touches_; |
| 170 if (!active_touches_) | 194 if (!active_touches_) { |
| 171 current_touch_target_ = nullptr; | 195 current_touch_target_ = nullptr; |
| 196 touch_delta_ = gfx::Vector2d(); |
| 197 } |
| 172 break; | 198 break; |
| 173 default: | 199 default: |
| 174 NOTREACHED(); | 200 NOTREACHED(); |
| 175 } | 201 } |
| 176 } | 202 } |
| 177 | 203 |
| 178 void RenderWidgetHostInputEventRouter::AddSurfaceIdNamespaceOwner( | 204 void RenderWidgetHostInputEventRouter::AddSurfaceIdNamespaceOwner( |
| 179 uint32_t id, | 205 uint32_t id, |
| 180 RenderWidgetHostViewBase* owner) { | 206 RenderWidgetHostViewBase* owner) { |
| 181 DCHECK(owner_map_.find(id) == owner_map_.end()); | 207 DCHECK(owner_map_.find(id) == owner_map_.end()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 206 if (owner_map_.find(cc::SurfaceIdAllocator::NamespaceForId( | 232 if (owner_map_.find(cc::SurfaceIdAllocator::NamespaceForId( |
| 207 params.surface_id)) == owner_map_.end()) { | 233 params.surface_id)) == owner_map_.end()) { |
| 208 return; | 234 return; |
| 209 } | 235 } |
| 210 HittestData data; | 236 HittestData data; |
| 211 data.ignored_for_hittest = params.ignored_for_hittest; | 237 data.ignored_for_hittest = params.ignored_for_hittest; |
| 212 hittest_data_[params.surface_id] = data; | 238 hittest_data_[params.surface_id] = data; |
| 213 } | 239 } |
| 214 | 240 |
| 215 } // namespace content | 241 } // namespace content |
| OLD | NEW |