| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/page/DragController.h" | 28 #include "core/page/DragController.h" |
| 29 | 29 |
| 30 #include <wtf/CurrentTime.h> | |
| 31 #include <wtf/RefPtr.h> | |
| 32 #include "HTMLNames.h" | 30 #include "HTMLNames.h" |
| 33 #include "core/dom/Clipboard.h" | 31 #include "core/dom/Clipboard.h" |
| 34 #include "core/dom/ClipboardAccessPolicy.h" | 32 #include "core/dom/ClipboardAccessPolicy.h" |
| 35 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 36 #include "core/dom/DocumentFragment.h" | 34 #include "core/dom/DocumentFragment.h" |
| 37 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
| 38 #include "core/dom/ExceptionCodePlaceholder.h" | 36 #include "core/dom/ExceptionCodePlaceholder.h" |
| 39 #include "core/dom/Node.h" | 37 #include "core/dom/Node.h" |
| 40 #include "core/dom/Text.h" | 38 #include "core/dom/Text.h" |
| 41 #include "core/dom/TextEvent.h" | 39 #include "core/dom/TextEvent.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 56 #include "core/page/DragActions.h" | 54 #include "core/page/DragActions.h" |
| 57 #include "core/page/DragClient.h" | 55 #include "core/page/DragClient.h" |
| 58 #include "core/page/DragSession.h" | 56 #include "core/page/DragSession.h" |
| 59 #include "core/page/DragState.h" | 57 #include "core/page/DragState.h" |
| 60 #include "core/page/EventHandler.h" | 58 #include "core/page/EventHandler.h" |
| 61 #include "core/page/Frame.h" | 59 #include "core/page/Frame.h" |
| 62 #include "core/page/FrameView.h" | 60 #include "core/page/FrameView.h" |
| 63 #include "core/page/Page.h" | 61 #include "core/page/Page.h" |
| 64 #include "core/page/Settings.h" | 62 #include "core/page/Settings.h" |
| 65 #include "core/platform/DragData.h" | 63 #include "core/platform/DragData.h" |
| 64 #include "core/platform/DragImage.h" |
| 66 #include "core/platform/graphics/FloatRect.h" | 65 #include "core/platform/graphics/FloatRect.h" |
| 67 #include "core/platform/graphics/Image.h" | 66 #include "core/platform/graphics/Image.h" |
| 68 #include "core/platform/graphics/ImageOrientation.h" | 67 #include "core/platform/graphics/ImageOrientation.h" |
| 69 #include "core/platform/network/ResourceRequest.h" | 68 #include "core/platform/network/ResourceRequest.h" |
| 70 #include "core/rendering/HitTestRequest.h" | 69 #include "core/rendering/HitTestRequest.h" |
| 71 #include "core/rendering/HitTestResult.h" | 70 #include "core/rendering/HitTestResult.h" |
| 72 #include "core/rendering/RenderImage.h" | 71 #include "core/rendering/RenderImage.h" |
| 73 #include "core/rendering/RenderTheme.h" | 72 #include "core/rendering/RenderTheme.h" |
| 74 #include "core/rendering/RenderView.h" | 73 #include "core/rendering/RenderView.h" |
| 75 #include "weborigin/SecurityOrigin.h" | 74 #include "weborigin/SecurityOrigin.h" |
| 75 #include "wtf/CurrentTime.h" |
| 76 #include "wtf/OwnPtr.h" |
| 77 #include "wtf/PassOwnPtr.h" |
| 78 #include "wtf/RefPtr.h" |
| 76 | 79 |
| 77 #if OS(WINDOWS) | 80 #if OS(WINDOWS) |
| 78 #include <windows.h> | 81 #include <windows.h> |
| 79 #endif | 82 #endif |
| 80 | 83 |
| 81 namespace WebCore { | 84 namespace WebCore { |
| 82 | 85 |
| 83 const int DragController::LinkDragBorderInset = 2; | 86 const int DragController::LinkDragBorderInset = 2; |
| 84 const int DragController::MaxOriginalImageArea = 1500 * 1500; | 87 const int DragController::MaxOriginalImageArea = 1500 * 1500; |
| 85 const int DragController::DragIconRightInset = 7; | 88 const int DragController::DragIconRightInset = 7; |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 // something that's not actually under the drag origin. | 722 // something that's not actually under the drag origin. |
| 720 return false; | 723 return false; |
| 721 KURL linkURL = hitTestResult.absoluteLinkURL(); | 724 KURL linkURL = hitTestResult.absoluteLinkURL(); |
| 722 KURL imageURL = hitTestResult.absoluteImageURL(); | 725 KURL imageURL = hitTestResult.absoluteImageURL(); |
| 723 | 726 |
| 724 IntPoint mouseDraggedPoint = src->view()->windowToContents(dragEvent.positio
n()); | 727 IntPoint mouseDraggedPoint = src->view()->windowToContents(dragEvent.positio
n()); |
| 725 | 728 |
| 726 m_draggingImageURL = KURL(); | 729 m_draggingImageURL = KURL(); |
| 727 m_sourceDragOperation = srcOp; | 730 m_sourceDragOperation = srcOp; |
| 728 | 731 |
| 729 DragImageRef dragImage = 0; | 732 OwnPtr<DragImage> dragImage; |
| 730 IntPoint dragLoc(0, 0); | 733 IntPoint dragLoc(0, 0); |
| 731 IntPoint dragImageOffset(0, 0); | 734 IntPoint dragImageOffset(0, 0); |
| 732 | 735 |
| 733 Clipboard* clipboard = state.m_dragClipboard.get(); | 736 Clipboard* clipboard = state.m_dragClipboard.get(); |
| 734 if (state.m_dragType == DragSourceActionDHTML) | 737 if (state.m_dragType == DragSourceActionDHTML) |
| 735 dragImage = clipboard->createDragImage(dragImageOffset); | 738 dragImage = clipboard->createDragImage(dragImageOffset); |
| 736 if (state.m_dragType == DragSourceActionSelection || !imageURL.isEmpty() ||
!linkURL.isEmpty()) | 739 if (state.m_dragType == DragSourceActionSelection || !imageURL.isEmpty() ||
!linkURL.isEmpty()) |
| 737 // Selection, image, and link drags receive a default set of allowed dra
g operations that | 740 // Selection, image, and link drags receive a default set of allowed dra
g operations that |
| 738 // follows from: | 741 // follows from: |
| 739 // http://trac.webkit.org/browser/trunk/WebKit/mac/WebView/WebHTMLView.m
m?rev=48526#L3430 | 742 // http://trac.webkit.org/browser/trunk/WebKit/mac/WebView/WebHTMLView.m
m?rev=48526#L3430 |
| 740 m_sourceDragOperation = static_cast<DragOperation>(m_sourceDragOperation
| DragOperationGeneric | DragOperationCopy); | 743 m_sourceDragOperation = static_cast<DragOperation>(m_sourceDragOperation
| DragOperationGeneric | DragOperationCopy); |
| 741 | 744 |
| 742 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. | 745 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. |
| 743 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. | 746 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. |
| 744 if (dragImage) { | 747 if (dragImage) { |
| 745 dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOf
fset, !linkURL.isEmpty()); | 748 dragLoc = dragLocForDHTMLDrag(mouseDraggedPoint, dragOrigin, dragImageOf
fset, !linkURL.isEmpty()); |
| 746 m_dragOffset = dragImageOffset; | 749 m_dragOffset = dragImageOffset; |
| 747 } | 750 } |
| 748 | 751 |
| 749 bool startedDrag = true; // optimism - we almost always manage to start the
drag | 752 bool startedDrag = true; // optimism - we almost always manage to start the
drag |
| 750 | 753 |
| 751 Node* node = state.m_dragSrc.get(); | 754 Node* node = state.m_dragSrc.get(); |
| 752 | 755 |
| 753 Image* image = node->isElementNode() ? getImage(toElement(node)) : 0; | 756 Image* image = node->isElementNode() ? getImage(toElement(node)) : 0; |
| 754 if (state.m_dragType == DragSourceActionSelection) { | 757 if (state.m_dragType == DragSourceActionSelection) { |
| 755 if (!clipboard->hasData()) { | 758 if (!clipboard->hasData()) { |
| 756 if (enclosingTextFormControl(src->selection()->start())) | 759 if (enclosingTextFormControl(src->selection()->start())) { |
| 757 clipboard->writePlainText(src->editor()->selectedTextForClipboar
d()); | 760 clipboard->writePlainText(src->editor()->selectedTextForClipboar
d()); |
| 758 else { | 761 } else { |
| 759 RefPtr<Range> selectionRange = src->selection()->toNormalizedRan
ge(); | 762 RefPtr<Range> selectionRange = src->selection()->toNormalizedRan
ge(); |
| 760 ASSERT(selectionRange); | 763 ASSERT(selectionRange); |
| 761 | 764 |
| 762 clipboard->writeRange(selectionRange.get(), src); | 765 clipboard->writeRange(selectionRange.get(), src); |
| 763 } | 766 } |
| 764 } | 767 } |
| 765 if (!dragImage) { | 768 if (!dragImage) { |
| 766 dragImage = createDragImageForSelection(src->dragImageForSelection()
, DragImageAlpha); | 769 dragImage = src->dragImageForSelection(); |
| 770 if (dragImage) |
| 771 dragImage->dissolveToFraction(DragImageAlpha); |
| 767 dragLoc = dragLocForSelectionDrag(src); | 772 dragLoc = dragLocForSelectionDrag(src); |
| 768 m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y()
- dragLoc.y()); | 773 m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y()
- dragLoc.y()); |
| 769 } | 774 } |
| 770 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); | 775 doSystemDrag(dragImage.get(), dragLoc, dragOrigin, clipboard, src, false
); |
| 771 } else if (!imageURL.isEmpty() && node && node->isElementNode() && image &&
!image->isNull() | 776 } else if (!imageURL.isEmpty() && node && node->isElementNode() && image &&
!image->isNull() |
| 772 && (m_dragSourceAction & DragSourceActionImage)) { | 777 && (m_dragSourceAction & DragSourceActionImage)) { |
| 773 // We shouldn't be starting a drag for an image that can't provide an ex
tension. | 778 // We shouldn't be starting a drag for an image that can't provide an ex
tension. |
| 774 // This is an early detection for problems encountered later upon drop. | 779 // This is an early detection for problems encountered later upon drop. |
| 775 ASSERT(!image->filenameExtension().isEmpty()); | 780 ASSERT(!image->filenameExtension().isEmpty()); |
| 776 Element* element = toElement(node); | 781 Element* element = toElement(node); |
| 777 if (!clipboard->hasData()) { | 782 if (!clipboard->hasData()) { |
| 778 m_draggingImageURL = imageURL; | 783 m_draggingImageURL = imageURL; |
| 779 prepareClipboardForImageDrag(src, clipboard, element, linkURL, image
URL, hitTestResult.altDisplayString()); | 784 prepareClipboardForImageDrag(src, clipboard, element, linkURL, image
URL, hitTestResult.altDisplayString()); |
| 780 } | 785 } |
| 781 | 786 |
| 782 if (!dragImage) { | 787 if (!dragImage) { |
| 783 IntRect imageRect = hitTestResult.imageRect(); | 788 IntRect imageRect = hitTestResult.imageRect(); |
| 784 imageRect.setLocation(m_page->mainFrame()->view()->rootViewToContent
s(src->view()->contentsToRootView(imageRect.location()))); | 789 imageRect.setLocation(m_page->mainFrame()->view()->rootViewToContent
s(src->view()->contentsToRootView(imageRect.location()))); |
| 785 doImageDrag(element, dragOrigin, hitTestResult.imageRect(), clipboar
d, src, m_dragOffset); | 790 doImageDrag(element, dragOrigin, hitTestResult.imageRect(), clipboar
d, src, m_dragOffset); |
| 786 } else | 791 } else { |
| 787 // DHTML defined drag image | 792 // DHTML defined drag image |
| 788 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); | 793 doSystemDrag(dragImage.get(), dragLoc, dragOrigin, clipboard, src, f
alse); |
| 789 | 794 } |
| 790 } else if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)
) { | 795 } else if (!linkURL.isEmpty() && (m_dragSourceAction & DragSourceActionLink)
) { |
| 791 if (!clipboard->hasData()) | 796 if (!clipboard->hasData()) |
| 792 // Simplify whitespace so the title put on the clipboard resembles w
hat the user sees | 797 // Simplify whitespace so the title put on the clipboard resembles w
hat the user sees |
| 793 // on the web page. This includes replacing newlines with spaces. | 798 // on the web page. This includes replacing newlines with spaces. |
| 794 clipboard->writeURL(linkURL, hitTestResult.textContent().simplifyWhi
teSpace(), src); | 799 clipboard->writeURL(linkURL, hitTestResult.textContent().simplifyWhi
teSpace(), src); |
| 795 | 800 |
| 796 if (src->selection()->isCaret() && src->selection()->isContentEditable()
) { | 801 if (src->selection()->isCaret() && src->selection()->isContentEditable()
) { |
| 797 // a user can initiate a drag on a link without having any text | 802 // a user can initiate a drag on a link without having any text |
| 798 // selected. In this case, we should expand the selection to | 803 // selected. In this case, we should expand the selection to |
| 799 // the enclosing anchor element | 804 // the enclosing anchor element |
| 800 Position pos = src->selection()->base(); | 805 Position pos = src->selection()->base(); |
| 801 Node* node = enclosingAnchorElement(pos); | 806 Node* node = enclosingAnchorElement(pos); |
| 802 if (node) | 807 if (node) |
| 803 src->selection()->setSelection(VisibleSelection::selectionFromCo
ntentsOfNode(node)); | 808 src->selection()->setSelection(VisibleSelection::selectionFromCo
ntentsOfNode(node)); |
| 804 } | 809 } |
| 805 | 810 |
| 806 if (!dragImage) { | 811 if (!dragImage) { |
| 807 FontDescription fontDescription; | 812 FontDescription fontDescription; |
| 808 RenderTheme::defaultTheme()->systemFont(WebCore::CSSValueNone, fontD
escription); | 813 RenderTheme::defaultTheme()->systemFont(WebCore::CSSValueNone, fontD
escription); |
| 809 float deviceScaleFactor = src->page() ? src->page()->deviceScaleFact
or() : 1; | 814 float deviceScaleFactor = src->page() ? src->page()->deviceScaleFact
or() : 1; |
| 810 dragImage = createDragImageForLink(linkURL, hitTestResult.textConten
t(), fontDescription, deviceScaleFactor); | 815 dragImage = DragImage::create(linkURL, hitTestResult.textContent(),
fontDescription, deviceScaleFactor); |
| 811 IntSize size = dragImageSize(dragImage); | 816 IntSize size = dragImage ? dragImage->size() : IntSize(); |
| 812 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); | 817 m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset); |
| 813 dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDr
aggedPoint.y() + m_dragOffset.y()); | 818 dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDr
aggedPoint.y() + m_dragOffset.y()); |
| 814 } | 819 } |
| 815 doSystemDrag(dragImage, dragLoc, mouseDraggedPoint, clipboard, src, true
); | 820 doSystemDrag(dragImage.get(), dragLoc, mouseDraggedPoint, clipboard, src
, true); |
| 816 } else if (state.m_dragType == DragSourceActionDHTML) { | 821 } else if (state.m_dragType == DragSourceActionDHTML) { |
| 817 if (dragImage) { | 822 if (dragImage) { |
| 818 ASSERT(m_dragSourceAction & DragSourceActionDHTML); | 823 ASSERT(m_dragSourceAction & DragSourceActionDHTML); |
| 819 doSystemDrag(dragImage, dragLoc, dragOrigin, clipboard, src, false); | 824 doSystemDrag(dragImage.get(), dragLoc, dragOrigin, clipboard, src, f
alse); |
| 820 } else { | 825 } else { |
| 821 startedDrag = false; | 826 startedDrag = false; |
| 822 } | 827 } |
| 823 } else { | 828 } else { |
| 824 // draggableNode() determined an image or link node was draggable, but i
t turns out the | 829 // draggableNode() determined an image or link node was draggable, but i
t turns out the |
| 825 // image or link had no URL, so there is nothing to drag. | 830 // image or link had no URL, so there is nothing to drag. |
| 826 startedDrag = false; | 831 startedDrag = false; |
| 827 } | 832 } |
| 828 | 833 |
| 829 if (dragImage) | |
| 830 deleteDragImage(dragImage); | |
| 831 return startedDrag; | 834 return startedDrag; |
| 832 } | 835 } |
| 833 | 836 |
| 834 void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, c
onst IntRect& rect, Clipboard* clipboard, Frame* frame, IntPoint& dragImageOffse
t) | 837 void DragController::doImageDrag(Element* element, const IntPoint& dragOrigin, c
onst IntRect& rect, Clipboard* clipboard, Frame* frame, IntPoint& dragImageOffse
t) |
| 835 { | 838 { |
| 836 IntPoint mouseDownPoint = dragOrigin; | 839 IntPoint mouseDownPoint = dragOrigin; |
| 837 DragImageRef dragImage; | 840 OwnPtr<DragImage> dragImage; |
| 838 IntPoint origin; | 841 IntPoint origin; |
| 839 | 842 |
| 840 Image* image = getImage(element); | 843 Image* image = getImage(element); |
| 841 if (image && image->size().height() * image->size().width() <= MaxOriginalIm
ageArea | 844 if (image && image->size().height() * image->size().width() <= MaxOriginalIm
ageArea |
| 842 && (dragImage = createDragImageFromImage(image, element->renderer() ? el
ement->renderer()->shouldRespectImageOrientation() : DoNotRespectImageOrientatio
n))) { | 845 && (dragImage = DragImage::create(image, element->renderer() ? element->
renderer()->shouldRespectImageOrientation() : DoNotRespectImageOrientation))) { |
| 843 IntSize originalSize = rect.size(); | 846 IntSize originalSize = rect.size(); |
| 844 origin = rect.location(); | 847 origin = rect.location(); |
| 845 | 848 |
| 846 dragImage = fitDragImageToMaxSize(dragImage, rect.size(), maxDragImageSi
ze()); | 849 dragImage->fitToMaxSize(rect.size(), maxDragImageSize()); |
| 847 dragImage = dissolveDragImageToFraction(dragImage, DragImageAlpha); | 850 dragImage->dissolveToFraction(DragImageAlpha); |
| 848 IntSize newSize = dragImageSize(dragImage); | 851 IntSize newSize = dragImage->size(); |
| 849 | 852 |
| 850 // Properly orient the drag image and orient it differently if it's smal
ler than the original | 853 // Properly orient the drag image and orient it differently if it's smal
ler than the original |
| 851 float scale = newSize.width() / (float)originalSize.width(); | 854 float scale = newSize.width() / (float)originalSize.width(); |
| 852 float dx = origin.x() - mouseDownPoint.x(); | 855 float dx = origin.x() - mouseDownPoint.x(); |
| 853 dx *= scale; | 856 dx *= scale; |
| 854 origin.setX((int)(dx + 0.5)); | 857 origin.setX((int)(dx + 0.5)); |
| 855 float dy = origin.y() - mouseDownPoint.y(); | 858 float dy = origin.y() - mouseDownPoint.y(); |
| 856 dy *= scale; | 859 dy *= scale; |
| 857 origin.setY((int)(dy + 0.5)); | 860 origin.setY((int)(dy + 0.5)); |
| 858 } else { | |
| 859 dragImage = createDragImageIconForCachedImage(getCachedImage(element)); | |
| 860 if (dragImage) | |
| 861 origin = IntPoint(DragIconRightInset - dragImageSize(dragImage).widt
h(), DragIconBottomInset); | |
| 862 } | 861 } |
| 863 | 862 |
| 864 dragImageOffset = mouseDownPoint + origin; | 863 dragImageOffset = mouseDownPoint + origin; |
| 865 doSystemDrag(dragImage, dragImageOffset, dragOrigin, clipboard, frame, false
); | 864 doSystemDrag(dragImage.get(), dragImageOffset, dragOrigin, clipboard, frame,
false); |
| 866 | |
| 867 deleteDragImage(dragImage); | |
| 868 } | 865 } |
| 869 | 866 |
| 870 void DragController::doSystemDrag(DragImageRef image, const IntPoint& dragLoc, c
onst IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool forLink) | 867 void DragController::doSystemDrag(DragImage* image, const IntPoint& dragLoc, con
st IntPoint& eventPos, Clipboard* clipboard, Frame* frame, bool forLink) |
| 871 { | 868 { |
| 872 m_didInitiateDrag = true; | 869 m_didInitiateDrag = true; |
| 873 m_dragInitiator = frame->document(); | 870 m_dragInitiator = frame->document(); |
| 874 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame | 871 // Protect this frame and view, as a load may occur mid drag and attempt to
unload this frame |
| 875 RefPtr<Frame> frameProtector = m_page->mainFrame(); | 872 RefPtr<Frame> frameProtector = m_page->mainFrame(); |
| 876 RefPtr<FrameView> viewProtector = frameProtector->view(); | 873 RefPtr<FrameView> viewProtector = frameProtector->view(); |
| 877 m_client->startDrag(image, viewProtector->rootViewToContents(frame->view()->
contentsToRootView(dragLoc)), | 874 m_client->startDrag(image, viewProtector->rootViewToContents(frame->view()->
contentsToRootView(dragLoc)), |
| 878 viewProtector->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), clipboard, frameProtector.get(), forLink); | 875 viewProtector->rootViewToContents(frame->view()->contentsToRootView(even
tPos)), clipboard, frameProtector.get(), forLink); |
| 879 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. | 876 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. |
| 880 if (!frameProtector->page()) | 877 if (!frameProtector->page()) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 #endif | 925 #endif |
| 929 return maxDragImageSize; | 926 return maxDragImageSize; |
| 930 } | 927 } |
| 931 | 928 |
| 932 void DragController::cleanupAfterSystemDrag() | 929 void DragController::cleanupAfterSystemDrag() |
| 933 { | 930 { |
| 934 } | 931 } |
| 935 | 932 |
| 936 } // namespace WebCore | 933 } // namespace WebCore |
| 937 | 934 |
| OLD | NEW |