OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "public/platform/WebTouchEvent.h" |
| 6 |
| 7 namespace blink { |
| 8 |
| 9 WebTouchEvent WebTouchEvent::flattenTransform() const { |
| 10 WebTouchEvent transformedEvent = *this; |
| 11 for (unsigned i = 0; i < touchesLength; ++i) { |
| 12 transformedEvent.touches[i] = touchPointInRootFrame(i); |
| 13 } |
| 14 transformedEvent.m_frameTranslate.x = 0; |
| 15 transformedEvent.m_frameTranslate.y = 0; |
| 16 transformedEvent.m_frameScale = 1; |
| 17 |
| 18 return transformedEvent; |
| 19 } |
| 20 |
| 21 WebTouchPoint WebTouchEvent::touchPointInRootFrame(unsigned point) const { |
| 22 DCHECK_LT(point, touchesLength); |
| 23 if (point >= touchesLength) |
| 24 return WebTouchPoint(); |
| 25 |
| 26 WebTouchPoint transformedPoint = touches[point]; |
| 27 transformedPoint.radiusX /= m_frameScale; |
| 28 transformedPoint.radiusY /= m_frameScale; |
| 29 transformedPoint.position.x = |
| 30 (transformedPoint.position.x / m_frameScale) + m_frameTranslate.x; |
| 31 transformedPoint.position.y = |
| 32 (transformedPoint.position.y / m_frameScale) + m_frameTranslate.y; |
| 33 return transformedPoint; |
| 34 } |
| 35 |
| 36 } // namespace blink |
OLD | NEW |