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

Side by Side Diff: Source/core/input/EventHandler.cpp

Issue 1232003009: Implement DragEvent and move MouseEvent.dataTransfer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase and add layoutTest Created 5 years, 4 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 22 matching lines...) Expand all
33 #include "core/InputTypeNames.h" 33 #include "core/InputTypeNames.h"
34 #include "core/clipboard/DataObject.h" 34 #include "core/clipboard/DataObject.h"
35 #include "core/clipboard/DataTransfer.h" 35 #include "core/clipboard/DataTransfer.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/TouchList.h" 37 #include "core/dom/TouchList.h"
38 #include "core/dom/shadow/ComposedTreeTraversal.h" 38 #include "core/dom/shadow/ComposedTreeTraversal.h"
39 #include "core/dom/shadow/ShadowRoot.h" 39 #include "core/dom/shadow/ShadowRoot.h"
40 #include "core/editing/Editor.h" 40 #include "core/editing/Editor.h"
41 #include "core/editing/FrameSelection.h" 41 #include "core/editing/FrameSelection.h"
42 #include "core/editing/SelectionController.h" 42 #include "core/editing/SelectionController.h"
43 #include "core/events/DragEvent.h"
43 #include "core/events/EventPath.h" 44 #include "core/events/EventPath.h"
44 #include "core/events/KeyboardEvent.h" 45 #include "core/events/KeyboardEvent.h"
45 #include "core/events/MouseEvent.h" 46 #include "core/events/MouseEvent.h"
46 #include "core/events/PointerEvent.h" 47 #include "core/events/PointerEvent.h"
47 #include "core/events/TextEvent.h" 48 #include "core/events/TextEvent.h"
48 #include "core/events/TouchEvent.h" 49 #include "core/events/TouchEvent.h"
49 #include "core/events/WheelEvent.h" 50 #include "core/events/WheelEvent.h"
50 #include "core/fetch/ImageResource.h" 51 #include "core/fetch/ImageResource.h"
51 #include "core/frame/EventHandlerRegistry.h" 52 #include "core/frame/EventHandlerRegistry.h"
52 #include "core/frame/FrameHost.h" 53 #include "core/frame/FrameHost.h"
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 } 1272 }
1272 1273
1273 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer) 1274 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer)
1274 { 1275 {
1275 FrameView* view = m_frame->view(); 1276 FrameView* view = m_frame->view();
1276 1277
1277 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1278 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1278 if (!view) 1279 if (!view)
1279 return false; 1280 return false;
1280 1281
1281 RefPtrWillBeRawPtr<MouseEvent> me = MouseEvent::create(eventType, 1282 DragEventInit dragEventInit;
1282 true, true, m_frame->document()->domWindow(), 1283 dragEventInit.setBubbles(true);
1283 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1284 dragEventInit.setCancelable(true);
1284 event.movementDelta().x(), event.movementDelta().y(), 1285 dragEventInit.setView(m_frame->document()->domWindow());
1285 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), 1286 dragEventInit.setDetail(0);
1286 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, d ataTransfer, false, event.syntheticEventType(), event.timestamp()); 1287 dragEventInit.setScreenX(event.globalPosition().x());
1288 dragEventInit.setScreenY(event.globalPosition().y());
1289 dragEventInit.setMovementX(event.movementDelta().x());
1290 dragEventInit.setMovementY(event.movementDelta().y());
1291
1292 dragEventInit.setCtrlKey(event.ctrlKey());
1293 dragEventInit.setShiftKey(event.shiftKey());
1294 dragEventInit.setAltKey(event.altKey());
1295 dragEventInit.setMetaKey(event.metaKey());
1296
1297 dragEventInit.setButton(0);
1298 dragEventInit.setButtons(MouseEvent::platformModifiersToButtons(event.modifi ers()));
1299 dragEventInit.setDataTransfer(dataTransfer);
1300
1301 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, dragEventIni t);
1287 1302
1288 dragTarget->dispatchEvent(me.get()); 1303 dragTarget->dispatchEvent(me.get());
1289 return me->defaultPrevented(); 1304 return me->defaultPrevented();
1290 } 1305 }
1291 1306
1292 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1307 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1293 { 1308 {
1294 if (!isHTMLFrameElementBase(target)) 1309 if (!isHTMLFrameElementBase(target))
1295 return false; 1310 return false;
1296 1311
(...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after
3995 unsigned EventHandler::accessKeyModifiers() 4010 unsigned EventHandler::accessKeyModifiers()
3996 { 4011 {
3997 #if OS(MACOSX) 4012 #if OS(MACOSX)
3998 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4013 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3999 #else 4014 #else
4000 return PlatformEvent::AltKey; 4015 return PlatformEvent::AltKey;
4001 #endif 4016 #endif
4002 } 4017 }
4003 4018
4004 } // namespace blink 4019 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698