Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: Source/core/page/DragController.cpp

Issue 1290133002: SkImage-ify DragImage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: expectations Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/LocalFrame.cpp ('k') | Source/platform/DragImage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 return maxDragImageSize; 793 return maxDragImageSize;
794 } 794 }
795 795
796 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, c onst IntPoint& dragOrigin, const IntRect& imageRect, IntPoint& dragLocation) 796 static PassOwnPtr<DragImage> dragImageForImage(Element* element, Image* image, c onst IntPoint& dragOrigin, const IntRect& imageRect, IntPoint& dragLocation)
797 { 797 {
798 OwnPtr<DragImage> dragImage; 798 OwnPtr<DragImage> dragImage;
799 IntPoint origin; 799 IntPoint origin;
800 800
801 InterpolationQuality interpolationQuality = element->ensureComputedStyle()-> imageRendering() == ImageRenderingPixelated ? InterpolationNone : InterpolationH igh; 801 InterpolationQuality interpolationQuality = element->ensureComputedStyle()-> imageRendering() == ImageRenderingPixelated ? InterpolationNone : InterpolationH igh;
802 if (image->size().height() * image->size().width() <= MaxOriginalImageArea 802 if (image->size().height() * image->size().width() <= MaxOriginalImageArea
803 && (dragImage = DragImage::create(image, element->layoutObject() ? eleme nt->layoutObject()->shouldRespectImageOrientation() : DoNotRespectImageOrientati on, 1 /* deviceScaleFactor */, interpolationQuality))) { 803 && (dragImage = DragImage::create(image,
804 element->layoutObject() ? element->layoutObject()->shouldRespectImag eOrientation() : DoNotRespectImageOrientation,
805 1 /* deviceScaleFactor */, interpolationQuality, DragImageAlpha,
806 DragImage::clampedImageScale(*image, imageRect.size(), maxDragImageS ize())))) {
804 IntSize originalSize = imageRect.size(); 807 IntSize originalSize = imageRect.size();
805 origin = imageRect.location(); 808 origin = imageRect.location();
806 809
807 dragImage->fitToMaxSize(imageRect.size(), maxDragImageSize());
808 dragImage->dissolveToFraction(DragImageAlpha);
809 IntSize newSize = dragImage->size(); 810 IntSize newSize = dragImage->size();
810 811
811 // Properly orient the drag image and orient it differently if it's smal ler than the original 812 // Properly orient the drag image and orient it differently if it's smal ler than the original
812 float scale = newSize.width() / (float)originalSize.width(); 813 float scale = newSize.width() / (float)originalSize.width();
813 float dx = origin.x() - dragOrigin.x(); 814 float dx = origin.x() - dragOrigin.x();
814 dx *= scale; 815 dx *= scale;
815 origin.setX((int)(dx + 0.5)); 816 origin.setX((int)(dx + 0.5));
816 float dy = origin.y() - dragOrigin.y(); 817 float dy = origin.y() - dragOrigin.y();
817 dy *= scale; 818 dy *= scale;
818 origin.setY((int)(dy + 0.5)); 819 origin.setY((int)(dy + 0.5));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 // We allow DHTML/JS to set the drag image, even if its a link, image or tex t we're dragging. 862 // We allow DHTML/JS to set the drag image, even if its a link, image or tex t we're dragging.
862 // This is in the spirit of the IE API, which allows overriding of pasteboar d data and DragOp. 863 // This is in the spirit of the IE API, which allows overriding of pasteboar d data and DragOp.
863 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src) ; 864 OwnPtr<DragImage> dragImage = dataTransfer->createDragImage(dragOffset, src) ;
864 if (dragImage) { 865 if (dragImage) {
865 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d ragOffset, !linkURL.isEmpty()); 866 dragLocation = dragLocationForDHTMLDrag(mouseDraggedPoint, dragOrigin, d ragOffset, !linkURL.isEmpty());
866 } 867 }
867 868
868 Node* node = state.m_dragSrc.get(); 869 Node* node = state.m_dragSrc.get();
869 if (state.m_dragType == DragSourceActionSelection) { 870 if (state.m_dragType == DragSourceActionSelection) {
870 if (!dragImage) { 871 if (!dragImage) {
871 dragImage = src->dragImageForSelection(); 872 dragImage = src->dragImageForSelection(DragImageAlpha);
872 if (dragImage)
873 dragImage->dissolveToFraction(DragImageAlpha);
874 dragLocation = dragLocationForSelectionDrag(src); 873 dragLocation = dragLocationForSelectionDrag(src);
875 } 874 }
876 doSystemDrag(dragImage.get(), dragLocation, dragOrigin, dataTransfer, sr c, false); 875 doSystemDrag(dragImage.get(), dragLocation, dragOrigin, dataTransfer, sr c, false);
877 } else if (state.m_dragType == DragSourceActionImage) { 876 } else if (state.m_dragType == DragSourceActionImage) {
878 if (imageURL.isEmpty() || !node || !node->isElementNode()) 877 if (imageURL.isEmpty() || !node || !node->isElementNode())
879 return false; 878 return false;
880 Element* element = toElement(node); 879 Element* element = toElement(node);
881 Image* image = getImage(element); 880 Image* image = getImage(element);
882 if (!image || image->isNull()) 881 if (!image || image->isNull())
883 return false; 882 return false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 958
960 DEFINE_TRACE(DragController) 959 DEFINE_TRACE(DragController)
961 { 960 {
962 visitor->trace(m_page); 961 visitor->trace(m_page);
963 visitor->trace(m_documentUnderMouse); 962 visitor->trace(m_documentUnderMouse);
964 visitor->trace(m_dragInitiator); 963 visitor->trace(m_dragInitiator);
965 visitor->trace(m_fileInputElementUnderMouse); 964 visitor->trace(m_fileInputElementUnderMouse);
966 } 965 }
967 966
968 } // namespace blink 967 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalFrame.cpp ('k') | Source/platform/DragImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698