| OLD | NEW |
| 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 804 } |
| 805 | 805 |
| 806 bool MouseEventManager::tryStartDrag( | 806 bool MouseEventManager::tryStartDrag( |
| 807 const MouseEventWithHitTestResults& event) { | 807 const MouseEventWithHitTestResults& event) { |
| 808 // The DataTransfer would only be non-empty if we missed a dragEnd. | 808 // The DataTransfer would only be non-empty if we missed a dragEnd. |
| 809 // Clear it anyway, just to make sure it gets numbified. | 809 // Clear it anyway, just to make sure it gets numbified. |
| 810 clearDragDataTransfer(); | 810 clearDragDataTransfer(); |
| 811 | 811 |
| 812 dragState().m_dragDataTransfer = createDraggingDataTransfer(); | 812 dragState().m_dragDataTransfer = createDraggingDataTransfer(); |
| 813 | 813 |
| 814 // Check to see if this a DOM based drag, if it is get the DOM specified drag | |
| 815 // image and offset | |
| 816 if (dragState().m_dragType == DragSourceActionDHTML) { | |
| 817 if (LayoutObject* layoutObject = dragState().m_dragSrc->layoutObject()) { | |
| 818 IntRect boundingIncludingDescendants = | |
| 819 layoutObject->absoluteBoundingBoxRectIncludingDescendants(); | |
| 820 IntSize delta = m_mouseDownPos - boundingIncludingDescendants.location(); | |
| 821 dragState().m_dragDataTransfer->setDragImageElement( | |
| 822 dragState().m_dragSrc.get(), IntPoint(delta)); | |
| 823 } else { | |
| 824 // The layoutObject has disappeared, this can happen if the onStartDrag | |
| 825 // handler has hidden the element in some way. In this case we just kill | |
| 826 // the drag. | |
| 827 return false; | |
| 828 } | |
| 829 } | |
| 830 | |
| 831 DragController& dragController = m_frame->page()->dragController(); | 814 DragController& dragController = m_frame->page()->dragController(); |
| 832 if (!dragController.populateDragDataTransfer(m_frame, dragState(), | 815 if (!dragController.populateDragDataTransfer(m_frame, dragState(), |
| 833 m_mouseDownPos)) | 816 m_mouseDownPos)) |
| 834 return false; | 817 return false; |
| 835 | 818 |
| 836 // If dispatching dragstart brings about another mouse down -- one way | 819 // If dispatching dragstart brings about another mouse down -- one way |
| 837 // this will happen is if a DevTools user breaks within a dragstart | 820 // this will happen is if a DevTools user breaks within a dragstart |
| 838 // handler and then clicks on the suspended page -- the drag state is | 821 // handler and then clicks on the suspended page -- the drag state is |
| 839 // reset. Hence, need to check if this particular drag operation can | 822 // reset. Hence, need to check if this particular drag operation can |
| 840 // continue even if dispatchEvent() indicates no (direct) cancellation. | 823 // continue even if dispatchEvent() indicates no (direct) cancellation. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 977 |
| 995 void MouseEventManager::setClickCount(int clickCount) { | 978 void MouseEventManager::setClickCount(int clickCount) { |
| 996 m_clickCount = clickCount; | 979 m_clickCount = clickCount; |
| 997 } | 980 } |
| 998 | 981 |
| 999 bool MouseEventManager::mouseDownMayStartDrag() { | 982 bool MouseEventManager::mouseDownMayStartDrag() { |
| 1000 return m_mouseDownMayStartDrag; | 983 return m_mouseDownMayStartDrag; |
| 1001 } | 984 } |
| 1002 | 985 |
| 1003 } // namespace blink | 986 } // namespace blink |
| OLD | NEW |