| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 DragSession DragController::dragUpdated(DragData* dragData) | 231 DragSession DragController::dragUpdated(DragData* dragData) |
| 232 { | 232 { |
| 233 return dragEnteredOrUpdated(dragData); | 233 return dragEnteredOrUpdated(dragData); |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool DragController::performDrag(DragData* dragData) | 236 bool DragController::performDrag(DragData* dragData) |
| 237 { | 237 { |
| 238 ASSERT(dragData); | 238 ASSERT(dragData); |
| 239 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d
ragData->clientPosition()); | 239 m_documentUnderMouse = m_page->deprecatedLocalMainFrame()->documentAtPoint(d
ragData->clientPosition()); |
| 240 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { | 240 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa
ndlingDrag) { |
| 241 RefPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); | 241 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFr
ame(); |
| 242 bool preventedDefault = false; | 242 bool preventedDefault = false; |
| 243 if (mainFrame->view()) { | 243 if (mainFrame->view()) { |
| 244 // Sending an event can result in the destruction of the view and pa
rt. | 244 // Sending an event can result in the destruction of the view and pa
rt. |
| 245 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTr
ansfer(DataTransferReadable, dragData); | 245 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTr
ansfer(DataTransferReadable, dragData); |
| 246 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa
sk()); | 246 dataTransfer->setSourceOperation(dragData->draggingSourceOperationMa
sk()); |
| 247 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), dataTransfer.get()); | 247 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea
teMouseEvent(dragData), dataTransfer.get()); |
| 248 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb
oard here for security | 248 dataTransfer->setAccessPolicy(DataTransferNumb); // Invalidate clipb
oard here for security |
| 249 } | 249 } |
| 250 if (preventedDefault) { | 250 if (preventedDefault) { |
| 251 m_documentUnderMouse = nullptr; | 251 m_documentUnderMouse = nullptr; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 m_fileInputElementUnderMouse = nullptr; | 452 m_fileInputElementUnderMouse = nullptr; |
| 453 } | 453 } |
| 454 | 454 |
| 455 if (!m_documentUnderMouse) | 455 if (!m_documentUnderMouse) |
| 456 return false; | 456 return false; |
| 457 | 457 |
| 458 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl
ientPosition()); | 458 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl
ientPosition()); |
| 459 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 459 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 460 if (!element) | 460 if (!element) |
| 461 return false; | 461 return false; |
| 462 RefPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(); | 462 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(
); |
| 463 ASSERT(innerFrame); | 463 ASSERT(innerFrame); |
| 464 | 464 |
| 465 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) | 465 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) |
| 466 return true; | 466 return true; |
| 467 | 467 |
| 468 if (dragData->containsFiles() && fileInput) { | 468 if (dragData->containsFiles() && fileInput) { |
| 469 // fileInput should be the element we hit tested for, unless it was made | 469 // fileInput should be the element we hit tested for, unless it was made |
| 470 // display:none in a drop event handler. | 470 // display:none in a drop event handler. |
| 471 ASSERT(fileInput == element || !fileInput->renderer()); | 471 ASSERT(fileInput == element || !fileInput->renderer()); |
| 472 if (fileInput->isDisabledFormControl()) | 472 if (fileInput->isDisabledFormControl()) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 return DragOperationLink; | 582 return DragOperationLink; |
| 583 | 583 |
| 584 // FIXME: Does IE really return "generic" even if no operations were allowed
by the source? | 584 // FIXME: Does IE really return "generic" even if no operations were allowed
by the source? |
| 585 return DragOperationGeneric; | 585 return DragOperationGeneric; |
| 586 } | 586 } |
| 587 | 587 |
| 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<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(); | 592 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); |
| 593 RefPtr<FrameView> viewProtector = mainFrame->view(); | 593 if (!mainFrame->view()) |
| 594 if (!viewProtector) | |
| 595 return false; | 594 return false; |
| 596 | 595 |
| 596 RefPtr<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 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = createDraggingDataTransfer(p
olicy, 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.get()))
{ |
| 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 } |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 } | 920 } |
| 921 | 921 |
| 922 return true; | 922 return true; |
| 923 } | 923 } |
| 924 | 924 |
| 925 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool
forLink) | 925 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLocation
, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, bool
forLink) |
| 926 { | 926 { |
| 927 m_didInitiateDrag = true; | 927 m_didInitiateDrag = true; |
| 928 m_dragInitiator = frame->document(); | 928 m_dragInitiator = frame->document(); |
| 929 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame | 929 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame |
| 930 RefPtr<LocalFrame> frameProtector = m_page->deprecatedLocalMainFrame(); | 930 RefPtrWillBeRawPtr<LocalFrame> mainFrame = m_page->deprecatedLocalMainFrame(
); |
| 931 RefPtr<FrameView> viewProtector = frameProtector->view(); | 931 RefPtr<FrameView> mainFrameView = mainFrame->view(); |
| 932 m_client->startDrag(image, viewProtector->rootViewToContents(frame->view()->
contentsToRootView(dragLocation)), | 932 |
| 933 viewProtector->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), dataTransfer, frameProtector.get(), forLink); | 933 m_client->startDrag(image, mainFrameView->rootViewToContents(frame->view()->
contentsToRootView(dragLocation)), |
| 934 mainFrameView->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), dataTransfer, frame, forLink); |
| 934 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. | 935 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. |
| 935 if (!frameProtector->page()) | 936 if (!frame->page()) |
| 936 return; | 937 return; |
| 937 | 938 |
| 938 cleanupAfterSystemDrag(); | 939 cleanupAfterSystemDrag(); |
| 939 } | 940 } |
| 940 | 941 |
| 941 DragOperation DragController::dragOperation(DragData* dragData) | 942 DragOperation DragController::dragOperation(DragData* dragData) |
| 942 { | 943 { |
| 943 // FIXME: To match the MacOS behaviour we should return DragOperationNone | 944 // FIXME: To match the MacOS behaviour we should return DragOperationNone |
| 944 // if we are a modal window, we are the drag source, or the window is an | 945 // if we are a modal window, we are the drag source, or the window is an |
| 945 // attached sheet If this can be determined from within WebCore | 946 // attached sheet If this can be determined from within WebCore |
| (...skipping 19 matching lines...) Expand all Loading... |
| 965 | 966 |
| 966 void DragController::trace(Visitor* visitor) | 967 void DragController::trace(Visitor* visitor) |
| 967 { | 968 { |
| 968 visitor->trace(m_page); | 969 visitor->trace(m_page); |
| 969 visitor->trace(m_documentUnderMouse); | 970 visitor->trace(m_documentUnderMouse); |
| 970 visitor->trace(m_dragInitiator); | 971 visitor->trace(m_dragInitiator); |
| 971 visitor->trace(m_fileInputElementUnderMouse); | 972 visitor->trace(m_fileInputElementUnderMouse); |
| 972 } | 973 } |
| 973 | 974 |
| 974 } // namespace blink | 975 } // namespace blink |
| OLD | NEW |