OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Google Inc. | 3 * Copyright (C) 2008 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #endif | 110 #endif |
111 | 111 |
112 static PlatformMouseEvent createMouseEvent(DragData* dragData) | 112 static PlatformMouseEvent createMouseEvent(DragData* dragData) |
113 { | 113 { |
114 return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPositi
on(), | 114 return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPositi
on(), |
115 LeftButton, PlatformEvent::MouseMoved, 0, | 115 LeftButton, PlatformEvent::MouseMoved, 0, |
116 static_cast<PlatformEvent::Modifiers>(dragData->modifiers()), | 116 static_cast<PlatformEvent::Modifiers>(dragData->modifiers()), |
117 PlatformMouseEvent::RealOrIndistinguishable, currentTime()); | 117 PlatformMouseEvent::RealOrIndistinguishable, currentTime()); |
118 } | 118 } |
119 | 119 |
120 static PassRefPtrWillBeRawPtr<DataTransfer> createDraggingDataTransfer(DataTrans
ferAccessPolicy policy, DragData* dragData) | 120 static DataTransfer* createDraggingDataTransfer(DataTransferAccessPolicy policy,
DragData* dragData) |
121 { | 121 { |
122 return DataTransfer::create(DataTransfer::DragAndDrop, policy, dragData->pla
tformData()); | 122 return DataTransfer::create(DataTransfer::DragAndDrop, policy, dragData->pla
tformData()); |
123 } | 123 } |
124 | 124 |
125 DragController::DragController(Page* page, DragClient* client) | 125 DragController::DragController(Page* page, DragClient* client) |
126 : m_page(page) | 126 : m_page(page) |
127 , m_client(client) | 127 , m_client(client) |
128 , m_documentUnderMouse(nullptr) | 128 , m_documentUnderMouse(nullptr) |
129 , m_dragInitiator(nullptr) | 129 , m_dragInitiator(nullptr) |
130 , m_fileInputElementUnderMouse(nullptr) | 130 , m_fileInputElementUnderMouse(nullptr) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 | 208 |
209 void DragController::dragExited(DragData* dragData) | 209 void DragController::dragExited(DragData* dragData) |
210 { | 210 { |
211 ASSERT(dragData); | 211 ASSERT(dragData); |
212 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); | 212 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); |
213 | 213 |
214 RefPtrWillBeRawPtr<FrameView> frameView(mainFrame->view()); | 214 RefPtrWillBeRawPtr<FrameView> frameView(mainFrame->view()); |
215 if (frameView) { | 215 if (frameView) { |
216 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn
derMouse->securityOrigin()->isLocal()) ? DataTransferReadable : DataTransferType
sReadable; | 216 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn
derMouse->securityOrigin()->isLocal()) ? DataTransferReadable : DataTransferType
sReadable; |
217 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransf
er(policy, dragData); | 217 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData
); |
218 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()
); | 218 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()
); |
219 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
dataTransfer.get()); | 219 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
dataTransfer); |
220 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security | 220 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security |
221 } | 221 } |
222 mouseMovedIntoDocument(nullptr); | 222 mouseMovedIntoDocument(nullptr); |
223 if (m_fileInputElementUnderMouse) | 223 if (m_fileInputElementUnderMouse) |
224 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 224 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
225 m_fileInputElementUnderMouse = nullptr; | 225 m_fileInputElementUnderMouse = nullptr; |
226 } | 226 } |
227 | 227 |
228 DragSession DragController::dragUpdated(DragData* dragData) | 228 DragSession DragController::dragUpdated(DragData* dragData) |
229 { | 229 { |
230 return dragEnteredOrUpdated(dragData); | 230 return dragEnteredOrUpdated(dragData); |
231 } | 231 } |
232 | 232 |
233 bool DragController::performDrag(DragData* dragData) | 233 bool DragController::performDrag(DragData* dragData) |
234 { | 234 { |
235 ASSERT(dragData); | 235 ASSERT(dragData); |
236 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d
ragData->clientPosition()); | 236 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d
ragData->clientPosition()); |
237 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { | 237 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { |
238 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFr
ame(); | 238 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFr
ame(); |
239 bool preventedDefault = false; | 239 bool preventedDefault = false; |
240 if (mainFrame->view()) { | 240 if (mainFrame->view()) { |
241 // Sending an event can result in the destruction of the view and pa
rt. | 241 // Sending an event can result in the destruction of the view and pa
rt. |
242 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTr
ansfer(DataTransferReadable, dragData); | 242 DataTransfer* dataTransfer = createDraggingDataTransfer(DataTransfer
Readable, dragData); |
243 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa
sk()); | 243 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa
sk()); |
244 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), dataTransfer.get()); | 244 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), dataTransfer); |
245 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb
oard here for security | 245 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb
oard here for security |
246 } | 246 } |
247 if (preventedDefault) { | 247 if (preventedDefault) { |
248 m_documentUnderMouse = nullptr; | 248 m_documentUnderMouse = nullptr; |
249 cancelDrag(); | 249 cancelDrag(); |
250 return true; | 250 return true; |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDra
g(dragData)) { | 254 if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDra
g(dragData)) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) | 588 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) |
589 { | 589 { |
590 ASSERT(dragData); | 590 ASSERT(dragData); |
591 ASSERT(m_documentUnderMouse); | 591 ASSERT(m_documentUnderMouse); |
592 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); | 592 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); |
593 if (!mainFrame->view()) | 593 if (!mainFrame->view()) |
594 return false; | 594 return false; |
595 | 595 |
596 RefPtrWillBeRawPtr<FrameView> viewProtector(mainFrame->view()); | 596 RefPtrWillBeRawPtr<FrameView> viewProtector(mainFrame->view()); |
597 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is
Local() ? DataTransferReadable : DataTransferTypesReadable; | 597 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is
Local() ? DataTransferReadable : DataTransferTypesReadable; |
598 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransfer(p
olicy, dragData); | 598 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); |
599 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 599 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
600 dataTransfer->setSourceOperation(srcOpMask); | 600 dataTransfer->setSourceOperation(srcOpMask); |
601 | 601 |
602 PlatformMouseEvent event = createMouseEvent(dragData); | 602 PlatformMouseEvent event = createMouseEvent(dragData); |
603 if (!mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer.get()))
{ | 603 if (!mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer)) { |
604 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security | 604 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 operation = dataTransfer->destinationOperation(); | 608 operation = dataTransfer->destinationOperation(); |
609 if (dataTransfer->dropEffectIsUninitialized()) | 609 if (dataTransfer->dropEffectIsUninitialized()) |
610 operation = defaultOperationForDrag(srcOpMask); | 610 operation = defaultOperationForDrag(srcOpMask); |
611 else if (!(srcOpMask & operation)) { | 611 else if (!(srcOpMask & operation)) { |
612 // The element picked an operation which is not supported by the source | 612 // The element picked an operation which is not supported by the source |
613 operation = DragOperationNone; | 613 operation = DragOperationNone; |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 965 |
966 DEFINE_TRACE(DragController) | 966 DEFINE_TRACE(DragController) |
967 { | 967 { |
968 visitor->trace(m_page); | 968 visitor->trace(m_page); |
969 visitor->trace(m_documentUnderMouse); | 969 visitor->trace(m_documentUnderMouse); |
970 visitor->trace(m_dragInitiator); | 970 visitor->trace(m_dragInitiator); |
971 visitor->trace(m_fileInputElementUnderMouse); | 971 visitor->trace(m_fileInputElementUnderMouse); |
972 } | 972 } |
973 | 973 |
974 } // namespace blink | 974 } // namespace blink |
OLD | NEW |