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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool shiftKey = static_cast<bool>(keyState & PlatformEvent::ShiftKey); | 114 bool shiftKey = static_cast<bool>(keyState & PlatformEvent::ShiftKey); |
115 bool ctrlKey = static_cast<bool>(keyState & PlatformEvent::CtrlKey); | 115 bool ctrlKey = static_cast<bool>(keyState & PlatformEvent::CtrlKey); |
116 bool altKey = static_cast<bool>(keyState & PlatformEvent::AltKey); | 116 bool altKey = static_cast<bool>(keyState & PlatformEvent::AltKey); |
117 bool metaKey = static_cast<bool>(keyState & PlatformEvent::MetaKey); | 117 bool metaKey = static_cast<bool>(keyState & PlatformEvent::MetaKey); |
118 | 118 |
119 return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPositi
on(), | 119 return PlatformMouseEvent(dragData->clientPosition(), dragData->globalPositi
on(), |
120 LeftButton, PlatformEvent::MouseMoved, 0, shiftKey
, ctrlKey, altKey, | 120 LeftButton, PlatformEvent::MouseMoved, 0, shiftKey
, ctrlKey, altKey, |
121 metaKey, currentTime()); | 121 metaKey, currentTime()); |
122 } | 122 } |
123 | 123 |
124 static PassRefPtr<Clipboard> createDraggingClipboard(ClipboardAccessPolicy polic
y, DragData* dragData) | 124 static PassRefPtrWillBeRawPtr<Clipboard> createDraggingClipboard(ClipboardAccess
Policy policy, DragData* dragData) |
125 { | 125 { |
126 return Clipboard::create(Clipboard::DragAndDrop, policy, dragData->platformD
ata()); | 126 return Clipboard::create(Clipboard::DragAndDrop, policy, dragData->platformD
ata()); |
127 } | 127 } |
128 | 128 |
129 DragController::DragController(Page* page, DragClient* client) | 129 DragController::DragController(Page* page, DragClient* client) |
130 : m_page(page) | 130 : m_page(page) |
131 , m_client(client) | 131 , m_client(client) |
132 , m_documentUnderMouse(0) | 132 , m_documentUnderMouse(0) |
133 , m_dragInitiator(0) | 133 , m_dragInitiator(0) |
134 , m_fileInputElementUnderMouse(0) | 134 , m_fileInputElementUnderMouse(0) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return dragEnteredOrUpdated(dragData); | 211 return dragEnteredOrUpdated(dragData); |
212 } | 212 } |
213 | 213 |
214 void DragController::dragExited(DragData* dragData) | 214 void DragController::dragExited(DragData* dragData) |
215 { | 215 { |
216 ASSERT(dragData); | 216 ASSERT(dragData); |
217 Frame* mainFrame = m_page->mainFrame(); | 217 Frame* mainFrame = m_page->mainFrame(); |
218 | 218 |
219 if (RefPtr<FrameView> v = mainFrame->view()) { | 219 if (RefPtr<FrameView> v = mainFrame->view()) { |
220 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder
Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable
; | 220 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder
Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable
; |
221 RefPtr<Clipboard> clipboard = createDraggingClipboard(policy, dragData); | 221 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy
, dragData); |
222 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); | 222 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); |
223 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
clipboard.get()); | 223 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
clipboard.get()); |
224 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security | 224 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security |
225 } | 225 } |
226 mouseMovedIntoDocument(0); | 226 mouseMovedIntoDocument(0); |
227 if (m_fileInputElementUnderMouse) | 227 if (m_fileInputElementUnderMouse) |
228 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 228 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
229 m_fileInputElementUnderMouse = 0; | 229 m_fileInputElementUnderMouse = 0; |
230 } | 230 } |
231 | 231 |
232 DragSession DragController::dragUpdated(DragData* dragData) | 232 DragSession DragController::dragUpdated(DragData* dragData) |
233 { | 233 { |
234 return dragEnteredOrUpdated(dragData); | 234 return dragEnteredOrUpdated(dragData); |
235 } | 235 } |
236 | 236 |
237 bool DragController::performDrag(DragData* dragData) | 237 bool DragController::performDrag(DragData* dragData) |
238 { | 238 { |
239 ASSERT(dragData); | 239 ASSERT(dragData); |
240 m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->client
Position()); | 240 m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->client
Position()); |
241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { | 241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { |
242 RefPtr<Frame> mainFrame = m_page->mainFrame(); | 242 RefPtr<Frame> mainFrame = m_page->mainFrame(); |
243 bool preventedDefault = false; | 243 bool preventedDefault = false; |
244 if (mainFrame->view()) { | 244 if (mainFrame->view()) { |
245 // Sending an event can result in the destruction of the view and pa
rt. | 245 // Sending an event can result in the destruction of the view and pa
rt. |
246 RefPtr<Clipboard> clipboard = createDraggingClipboard(ClipboardReada
ble, dragData); | 246 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(Cl
ipboardReadable, dragData); |
247 clipboard->setSourceOperation(dragData->draggingSourceOperationMask(
)); | 247 clipboard->setSourceOperation(dragData->draggingSourceOperationMask(
)); |
248 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), clipboard.get()); | 248 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), clipboard.get()); |
249 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard h
ere for security | 249 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard h
ere for security |
250 } | 250 } |
251 if (preventedDefault) { | 251 if (preventedDefault) { |
252 m_documentUnderMouse = 0; | 252 m_documentUnderMouse = 0; |
253 return true; | 253 return true; |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
(...skipping 331 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 RefPtr<Frame> mainFrame = m_page->mainFrame(); | 592 RefPtr<Frame> mainFrame = m_page->mainFrame(); |
593 RefPtr<FrameView> viewProtector = mainFrame->view(); | 593 RefPtr<FrameView> viewProtector = mainFrame->view(); |
594 if (!viewProtector) | 594 if (!viewProtector) |
595 return false; | 595 return false; |
596 | 596 |
597 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLoc
al() ? ClipboardReadable : ClipboardTypesReadable; | 597 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLoc
al() ? ClipboardReadable : ClipboardTypesReadable; |
598 RefPtr<Clipboard> clipboard = createDraggingClipboard(policy, dragData); | 598 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy, dr
agData); |
599 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 599 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
600 clipboard->setSourceOperation(srcOpMask); | 600 clipboard->setSourceOperation(srcOpMask); |
601 | 601 |
602 PlatformMouseEvent event = createMouseEvent(dragData); | 602 PlatformMouseEvent event = createMouseEvent(dragData); |
603 if (!mainFrame->eventHandler().updateDragAndDrop(event, clipboard.get())) { | 603 if (!mainFrame->eventHandler().updateDragAndDrop(event, clipboard.get())) { |
604 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security | 604 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security |
605 return false; | 605 return false; |
606 } | 606 } |
607 | 607 |
608 operation = clipboard->destinationOperation(); | 608 operation = clipboard->destinationOperation(); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 return false; | 957 return false; |
958 #endif | 958 #endif |
959 } | 959 } |
960 | 960 |
961 void DragController::cleanupAfterSystemDrag() | 961 void DragController::cleanupAfterSystemDrag() |
962 { | 962 { |
963 } | 963 } |
964 | 964 |
965 } // namespace WebCore | 965 } // namespace WebCore |
966 | 966 |
OLD | NEW |