Index: third_party/WebKit/Source/core/page/DragController.cpp |
diff --git a/third_party/WebKit/Source/core/page/DragController.cpp b/third_party/WebKit/Source/core/page/DragController.cpp |
index f5b309f22885e32fba7350c4a339df37498dde52..06c544bed155ed543989635af499616f2a07917d 100644 |
--- a/third_party/WebKit/Source/core/page/DragController.cpp |
+++ b/third_party/WebKit/Source/core/page/DragController.cpp |
@@ -76,6 +76,7 @@ |
#include "platform/graphics/BitmapImage.h" |
#include "platform/graphics/Image.h" |
#include "platform/graphics/ImageOrientation.h" |
+#include "platform/graphics/paint/PaintRecordBuilder.h" |
#include "platform/loader/fetch/ResourceFetcher.h" |
#include "platform/loader/fetch/ResourceRequest.h" |
#include "platform/weborigin/SecurityOrigin.h" |
@@ -1080,6 +1081,29 @@ static std::unique_ptr<DragImage> DragImageForLink( |
return drag_image; |
} |
+// static |
+std::unique_ptr<DragImage> DragController::DragImageForSelection( |
+ const LocalFrame& frame, |
+ float opacity) { |
+ if (!frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) |
+ return nullptr; |
+ |
+ frame.View()->UpdateAllLifecyclePhasesExceptPaint(); |
+ DCHECK(frame.GetDocument()->IsActive()); |
+ |
+ FloatRect painting_rect = FloatRect(frame.Selection().Bounds()); |
+ GlobalPaintFlags paint_flags = |
+ kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; |
+ |
+ PaintRecordBuilder builder( |
+ DataTransfer::DeviceSpaceBounds(painting_rect, frame)); |
+ frame.View()->PaintContents(builder.Context(), paint_flags, |
+ EnclosingIntRect(painting_rect)); |
+ return DataTransfer::CreateDragImageForFrame( |
+ frame, opacity, kDoNotRespectImageOrientation, painting_rect, builder, |
+ PropertyTreeState::Root()); |
+} |
+ |
bool DragController::StartDrag(LocalFrame* src, |
const DragState& state, |
const WebMouseEvent& drag_event, |