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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); | 358 RefPtrWillBeRawPtr<FrameView> frameView = m_documentUnderMouse->view(); |
359 if (!frameView) | 359 if (!frameView) |
360 return false; | 360 return false; |
361 | 361 |
362 if (isHandlingDrag) { | 362 if (isHandlingDrag) { |
363 m_page->dragCaretController().clear(); | 363 m_page->dragCaretController().clear(); |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
367 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { | 367 if ((actionMask & DragDestinationActionEdit) && canProcessDrag(dragData)) { |
368 IntPoint point = frameView->windowToContents(dragData->clientPosition())
; | 368 IntPoint point = frameView->rootFrameToContents(dragData->clientPosition
()); |
369 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 369 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
370 if (!element) | 370 if (!element) |
371 return false; | 371 return false; |
372 | 372 |
373 HTMLInputElement* elementAsFileInput = asFileInput(element); | 373 HTMLInputElement* elementAsFileInput = asFileInput(element); |
374 if (m_fileInputElementUnderMouse != elementAsFileInput) { | 374 if (m_fileInputElementUnderMouse != elementAsFileInput) { |
375 if (m_fileInputElementUnderMouse) | 375 if (m_fileInputElementUnderMouse) |
376 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 376 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
377 m_fileInputElementUnderMouse = elementAsFileInput; | 377 m_fileInputElementUnderMouse = elementAsFileInput; |
378 } | 378 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 453 |
454 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; | 454 RefPtrWillBeRawPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMous
e; |
455 if (m_fileInputElementUnderMouse) { | 455 if (m_fileInputElementUnderMouse) { |
456 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); | 456 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); |
457 m_fileInputElementUnderMouse = nullptr; | 457 m_fileInputElementUnderMouse = nullptr; |
458 } | 458 } |
459 | 459 |
460 if (!m_documentUnderMouse) | 460 if (!m_documentUnderMouse) |
461 return false; | 461 return false; |
462 | 462 |
463 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl
ientPosition()); | 463 IntPoint point = m_documentUnderMouse->view()->rootFrameToContents(dragData-
>clientPosition()); |
464 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); | 464 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); |
465 if (!element) | 465 if (!element) |
466 return false; | 466 return false; |
467 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(
); | 467 RefPtrWillBeRawPtr<LocalFrame> innerFrame = element->ownerDocument()->frame(
); |
468 ASSERT(innerFrame); | 468 ASSERT(innerFrame); |
469 | 469 |
470 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) | 470 if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(i
nnerFrame.get(), dragData)) |
471 return true; | 471 return true; |
472 | 472 |
473 if (dragData->containsFiles() && fileInput) { | 473 if (dragData->containsFiles() && fileInput) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return true; | 538 return true; |
539 } | 539 } |
540 | 540 |
541 bool DragController::canProcessDrag(DragData* dragData) | 541 bool DragController::canProcessDrag(DragData* dragData) |
542 { | 542 { |
543 ASSERT(dragData); | 543 ASSERT(dragData); |
544 | 544 |
545 if (!dragData->containsCompatibleContent()) | 545 if (!dragData->containsCompatibleContent()) |
546 return false; | 546 return false; |
547 | 547 |
548 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->windowToContent
s(dragData->clientPosition()); | 548 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToCont
ents(dragData->clientPosition()); |
549 HitTestResult result = HitTestResult(point); | 549 HitTestResult result = HitTestResult(point); |
550 if (!m_page->deprecatedLocalMainFrame()->contentRenderer()) | 550 if (!m_page->deprecatedLocalMainFrame()->contentRenderer()) |
551 return false; | 551 return false; |
552 | 552 |
553 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP
oint(point); | 553 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP
oint(point); |
554 | 554 |
555 if (!result.innerNonSharedNode()) | 555 if (!result.innerNonSharedNode()) |
556 return false; | 556 return false; |
557 | 557 |
558 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) | 558 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragO
rigin); | 856 HitTestResult hitTestResult = src->eventHandler().hitTestResultAtPoint(dragO
rigin); |
857 if (!state.m_dragSrc->containsIncludingShadowDOM(hitTestResult.innerNode()))
{ | 857 if (!state.m_dragSrc->containsIncludingShadowDOM(hitTestResult.innerNode()))
{ |
858 // The original node being dragged isn't under the drag origin anymore..
. maybe it was | 858 // The original node being dragged isn't under the drag origin anymore..
. maybe it was |
859 // hidden or moved out from under the cursor. Regardless, we don't want
to start a drag on | 859 // hidden or moved out from under the cursor. Regardless, we don't want
to start a drag on |
860 // something that's not actually under the drag origin. | 860 // something that's not actually under the drag origin. |
861 return false; | 861 return false; |
862 } | 862 } |
863 const KURL& linkURL = hitTestResult.absoluteLinkURL(); | 863 const KURL& linkURL = hitTestResult.absoluteLinkURL(); |
864 const KURL& imageURL = hitTestResult.absoluteImageURL(); | 864 const KURL& imageURL = hitTestResult.absoluteImageURL(); |
865 | 865 |
866 IntPoint mouseDraggedPoint = src->view()->windowToContents(dragEvent.positio
n()); | 866 IntPoint mouseDraggedPoint = src->view()->rootFrameToContents(dragEvent.posi
tion()); |
867 | 867 |
868 IntPoint dragLocation; | 868 IntPoint dragLocation; |
869 IntPoint dragOffset; | 869 IntPoint dragOffset; |
870 | 870 |
871 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); | 871 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); |
872 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. | 872 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. |
873 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. | 873 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. |
874 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src)
; | 874 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src)
; |
875 if (dragImage) { | 875 if (dragImage) { |
876 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d
ragOffset, !linkURL.isEmpty()); | 876 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d
ragOffset, !linkURL.isEmpty()); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 | 970 |
971 DEFINE_TRACE(DragController) | 971 DEFINE_TRACE(DragController) |
972 { | 972 { |
973 visitor->trace(m_page); | 973 visitor->trace(m_page); |
974 visitor->trace(m_documentUnderMouse); | 974 visitor->trace(m_documentUnderMouse); |
975 visitor->trace(m_dragInitiator); | 975 visitor->trace(m_dragInitiator); |
976 visitor->trace(m_fileInputElementUnderMouse); | 976 visitor->trace(m_fileInputElementUnderMouse); |
977 } | 977 } |
978 | 978 |
979 } // namespace blink | 979 } // namespace blink |
OLD | NEW |