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

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

Issue 2940583002: Move drag related functionality out of LocalFrame (Closed)
Patch Set: updatedPS Created 3 years, 6 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..d1f4791f7087bd1d8645262ff1a32f743b1d3572 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(
+ const LocalFrame& src,
+ 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::CreateDragImageForFrame(
+ 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 = DragImageForSelection(*src, kDragImageAlpha);
drag_location = DragLocationForSelectionDrag(src);
}
DoSystemDrag(drag_image.get(), drag_location, drag_origin, data_transfer,
« no previous file with comments | « third_party/WebKit/Source/core/page/DragController.h ('k') | third_party/WebKit/Source/core/page/DragControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698