OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 { | 51 { |
52 if (m_webView->client() && m_webView->client()->acceptsLoadDrops()) | 52 if (m_webView->client() && m_webView->client()->acceptsLoadDrops()) |
53 return DragDestinationActionAny; | 53 return DragDestinationActionAny; |
54 | 54 |
55 return static_cast<DragDestinationAction>( | 55 return static_cast<DragDestinationAction>( |
56 DragDestinationActionDHTML | DragDestinationActionEdit); | 56 DragDestinationActionDHTML | DragDestinationActionEdit); |
57 } | 57 } |
58 | 58 |
59 void DragClientImpl::startDrag(DragImage* dragImage, const IntPoint& dragImageOr
igin, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, b
ool isLinkDrag) | 59 void DragClientImpl::startDrag(DragImage* dragImage, const IntPoint& dragImageOr
igin, const IntPoint& eventPos, DataTransfer* dataTransfer, LocalFrame* frame, b
ool isLinkDrag) |
60 { | 60 { |
61 // Add a ref to the frame just in case a load occurs mid-drag. | |
62 RawPtr<LocalFrame> frameProtector(frame); | |
63 | |
64 WebDragData dragData = dataTransfer->dataObject()->toWebDragData(); | 61 WebDragData dragData = dataTransfer->dataObject()->toWebDragData(); |
65 WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>
(dataTransfer->sourceOperation()); | 62 WebDragOperationsMask dragOperationMask = static_cast<WebDragOperationsMask>
(dataTransfer->sourceOperation()); |
66 WebImage image; | 63 WebImage image; |
67 IntSize offsetSize(eventPos - dragImageOrigin); | 64 IntSize offsetSize(eventPos - dragImageOrigin); |
68 WebPoint offsetPoint(offsetSize.width(), offsetSize.height()); | 65 WebPoint offsetPoint(offsetSize.width(), offsetSize.height()); |
69 | 66 |
70 if (dragImage) { | 67 if (dragImage) { |
71 float resolutionScale = dragImage->resolutionScale(); | 68 float resolutionScale = dragImage->resolutionScale(); |
72 float deviceScaleFactor = | 69 float deviceScaleFactor = |
73 m_webView->client()->screenInfo().deviceScaleFactor; | 70 m_webView->client()->screenInfo().deviceScaleFactor; |
74 if (deviceScaleFactor != resolutionScale) { | 71 if (deviceScaleFactor != resolutionScale) { |
75 DCHECK_GT(resolutionScale, 0); | 72 DCHECK_GT(resolutionScale, 0); |
76 float scale = deviceScaleFactor / resolutionScale; | 73 float scale = deviceScaleFactor / resolutionScale; |
77 dragImage->scale(scale, scale); | 74 dragImage->scale(scale, scale); |
78 } | 75 } |
79 image = dragImage->bitmap(); | 76 image = dragImage->bitmap(); |
80 } | 77 } |
81 | 78 |
82 m_webView->startDragging(frame, dragData, dragOperationMask, image, offsetPo
int); | 79 m_webView->startDragging(frame, dragData, dragOperationMask, image, offsetPo
int); |
83 } | 80 } |
84 | 81 |
85 } // namespace blink | 82 } // namespace blink |
OLD | NEW |