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

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

Issue 894913002: Prevent default actions for JS-generated mouse events other than click (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: EventHandler.cpp moved from page to input dir Created 5 years, 6 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) 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 EventTarget* relatedTarget() const { return m_relatedTarget.get(); } 72 EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
73 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m _relatedTarget = relatedTarget; } 73 void setRelatedTarget(PassRefPtrWillBeRawPtr<EventTarget> relatedTarget) { m _relatedTarget = relatedTarget; }
74 74
75 Node* toElement() const; 75 Node* toElement() const;
76 Node* fromElement() const; 76 Node* fromElement() const;
77 77
78 DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.g et() : 0; } 78 DataTransfer* dataTransfer() const { return isDragEvent() ? m_dataTransfer.g et() : 0; }
79 79
80 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent:: FromTouch; } 80 bool fromTouch() const { return m_syntheticEventType == PlatformMouseEvent:: FromTouch; }
81 81
82 bool fromScript() const { return m_syntheticEventType == PlatformMouseEvent: :FromScript; }
83 void setFromScript() { m_syntheticEventType = PlatformMouseEvent::FromScript ; }
84
82 virtual const AtomicString& interfaceName() const override; 85 virtual const AtomicString& interfaceName() const override;
83 86
84 virtual bool isMouseEvent() const override; 87 virtual bool isMouseEvent() const override;
85 virtual bool isDragEvent() const override final; 88 virtual bool isDragEvent() const override final;
86 virtual int which() const override final; 89 virtual int which() const override final;
87 90
88 DECLARE_VIRTUAL_TRACE(); 91 DECLARE_VIRTUAL_TRACE();
89 92
90 protected: 93 protected:
91 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe fPtrWillBeRawPtr<AbstractView>, 94 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRe fPtrWillBeRawPtr<AbstractView>,
(...skipping 22 matching lines...) Expand all
114 virtual ~SimulatedMouseEvent(); 117 virtual ~SimulatedMouseEvent();
115 118
116 DECLARE_VIRTUAL_TRACE(); 119 DECLARE_VIRTUAL_TRACE();
117 120
118 private: 121 private:
119 SimulatedMouseEvent(const AtomicString& eventType, PassRefPtrWillBeRawPtr<Ab stractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent); 122 SimulatedMouseEvent(const AtomicString& eventType, PassRefPtrWillBeRawPtr<Ab stractView>, PassRefPtrWillBeRawPtr<Event> underlyingEvent);
120 }; 123 };
121 124
122 class MouseEventDispatchMediator final : public EventDispatchMediator { 125 class MouseEventDispatchMediator final : public EventDispatchMediator {
123 public: 126 public:
124 enum MouseEventType { SyntheticMouseEvent, NonSyntheticMouseEvent}; 127 static PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> create(PassRefPtrW illBeRawPtr<MouseEvent>);
125 static PassRefPtrWillBeRawPtr<MouseEventDispatchMediator> create(PassRefPtrW illBeRawPtr<MouseEvent>, MouseEventType = NonSyntheticMouseEvent);
126 128
127 private: 129 private:
128 explicit MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent>, Mous eEventType); 130 explicit MouseEventDispatchMediator(PassRefPtrWillBeRawPtr<MouseEvent>);
129 MouseEvent& event() const; 131 MouseEvent& event() const;
130 132
131 virtual bool dispatchEvent(EventDispatcher&) const override; 133 virtual bool dispatchEvent(EventDispatcher&) const override;
132 bool isSyntheticMouseEvent() const { return m_mouseEventType == SyntheticMou seEvent; }
133 MouseEventType m_mouseEventType;
134 }; 134 };
135 135
136 DEFINE_EVENT_TYPE_CASTS(MouseEvent); 136 DEFINE_EVENT_TYPE_CASTS(MouseEvent);
137 137
138 } // namespace blink 138 } // namespace blink
139 139
140 #endif // MouseEvent_h 140 #endif // MouseEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698