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

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

Issue 488923003: Gracefully handle drag cancellation during drag start. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Expand comment somewhat Created 6 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
« no previous file with comments | « LayoutTests/fast/events/mousedown-inside-dragstart-should-not-cause-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3244 matching lines...) Expand 10 before | Expand all | Expand 10 after
3255 } else { 3255 } else {
3256 // The renderer has disappeared, this can happen if the onStartDrag handler has hidden 3256 // The renderer has disappeared, this can happen if the onStartDrag handler has hidden
3257 // the element in some way. In this case we just kill the drag. 3257 // the element in some way. In this case we just kill the drag.
3258 return false; 3258 return false;
3259 } 3259 }
3260 } 3260 }
3261 3261
3262 DragController& dragController = m_frame->page()->dragController(); 3262 DragController& dragController = m_frame->page()->dragController();
3263 if (!dragController.populateDragDataTransfer(m_frame, dragState(), m_mouseDo wnPos)) 3263 if (!dragController.populateDragDataTransfer(m_frame, dragState(), m_mouseDo wnPos))
3264 return false; 3264 return false;
3265
3266 // If dispatching dragstart brings about another mouse down -- one way
3267 // this will happen is if a DevTools user breaks within a dragstart
3268 // handler and then clicks on the suspended page -- the drag state is
3269 // reset. Hence, need to check if this particular drag operation can
3270 // continue even if dispatchEvent() indicates no (direct) cancellation.
3271 // Do that by checking if m_dragSrc is still set.
3265 m_mouseDownMayStartDrag = dispatchDragSrcEvent(EventTypeNames::dragstart, m_ mouseDown) 3272 m_mouseDownMayStartDrag = dispatchDragSrcEvent(EventTypeNames::dragstart, m_ mouseDown)
3266 && !m_frame->selection().isInPasswordField(); 3273 && !m_frame->selection().isInPasswordField() && dragState().m_dragSrc;
3267 3274
3268 // Invalidate clipboard here against anymore pasteboard writing for security . The drag 3275 // Invalidate clipboard here against anymore pasteboard writing for security . The drag
3269 // image can still be changed as we drag, but not the pasteboard data. 3276 // image can still be changed as we drag, but not the pasteboard data.
3270 dragState().m_dragDataTransfer->setAccessPolicy(DataTransferImageWritable); 3277 dragState().m_dragDataTransfer->setAccessPolicy(DataTransferImageWritable);
3271 3278
3272 if (m_mouseDownMayStartDrag) { 3279 if (m_mouseDownMayStartDrag) {
3273 // Dispatching the event could cause Page to go away. Make sure it's sti ll valid before trying to use DragController. 3280 // Dispatching the event could cause Page to go away. Make sure it's sti ll valid before trying to use DragController.
3274 m_didStartDrag = m_frame->page() && dragController.startDrag(m_frame, dr agState(), event.event(), m_mouseDownPos); 3281 m_didStartDrag = m_frame->page() && dragController.startDrag(m_frame, dr agState(), event.event(), m_mouseDownPos);
3275 // FIXME: This seems pretty useless now. The gesture code uses this as a signal for 3282 // FIXME: This seems pretty useless now. The gesture code uses this as a signal for
3276 // whether or not the drag started, but perhaps it can simply use the re turn value from 3283 // whether or not the drag started, but perhaps it can simply use the re turn value from
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
3850 unsigned EventHandler::accessKeyModifiers() 3857 unsigned EventHandler::accessKeyModifiers()
3851 { 3858 {
3852 #if OS(MACOSX) 3859 #if OS(MACOSX)
3853 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3860 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3854 #else 3861 #else
3855 return PlatformEvent::AltKey; 3862 return PlatformEvent::AltKey;
3856 #endif 3863 #endif
3857 } 3864 }
3858 3865
3859 } // namespace blink 3866 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/mousedown-inside-dragstart-should-not-cause-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698