Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: Source/WebKit/chromium/src/DragClientImpl.cpp

Issue 16715002: Refactor WebCore::DragImage. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: merge upstream changes, some changes per jamesr Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "DragClientImpl.h" 32 #include "DragClientImpl.h"
33 #include "WebViewClient.h" 33 #include "WebViewClient.h"
34 #include "WebViewImpl.h" 34 #include "WebViewImpl.h"
35 #include "core/page/Frame.h" 35 #include "core/page/Frame.h"
36 #include "core/platform/DragImage.h"
36 #include "core/platform/chromium/ChromiumDataObject.h" 37 #include "core/platform/chromium/ChromiumDataObject.h"
37 #include "core/platform/chromium/ClipboardChromium.h" 38 #include "core/platform/chromium/ClipboardChromium.h"
38 #include "core/platform/chromium/DragImageRef.h" 39 #include "core/platform/graphics/IntSize.h"
39 #include "core/platform/graphics/skia/NativeImageSkia.h" 40 #include "core/platform/graphics/skia/NativeImageSkia.h"
40 #include "public/platform/WebCommon.h" 41 #include "public/platform/WebCommon.h"
41 #include "public/platform/WebDragData.h" 42 #include "public/platform/WebDragData.h"
42 #include "public/platform/WebImage.h" 43 #include "public/platform/WebImage.h"
44 #include "public/platform/WebPoint.h"
45 #include "public/web/WebDragOperation.h"
46 #include "wtf/Assertions.h"
47 #include "wtf/RefPtr.h"
43 48
44 using namespace WebCore; 49 using namespace WebCore;
45 50
46 namespace WebKit { 51 namespace WebKit {
47 52
48 DragDestinationAction DragClientImpl::actionMaskForDrag(DragData*) 53 DragDestinationAction DragClientImpl::actionMaskForDrag(DragData*)
49 { 54 {
50 if (m_webView->client() && m_webView->client()->acceptsLoadDrops()) 55 if (m_webView->client() && m_webView->client()->acceptsLoadDrops())
51 return DragDestinationActionAny; 56 return DragDestinationActionAny;
52 57
53 return static_cast<DragDestinationAction>( 58 return static_cast<DragDestinationAction>(
54 DragDestinationActionDHTML | DragDestinationActionEdit); 59 DragDestinationActionDHTML | DragDestinationActionEdit);
55 } 60 }
56 61
57 void DragClientImpl::startDrag(DragImageRef dragImage, 62 void DragClientImpl::startDrag(DragImage* dragImage,
58 const IntPoint& dragImageOrigin, 63 const IntPoint& dragImageOrigin,
59 const IntPoint& eventPos, 64 const IntPoint& eventPos,
60 Clipboard* clipboard, 65 Clipboard* clipboard,
61 Frame* frame, 66 Frame* frame,
62 bool isLinkDrag) 67 bool isLinkDrag)
63 { 68 {
64 // Add a ref to the frame just in case a load occurs mid-drag. 69 // Add a ref to the frame just in case a load occurs mid-drag.
65 RefPtr<Frame> frameProtector = frame; 70 RefPtr<Frame> frameProtector = frame;
66 71
67 WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObjec t(); 72 WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObjec t();
68 73 WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask> (clipboard->sourceOperation());
69 DragOperation dragOperationMask = clipboard->sourceOperation(); 74 WebImage image;
70
71 IntSize offsetSize(eventPos - dragImageOrigin); 75 IntSize offsetSize(eventPos - dragImageOrigin);
72 WebPoint offsetPoint(offsetSize.width(), offsetSize.height()); 76 WebPoint offsetPoint(offsetSize.width(), offsetSize.height());
73 77
74 if (dragImage && dragImage->bitmap && m_webView->deviceScaleFactor() != drag Image->resolutionScale) { 78 if (dragImage) {
75 ASSERT(dragImage->resolutionScale > 0); 79 float resolutionScale = dragImage->resolutionScale();
76 float scale = m_webView->deviceScaleFactor() / dragImage->resolutionScal e; 80 if (m_webView->deviceScaleFactor() != resolutionScale) {
77 dragImage = scaleDragImage(dragImage, WebCore::FloatSize(scale, scale)); 81 ASSERT(resolutionScale > 0);
82 float scale = m_webView->deviceScaleFactor() / resolutionScale;
83 dragImage->scale(scale, scale);
84 }
85 image = dragImage->bitmap();
78 } 86 }
79 m_webView->startDragging(frame, dragData, static_cast<WebDragOperationsMask> (dragOperationMask), (dragImage && dragImage->bitmap) ? WebImage(*dragImage->bit map) : WebImage(), offsetPoint); 87
88 m_webView->startDragging(frame, dragData, dragOperationMask, image, offsetPo int);
80 } 89 }
81 90
82 } // namespace WebKit 91 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/DragClientImpl.h ('k') | Source/WebKit/chromium/tests/DragImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698