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

Side by Side Diff: Source/core/events/MouseEvent.h

Issue 727593003: Implement MouseEvent buttons attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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) 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, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
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 27 matching lines...) Expand all
38 38
39 int screenX; 39 int screenX;
40 int screenY; 40 int screenY;
41 int clientX; 41 int clientX;
42 int clientY; 42 int clientY;
43 bool ctrlKey; 43 bool ctrlKey;
44 bool altKey; 44 bool altKey;
45 bool shiftKey; 45 bool shiftKey;
46 bool metaKey; 46 bool metaKey;
47 unsigned short button; 47 unsigned short button;
48 unsigned short buttons;
48 RefPtrWillBeMember<EventTarget> relatedTarget; 49 RefPtrWillBeMember<EventTarget> relatedTarget;
49 }; 50 };
50 51
51 class MouseEvent : public MouseRelatedEvent { 52 class MouseEvent : public MouseRelatedEvent {
52 DEFINE_WRAPPERTYPEINFO(); 53 DEFINE_WRAPPERTYPEINFO();
53 public: 54 public:
54 static PassRefPtrWillBeRawPtr<MouseEvent> create() 55 static PassRefPtrWillBeRawPtr<MouseEvent> create()
55 { 56 {
56 return adoptRefWillBeNoop(new MouseEvent); 57 return adoptRefWillBeNoop(new MouseEvent);
57 } 58 }
58 59
59 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, b ool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>, 60 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& type, b ool canBubble, bool cancelable, PassRefPtrWillBeRawPtr<AbstractView>,
60 int detail, int screenX, int screenY, int pageX, int pageY, 61 int detail, int screenX, int screenY, int pageX, int pageY,
61 int movementX, int movementY, 62 int movementX, int movementY,
62 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b utton, 63 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b utton, unsigned short buttons,
63 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt r<DataTransfer>, 64 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt r<DataTransfer>,
64 bool isSimulated = false, PlatformMouseEvent::SyntheticEventType = Platf ormMouseEvent::RealOrIndistinguishable); 65 bool isSimulated = false, PlatformMouseEvent::SyntheticEventType = Platf ormMouseEvent::RealOrIndistinguishable);
65 66
66 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy pe, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget); 67 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy pe, PassRefPtrWillBeRawPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtrWillBeRawPtr<Node> relatedTarget);
67 68
68 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy pe, const MouseEventInit&); 69 static PassRefPtrWillBeRawPtr<MouseEvent> create(const AtomicString& eventTy pe, const MouseEventInit&);
69 70
70 virtual ~MouseEvent(); 71 virtual ~MouseEvent();
71 72
72 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelabl e, PassRefPtrWillBeRawPtr<AbstractView>, 73 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelabl e, PassRefPtrWillBeRawPtr<AbstractView>,
73 int detail, int screenX, int screenY, int clientX, int clientY, 74 int detail, int screenX, int screenY, int clientX, int clientY,
74 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, 75 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
75 unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget ); 76 unsigned short button, PassRefPtrWillBeRawPtr<EventTarget> relatedTarget , unsigned short buttons = 0);
76 77
77 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused own/up, maybe others), 78 // WinIE uses 1,4,2 for left/middle/right but not for click (just for moused own/up, maybe others),
78 // but we will match the standard DOM. 79 // but we will match the standard DOM.
79 unsigned short button() const { return m_button; } 80 unsigned short button() const { return m_button; }
81 unsigned short buttons() const { return m_buttons; }
80 bool buttonDown() const { return m_buttonDown; } 82 bool buttonDown() const { return m_buttonDown; }
81 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } 83 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
82 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m _relatedTarget = relatedTarget; } 84 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m _relatedTarget = relatedTarget; }
83 85
84 Node* toElement() const; 86 Node* toElement() const;
85 Node* fromElement() const; 87 Node* fromElement() const;
86 88
87 DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.g et() : 0; } 89 DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.g et() : 0; }
88 90
89 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent:: FromTouch; } 91 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent:: FromTouch; }
90 92
91 virtual const AtomicString& interfaceName() const override; 93 virtual const AtomicString& interfaceName() const override;
92 94
93 virtual bool isMouseEvent() const override; 95 virtual bool isMouseEvent() const override;
94 virtual bool isDragEvent() const override final; 96 virtual bool isDragEvent() const override final;
95 virtual int which() const override final; 97 virtual int which() const override final;
96 98
97 virtual void trace(Visitor*) override; 99 virtual void trace(Visitor*) override;
98 100
99 protected: 101 protected:
100 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe fPtrWillBeRawPtr<AbstractView>, 102 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe fPtrWillBeRawPtr<AbstractView>,
101 int detail, int screenX, int screenY, int pageX, int pageY, 103 int detail, int screenX, int screenY, int pageX, int pageY,
102 int movementX, int movementY, 104 int movementX, int movementY,
103 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b utton, 105 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short b utton, unsigned short buttons,
104 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt r<DataTransfer>, 106 PassRefPtrWillBeRawPtr<EventTarget> relatedTarget, PassRefPtrWillBeRawPt r<DataTransfer>,
105 bool isSimulated, PlatformMouseEvent::SyntheticEventType); 107 bool isSimulated, PlatformMouseEvent::SyntheticEventType);
106 108
107 MouseEvent(const AtomicString& type, const MouseEventInit&); 109 MouseEvent(const AtomicString& type, const MouseEventInit&);
108 110
109 MouseEvent(); 111 MouseEvent();
110 112
111 private: 113 private:
112 unsigned short m_button; 114 unsigned short m_button;
115 unsigned short m_buttons;
113 bool m_buttonDown; 116 bool m_buttonDown;
114 RefPtrWillBeMember<EventTarget> m_relatedTarget; 117 RefPtrWillBeMember<EventTarget> m_relatedTarget;
115 RefPtrWillBeMember<DataTransfer> m_dataTransfer; 118 RefPtrWillBeMember<DataTransfer> m_dataTransfer;
116 PlatformMouseEvent::SyntheticEventType m_syntheticEventType; 119 PlatformMouseEvent::SyntheticEventType m_syntheticEventType;
117 }; 120 };
118 121
119 class SimulatedMouseEvent final : public MouseEvent { 122 class SimulatedMouseEvent final : public MouseEvent {
120 public: 123 public:
121 static PassRefPtrWillBeRawPtr<SimulatedMouseEvent> create(const AtomicString & eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent); 124 static PassRefPtrWillBeRawPtr<SimulatedMouseEvent> create(const AtomicString & eventType, PassRefPtrWillBeRawPtr<AbstractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent);
122 virtual ~SimulatedMouseEvent(); 125 virtual ~SimulatedMouseEvent();
(...skipping 16 matching lines...) Expand all
139 virtual bool dispatchEvent(EventDispatcher*) const override; 142 virtual bool dispatchEvent(EventDispatcher*) const override;
140 bool isSyntheticMouseEvent() const { return m_mouseEventType == SyntheticMou seEvent; } 143 bool isSyntheticMouseEvent() const { return m_mouseEventType == SyntheticMou seEvent; }
141 MouseEventType m_mouseEventType; 144 MouseEventType m_mouseEventType;
142 }; 145 };
143 146
144 DEFINE_EVENT_TYPE_CASTS(MouseEvent); 147 DEFINE_EVENT_TYPE_CASTS(MouseEvent);
145 148
146 } // namespace blink 149 } // namespace blink
147 150
148 #endif // MouseEvent_h 151 #endif // MouseEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698