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

Side by Side Diff: third_party/WebKit/Source/core/input/MouseEventManager.cpp

Issue 2842483002: Set relatedtarget for dragleave/enter events (Closed)
Patch Set: Fix test title Created 3 years, 7 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/MouseEventManager.h" 5 #include "core/input/MouseEventManager.h"
6 6
7 #include "core/clipboard/DataObject.h" 7 #include "core/clipboard/DataObject.h"
8 #include "core/clipboard/DataTransfer.h" 8 #include "core/clipboard/DataTransfer.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/ElementTraversal.h" 10 #include "core/dom/ElementTraversal.h"
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 } 879 }
880 880
881 return false; 881 return false;
882 } 882 }
883 883
884 // Returns if we should continue "default processing", i.e., whether 884 // Returns if we should continue "default processing", i.e., whether
885 // eventhandler canceled. 885 // eventhandler canceled.
886 WebInputEventResult MouseEventManager::DispatchDragSrcEvent( 886 WebInputEventResult MouseEventManager::DispatchDragSrcEvent(
887 const AtomicString& event_type, 887 const AtomicString& event_type,
888 const WebMouseEvent& event) { 888 const WebMouseEvent& event) {
889 return DispatchDragEvent(event_type, GetDragState().drag_src_.Get(), event, 889 return DispatchDragEvent(event_type, GetDragState().drag_src_.Get(), nullptr,
890 GetDragState().drag_data_transfer_.Get()); 890 event, GetDragState().drag_data_transfer_.Get());
891 } 891 }
892 892
893 WebInputEventResult MouseEventManager::DispatchDragEvent( 893 WebInputEventResult MouseEventManager::DispatchDragEvent(
894 const AtomicString& event_type, 894 const AtomicString& event_type,
895 Node* drag_target, 895 Node* drag_target,
896 Node* related_target,
896 const WebMouseEvent& event, 897 const WebMouseEvent& event,
897 DataTransfer* data_transfer) { 898 DataTransfer* data_transfer) {
898 FrameView* view = frame_->View(); 899 FrameView* view = frame_->View();
899
900 // FIXME: We might want to dispatch a dragleave even if the view is gone. 900 // FIXME: We might want to dispatch a dragleave even if the view is gone.
901 if (!view) 901 if (!view)
902 return WebInputEventResult::kNotHandled; 902 return WebInputEventResult::kNotHandled;
903 903
904 // We should be setting relatedTarget correctly following the spec:
905 // https://html.spec.whatwg.org/multipage/interaction.html#dragevent
906 // At the same time this should prevent exposing a node from another document.
907 if (related_target &&
908 related_target->GetDocument() != drag_target->GetDocument())
909 related_target = nullptr;
910
904 const bool cancelable = event_type != EventTypeNames::dragleave && 911 const bool cancelable = event_type != EventTypeNames::dragleave &&
905 event_type != EventTypeNames::dragend; 912 event_type != EventTypeNames::dragend;
906 913
907 IntPoint position = FlooredIntPoint(event.PositionInRootFrame()); 914 IntPoint position = FlooredIntPoint(event.PositionInRootFrame());
908 IntPoint movement = FlooredIntPoint(event.MovementInRootFrame()); 915 IntPoint movement = FlooredIntPoint(event.MovementInRootFrame());
909 DragEvent* me = DragEvent::Create( 916 DragEvent* me = DragEvent::Create(
910 event_type, true, cancelable, frame_->GetDocument()->domWindow(), 0, 917 event_type, true, cancelable, frame_->GetDocument()->domWindow(), 0,
911 event.PositionInScreen().x, event.PositionInScreen().y, position.X(), 918 event.PositionInScreen().x, event.PositionInScreen().y, position.X(),
912 position.Y(), movement.X(), movement.Y(), 919 position.Y(), movement.X(), movement.Y(),
913 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), 0, 920 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), 0,
914 MouseEvent::WebInputEventModifiersToButtons(event.GetModifiers()), 921 MouseEvent::WebInputEventModifiersToButtons(event.GetModifiers()),
915 nullptr, TimeTicks::FromSeconds(event.TimeStampSeconds()), data_transfer, 922 related_target, TimeTicks::FromSeconds(event.TimeStampSeconds()),
923 data_transfer,
916 event.FromTouch() ? MouseEvent::kFromTouch 924 event.FromTouch() ? MouseEvent::kFromTouch
917 : MouseEvent::kRealOrIndistinguishable); 925 : MouseEvent::kRealOrIndistinguishable);
918 926
919 return EventHandlingUtil::ToWebInputEventResult( 927 return EventHandlingUtil::ToWebInputEventResult(
920 drag_target->DispatchEvent(me)); 928 drag_target->DispatchEvent(me));
921 } 929 }
922 930
923 void MouseEventManager::ClearDragDataTransfer() { 931 void MouseEventManager::ClearDragDataTransfer() {
924 if (!frame_->GetPage()) 932 if (!frame_->GetPage())
925 return; 933 return;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1033
1026 void MouseEventManager::SetClickCount(int click_count) { 1034 void MouseEventManager::SetClickCount(int click_count) {
1027 click_count_ = click_count; 1035 click_count_ = click_count;
1028 } 1036 }
1029 1037
1030 bool MouseEventManager::MouseDownMayStartDrag() { 1038 bool MouseEventManager::MouseDownMayStartDrag() {
1031 return mouse_down_may_start_drag_; 1039 return mouse_down_may_start_drag_;
1032 } 1040 }
1033 1041
1034 } // namespace blink 1042 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698