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 fafb0d48a3b7a0f4dfefcf1e76748a2d8b6d83c7..379db84c8ca86558b67bbaaa346f7290f5745d84 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,28 @@ static std::unique_ptr<DragImage> DragImageForLink( |
return drag_image; |
} |
+std::unique_ptr<DragImage> DragController::DragImageForSelection( |
+ LocalFrame* src, |
Xiaocheng
2017/06/02 18:26:47
Can we pass a |const LocalFrame&| parameter?
|
+ float opacity) { |
+ if (!src->Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) |
+ return nullptr; |
+ |
+ src->View()->UpdateAllLifecyclePhasesExceptPaint(); |
+ DCHECK(src->GetDocument()->IsActive()); |
+ |
+ FloatRect painting_rect = FloatRect(src->Selection().Bounds()); |
+ GlobalPaintFlags paint_flags = |
+ kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; |
+ |
+ PaintRecordBuilder builder( |
+ DataTransfer::DeviceSpaceBounds(painting_rect, *src)); |
+ src->View()->PaintContents(builder.Context(), paint_flags, |
+ EnclosingIntRect(painting_rect)); |
+ return DataTransfer::CreateDragImage( |
+ *src, opacity, kDoNotRespectImageOrientation, painting_rect, builder, |
+ PropertyTreeState::Root()); |
+} |
+ |
bool DragController::StartDrag(LocalFrame* src, |
const DragState& state, |
const WebMouseEvent& drag_event, |
@@ -1124,7 +1147,7 @@ bool DragController::StartDrag(LocalFrame* src, |
Node* node = state.drag_src_.Get(); |
if (state.drag_type_ == kDragSourceActionSelection) { |
if (!drag_image) { |
- drag_image = src->DragImageForSelection(kDragImageAlpha); |
+ drag_image = DragController::DragImageForSelection(src, kDragImageAlpha); |
Xiaocheng
2017/06/02 18:26:47
nit: Remove |DragController|
|
drag_location = DragLocationForSelectionDrag(src); |
} |
DoSystemDrag(drag_image.get(), drag_location, drag_origin, data_transfer, |