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