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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
474 // fileInput should be the element we hit tested for, unless it was made | 474 // fileInput should be the element we hit tested for, unless it was made |
475 // display:none in a drop event handler. | 475 // display:none in a drop event handler. |
476 ASSERT(fileInput == element || !fileInput->renderer()); | 476 ASSERT(fileInput == element || !fileInput->layoutObject()); |
477 if (fileInput->isDisabledFormControl()) | 477 if (fileInput->isDisabledFormControl()) |
478 return false; | 478 return false; |
479 | 479 |
480 return fileInput->receiveDroppedFiles(dragData); | 480 return fileInput->receiveDroppedFiles(dragData); |
481 } | 481 } |
482 | 482 |
483 if (!m_page->dragController().canProcessDrag(dragData)) { | 483 if (!m_page->dragController().canProcessDrag(dragData)) { |
484 m_page->dragCaretController().clear(); | 484 m_page->dragCaretController().clear(); |
485 return false; | 485 return false; |
486 } | 486 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 if (src->selection().contains(dragOrigin)) { | 627 if (src->selection().contains(dragOrigin)) { |
628 dragType = DragSourceActionSelection; | 628 dragType = DragSourceActionSelection; |
629 if (selectionDragPolicy == ImmediateSelectionDragResolution) | 629 if (selectionDragPolicy == ImmediateSelectionDragResolution) |
630 return startNode; | 630 return startNode; |
631 } else { | 631 } else { |
632 dragType = DragSourceActionNone; | 632 dragType = DragSourceActionNone; |
633 } | 633 } |
634 | 634 |
635 Node* node = nullptr; | 635 Node* node = nullptr; |
636 DragSourceAction candidateDragType = DragSourceActionNone; | 636 DragSourceAction candidateDragType = DragSourceActionNone; |
637 for (const LayoutObject* renderer = startNode->renderer(); renderer; rendere
r = renderer->parent()) { | 637 for (const LayoutObject* renderer = startNode->layoutObject(); renderer; ren
derer = renderer->parent()) { |
638 node = renderer->nonPseudoNode(); | 638 node = renderer->nonPseudoNode(); |
639 if (!node) { | 639 if (!node) { |
640 // Anonymous render blocks don't correspond to actual DOM nodes, so
we skip over them | 640 // Anonymous render blocks don't correspond to actual DOM nodes, so
we skip over them |
641 // for the purposes of finding a draggable node. | 641 // for the purposes of finding a draggable node. |
642 continue; | 642 continue; |
643 } | 643 } |
644 if (dragType != DragSourceActionSelection && node->isTextNode() && node-
>canStartSelection()) { | 644 if (dragType != DragSourceActionSelection && node->isTextNode() && node-
>canStartSelection()) { |
645 // In this case we have a click in the unselected portion of text. I
f this text is | 645 // In this case we have a click in the unselected portion of text. I
f this text is |
646 // selectable, we want to start the selection process instead of loo
king for a parent | 646 // selectable, we want to start the selection process instead of loo
king for a parent |
647 // to try to drag. | 647 // to try to drag. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 // If the cursor isn't over a selection, then just drag the node we foun
d earlier. | 690 // If the cursor isn't over a selection, then just drag the node we foun
d earlier. |
691 ASSERT(dragType == DragSourceActionNone); | 691 ASSERT(dragType == DragSourceActionNone); |
692 dragType = candidateDragType; | 692 dragType = candidateDragType; |
693 } | 693 } |
694 return node; | 694 return node; |
695 } | 695 } |
696 | 696 |
697 static ImageResource* getImageResource(Element* element) | 697 static ImageResource* getImageResource(Element* element) |
698 { | 698 { |
699 ASSERT(element); | 699 ASSERT(element); |
700 LayoutObject* renderer = element->renderer(); | 700 LayoutObject* renderer = element->layoutObject(); |
701 if (!renderer || !renderer->isImage()) | 701 if (!renderer || !renderer->isImage()) |
702 return nullptr; | 702 return nullptr; |
703 LayoutImage* image = toLayoutImage(renderer); | 703 LayoutImage* image = toLayoutImage(renderer); |
704 return image->cachedImage(); | 704 return image->cachedImage(); |
705 } | 705 } |
706 | 706 |
707 static Image* getImage(Element* element) | 707 static Image* getImage(Element* element) |
708 { | 708 { |
709 ASSERT(element); | 709 ASSERT(element); |
710 ImageResource* cachedImage = getImageResource(element); | 710 ImageResource* cachedImage = getImageResource(element); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 return maxDragImageSize; | 804 return maxDragImageSize; |
805 } | 805 } |
806 | 806 |
807 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, c
onst IntPoint& dragOrigin, const IntRect& imageRect, IntPoint& dragLocation) | 807 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, c
onst IntPoint& dragOrigin, const IntRect& imageRect, IntPoint& dragLocation) |
808 { | 808 { |
809 OwnPtr<DragImage> dragImage; | 809 OwnPtr<DragImage> dragImage; |
810 IntPoint origin; | 810 IntPoint origin; |
811 | 811 |
812 InterpolationQuality interpolationQuality = element->computedStyle()->imageR
endering() == ImageRenderingPixelated ? InterpolationNone : InterpolationHigh; | 812 InterpolationQuality interpolationQuality = element->computedStyle()->imageR
endering() == ImageRenderingPixelated ? InterpolationNone : InterpolationHigh; |
813 if (image->size().height() * image->size().width() <= MaxOriginalImageArea | 813 if (image->size().height() * image->size().width() <= MaxOriginalImageArea |
814 && (dragImage = DragImage::create(image, element->renderer() ? element->
renderer()->shouldRespectImageOrientation() : DoNotRespectImageOrientation, 1 /*
deviceScaleFactor */, interpolationQuality))) { | 814 && (dragImage = DragImage::create(image, element->layoutObject() ? eleme
nt->layoutObject()->shouldRespectImageOrientation() : DoNotRespectImageOrientati
on, 1 /* deviceScaleFactor */, interpolationQuality))) { |
815 IntSize originalSize = imageRect.size(); | 815 IntSize originalSize = imageRect.size(); |
816 origin = imageRect.location(); | 816 origin = imageRect.location(); |
817 | 817 |
818 dragImage->fitToMaxSize(imageRect.size(), maxDragImageSize()); | 818 dragImage->fitToMaxSize(imageRect.size(), maxDragImageSize()); |
819 dragImage->dissolveToFraction(DragImageAlpha); | 819 dragImage->dissolveToFraction(DragImageAlpha); |
820 IntSize newSize = dragImage->size(); | 820 IntSize newSize = dragImage->size(); |
821 | 821 |
822 // Properly orient the drag image and orient it differently if it's smal
ler than the original | 822 // Properly orient the drag image and orient it differently if it's smal
ler than the original |
823 float scale = newSize.width() / (float)originalSize.width(); | 823 float scale = newSize.width() / (float)originalSize.width(); |
824 float dx = origin.x() - dragOrigin.x(); | 824 float dx = origin.x() - dragOrigin.x(); |
(...skipping 145 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 |