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

Side by Side Diff: Source/core/dom/MouseEvent.cpp

Issue 18836002: Implement 'mouseenter' and 'mouseleave' from DOM Level 3 Events. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: new tests + esprehn is smart. Created 7 years, 5 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 | Annotate | Revision Log
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, 2005, 2006, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& type, const MouseE ventInit& initializer) 51 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& type, const MouseE ventInit& initializer)
52 { 52 {
53 return adoptRef(new MouseEvent(type, initializer)); 53 return adoptRef(new MouseEvent(type, initializer));
54 } 54 }
55 55
56 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRef Ptr<AbstractView> view, const PlatformMouseEvent& event, int detail, PassRefPtr< Node> relatedTarget) 56 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRef Ptr<AbstractView> view, const PlatformMouseEvent& event, int detail, PassRefPtr< Node> relatedTarget)
57 { 57 {
58 ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButt on); 58 ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButt on);
59 59
60 bool isCancelable = eventType != eventNames().mousemoveEvent; 60 bool isMouseEnterOrLeave = eventType == eventNames().mouseenterEvent || even tType == eventNames().mouseleaveEvent;
61 bool isCancelable = eventType != eventNames().mousemoveEvent && !isMouseEnte rOrLeave;
62 bool isBubbling = !isMouseEnterOrLeave;
61 63
62 return MouseEvent::create(eventType, true, isCancelable, view, 64 return MouseEvent::create(eventType, isBubbling, isCancelable, view,
63 detail, event.globalPosition().x(), event.globalPosition().y(), event.po sition().x(), event.position().y(), 65 detail, event.globalPosition().x(), event.globalPosition().y(), event.po sition().x(), event.position().y(),
64 event.movementDelta().x(), event.movementDelta().y(), 66 event.movementDelta().x(), event.movementDelta().y(),
65 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), even t.button(), 67 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), even t.button(),
66 relatedTarget, 0, false); 68 relatedTarget, 0, false);
67 } 69 }
68 70
69 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubb le, bool cancelable, PassRefPtr<AbstractView> view, 71 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& type, bool canBubb le, bool cancelable, PassRefPtr<AbstractView> view,
70 int detail, int screenX, int screenY, int pageX, int pageY, 72 int detail, int screenX, int screenY, int pageX, int pageY,
71 int movementX, int movementY, 73 int movementX, int movementY,
72 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short butto n, 74 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short butto n,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // For the Netscape "which" property, the return values for left, middle and right mouse buttons are 1, 2, 3, respectively. 184 // For the Netscape "which" property, the return values for left, middle and right mouse buttons are 1, 2, 3, respectively.
183 // So we must add 1. 185 // So we must add 1.
184 if (!m_buttonDown) 186 if (!m_buttonDown)
185 return 0; 187 return 0;
186 return m_button + 1; 188 return m_button + 1;
187 } 189 }
188 190
189 Node* MouseEvent::toElement() const 191 Node* MouseEvent::toElement() const
190 { 192 {
191 // MSIE extension - "the object toward which the user is moving the mouse po inter" 193 // MSIE extension - "the object toward which the user is moving the mouse po inter"
192 if (type() == eventNames().mouseoutEvent) 194 if (type() == eventNames().mouseoutEvent || type() == eventNames().mouseleav eEvent)
193 return relatedTarget() ? relatedTarget()->toNode() : 0; 195 return relatedTarget() ? relatedTarget()->toNode() : 0;
194 196
195 return target() ? target()->toNode() : 0; 197 return target() ? target()->toNode() : 0;
196 } 198 }
197 199
198 Node* MouseEvent::fromElement() const 200 Node* MouseEvent::fromElement() const
199 { 201 {
200 // MSIE extension - "object from which activation or the mouse pointer is ex iting during the event" (huh?) 202 // MSIE extension - "object from which activation or the mouse pointer is ex iting during the event" (huh?)
201 if (type() != eventNames().mouseoutEvent) 203 if (type() != eventNames().mouseoutEvent && type() != eventNames().mouseleav eEvent)
202 return relatedTarget() ? relatedTarget()->toNode() : 0; 204 return relatedTarget() ? relatedTarget()->toNode() : 0;
203 205
204 return target() ? target()->toNode() : 0; 206 return target() ? target()->toNode() : 0;
205 } 207 }
206 208
207 PassRefPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent) 209 PassRefPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent)
208 { 210 {
209 return adoptRef(new SimulatedMouseEvent(eventType, view, underlyingEvent)); 211 return adoptRef(new SimulatedMouseEvent(eventType, view, underlyingEvent));
210 } 212 }
211 213
212 SimulatedMouseEvent::~SimulatedMouseEvent() 214 SimulatedMouseEvent::~SimulatedMouseEvent()
213 { 215 {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 event()->button(), relatedTarget); 284 event()->button(), relatedTarget);
283 if (event()->defaultHandled()) 285 if (event()->defaultHandled())
284 doubleClickEvent->setDefaultHandled(); 286 doubleClickEvent->setDefaultHandled();
285 EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediato r::create(doubleClickEvent)); 287 EventDispatcher::dispatchEvent(dispatcher->node(), MouseEventDispatchMediato r::create(doubleClickEvent));
286 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ()) 288 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented ())
287 return false; 289 return false;
288 return !swallowEvent; 290 return !swallowEvent;
289 } 291 }
290 292
291 } // namespace WebCore 293 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698