OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return FloatPoint( | 82 return FloatPoint( |
83 -offset.width() / scale + visualViewport.x() + overscrollOffset.width(), | 83 -offset.width() / scale + visualViewport.x() + overscrollOffset.width(), |
84 -offset.height() / scale + visualViewport.y() + | 84 -offset.height() / scale + visualViewport.y() + |
85 overscrollOffset.height()); | 85 overscrollOffset.height()); |
86 } | 86 } |
87 | 87 |
88 float scaleDeltaToWindow(const Widget* widget, float delta) { | 88 float scaleDeltaToWindow(const Widget* widget, float delta) { |
89 return delta / frameScale(widget); | 89 return delta / frameScale(widget); |
90 } | 90 } |
91 | 91 |
92 FloatSize scaleSizeToWindow(const Widget* widget, FloatSize size) { | |
93 return FloatSize(scaleDeltaToWindow(widget, size.width()), | |
94 scaleDeltaToWindow(widget, size.height())); | |
95 } | |
96 | |
97 // This method converts from the renderer's coordinate space into Blink's root | 92 // This method converts from the renderer's coordinate space into Blink's root |
98 // frame coordinate space. It's somewhat unique in that it takes into account | 93 // frame coordinate space. It's somewhat unique in that it takes into account |
99 // DevTools emulation, which applies a scale and offset in the root layer (see | 94 // DevTools emulation, which applies a scale and offset in the root layer (see |
100 // updateRootLayerTransform in WebViewImpl) as well as the overscroll effect on | 95 // updateRootLayerTransform in WebViewImpl) as well as the overscroll effect on |
101 // OSX. This is in addition to the visual viewport "pinch-zoom" transformation | 96 // OSX. This is in addition to the visual viewport "pinch-zoom" transformation |
102 // and is one of the few cases where the visual viewport is not equal to the | 97 // and is one of the few cases where the visual viewport is not equal to the |
103 // renderer's coordinate-space. | 98 // renderer's coordinate-space. |
104 FloatPoint convertHitPointToRootFrame(const Widget* widget, | 99 FloatPoint convertHitPointToRootFrame(const Widget* widget, |
105 FloatPoint pointInRendererViewport) { | 100 FloatPoint pointInRendererViewport) { |
106 float scale = 1; | 101 float scale = 1; |
(...skipping 13 matching lines...) Expand all Loading... |
120 overscrollOffset = | 115 overscrollOffset = |
121 rootView->page()->frameHost().chromeClient().elasticOverscroll(); | 116 rootView->page()->frameHost().chromeClient().elasticOverscroll(); |
122 } | 117 } |
123 } | 118 } |
124 return FloatPoint((pointInRendererViewport.x() - offset.width()) / scale + | 119 return FloatPoint((pointInRendererViewport.x() - offset.width()) / scale + |
125 visualViewport.x() + overscrollOffset.width(), | 120 visualViewport.x() + overscrollOffset.width(), |
126 (pointInRendererViewport.y() - offset.height()) / scale + | 121 (pointInRendererViewport.y() - offset.height()) / scale + |
127 visualViewport.y() + overscrollOffset.height()); | 122 visualViewport.y() + overscrollOffset.height()); |
128 } | 123 } |
129 | 124 |
130 PlatformEvent::DispatchType toPlatformDispatchType( | |
131 WebInputEvent::DispatchType type) { | |
132 static_assert(PlatformEvent::DispatchType::Blocking == | |
133 static_cast<PlatformEvent::DispatchType>( | |
134 WebInputEvent::DispatchType::Blocking), | |
135 "Dispatch Types not equal"); | |
136 static_assert(PlatformEvent::DispatchType::EventNonBlocking == | |
137 static_cast<PlatformEvent::DispatchType>( | |
138 WebInputEvent::DispatchType::EventNonBlocking), | |
139 "Dispatch Types not equal"); | |
140 static_assert( | |
141 PlatformEvent::DispatchType::ListenersNonBlockingPassive == | |
142 static_cast<PlatformEvent::DispatchType>( | |
143 WebInputEvent::DispatchType::ListenersNonBlockingPassive), | |
144 "Dispatch Types not equal"); | |
145 static_assert( | |
146 PlatformEvent::DispatchType::ListenersForcedNonBlockingDueToFling == | |
147 static_cast<PlatformEvent::DispatchType>( | |
148 WebInputEvent::DispatchType:: | |
149 ListenersForcedNonBlockingDueToFling), | |
150 "Dispatch Types not equal"); | |
151 | |
152 return static_cast<PlatformEvent::DispatchType>(type); | |
153 } | |
154 | |
155 unsigned toPlatformModifierFrom(WebMouseEvent::Button button) { | 125 unsigned toPlatformModifierFrom(WebMouseEvent::Button button) { |
156 if (button == WebMouseEvent::Button::NoButton) | 126 if (button == WebMouseEvent::Button::NoButton) |
157 return 0; | 127 return 0; |
158 | 128 |
159 unsigned webMouseButtonToPlatformModifier[] = { | 129 unsigned webMouseButtonToPlatformModifier[] = { |
160 PlatformEvent::LeftButtonDown, PlatformEvent::MiddleButtonDown, | 130 PlatformEvent::LeftButtonDown, PlatformEvent::MiddleButtonDown, |
161 PlatformEvent::RightButtonDown}; | 131 PlatformEvent::RightButtonDown}; |
162 | 132 |
163 return webMouseButtonToPlatformModifier[static_cast<int>(button)]; | 133 return webMouseButtonToPlatformModifier[static_cast<int>(button)]; |
164 } | 134 } |
165 | 135 |
| 136 FloatPoint convertAbsoluteLocationForLayoutObjectFloat( |
| 137 const DoublePoint& location, |
| 138 const LayoutItem layoutItem) { |
| 139 return layoutItem.absoluteToLocal(FloatPoint(location), UseTransforms); |
| 140 } |
| 141 |
| 142 IntPoint convertAbsoluteLocationForLayoutObjectInt( |
| 143 const DoublePoint& location, |
| 144 const LayoutItem layoutItem) { |
| 145 return roundedIntPoint( |
| 146 convertAbsoluteLocationForLayoutObjectFloat(location, layoutItem)); |
| 147 } |
| 148 |
| 149 // FIXME: Change |widget| to const Widget& after RemoteFrames get |
| 150 // RemoteFrameViews. |
| 151 void updateWebMouseEventFromCoreMouseEvent(const MouseEvent& event, |
| 152 const Widget* widget, |
| 153 const LayoutItem layoutItem, |
| 154 WebMouseEvent& webEvent) { |
| 155 webEvent.setTimeStampSeconds(event.platformTimeStamp().InSeconds()); |
| 156 webEvent.setModifiers(event.modifiers()); |
| 157 |
| 158 FrameView* view = widget ? toFrameView(widget->parent()) : 0; |
| 159 // TODO(bokan): If view == nullptr, pointInRootFrame will really be |
| 160 // pointInRootContent. |
| 161 IntPoint pointInRootFrame(event.absoluteLocation().x(), |
| 162 event.absoluteLocation().y()); |
| 163 if (view) |
| 164 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); |
| 165 webEvent.globalX = event.screenX(); |
| 166 webEvent.globalY = event.screenY(); |
| 167 webEvent.windowX = pointInRootFrame.x(); |
| 168 webEvent.windowY = pointInRootFrame.y(); |
| 169 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( |
| 170 event.absoluteLocation(), layoutItem); |
| 171 webEvent.x = localPoint.x(); |
| 172 webEvent.y = localPoint.y(); |
| 173 } |
| 174 |
166 } // namespace | 175 } // namespace |
167 | 176 |
168 // MakePlatformMouseEvent ----------------------------------------------------- | 177 // MakePlatformMouseEvent ----------------------------------------------------- |
169 | 178 |
170 // TODO(mustaq): Add tests for this. | 179 // TODO(mustaq): Add tests for this. |
171 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, | 180 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, |
172 const WebMouseEvent& e) { | 181 const WebMouseEvent& e) { |
173 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 182 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
174 // to get rid of this once we abstract popups into a WebKit API. | 183 // to get rid of this once we abstract popups into a WebKit API. |
175 m_position = widget->convertFromRootFrame( | 184 m_position = widget->convertFromRootFrame( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 229 } |
221 | 230 |
222 WebGestureEvent TransformWebGestureEvent(Widget* widget, | 231 WebGestureEvent TransformWebGestureEvent(Widget* widget, |
223 const WebGestureEvent& event) { | 232 const WebGestureEvent& event) { |
224 WebGestureEvent result = event; | 233 WebGestureEvent result = event; |
225 result.setFrameScale(frameScale(widget)); | 234 result.setFrameScale(frameScale(widget)); |
226 result.setFrameTranslate(frameTranslation(widget)); | 235 result.setFrameTranslate(frameTranslation(widget)); |
227 return result; | 236 return result; |
228 } | 237 } |
229 | 238 |
230 inline PlatformEvent::EventType toPlatformTouchEventType( | 239 WebTouchEvent TransformWebTouchEvent(float frameScale, |
231 const WebInputEvent::Type type) { | 240 FloatPoint frameTranslate, |
232 switch (type) { | 241 const WebTouchEvent& event) { |
233 case WebInputEvent::TouchStart: | 242 // frameScale is default initialized in debug builds to be 0. |
234 return PlatformEvent::TouchStart; | 243 DCHECK_EQ(0, event.frameScale()); |
235 case WebInputEvent::TouchMove: | 244 DCHECK_EQ(0, event.frameTranslate().x); |
236 return PlatformEvent::TouchMove; | 245 DCHECK_EQ(0, event.frameTranslate().y); |
237 case WebInputEvent::TouchEnd: | 246 WebTouchEvent result = event; |
238 return PlatformEvent::TouchEnd; | 247 result.setFrameScale(frameScale); |
239 case WebInputEvent::TouchCancel: | 248 result.setFrameTranslate(frameTranslate); |
240 return PlatformEvent::TouchCancel; | 249 return result; |
241 case WebInputEvent::TouchScrollStarted: | |
242 return PlatformEvent::TouchScrollStarted; | |
243 default: | |
244 NOTREACHED(); | |
245 } | |
246 return PlatformEvent::TouchStart; | |
247 } | 250 } |
248 | 251 |
249 inline PlatformTouchPoint::TouchState toPlatformTouchPointState( | 252 WebTouchEvent TransformWebTouchEvent(Widget* widget, |
250 const WebTouchPoint::State state) { | 253 const WebTouchEvent& event) { |
251 switch (state) { | 254 return TransformWebTouchEvent(frameScale(widget), frameTranslation(widget), |
252 case WebTouchPoint::StateReleased: | 255 event); |
253 return PlatformTouchPoint::TouchReleased; | |
254 case WebTouchPoint::StatePressed: | |
255 return PlatformTouchPoint::TouchPressed; | |
256 case WebTouchPoint::StateMoved: | |
257 return PlatformTouchPoint::TouchMoved; | |
258 case WebTouchPoint::StateStationary: | |
259 return PlatformTouchPoint::TouchStationary; | |
260 case WebTouchPoint::StateCancelled: | |
261 return PlatformTouchPoint::TouchCancelled; | |
262 case WebTouchPoint::StateUndefined: | |
263 NOTREACHED(); | |
264 } | |
265 return PlatformTouchPoint::TouchReleased; | |
266 } | |
267 | |
268 inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type) { | |
269 if (type == EventTypeNames::touchend) | |
270 return WebTouchPoint::StateReleased; | |
271 if (type == EventTypeNames::touchcancel) | |
272 return WebTouchPoint::StateCancelled; | |
273 if (type == EventTypeNames::touchstart) | |
274 return WebTouchPoint::StatePressed; | |
275 if (type == EventTypeNames::touchmove) | |
276 return WebTouchPoint::StateMoved; | |
277 return WebTouchPoint::StateUndefined; | |
278 } | |
279 | |
280 // TODO(mustaq): Add tests for this. | |
281 PlatformTouchPointBuilder::PlatformTouchPointBuilder( | |
282 Widget* widget, | |
283 const WebTouchPoint& point) { | |
284 m_pointerProperties = point; | |
285 m_state = toPlatformTouchPointState(point.state); | |
286 | |
287 FloatPoint floatPos = convertHitPointToRootFrame(widget, point.position); | |
288 IntPoint flooredPoint = flooredIntPoint(floatPos); | |
289 m_pos = | |
290 widget->convertFromRootFrame(flooredPoint) + (floatPos - flooredPoint); | |
291 | |
292 m_screenPos = FloatPoint(point.screenPosition.x, point.screenPosition.y); | |
293 m_radius = scaleSizeToWindow(widget, FloatSize(point.radiusX, point.radiusY)); | |
294 m_rotationAngle = point.rotationAngle; | |
295 } | |
296 | |
297 PlatformTouchEventBuilder::PlatformTouchEventBuilder( | |
298 Widget* widget, | |
299 const WebTouchEvent& event) { | |
300 m_type = toPlatformTouchEventType(event.type()); | |
301 m_modifiers = event.modifiers(); | |
302 m_timestamp = TimeTicks::FromSeconds(event.timeStampSeconds()); | |
303 m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion; | |
304 m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove; | |
305 | |
306 for (unsigned i = 0; i < event.touchesLength; ++i) | |
307 m_touchPoints.push_back( | |
308 PlatformTouchPointBuilder(widget, event.touches[i])); | |
309 | |
310 m_dispatchType = toPlatformDispatchType(event.dispatchType); | |
311 m_uniqueTouchEventId = event.uniqueTouchEventId; | |
312 } | |
313 | |
314 static FloatPoint convertAbsoluteLocationForLayoutObjectFloat( | |
315 const DoublePoint& location, | |
316 const LayoutItem layoutItem) { | |
317 return layoutItem.absoluteToLocal(FloatPoint(location), UseTransforms); | |
318 } | |
319 | |
320 static IntPoint convertAbsoluteLocationForLayoutObjectInt( | |
321 const DoublePoint& location, | |
322 const LayoutItem layoutItem) { | |
323 return roundedIntPoint( | |
324 convertAbsoluteLocationForLayoutObjectFloat(location, layoutItem)); | |
325 } | |
326 | |
327 // FIXME: Change |widget| to const Widget& after RemoteFrames get | |
328 // RemoteFrameViews. | |
329 static void updateWebMouseEventFromCoreMouseEvent(const MouseEvent& event, | |
330 const Widget* widget, | |
331 const LayoutItem layoutItem, | |
332 WebMouseEvent& webEvent) { | |
333 webEvent.setTimeStampSeconds(event.platformTimeStamp().InSeconds()); | |
334 webEvent.setModifiers(event.modifiers()); | |
335 | |
336 FrameView* view = widget ? toFrameView(widget->parent()) : 0; | |
337 // TODO(bokan): If view == nullptr, pointInRootFrame will really be | |
338 // pointInRootContent. | |
339 IntPoint pointInRootFrame(event.absoluteLocation().x(), | |
340 event.absoluteLocation().y()); | |
341 if (view) | |
342 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); | |
343 webEvent.globalX = event.screenX(); | |
344 webEvent.globalY = event.screenY(); | |
345 webEvent.windowX = pointInRootFrame.x(); | |
346 webEvent.windowY = pointInRootFrame.y(); | |
347 IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt( | |
348 event.absoluteLocation(), layoutItem); | |
349 webEvent.x = localPoint.x(); | |
350 webEvent.y = localPoint.y(); | |
351 } | 256 } |
352 | 257 |
353 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, | 258 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, |
354 const LayoutItem layoutItem, | 259 const LayoutItem layoutItem, |
355 const MouseEvent& event) { | 260 const MouseEvent& event) { |
356 if (event.type() == EventTypeNames::mousemove) | 261 if (event.type() == EventTypeNames::mousemove) |
357 m_type = WebInputEvent::MouseMove; | 262 m_type = WebInputEvent::MouseMove; |
358 else if (event.type() == EventTypeNames::mouseout) | 263 else if (event.type() == EventTypeNames::mouseout) |
359 m_type = WebInputEvent::MouseLeave; | 264 m_type = WebInputEvent::MouseLeave; |
360 else if (event.type() == EventTypeNames::mouseover) | 265 else if (event.type() == EventTypeNames::mouseover) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 m_type = MouseDown; | 335 m_type = MouseDown; |
431 else if (event.type() == EventTypeNames::touchmove) | 336 else if (event.type() == EventTypeNames::touchmove) |
432 m_type = MouseMove; | 337 m_type = MouseMove; |
433 else if (event.type() == EventTypeNames::touchend) | 338 else if (event.type() == EventTypeNames::touchend) |
434 m_type = MouseUp; | 339 m_type = MouseUp; |
435 else | 340 else |
436 return; | 341 return; |
437 | 342 |
438 m_timeStampSeconds = event.platformTimeStamp().InSeconds(); | 343 m_timeStampSeconds = event.platformTimeStamp().InSeconds(); |
439 m_modifiers = event.modifiers(); | 344 m_modifiers = event.modifiers(); |
| 345 m_frameScale = 1; |
| 346 m_frameTranslate = WebFloatPoint(); |
440 | 347 |
441 // The mouse event co-ordinates should be generated from the co-ordinates of | 348 // The mouse event co-ordinates should be generated from the co-ordinates of |
442 // the touch point. | 349 // the touch point. |
443 FrameView* view = toFrameView(widget->parent()); | 350 FrameView* view = toFrameView(widget->parent()); |
444 // FIXME: if view == nullptr, pointInRootFrame will really be | 351 // FIXME: if view == nullptr, pointInRootFrame will really be |
445 // pointInRootContent. | 352 // pointInRootContent. |
446 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); | 353 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); |
447 if (view) | 354 if (view) |
448 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); | 355 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); |
449 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); | 356 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 else if (event.type() == EventTypeNames::keypress) | 389 else if (event.type() == EventTypeNames::keypress) |
483 m_type = WebInputEvent::Char; | 390 m_type = WebInputEvent::Char; |
484 else | 391 else |
485 return; // Skip all other keyboard events. | 392 return; // Skip all other keyboard events. |
486 | 393 |
487 m_modifiers = event.modifiers(); | 394 m_modifiers = event.modifiers(); |
488 m_timeStampSeconds = event.platformTimeStamp().InSeconds(); | 395 m_timeStampSeconds = event.platformTimeStamp().InSeconds(); |
489 windowsKeyCode = event.keyCode(); | 396 windowsKeyCode = event.keyCode(); |
490 } | 397 } |
491 | 398 |
492 static WebTouchPoint toWebTouchPoint(const Touch* touch, | |
493 const LayoutItem layoutItem, | |
494 WebTouchPoint::State state, | |
495 WebPointerProperties::PointerType type) { | |
496 WebTouchPoint point; | |
497 point.pointerType = type; | |
498 point.id = touch->identifier(); | |
499 point.screenPosition = touch->screenLocation(); | |
500 point.position = convertAbsoluteLocationForLayoutObjectFloat( | |
501 DoublePoint(touch->absoluteLocation()), layoutItem); | |
502 point.radiusX = touch->radiusX(); | |
503 point.radiusY = touch->radiusY(); | |
504 point.rotationAngle = touch->rotationAngle(); | |
505 point.force = touch->force(); | |
506 point.state = state; | |
507 return point; | |
508 } | |
509 | |
510 static unsigned indexOfTouchPointWithId(const WebTouchPoint* touchPoints, | |
511 unsigned touchPointsLength, | |
512 unsigned id) { | |
513 for (unsigned i = 0; i < touchPointsLength; ++i) { | |
514 if (touchPoints[i].id == static_cast<int>(id)) | |
515 return i; | |
516 } | |
517 return std::numeric_limits<unsigned>::max(); | |
518 } | |
519 | |
520 static void addTouchPointsUpdateStateIfNecessary( | |
521 WebTouchPoint::State state, | |
522 TouchList* touches, | |
523 WebTouchPoint* touchPoints, | |
524 unsigned* touchPointsLength, | |
525 const LayoutItem layoutItem, | |
526 WebPointerProperties::PointerType pointerType) { | |
527 unsigned initialTouchPointsLength = *touchPointsLength; | |
528 for (unsigned i = 0; i < touches->length(); ++i) { | |
529 const unsigned pointIndex = *touchPointsLength; | |
530 if (pointIndex >= static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap)) | |
531 return; | |
532 | |
533 const Touch* touch = touches->item(i); | |
534 unsigned existingPointIndex = indexOfTouchPointWithId( | |
535 touchPoints, initialTouchPointsLength, touch->identifier()); | |
536 if (existingPointIndex != std::numeric_limits<unsigned>::max()) { | |
537 touchPoints[existingPointIndex].state = state; | |
538 } else { | |
539 touchPoints[pointIndex] = | |
540 toWebTouchPoint(touch, layoutItem, state, pointerType); | |
541 ++(*touchPointsLength); | |
542 } | |
543 } | |
544 } | |
545 | |
546 WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem, | |
547 const TouchEvent& event) { | |
548 if (event.type() == EventTypeNames::touchstart) | |
549 m_type = TouchStart; | |
550 else if (event.type() == EventTypeNames::touchmove) | |
551 m_type = TouchMove; | |
552 else if (event.type() == EventTypeNames::touchend) | |
553 m_type = TouchEnd; | |
554 else if (event.type() == EventTypeNames::touchcancel) | |
555 m_type = TouchCancel; | |
556 else { | |
557 NOTREACHED(); | |
558 m_type = Undefined; | |
559 return; | |
560 } | |
561 | |
562 m_timeStampSeconds = event.platformTimeStamp().InSeconds(); | |
563 m_modifiers = event.modifiers(); | |
564 dispatchType = event.cancelable() ? WebInputEvent::Blocking | |
565 : WebInputEvent::EventNonBlocking; | |
566 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); | |
567 | |
568 // Currently touches[] is empty, add stationary points as-is. | |
569 for (unsigned i = 0; | |
570 i < event.touches()->length() && | |
571 i < static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap); | |
572 ++i) { | |
573 touches[i] = | |
574 toWebTouchPoint(event.touches()->item(i), layoutItem, | |
575 WebTouchPoint::StateStationary, event.pointerType()); | |
576 ++touchesLength; | |
577 } | |
578 // If any existing points are also in the change list, we should update | |
579 // their state, otherwise just add the new points. | |
580 addTouchPointsUpdateStateIfNecessary( | |
581 toWebTouchPointState(event.type()), event.changedTouches(), touches, | |
582 &touchesLength, layoutItem, event.pointerType()); | |
583 } | |
584 | |
585 Vector<PlatformMouseEvent> createPlatformMouseEventVector( | 399 Vector<PlatformMouseEvent> createPlatformMouseEventVector( |
586 Widget* widget, | 400 Widget* widget, |
587 const std::vector<const WebInputEvent*>& coalescedEvents) { | 401 const std::vector<const WebInputEvent*>& coalescedEvents) { |
588 Vector<PlatformMouseEvent> result; | 402 Vector<PlatformMouseEvent> result; |
589 for (const auto& event : coalescedEvents) { | 403 for (const auto& event : coalescedEvents) { |
590 DCHECK(WebInputEvent::isMouseEventType(event->type())); | 404 DCHECK(WebInputEvent::isMouseEventType(event->type())); |
591 result.push_back(PlatformMouseEventBuilder( | 405 result.push_back(PlatformMouseEventBuilder( |
592 widget, static_cast<const WebMouseEvent&>(*event))); | 406 widget, static_cast<const WebMouseEvent&>(*event))); |
593 } | 407 } |
594 return result; | 408 return result; |
595 } | 409 } |
596 | 410 |
597 Vector<PlatformTouchEvent> createPlatformTouchEventVector( | 411 Vector<WebTouchEvent> TransformWebTouchEventVector( |
598 Widget* widget, | 412 Widget* widget, |
599 const std::vector<const WebInputEvent*>& coalescedEvents) { | 413 const std::vector<const WebInputEvent*>& coalescedEvents) { |
600 Vector<PlatformTouchEvent> result; | 414 float scale = frameScale(widget); |
| 415 FloatPoint translation = frameTranslation(widget); |
| 416 Vector<WebTouchEvent> result; |
601 for (const auto& event : coalescedEvents) { | 417 for (const auto& event : coalescedEvents) { |
602 DCHECK(WebInputEvent::isTouchEventType(event->type())); | 418 DCHECK(WebInputEvent::isTouchEventType(event->type())); |
603 result.push_back(PlatformTouchEventBuilder( | 419 result.push_back(TransformWebTouchEvent( |
604 widget, static_cast<const WebTouchEvent&>(*event))); | 420 scale, translation, static_cast<const WebTouchEvent&>(*event))); |
605 } | 421 } |
606 return result; | 422 return result; |
607 } | 423 } |
608 | 424 |
609 } // namespace blink | 425 } // namespace blink |
OLD | NEW |