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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "core/page/DragClient.h" | 64 #include "core/page/DragClient.h" |
65 #include "core/page/DragData.h" | 65 #include "core/page/DragData.h" |
66 #include "core/page/DragSession.h" | 66 #include "core/page/DragSession.h" |
67 #include "core/page/DragState.h" | 67 #include "core/page/DragState.h" |
68 #include "core/page/Page.h" | 68 #include "core/page/Page.h" |
69 #include "core/layout/HitTestRequest.h" | 69 #include "core/layout/HitTestRequest.h" |
70 #include "core/layout/HitTestResult.h" | 70 #include "core/layout/HitTestResult.h" |
71 #include "core/layout/LayoutImage.h" | 71 #include "core/layout/LayoutImage.h" |
72 #include "platform/DragImage.h" | 72 #include "platform/DragImage.h" |
73 #include "platform/geometry/IntRect.h" | 73 #include "platform/geometry/IntRect.h" |
| 74 #include "platform/graphics/BitmapImage.h" |
74 #include "platform/graphics/Image.h" | 75 #include "platform/graphics/Image.h" |
75 #include "platform/graphics/ImageOrientation.h" | 76 #include "platform/graphics/ImageOrientation.h" |
76 #include "platform/network/ResourceRequest.h" | 77 #include "platform/network/ResourceRequest.h" |
77 #include "platform/weborigin/SecurityOrigin.h" | 78 #include "platform/weborigin/SecurityOrigin.h" |
78 #include "wtf/CurrentTime.h" | 79 #include "wtf/CurrentTime.h" |
79 #include "wtf/OwnPtr.h" | 80 #include "wtf/OwnPtr.h" |
80 #include "wtf/PassOwnPtr.h" | 81 #include "wtf/PassOwnPtr.h" |
81 #include "wtf/RefPtr.h" | 82 #include "wtf/RefPtr.h" |
82 | 83 |
83 #if OS(WIN) | 84 #if OS(WIN) |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 #endif | 793 #endif |
793 return maxDragImageSize; | 794 return maxDragImageSize; |
794 } | 795 } |
795 | 796 |
796 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, c
onst IntPoint& dragOrigin, const IntRect& imageRect, IntPoint& dragLocation) | 797 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, c
onst IntPoint& dragOrigin, const IntRect& imageRect, IntPoint& dragLocation) |
797 { | 798 { |
798 OwnPtr<DragImage> dragImage; | 799 OwnPtr<DragImage> dragImage; |
799 IntPoint origin; | 800 IntPoint origin; |
800 | 801 |
801 InterpolationQuality interpolationQuality = element->ensureComputedStyle()->
imageRendering() == ImageRenderingPixelated ? InterpolationNone : InterpolationH
igh; | 802 InterpolationQuality interpolationQuality = element->ensureComputedStyle()->
imageRendering() == ImageRenderingPixelated ? InterpolationNone : InterpolationH
igh; |
| 803 RespectImageOrientationEnum shouldRespectImageOrientation = element->layoutO
bject() ? element->layoutObject()->shouldRespectImageOrientation() : DoNotRespec
tImageOrientation; |
| 804 ImageOrientation orientation; |
| 805 |
| 806 if (shouldRespectImageOrientation == RespectImageOrientation && image->isBit
mapImage()) |
| 807 orientation = toBitmapImage(image)->currentFrameOrientation(); |
| 808 |
802 if (image->size().height() * image->size().width() <= MaxOriginalImageArea | 809 if (image->size().height() * image->size().width() <= MaxOriginalImageArea |
803 && (dragImage = DragImage::create(image, | 810 && (dragImage = DragImage::create(image, shouldRespectImageOrientation, |
804 element->layoutObject() ? element->layoutObject()->shouldRespectImag
eOrientation() : DoNotRespectImageOrientation, | |
805 1 /* deviceScaleFactor */, interpolationQuality, DragImageAlpha, | 811 1 /* deviceScaleFactor */, interpolationQuality, DragImageAlpha, |
806 DragImage::clampedImageScale(*image, imageRect.size(), maxDragImageS
ize())))) { | 812 DragImage::clampedImageScale(orientation.usesWidthAsHeight() ? image
->size().transposedSize() : image->size(), imageRect.size(), maxDragImageSize())
))) { |
807 IntSize originalSize = imageRect.size(); | 813 IntSize originalSize = imageRect.size(); |
808 origin = imageRect.location(); | 814 origin = imageRect.location(); |
809 | 815 |
810 IntSize newSize = dragImage->size(); | 816 IntSize newSize = dragImage->size(); |
811 | 817 |
812 // Properly orient the drag image and orient it differently if it's smal
ler than the original | 818 // Properly orient the drag image and orient it differently if it's smal
ler than the original |
813 float scale = newSize.width() / (float)originalSize.width(); | 819 float scale = newSize.width() / (float)originalSize.width(); |
814 float dx = origin.x() - dragOrigin.x(); | 820 float dx = origin.x() - dragOrigin.x(); |
815 dx *= scale; | 821 dx *= scale; |
816 origin.setX((int)(dx + 0.5)); | 822 origin.setX((int)(dx + 0.5)); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 964 |
959 DEFINE_TRACE(DragController) | 965 DEFINE_TRACE(DragController) |
960 { | 966 { |
961 visitor->trace(m_page); | 967 visitor->trace(m_page); |
962 visitor->trace(m_documentUnderMouse); | 968 visitor->trace(m_documentUnderMouse); |
963 visitor->trace(m_dragInitiator); | 969 visitor->trace(m_dragInitiator); |
964 visitor->trace(m_fileInputElementUnderMouse); | 970 visitor->trace(m_fileInputElementUnderMouse); |
965 } | 971 } |
966 | 972 |
967 } // namespace blink | 973 } // namespace blink |
OLD | NEW |