| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #include "platform/network/ResourceRequest.h" | 76 #include "platform/network/ResourceRequest.h" |
| 77 #include "platform/weborigin/SecurityOrigin.h" | 77 #include "platform/weborigin/SecurityOrigin.h" |
| 78 #include "public/platform/WebCommon.h" | 78 #include "public/platform/WebCommon.h" |
| 79 #include "public/platform/WebDragData.h" | 79 #include "public/platform/WebDragData.h" |
| 80 #include "public/platform/WebDragOperation.h" | 80 #include "public/platform/WebDragOperation.h" |
| 81 #include "public/platform/WebImage.h" | 81 #include "public/platform/WebImage.h" |
| 82 #include "public/platform/WebPoint.h" | 82 #include "public/platform/WebPoint.h" |
| 83 #include "public/platform/WebScreenInfo.h" | 83 #include "public/platform/WebScreenInfo.h" |
| 84 #include "wtf/Assertions.h" | 84 #include "wtf/Assertions.h" |
| 85 #include "wtf/CurrentTime.h" | 85 #include "wtf/CurrentTime.h" |
| 86 #include "wtf/OwnPtr.h" | |
| 87 #include "wtf/PassOwnPtr.h" | |
| 88 #include "wtf/RefPtr.h" | 86 #include "wtf/RefPtr.h" |
| 87 #include <memory> |
| 89 | 88 |
| 90 #if OS(WIN) | 89 #if OS(WIN) |
| 91 #include <windows.h> | 90 #include <windows.h> |
| 92 #endif | 91 #endif |
| 93 | 92 |
| 94 namespace blink { | 93 namespace blink { |
| 95 | 94 |
| 96 const int DragController::DragIconRightInset = 7; | 95 const int DragController::DragIconRightInset = 7; |
| 97 const int DragController::DragIconBottomInset = 3; | 96 const int DragController::DragIconBottomInset = 3; |
| 98 | 97 |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 // Match Safari's drag image size. | 795 // Match Safari's drag image size. |
| 797 static const IntSize maxDragImageSize(400, 400); | 796 static const IntSize maxDragImageSize(400, 400); |
| 798 #else | 797 #else |
| 799 static const IntSize maxDragImageSize(200, 200); | 798 static const IntSize maxDragImageSize(200, 200); |
| 800 #endif | 799 #endif |
| 801 IntSize maxSizeInPixels = maxDragImageSize; | 800 IntSize maxSizeInPixels = maxDragImageSize; |
| 802 maxSizeInPixels.scale(deviceScaleFactor); | 801 maxSizeInPixels.scale(deviceScaleFactor); |
| 803 return maxSizeInPixels; | 802 return maxSizeInPixels; |
| 804 } | 803 } |
| 805 | 804 |
| 806 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, f
loat deviceScaleFactor, const IntPoint& dragOrigin, const IntPoint& imageElement
Location, const IntSize& imageElementSizeInPixels, IntPoint& dragLocation) | 805 static std::unique_ptr<DragImage> dragImageForImage(Element* element, Image* ima
ge, float deviceScaleFactor, const IntPoint& dragOrigin, const IntPoint& imageEl
ementLocation, const IntSize& imageElementSizeInPixels, IntPoint& dragLocation) |
| 807 { | 806 { |
| 808 OwnPtr<DragImage> dragImage; | 807 std::unique_ptr<DragImage> dragImage; |
| 809 IntPoint origin; | 808 IntPoint origin; |
| 810 | 809 |
| 811 InterpolationQuality interpolationQuality = element->ensureComputedStyle()->
imageRendering() == ImageRenderingPixelated ? InterpolationNone : InterpolationH
igh; | 810 InterpolationQuality interpolationQuality = element->ensureComputedStyle()->
imageRendering() == ImageRenderingPixelated ? InterpolationNone : InterpolationH
igh; |
| 812 RespectImageOrientationEnum shouldRespectImageOrientation = LayoutObject::sh
ouldRespectImageOrientation(element->layoutObject()); | 811 RespectImageOrientationEnum shouldRespectImageOrientation = LayoutObject::sh
ouldRespectImageOrientation(element->layoutObject()); |
| 813 ImageOrientation orientation; | 812 ImageOrientation orientation; |
| 814 | 813 |
| 815 if (shouldRespectImageOrientation == RespectImageOrientation && image->isBit
mapImage()) | 814 if (shouldRespectImageOrientation == RespectImageOrientation && image->isBit
mapImage()) |
| 816 orientation = toBitmapImage(image)->currentFrameOrientation(); | 815 orientation = toBitmapImage(image)->currentFrameOrientation(); |
| 817 | 816 |
| 818 IntSize imageSize = orientation.usesWidthAsHeight() ? image->size().transpos
edSize() : image->size(); | 817 IntSize imageSize = orientation.usesWidthAsHeight() ? image->size().transpos
edSize() : image->size(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 834 origin.setX((int)(dx + 0.5)); | 833 origin.setX((int)(dx + 0.5)); |
| 835 float dy = origin.y() - dragOrigin.y(); | 834 float dy = origin.y() - dragOrigin.y(); |
| 836 dy *= scale; | 835 dy *= scale; |
| 837 origin.setY((int)(dy + 0.5)); | 836 origin.setY((int)(dy + 0.5)); |
| 838 } | 837 } |
| 839 | 838 |
| 840 dragLocation = dragOrigin + origin; | 839 dragLocation = dragOrigin + origin; |
| 841 return dragImage; | 840 return dragImage; |
| 842 } | 841 } |
| 843 | 842 |
| 844 static PassOwnPtr<DragImage> dragImageForLink(const KURL& linkURL, const String&
linkText, float deviceScaleFactor, const IntPoint& mouseDraggedPoint, IntPoint&
dragLoc) | 843 static std::unique_ptr<DragImage> dragImageForLink(const KURL& linkURL, const St
ring& linkText, float deviceScaleFactor, const IntPoint& mouseDraggedPoint, IntP
oint& dragLoc) |
| 845 { | 844 { |
| 846 FontDescription fontDescription; | 845 FontDescription fontDescription; |
| 847 LayoutTheme::theme().systemFont(blink::CSSValueNone, fontDescription); | 846 LayoutTheme::theme().systemFont(blink::CSSValueNone, fontDescription); |
| 848 OwnPtr<DragImage> dragImage = DragImage::create(linkURL, linkText, fontDescr
iption, deviceScaleFactor); | 847 std::unique_ptr<DragImage> dragImage = DragImage::create(linkURL, linkText,
fontDescription, deviceScaleFactor); |
| 849 | 848 |
| 850 IntSize size = dragImage ? dragImage->size() : IntSize(); | 849 IntSize size = dragImage ? dragImage->size() : IntSize(); |
| 851 IntPoint dragImageOffset(-size.width() / 2, -LinkDragBorderInset); | 850 IntPoint dragImageOffset(-size.width() / 2, -LinkDragBorderInset); |
| 852 dragLoc = IntPoint(mouseDraggedPoint.x() + dragImageOffset.x(), mouseDragged
Point.y() + dragImageOffset.y()); | 851 dragLoc = IntPoint(mouseDraggedPoint.x() + dragImageOffset.x(), mouseDragged
Point.y() + dragImageOffset.y()); |
| 853 | 852 |
| 854 return dragImage; | 853 return dragImage; |
| 855 } | 854 } |
| 856 | 855 |
| 857 bool DragController::startDrag(LocalFrame* src, const DragState& state, const Pl
atformMouseEvent& dragEvent, const IntPoint& dragOrigin) | 856 bool DragController::startDrag(LocalFrame* src, const DragState& state, const Pl
atformMouseEvent& dragEvent, const IntPoint& dragOrigin) |
| 858 { | 857 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 872 const KURL& imageURL = hitTestResult.absoluteImageURL(); | 871 const KURL& imageURL = hitTestResult.absoluteImageURL(); |
| 873 | 872 |
| 874 IntPoint mouseDraggedPoint = src->view()->rootFrameToContents(dragEvent.posi
tion()); | 873 IntPoint mouseDraggedPoint = src->view()->rootFrameToContents(dragEvent.posi
tion()); |
| 875 | 874 |
| 876 IntPoint dragLocation; | 875 IntPoint dragLocation; |
| 877 IntPoint dragOffset; | 876 IntPoint dragOffset; |
| 878 | 877 |
| 879 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); | 878 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); |
| 880 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. | 879 // We allow DHTML/JS to set the drag image, even if its a link, image or tex
t we're dragging. |
| 881 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. | 880 // This is in the spirit of the IE API, which allows overriding of pasteboar
d data and DragOp. |
| 882 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src)
; | 881 std::unique_ptr<DragImage> dragImage = dataTransfer->createDragImage(dragOff
set, src); |
| 883 if (dragImage) { | 882 if (dragImage) { |
| 884 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d
ragOffset, !linkURL.isEmpty()); | 883 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d
ragOffset, !linkURL.isEmpty()); |
| 885 } | 884 } |
| 886 | 885 |
| 887 Node* node = state.m_dragSrc.get(); | 886 Node* node = state.m_dragSrc.get(); |
| 888 if (state.m_dragType == DragSourceActionSelection) { | 887 if (state.m_dragType == DragSourceActionSelection) { |
| 889 if (!dragImage) { | 888 if (!dragImage) { |
| 890 dragImage = src->dragImageForSelection(DragImageAlpha); | 889 dragImage = src->dragImageForSelection(DragImageAlpha); |
| 891 dragLocation = dragLocationForSelectionDrag(src); | 890 dragLocation = dragLocationForSelectionDrag(src); |
| 892 } | 891 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 | 998 |
| 1000 DEFINE_TRACE(DragController) | 999 DEFINE_TRACE(DragController) |
| 1001 { | 1000 { |
| 1002 visitor->trace(m_page); | 1001 visitor->trace(m_page); |
| 1003 visitor->trace(m_documentUnderMouse); | 1002 visitor->trace(m_documentUnderMouse); |
| 1004 visitor->trace(m_dragInitiator); | 1003 visitor->trace(m_dragInitiator); |
| 1005 visitor->trace(m_fileInputElementUnderMouse); | 1004 visitor->trace(m_fileInputElementUnderMouse); |
| 1006 } | 1005 } |
| 1007 | 1006 |
| 1008 } // namespace blink | 1007 } // namespace blink |
| OLD | NEW |