Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 public: | 36 public: |
| 37 enum class PositionType { | 37 enum class PositionType { |
| 38 Position, | 38 Position, |
| 39 // Positionless mouse events are used, for example, for 'click' events from | 39 // Positionless mouse events are used, for example, for 'click' events from |
| 40 // keyboard input. It's kind of surprising for a mouse event not to have a | 40 // keyboard input. It's kind of surprising for a mouse event not to have a |
| 41 // position. | 41 // position. |
| 42 Positionless | 42 Positionless |
| 43 }; | 43 }; |
| 44 // Note that these values are adjusted to counter the effects of zoom, so that | 44 // Note that these values are adjusted to counter the effects of zoom, so that |
| 45 // values exposed via DOM APIs are invariant under zooming. | 45 // values exposed via DOM APIs are invariant under zooming. |
| 46 int screenX() const { return m_screenLocation.x(); } | 46 double screenX() const { |
| 47 int screenY() const { return m_screenLocation.y(); } | 47 return isPointerEvent() ? m_screenLocation.x().toDouble() |
|
Rick Byers
2016/10/12 14:09:54
It seems odd that this pattern of conditional retu
mustaq
2016/10/12 16:00:01
The problem here is that the initialization is don
| |
| 48 const IntPoint& screenLocation() const { return m_screenLocation; } | 48 : m_screenLocation.x().toInt(); |
| 49 int clientX() const { return m_clientLocation.x().toInt(); } | 49 } |
| 50 int clientY() const { return m_clientLocation.y().toInt(); } | 50 double screenY() const { |
| 51 return isPointerEvent() ? m_screenLocation.y().toDouble() | |
| 52 : m_screenLocation.y().toInt(); | |
| 53 } | |
| 54 double clientX() const { | |
| 55 return isPointerEvent() ? m_clientLocation.x().toDouble() | |
| 56 : m_clientLocation.x().toInt(); | |
| 57 } | |
| 58 double clientY() const { | |
| 59 return isPointerEvent() ? m_clientLocation.y().toDouble() | |
| 60 : m_clientLocation.y().toInt(); | |
| 61 } | |
| 51 int movementX() const { return m_movementDelta.x().toInt(); } | 62 int movementX() const { return m_movementDelta.x().toInt(); } |
| 52 int movementY() const { return m_movementDelta.y().toInt(); } | 63 int movementY() const { return m_movementDelta.y().toInt(); } |
| 53 const LayoutPoint& clientLocation() const { return m_clientLocation; } | |
| 54 int layerX(); | 64 int layerX(); |
| 55 int layerY(); | 65 int layerY(); |
| 56 int offsetX(); | 66 int offsetX(); |
| 57 int offsetY(); | 67 int offsetY(); |
| 58 int pageX() const; | 68 int pageX() const; |
| 59 int pageY() const; | 69 int pageY() const; |
| 60 int x() const; | 70 int x() const; |
| 61 int y() const; | 71 int y() const; |
| 62 bool hasPosition() const { return m_positionType == PositionType::Position; } | 72 bool hasPosition() const { return m_positionType == PositionType::Position; } |
| 63 | 73 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 83 const IntPoint& rootFrameLocation, | 93 const IntPoint& rootFrameLocation, |
| 84 const IntPoint& movementDelta, | 94 const IntPoint& movementDelta, |
| 85 PlatformEvent::Modifiers, | 95 PlatformEvent::Modifiers, |
| 86 double platformTimeStamp, | 96 double platformTimeStamp, |
| 87 PositionType, | 97 PositionType, |
| 88 InputDeviceCapabilities* sourceCapabilities = nullptr); | 98 InputDeviceCapabilities* sourceCapabilities = nullptr); |
| 89 | 99 |
| 90 MouseRelatedEvent(const AtomicString& type, | 100 MouseRelatedEvent(const AtomicString& type, |
| 91 const MouseEventInit& initializer); | 101 const MouseEventInit& initializer); |
| 92 | 102 |
| 93 void initCoordinates(const LayoutPoint& clientLocation); | 103 void initCoordinates(const double clientX, const double clientY); |
| 94 void receivedTarget() final; | 104 void receivedTarget() final; |
| 95 | 105 |
| 96 void computePageLocation(); | 106 void computePageLocation(); |
| 97 void computeRelativePosition(); | 107 void computeRelativePosition(); |
| 98 | 108 |
| 99 // Expose these so MouseEvent::initMouseEvent can set them. | 109 // Expose these so MouseEvent::initMouseEvent can set them. |
| 100 IntPoint m_screenLocation; | 110 LayoutPoint m_screenLocation; |
| 101 LayoutPoint m_clientLocation; | 111 LayoutPoint m_clientLocation; |
| 102 LayoutPoint m_movementDelta; | 112 LayoutPoint m_movementDelta; |
| 103 | 113 |
| 104 private: | 114 private: |
| 105 LayoutPoint m_pageLocation; | 115 LayoutPoint m_pageLocation; |
| 106 LayoutPoint m_layerLocation; | 116 LayoutPoint m_layerLocation; |
| 107 LayoutPoint m_offsetLocation; | 117 LayoutPoint m_offsetLocation; |
| 108 LayoutPoint m_absoluteLocation; | 118 LayoutPoint m_absoluteLocation; |
| 109 PositionType m_positionType; | 119 PositionType m_positionType; |
| 110 bool m_hasCachedRelativePosition; | 120 bool m_hasCachedRelativePosition; |
| 111 }; | 121 }; |
| 112 | 122 |
| 113 } // namespace blink | 123 } // namespace blink |
| 114 | 124 |
| 115 #endif // MouseRelatedEvent_h | 125 #endif // MouseRelatedEvent_h |
| OLD | NEW |