| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 DragSession DragController::dragEntered(DragData* dragData) | 209 DragSession DragController::dragEntered(DragData* dragData) |
| 210 { | 210 { |
| 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 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); | 217 LocalFrame* mainFrame = m_page->deprecatedLocalMainFrame(); |
| 218 | 218 |
| 219 if (RefPtr<FrameView> v = mainFrame->view()) { | 219 RefPtrWillBeRawPtr<FrameView> frameView(mainFrame->view()); |
| 220 if (frameView) { |
| 220 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn
derMouse->securityOrigin()->isLocal()) ? DataTransferReadable : DataTransferType
sReadable; | 221 DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUn
derMouse->securityOrigin()->isLocal()) ? DataTransferReadable : DataTransferType
sReadable; |
| 221 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransf
er(policy, dragData); | 222 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransf
er(policy, dragData); |
| 222 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()
); | 223 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMask()
); |
| 223 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
dataTransfer.get()); | 224 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData),
dataTransfer.get()); |
| 224 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security | 225 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security |
| 225 } | 226 } |
| 226 mouseMovedIntoDocument(0); | 227 mouseMovedIntoDocument(0); |
| 227 if (m_fileInputElementUnderMouse) | 228 if (m_fileInputElementUnderMouse) |
| 228 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 229 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 229 m_fileInputElementUnderMouse = nullptr; | 230 m_fileInputElementUnderMouse = nullptr; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // tryDHTMLDrag fires dragenter event. The event listener that listens | 347 // tryDHTMLDrag fires dragenter event. The event listener that listens |
| 347 // to this event may create a nested message loop (open a modal dialog), | 348 // to this event may create a nested message loop (open a modal dialog), |
| 348 // which could process dragleave event and reset m_documentUnderMouse in | 349 // which could process dragleave event and reset m_documentUnderMouse in |
| 349 // dragExited. | 350 // dragExited. |
| 350 if (!m_documentUnderMouse) | 351 if (!m_documentUnderMouse) |
| 351 return false; | 352 return false; |
| 352 } | 353 } |
| 353 | 354 |
| 354 // It's unclear why this check is after tryDHTMLDrag. | 355 // It's unclear why this check is after tryDHTMLDrag. |
| 355 // We send drag events in tryDHTMLDrag and that may be the reason. | 356 // We send drag events in tryDHTMLDrag and that may be the reason. |
| 356 RefPtr<FrameView> frameView = m_documentUnderMouse->view(); | 357 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); |
| 357 if (!frameView) | 358 if (!frameView) |
| 358 return false; | 359 return false; |
| 359 | 360 |
| 360 if (isHandlingDrag) { | 361 if (isHandlingDrag) { |
| 361 m_page->dragCaretController().clear(); | 362 m_page->dragCaretController().clear(); |
| 362 return true; | 363 return true; |
| 363 } | 364 } |
| 364 | 365 |
| 365 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { | 366 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { |
| 366 IntPoint point = frameView->windowToContents(dragData->clientPosition())
; | 367 IntPoint point = frameView->windowToContents(dragData->clientPosition())
; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 } | 588 } |
| 588 | 589 |
| 589 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) | 590 bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation) |
| 590 { | 591 { |
| 591 ASSERT(dragData); | 592 ASSERT(dragData); |
| 592 ASSERT(m_documentUnderMouse); | 593 ASSERT(m_documentUnderMouse); |
| 593 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); | 594 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); |
| 594 if (!mainFrame->view()) | 595 if (!mainFrame->view()) |
| 595 return false; | 596 return false; |
| 596 | 597 |
| 597 RefPtr<FrameView> viewProtector(mainFrame->view()); | 598 RefPtrWillBeRawPtr<FrameView> viewProtector(mainFrame->view()); |
| 598 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is
Local() ? DataTransferReadable : DataTransferTypesReadable; | 599 DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->is
Local() ? DataTransferReadable : DataTransferTypesReadable; |
| 599 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransfer(p
olicy, dragData); | 600 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransfer(p
olicy, dragData); |
| 600 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); | 601 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); |
| 601 dataTransfer->setSourceOperation(srcOpMask); | 602 dataTransfer->setSourceOperation(srcOpMask); |
| 602 | 603 |
| 603 PlatformMouseEvent event = createMouseEvent(dragData); | 604 PlatformMouseEvent event = createMouseEvent(dragData); |
| 604 if (!mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer.get()))
{ | 605 if (!mainFrame->eventHandler().updateDragAndDrop(event, dataTransfer.get()))
{ |
| 605 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security | 606 dataTransfer->setAccessPolicy(DataTransferNumb); // invalidate clipboard
here for security |
| 606 return false; | 607 return false; |
| 607 } | 608 } |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 | 940 |
| 940 return true; | 941 return true; |
| 941 } | 942 } |
| 942 | 943 |
| 943 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool
forLink) | 944 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool
forLink) |
| 944 { | 945 { |
| 945 m_didInitiateDrag = true; | 946 m_didInitiateDrag = true; |
| 946 m_dragInitiator = frame->document(); | 947 m_dragInitiator = frame->document(); |
| 947 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame | 948 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame |
| 948 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); | 949 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); |
| 949 RefPtr<FrameView> mainFrameView = mainFrame->view(); | 950 RefPtrWillBeRawPtr<FrameView> mainFrameView = mainFrame->view(); |
| 950 | 951 |
| 951 m_client->startDrag(image, mainFrameView->rootViewToContents(frame->view()->
contentsToRootView(dragLocation)), | 952 m_client->startDrag(image, mainFrameView->rootViewToContents(frame->view()->
contentsToRootView(dragLocation)), |
| 952 mainFrameView->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), dataTransfer, frame, forLink); | 953 mainFrameView->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), dataTransfer, frame, forLink); |
| 953 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. | 954 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. |
| 954 if (!frame->page()) | 955 if (!frame->page()) |
| 955 return; | 956 return; |
| 956 | 957 |
| 957 cleanupAfterSystemDrag(); | 958 cleanupAfterSystemDrag(); |
| 958 } | 959 } |
| 959 | 960 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 984 | 985 |
| 985 void DragController::trace(Visitor* visitor) | 986 void DragController::trace(Visitor* visitor) |
| 986 { | 987 { |
| 987 visitor->trace(m_page); | 988 visitor->trace(m_page); |
| 988 visitor->trace(m_documentUnderMouse); | 989 visitor->trace(m_documentUnderMouse); |
| 989 visitor->trace(m_dragInitiator); | 990 visitor->trace(m_dragInitiator); |
| 990 visitor->trace(m_fileInputElementUnderMouse); | 991 visitor->trace(m_fileInputElementUnderMouse); |
| 991 } | 992 } |
| 992 | 993 |
| 993 } // namespace blink | 994 } // namespace blink |
| OLD | NEW |