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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/MouseEvent.cpp
diff --git a/Source/core/dom/MouseEvent.cpp b/Source/core/dom/MouseEvent.cpp
index c0a6cbedeb3bfba19dca9035e822726865cbd148..e11d1d85bae1ca5cfb61a95c02f29761b1b9b914 100644
--- a/Source/core/dom/MouseEvent.cpp
+++ b/Source/core/dom/MouseEvent.cpp
@@ -57,9 +57,11 @@ PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRef
{
ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButton);
- bool isCancelable = eventType != eventNames().mousemoveEvent;
+ bool isMouseEnterOrLeave = eventType == eventNames().mouseenterEvent || eventType == eventNames().mouseleaveEvent;
+ bool isCancelable = eventType != eventNames().mousemoveEvent && !isMouseEnterOrLeave;
+ bool isBubbling = !isMouseEnterOrLeave;
- return MouseEvent::create(eventType, true, isCancelable, view,
+ return MouseEvent::create(eventType, isBubbling, isCancelable, view,
detail, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(),
event.movementDelta().x(), event.movementDelta().y(),
event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.button(),
@@ -189,18 +191,18 @@ int MouseEvent::which() const
Node* MouseEvent::toElement() const
{
// MSIE extension - "the object toward which the user is moving the mouse pointer"
- if (type() == eventNames().mouseoutEvent)
+ if (type() == eventNames().mouseoutEvent || type() == eventNames().mouseleaveEvent)
return relatedTarget() ? relatedTarget()->toNode() : 0;
-
+
return target() ? target()->toNode() : 0;
}
Node* MouseEvent::fromElement() const
{
// MSIE extension - "object from which activation or the mouse pointer is exiting during the event" (huh?)
- if (type() != eventNames().mouseoutEvent)
+ if (type() != eventNames().mouseoutEvent && type() != eventNames().mouseleaveEvent)
return relatedTarget() ? relatedTarget()->toNode() : 0;
-
+
return target() ? target()->toNode() : 0;
}

Powered by Google App Engine
This is Rietveld 408576698