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