| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); | 353 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); |
| 354 if (!frameView) | 354 if (!frameView) |
| 355 return false; | 355 return false; |
| 356 | 356 |
| 357 if (isHandlingDrag) { | 357 if (isHandlingDrag) { |
| 358 m_page->dragCaretController().clear(); | 358 m_page->dragCaretController().clear(); |
| 359 return true; | 359 return true; |
| 360 } | 360 } |
| 361 | 361 |
| 362 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { | 362 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { |
| 363 IntPoint point = frameView->windowToContents(dragData->clientPosition())
; | 363 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition
()); |
| 364 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 364 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
| 365 if (!element) | 365 if (!element) |
| 366 return false; | 366 return false; |
| 367 | 367 |
| 368 HTMLInputElement* elementAsFileInput = asFileInput(element); | 368 HTMLInputElement* elementAsFileInput = asFileInput(element); |
| 369 if (m_fileInputElementUnderMouse != elementAsFileInput) { | 369 if (m_fileInputElementUnderMouse != elementAsFileInput) { |
| 370 if (m_fileInputElementUnderMouse) | 370 if (m_fileInputElementUnderMouse) |
| 371 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 371 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 372 m_fileInputElementUnderMouse = elementAsFileInput; | 372 m_fileInputElementUnderMouse = elementAsFileInput; |
| 373 } | 373 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; | 449 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; |
| 450 if (m_fileInputElementUnderMouse) { | 450 if (m_fileInputElementUnderMouse) { |
| 451 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 451 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
| 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()->rootFrameToContents(dragData-
>clientPosition()); |
| 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 RefPtrWillBeRawPtr<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) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 return true; | 533 return true; |
| 534 } | 534 } |
| 535 | 535 |
| 536 bool DragController::canProcessDrag(DragData* dragData) | 536 bool DragController::canProcessDrag(DragData* dragData) |
| 537 { | 537 { |
| 538 ASSERT(dragData); | 538 ASSERT(dragData); |
| 539 | 539 |
| 540 if (!dragData->containsCompatibleContent()) | 540 if (!dragData->containsCompatibleContent()) |
| 541 return false; | 541 return false; |
| 542 | 542 |
| 543 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->windowToContent
s(dragData->clientPosition()); | 543 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToCont
ents(dragData->clientPosition()); |
| 544 HitTestResult result = HitTestResult(point); | 544 HitTestResult result = HitTestResult(point); |
| 545 if (!m_page->deprecatedLocalMainFrame()->contentRenderer()) | 545 if (!m_page->deprecatedLocalMainFrame()->contentRenderer()) |
| 546 return false; | 546 return false; |
| 547 | 547 |
| 548 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP
oint(point); | 548 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP
oint(point); |
| 549 | 549 |
| 550 if (!result.innerNonSharedNode()) | 550 if (!result.innerNonSharedNode()) |
| 551 return false; | 551 return false; |
| 552 | 552 |
| 553 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) | 553 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragO
rigin); | 851 HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragO
rigin); |
| 852 if (!state.m_dragSrc->containsIncludingShadowDOM(hitTestResult.innerNode()))
{ | 852 if (!state.m_dragSrc->containsIncludingShadowDOM(hitTestResult.innerNode()))
{ |
| 853 // The original node being dragged isn't under the drag origin anymore..
. maybe it was | 853 // The original node being dragged isn't under the drag origin anymore..
. maybe it was |
| 854 // hidden or moved out from under the cursor. Regardless, we don't want
to start a drag on | 854 // hidden or moved out from under the cursor. Regardless, we don't want
to start a drag on |
| 855 // something that's not actually under the drag origin. | 855 // something that's not actually under the drag origin. |
| 856 return false; | 856 return false; |
| 857 } | 857 } |
| 858 const KURL& linkURL = hitTestResult.absoluteLinkURL(); | 858 const KURL& linkURL = hitTestResult.absoluteLinkURL(); |
| 859 const KURL& imageURL = hitTestResult.absoluteImageURL(); | 859 const KURL& imageURL = hitTestResult.absoluteImageURL(); |
| 860 | 860 |
| 861 IntPoint mouseDraggedPoint = src->view()->windowToContents(dragEvent.positio
n()); | 861 IntPoint mouseDraggedPoint = src->view()->rootFrameToContents(dragEvent.posi
tion()); |
| 862 | 862 |
| 863 IntPoint dragLocation; | 863 IntPoint dragLocation; |
| 864 IntPoint dragOffset; | 864 IntPoint dragOffset; |
| 865 | 865 |
| 866 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); | 866 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); |
| 867 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. | 867 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. |
| 868 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. | 868 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. |
| 869 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src)
; | 869 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src)
; |
| 870 if (dragImage) { | 870 if (dragImage) { |
| 871 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d
ragOffset, !linkURL.isEmpty()); | 871 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d
ragOffset, !linkURL.isEmpty()); |
| (...skipping 93 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 |