Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: third_party/WebKit/Source/platform/PlatformMouseEvent.h

Issue 2227563003: Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix new instances Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #ifndef PlatformMouseEvent_h 26 #ifndef PlatformMouseEvent_h
27 #define PlatformMouseEvent_h 27 #define PlatformMouseEvent_h
28 28
29 #include "platform/PlatformEvent.h" 29 #include "platform/PlatformEvent.h"
30 #include "platform/geometry/IntPoint.h" 30 #include "platform/geometry/IntPoint.h"
31 #include "public/platform/WebPointerProperties.h" 31 #include "public/platform/WebPointerProperties.h"
32 #include "wtf/text/WTFString.h" 32 #include "wtf/text/WTFString.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 // These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which is specified in PointerEvent
37 // spec but not in MouseEvent spec.
38 enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton };
39
40 class PlatformMouseEvent : public PlatformEvent { 36 class PlatformMouseEvent : public PlatformEvent {
41 public: 37 public:
42 enum SyntheticEventType { 38 enum SyntheticEventType {
43 // Real mouse input events or synthetic events that behave just like rea l events 39 // Real mouse input events or synthetic events that behave just like rea l events
44 RealOrIndistinguishable, 40 RealOrIndistinguishable,
45 // Synthetic mouse events derived from touch input 41 // Synthetic mouse events derived from touch input
46 FromTouch, 42 FromTouch,
47 // Synthetic mouse events generated without a position, for example thos e generated 43 // Synthetic mouse events generated without a position, for example thos e generated
48 // from keyboard input. 44 // from keyboard input.
49 Positionless, 45 Positionless,
50 }; 46 };
51 47
52 PlatformMouseEvent() 48 PlatformMouseEvent()
53 : PlatformEvent(PlatformEvent::MouseMoved) 49 : PlatformEvent(PlatformEvent::MouseMoved)
54 , m_button(NoButton)
55 , m_clickCount(0) 50 , m_clickCount(0)
56 , m_synthesized(RealOrIndistinguishable) 51 , m_synthesized(RealOrIndistinguishable)
57 { 52 {
58 } 53 }
59 54
60 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, EventType type, int clickCount, Modifiers modifiers, double timestamp) 55 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, WebPointerProperties::Button button, EventType type, int clickCount, Modifiers modifiers, double timestamp)
61 : PlatformEvent(type, modifiers, timestamp) 56 : PlatformEvent(type, modifiers, timestamp)
62 , m_position(position) 57 , m_position(position)
63 , m_globalPosition(globalPosition) 58 , m_globalPosition(globalPosition)
64 , m_button(button)
65 , m_clickCount(clickCount) 59 , m_clickCount(clickCount)
66 , m_synthesized(RealOrIndistinguishable) 60 , m_synthesized(RealOrIndistinguishable)
67 { 61 {
62 m_pointerProperties.button = button;
68 } 63 }
69 64
70 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, EventType type, int clickCount, Modifiers modifiers, Synthe ticEventType synthesized, double timestamp, WebPointerProperties::PointerType po interType = WebPointerProperties::PointerType::Unknown) 65 PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, WebPointerProperties::Button button, EventType type, int clickCount, Modifiers modifiers, SyntheticEventType synthesized, double timestamp, WebPointerPropertie s::PointerType pointerType = WebPointerProperties::PointerType::Unknown)
71 : PlatformEvent(type, modifiers, timestamp) 66 : PlatformEvent(type, modifiers, timestamp)
72 , m_position(position) 67 , m_position(position)
73 , m_globalPosition(globalPosition) 68 , m_globalPosition(globalPosition)
74 , m_button(button)
75 , m_clickCount(clickCount) 69 , m_clickCount(clickCount)
76 , m_synthesized(synthesized) 70 , m_synthesized(synthesized)
77 { 71 {
78 m_pointerProperties.pointerType = pointerType; 72 m_pointerProperties.pointerType = pointerType;
73 m_pointerProperties.button = button;
79 } 74 }
80 75
81 const WebPointerProperties& pointerProperties() const { return m_pointerProp erties; } 76 const WebPointerProperties& pointerProperties() const { return m_pointerProp erties; }
82 const IntPoint& position() const { return m_position; } 77 const IntPoint& position() const { return m_position; }
83 const IntPoint& globalPosition() const { return m_globalPosition; } 78 const IntPoint& globalPosition() const { return m_globalPosition; }
84 const IntPoint& movementDelta() const { return m_movementDelta; } 79 const IntPoint& movementDelta() const { return m_movementDelta; }
85 80
86 MouseButton button() const { return m_button; }
87 int clickCount() const { return m_clickCount; } 81 int clickCount() const { return m_clickCount; }
88 bool fromTouch() const { return m_synthesized == FromTouch; } 82 bool fromTouch() const { return m_synthesized == FromTouch; }
89 SyntheticEventType getSyntheticEventType() const { return m_synthesized; } 83 SyntheticEventType getSyntheticEventType() const { return m_synthesized; }
90 84
91 const String& region() const { return m_region; } 85 const String& region() const { return m_region; }
92 void setRegion(const String& region) { m_region = region; } 86 void setRegion(const String& region) { m_region = region; }
93 87
94 protected: 88 protected:
95 WebPointerProperties m_pointerProperties; 89 WebPointerProperties m_pointerProperties;
96 90
97 // In local root frame coordinates. (Except possibly if the Widget under 91 // In local root frame coordinates. (Except possibly if the Widget under
98 // the mouse is a popup, see FIXME in PlatformMouseEventBuilder). 92 // the mouse is a popup, see FIXME in PlatformMouseEventBuilder).
99 IntPoint m_position; 93 IntPoint m_position;
100 94
101 // In screen coordinates. 95 // In screen coordinates.
102 IntPoint m_globalPosition; 96 IntPoint m_globalPosition;
103 97
104 IntPoint m_movementDelta; 98 IntPoint m_movementDelta;
105 MouseButton m_button;
106 int m_clickCount; 99 int m_clickCount;
107 SyntheticEventType m_synthesized; 100 SyntheticEventType m_synthesized;
108 101
109 // For canvas hit region. 102 // For canvas hit region.
110 // TODO(zino): This might make more sense to put in HitTestResults or 103 // TODO(zino): This might make more sense to put in HitTestResults or
111 // some other part of MouseEventWithHitTestResults, but for now it's 104 // some other part of MouseEventWithHitTestResults, but for now it's
112 // most convenient to stash it here. Please see: http://crbug.com/592947. 105 // most convenient to stash it here. Please see: http://crbug.com/592947.
113 String m_region; 106 String m_region;
114 }; 107 };
115 108
116 } // namespace blink 109 } // namespace blink
117 110
118 #endif // PlatformMouseEvent_h 111 #endif // PlatformMouseEvent_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/DragController.cpp ('k') | third_party/WebKit/Source/platform/scroll/Scrollbar.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698