diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-05-03 12:02:08 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-05-03 12:02:08 +0000 |
commit | 8495306dba092939ef6c471b828d5d1d1f5767f5 (patch) | |
tree | ea165df1ae8449f1b129c216cd1a58ef37520181 /src/com/vaadin | |
parent | 181a4567f5faca694d6f6c6c1889983e837f3829 (diff) | |
download | vaadin-framework-8495306dba092939ef6c471b828d5d1d1f5767f5.tar.gz vaadin-framework-8495306dba092939ef6c471b828d5d1d1f5767f5.zip |
fixes #4559. Sanity checks for event target + cleanup.
svn changeset:12989/svn branch:6.3
Diffstat (limited to 'src/com/vaadin')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java b/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java index 0fbc561c7f..936cdf8408 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java +++ b/src/com/vaadin/terminal/gwt/client/ui/dd/VDragAndDropManager.java @@ -4,6 +4,7 @@ package com.vaadin.terminal.gwt.client.ui.dd; import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.EventTarget; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.Style; @@ -59,8 +60,7 @@ public class VDragAndDropManager { currentDrag.setCurrentGwtEvent(nativeEvent); updateDragImagePosition(); - Element targetElement = (Element) nativeEvent.getEventTarget() - .cast(); + Element targetElement = Element.as(nativeEvent.getEventTarget()); if (dragElement != null && dragElement.isOrHasChild(targetElement)) { // to detect the "real" target, hide dragelement temporary and @@ -168,8 +168,8 @@ public class VDragAndDropManager { } break; case Event.ONMOUSEOUT: - Element relatedTarget = (Element) nativeEvent - .getRelatedEventTarget().cast(); + Element relatedTarget = Element.as(nativeEvent + .getRelatedEventTarget()); VDropHandler newDragHanler = findDragTarget(relatedTarget); if (dragElement != null && dragElement.isOrHasChild(relatedTarget)) { @@ -294,8 +294,8 @@ public class VDragAndDropManager { isStarted = true; VDropHandler dh = null; if (startEvent != null) { - dh = findDragTarget((Element) currentDrag - .getCurrentGwtEvent().getEventTarget().cast()); + dh = findDragTarget(Element.as(currentDrag + .getCurrentGwtEvent().getEventTarget())); } if (dh != null) { // drag has started on a DropHandler, kind of drag over @@ -331,12 +331,15 @@ public class VDragAndDropManager { int typeInt = event.getTypeInt(); switch (typeInt) { case Event.ONMOUSEOVER: - if (dragElement == null - || !dragElement - .isOrHasChild((Node) event - .getNativeEvent() - .getCurrentEventTarget() - .cast())) { + if (dragElement == null) { + break; + } + EventTarget currentEventTarget = event + .getNativeEvent() + .getCurrentEventTarget(); + if (Node.is(currentEventTarget) + && !dragElement.isOrHasChild(Node + .as(currentEventTarget))) { // drag image appeared below, ignore break; } @@ -348,12 +351,15 @@ public class VDragAndDropManager { break; case Event.ONMOUSEOUT: - if (dragElement == null - || !dragElement - .isOrHasChild((Node) event - .getNativeEvent() - .getRelatedEventTarget() - .cast())) { + if (dragElement == null) { + break; + } + EventTarget relatedEventTarget = event + .getNativeEvent() + .getRelatedEventTarget(); + if (Node.is(relatedEventTarget) + && !dragElement.isOrHasChild(Node + .as(relatedEventTarget))) { // drag image appeared below, ignore break; } @@ -374,7 +380,6 @@ public class VDragAndDropManager { clearDragElement(); break; } - } }); |