| 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(nullptr) | 132 , m_documentUnderMouse(nullptr) |
| 133 , m_dragInitiator(nullptr) | 133 , m_dragInitiator(nullptr) |
| 134 , m_fileInputElementUnderMouse(nullptr) | 134 , m_fileInputElementUnderMouse(nullptr) |
| (...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 = nullptr; | 229 m_fileInputElementUnderMouse = nullptr; |
| 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 = nullptr; | 252 m_documentUnderMouse = nullptr; |
| 253 return true; | 253 return true; |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) | 589 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) |
| 590 { | 590 { |
| 591 ASSERT(dragData); | 591 ASSERT(dragData); |
| 592 ASSERT(m_documentUnderMouse); | 592 ASSERT(m_documentUnderMouse); |
| 593 RefPtr<Frame> mainFrame = m_page->mainFrame(); | 593 RefPtr<Frame> mainFrame = m_page->mainFrame(); |
| 594 RefPtr<FrameView> viewProtector = mainFrame->view(); | 594 RefPtr<FrameView> viewProtector = mainFrame->view(); |
| 595 if (!viewProtector) | 595 if (!viewProtector) |
| 596 return false; | 596 return false; |
| 597 | 597 |
| 598 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLoc
al() ? ClipboardReadable : ClipboardTypesReadable; | 598 ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLoc
al() ? ClipboardReadable : ClipboardTypesReadable; |
| 599 RefPtr<Clipboard> clipboard = createDraggingClipboard(policy, dragData); | 599 RefPtrWillBeRawPtr<Clipboard> clipboard = createDraggingClipboard(policy, dr
agData); |
| 600 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 600 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
| 601 clipboard->setSourceOperation(srcOpMask); | 601 clipboard->setSourceOperation(srcOpMask); |
| 602 | 602 |
| 603 PlatformMouseEvent event = createMouseEvent(dragData); | 603 PlatformMouseEvent event = createMouseEvent(dragData); |
| 604 if (!mainFrame->eventHandler().updateDragAndDrop(event, clipboard.get())) { | 604 if (!mainFrame->eventHandler().updateDragAndDrop(event, clipboard.get())) { |
| 605 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security | 605 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he
re for security |
| 606 return false; | 606 return false; |
| 607 } | 607 } |
| 608 | 608 |
| 609 operation = clipboard->destinationOperation(); | 609 operation = clipboard->destinationOperation(); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 return false; | 958 return false; |
| 959 #endif | 959 #endif |
| 960 } | 960 } |
| 961 | 961 |
| 962 void DragController::cleanupAfterSystemDrag() | 962 void DragController::cleanupAfterSystemDrag() |
| 963 { | 963 { |
| 964 } | 964 } |
| 965 | 965 |
| 966 } // namespace WebCore | 966 } // namespace WebCore |
| 967 | 967 |
| OLD | NEW |