Chromium Code Reviews| 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 clickCount(clickCountParam), |
| 21 y(gestureEvent.y), | 21 m_positionInWidget(WebFloatPoint(gestureEvent.x, gestureEvent.y)), |
|
dtapuska
2017/03/31 14:04:18
This is odd. Do you require the extra WebFloatPoin
mustaq
2017/03/31 15:50:31
Thanks for the catch, done.
| |
| 22 globalX(gestureEvent.globalX), | 22 m_positionInScreen( |
| 23 globalY(gestureEvent.globalY), | 23 WebFloatPoint(gestureEvent.globalX, gestureEvent.globalY)) { |
| 24 clickCount(clickCountParam) { | |
| 25 setFrameScale(gestureEvent.frameScale()); | 24 setFrameScale(gestureEvent.frameScale()); |
| 26 setFrameTranslate(gestureEvent.frameTranslate()); | 25 setFrameTranslate(gestureEvent.frameTranslate()); |
| 27 } | 26 } |
| 28 | 27 |
| 29 WebFloatPoint WebMouseEvent::movementInRootFrame() const { | 28 WebFloatPoint WebMouseEvent::movementInRootFrame() const { |
| 30 return WebFloatPoint((movementX / m_frameScale), (movementY / m_frameScale)); | 29 return WebFloatPoint((movementX / m_frameScale), (movementY / m_frameScale)); |
| 31 } | 30 } |
| 32 | 31 |
| 33 WebFloatPoint WebMouseEvent::positionInRootFrame() const { | 32 WebFloatPoint WebMouseEvent::positionInRootFrame() const { |
| 34 return WebFloatPoint((x / m_frameScale) + m_frameTranslate.x, | 33 return WebFloatPoint( |
| 35 (y / m_frameScale) + m_frameTranslate.y); | 34 (m_positionInWidget.x / m_frameScale) + m_frameTranslate.x, |
| 35 (m_positionInWidget.y / m_frameScale) + m_frameTranslate.y); | |
| 36 } | 36 } |
| 37 | 37 |
| 38 WebMouseEvent WebMouseEvent::flattenTransform() const { | 38 WebMouseEvent WebMouseEvent::flattenTransform() const { |
| 39 WebMouseEvent result = *this; | 39 WebMouseEvent result = *this; |
| 40 result.flattenTransformSelf(); | 40 result.flattenTransformSelf(); |
| 41 return result; | 41 return result; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void WebMouseEvent::flattenTransformSelf() { | 44 void WebMouseEvent::flattenTransformSelf() { |
| 45 x = (x / m_frameScale) + m_frameTranslate.x; | 45 m_positionInWidget.x = |
| 46 y = (y / m_frameScale) + m_frameTranslate.y; | 46 floor((m_positionInWidget.x / m_frameScale) + m_frameTranslate.x); |
|
dtapuska
2017/03/31 14:04:18
Can we add a comment why we are taking the floor?
mustaq
2017/03/31 15:50:32
Added a comment in the class header.
| |
| 47 m_positionInWidget.y = | |
| 48 floor((m_positionInWidget.y / m_frameScale) + m_frameTranslate.y); | |
| 47 m_frameTranslate.x = 0; | 49 m_frameTranslate.x = 0; |
| 48 m_frameTranslate.y = 0; | 50 m_frameTranslate.y = 0; |
| 49 m_frameScale = 1; | 51 m_frameScale = 1; |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace blink | 54 } // namespace blink |
| OLD | NEW |