| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "public/platform/WebMouseEvent.h" | 5 #include "public/platform/WebMouseEvent.h" |
| 6 | 6 |
| 7 #include "public/platform/WebGestureEvent.h" | 7 #include "public/platform/WebGestureEvent.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 WebMouseEvent::WebMouseEvent(WebInputEvent::Type type, | 11 WebMouseEvent::WebMouseEvent(WebInputEvent::Type type, |
| 12 const WebGestureEvent& gestureEvent, | 12 const WebGestureEvent& gestureEvent, |
| 13 Button buttonParam, | 13 Button buttonParam, |
| 14 int clickCountParam, | 14 int clickCountParam, |
| 15 int modifiers, | 15 int modifiers, |
| 16 double timeStampSeconds) | 16 double timeStampSeconds) |
| 17 : WebInputEvent(sizeof(WebMouseEvent), type, modifiers, timeStampSeconds), | 17 : WebInputEvent(sizeof(WebMouseEvent), type, modifiers, timeStampSeconds), |
| 18 WebPointerProperties(buttonParam, | 18 WebPointerProperties(buttonParam, |
| 19 WebPointerProperties::PointerType::Mouse), | 19 WebPointerProperties::PointerType::Mouse), |
| 20 x(gestureEvent.x), | 20 position(WebFloatPoint(gestureEvent.x, gestureEvent.y)), |
| 21 y(gestureEvent.y), | 21 screenPosition(WebFloatPoint(gestureEvent.globalX, gestureEvent.globalY)), |
| 22 globalX(gestureEvent.globalX), | |
| 23 globalY(gestureEvent.globalY), | |
| 24 clickCount(clickCountParam) { | 22 clickCount(clickCountParam) { |
| 25 setFrameScale(gestureEvent.frameScale()); | 23 setFrameScale(gestureEvent.frameScale()); |
| 26 setFrameTranslate(gestureEvent.frameTranslate()); | 24 setFrameTranslate(gestureEvent.frameTranslate()); |
| 27 } | 25 } |
| 28 | 26 |
| 29 WebFloatPoint WebMouseEvent::movementInRootFrame() const { | 27 WebFloatPoint WebMouseEvent::movementInRootFrame() const { |
| 30 return WebFloatPoint((movementX / m_frameScale), (movementY / m_frameScale)); | 28 return WebFloatPoint((movementX / m_frameScale), (movementY / m_frameScale)); |
| 31 } | 29 } |
| 32 | 30 |
| 33 WebFloatPoint WebMouseEvent::positionInRootFrame() const { | 31 WebFloatPoint WebMouseEvent::positionInRootFrame() const { |
| 34 return WebFloatPoint((x / m_frameScale) + m_frameTranslate.x, | 32 return WebFloatPoint((position.x / m_frameScale) + m_frameTranslate.x, |
| 35 (y / m_frameScale) + m_frameTranslate.y); | 33 (position.y / m_frameScale) + m_frameTranslate.y); |
| 36 } | 34 } |
| 37 | 35 |
| 38 WebMouseEvent WebMouseEvent::flattenTransform() const { | 36 WebMouseEvent WebMouseEvent::flattenTransform() const { |
| 39 WebMouseEvent result = *this; | 37 WebMouseEvent result = *this; |
| 40 result.flattenTransformSelf(); | 38 result.flattenTransformSelf(); |
| 41 return result; | 39 return result; |
| 42 } | 40 } |
| 43 | 41 |
| 44 void WebMouseEvent::flattenTransformSelf() { | 42 void WebMouseEvent::flattenTransformSelf() { |
| 45 x = (x / m_frameScale) + m_frameTranslate.x; | 43 position.x = (position.x / m_frameScale) + m_frameTranslate.x; |
| 46 y = (y / m_frameScale) + m_frameTranslate.y; | 44 position.y = (position.y / m_frameScale) + m_frameTranslate.y; |
| 47 m_frameTranslate.x = 0; | 45 m_frameTranslate.x = 0; |
| 48 m_frameTranslate.y = 0; | 46 m_frameTranslate.y = 0; |
| 49 m_frameScale = 1; | 47 m_frameScale = 1; |
| 50 } | 48 } |
| 51 | 49 |
| 52 } // namespace blink | 50 } // namespace blink |
| OLD | NEW |