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

Unified Diff: third_party/WebKit/Source/core/page/DragController.cpp

Issue 2916043002: Move LocalFrame::DragImageForSelection DragController (Closed)
Patch Set: updated Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698