| 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(gestureEvent.x, gestureEvent.y), | 
|  22       globalX(gestureEvent.globalX), |  22       m_positionInScreen(gestureEvent.globalX, gestureEvent.globalY) { | 
|  23       globalY(gestureEvent.globalY), |  | 
|  24       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( | 
|  35                        (y / m_frameScale) + m_frameTranslate.y); |  33       (m_positionInWidget.x / m_frameScale) + m_frameTranslate.x, | 
 |  34       (m_positionInWidget.y / m_frameScale) + m_frameTranslate.y); | 
|  36 } |  35 } | 
|  37  |  36  | 
|  38 WebMouseEvent WebMouseEvent::flattenTransform() const { |  37 WebMouseEvent WebMouseEvent::flattenTransform() const { | 
|  39   WebMouseEvent result = *this; |  38   WebMouseEvent result = *this; | 
|  40   result.flattenTransformSelf(); |  39   result.flattenTransformSelf(); | 
|  41   return result; |  40   return result; | 
|  42 } |  41 } | 
|  43  |  42  | 
|  44 void WebMouseEvent::flattenTransformSelf() { |  43 void WebMouseEvent::flattenTransformSelf() { | 
|  45   x = (x / m_frameScale) + m_frameTranslate.x; |  44   m_positionInWidget.x = | 
|  46   y = (y / m_frameScale) + m_frameTranslate.y; |  45       floor((m_positionInWidget.x / m_frameScale) + m_frameTranslate.x); | 
 |  46   m_positionInWidget.y = | 
 |  47       floor((m_positionInWidget.y / m_frameScale) + m_frameTranslate.y); | 
|  47   m_frameTranslate.x = 0; |  48   m_frameTranslate.x = 0; | 
|  48   m_frameTranslate.y = 0; |  49   m_frameTranslate.y = 0; | 
|  49   m_frameScale = 1; |  50   m_frameScale = 1; | 
|  50 } |  51 } | 
|  51  |  52  | 
|  52 }  // namespace blink |  53 }  // namespace blink | 
| OLD | NEW |