| 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 18 matching lines...) Expand all Loading... |
| 29 #include "core/events/UIEventWithKeyState.h" | 29 #include "core/events/UIEventWithKeyState.h" |
| 30 #include "platform/geometry/LayoutPoint.h" | 30 #include "platform/geometry/LayoutPoint.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 // Internal only: Helper class for what's common between mouse and wheel events. | 34 // Internal only: Helper class for what's common between mouse and wheel events. |
| 35 class CORE_EXPORT MouseRelatedEvent : public UIEventWithKeyState { | 35 class CORE_EXPORT MouseRelatedEvent : public UIEventWithKeyState { |
| 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
keyboard input. | 39 // Positionless mouse events are used, for example, for 'click' events from |
| 40 // It's kind of surprising for a mouse event not to have a position. | 40 // keyboard input. It's kind of surprising for a mouse event not to have a |
| 41 // position. |
| 41 Positionless | 42 Positionless |
| 42 }; | 43 }; |
| 43 // Note that these values are adjusted to counter the effects of zoom, so that
values | 44 // Note that these values are adjusted to counter the effects of zoom, so that |
| 44 // exposed via DOM APIs are invariant under zooming. | 45 // values exposed via DOM APIs are invariant under zooming. |
| 45 int screenX() const { return m_screenLocation.x(); } | 46 int screenX() const { return m_screenLocation.x(); } |
| 46 int screenY() const { return m_screenLocation.y(); } | 47 int screenY() const { return m_screenLocation.y(); } |
| 47 const IntPoint& screenLocation() const { return m_screenLocation; } | 48 const IntPoint& screenLocation() const { return m_screenLocation; } |
| 48 int clientX() const { return m_clientLocation.x().toInt(); } | 49 int clientX() const { return m_clientLocation.x().toInt(); } |
| 49 int clientY() const { return m_clientLocation.y().toInt(); } | 50 int clientY() const { return m_clientLocation.y().toInt(); } |
| 50 int movementX() const { return m_movementDelta.x().toInt(); } | 51 int movementX() const { return m_movementDelta.x().toInt(); } |
| 51 int movementY() const { return m_movementDelta.y().toInt(); } | 52 int movementY() const { return m_movementDelta.y().toInt(); } |
| 52 const LayoutPoint& clientLocation() const { return m_clientLocation; } | 53 const LayoutPoint& clientLocation() const { return m_clientLocation; } |
| 53 int layerX(); | 54 int layerX(); |
| 54 int layerY(); | 55 int layerY(); |
| 55 int offsetX(); | 56 int offsetX(); |
| 56 int offsetY(); | 57 int offsetY(); |
| 57 int pageX() const; | 58 int pageX() const; |
| 58 int pageY() const; | 59 int pageY() const; |
| 59 int x() const; | 60 int x() const; |
| 60 int y() const; | 61 int y() const; |
| 61 bool hasPosition() const { return m_positionType == PositionType::Position; } | 62 bool hasPosition() const { return m_positionType == PositionType::Position; } |
| 62 | 63 |
| 63 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative coord
s, | 64 // Page point in "absolute" coordinates (i.e. post-zoomed, page-relative |
| 64 // usable with LayoutObject::absoluteToLocal) relative to view(), i.e. the loc
al frame. | 65 // coords, usable with LayoutObject::absoluteToLocal) relative to view(), i.e. |
| 66 // the local frame. |
| 65 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } | 67 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } |
| 66 void setAbsoluteLocation(const LayoutPoint& p) { m_absoluteLocation = p; } | 68 void setAbsoluteLocation(const LayoutPoint& p) { m_absoluteLocation = p; } |
| 67 | 69 |
| 68 DECLARE_VIRTUAL_TRACE(); | 70 DECLARE_VIRTUAL_TRACE(); |
| 69 | 71 |
| 70 protected: | 72 protected: |
| 71 MouseRelatedEvent(); | 73 MouseRelatedEvent(); |
| 72 // TODO(lanwei): Will make this argument non-optional and all the callers need
to provide | 74 // TODO(lanwei): Will make this argument non-optional and all the callers need |
| 73 // sourceCapabilities even when it is null, see https://crbug.com/476530. | 75 // to provide sourceCapabilities even when it is null, see |
| 76 // https://crbug.com/476530. |
| 74 MouseRelatedEvent(const AtomicString& type, | 77 MouseRelatedEvent(const AtomicString& type, |
| 75 bool canBubble, | 78 bool canBubble, |
| 76 bool cancelable, | 79 bool cancelable, |
| 77 AbstractView*, | 80 AbstractView*, |
| 78 int detail, | 81 int detail, |
| 79 const IntPoint& screenLocation, | 82 const IntPoint& screenLocation, |
| 80 const IntPoint& rootFrameLocation, | 83 const IntPoint& rootFrameLocation, |
| 81 const IntPoint& movementDelta, | 84 const IntPoint& movementDelta, |
| 82 PlatformEvent::Modifiers, | 85 PlatformEvent::Modifiers, |
| 83 double platformTimeStamp, | 86 double platformTimeStamp, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 LayoutPoint m_layerLocation; | 106 LayoutPoint m_layerLocation; |
| 104 LayoutPoint m_offsetLocation; | 107 LayoutPoint m_offsetLocation; |
| 105 LayoutPoint m_absoluteLocation; | 108 LayoutPoint m_absoluteLocation; |
| 106 PositionType m_positionType; | 109 PositionType m_positionType; |
| 107 bool m_hasCachedRelativePosition; | 110 bool m_hasCachedRelativePosition; |
| 108 }; | 111 }; |
| 109 | 112 |
| 110 } // namespace blink | 113 } // namespace blink |
| 111 | 114 |
| 112 #endif // MouseRelatedEvent_h | 115 #endif // MouseRelatedEvent_h |
| OLD | NEW |