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

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

Issue 2650403006: Remove PlatformMouseEvent and use WebMouseEvent instead (Closed)
Patch Set: Fix nits Created 3 years, 10 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
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return true; 111 return true;
112 case DragSourceActionNone: 112 case DragSourceActionNone:
113 return false; 113 return false;
114 } 114 }
115 // Make sure MSVC doesn't complain that not all control paths return a value. 115 // Make sure MSVC doesn't complain that not all control paths return a value.
116 NOTREACHED(); 116 NOTREACHED();
117 return false; 117 return false;
118 } 118 }
119 #endif // DCHECK_IS_ON() 119 #endif // DCHECK_IS_ON()
120 120
121 static PlatformMouseEvent createMouseEvent(DragData* dragData) { 121 static WebMouseEvent createMouseEvent(DragData* dragData) {
122 return PlatformMouseEvent( 122 WebMouseEvent result(
123 dragData->clientPosition(), dragData->globalPosition(), 123 WebInputEvent::MouseMove, WebFloatPoint(dragData->clientPosition().x(),
124 WebPointerProperties::Button::Left, PlatformEvent::MouseMoved, 0, 124 dragData->clientPosition().y()),
125 WebFloatPoint(dragData->globalPosition().x(),
126 dragData->globalPosition().y()),
127 WebPointerProperties::Button::Left, 0,
125 static_cast<PlatformEvent::Modifiers>(dragData->modifiers()), 128 static_cast<PlatformEvent::Modifiers>(dragData->modifiers()),
126 PlatformMouseEvent::RealOrIndistinguishable, TimeTicks::Now()); 129 TimeTicks::Now().InSeconds());
130 // TODO(dtapuska): Really we should chnage DragData to store the viewport
131 // coordinates and scale.
132 result.setFrameScale(1);
133 return result;
127 } 134 }
128 135
129 static DataTransfer* createDraggingDataTransfer(DataTransferAccessPolicy policy, 136 static DataTransfer* createDraggingDataTransfer(DataTransferAccessPolicy policy,
130 DragData* dragData) { 137 DragData* dragData) {
131 return DataTransfer::create(DataTransfer::DragAndDrop, policy, 138 return DataTransfer::create(DataTransfer::DragAndDrop, policy,
132 dragData->platformData()); 139 dragData->platformData());
133 } 140 }
134 141
135 DragController::DragController(Page* page) 142 DragController::DragController(Page* page)
136 : m_page(page), 143 : m_page(page),
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 DCHECK(dragData); 719 DCHECK(dragData);
713 DCHECK(m_documentUnderMouse); 720 DCHECK(m_documentUnderMouse);
714 if (!localRoot.view()) 721 if (!localRoot.view())
715 return false; 722 return false;
716 723
717 DataTransferAccessPolicy policy = DataTransferTypesReadable; 724 DataTransferAccessPolicy policy = DataTransferTypesReadable;
718 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData); 725 DataTransfer* dataTransfer = createDraggingDataTransfer(policy, dragData);
719 DragOperation srcOpMask = dragData->draggingSourceOperationMask(); 726 DragOperation srcOpMask = dragData->draggingSourceOperationMask();
720 dataTransfer->setSourceOperation(srcOpMask); 727 dataTransfer->setSourceOperation(srcOpMask);
721 728
722 PlatformMouseEvent event = createMouseEvent(dragData); 729 WebMouseEvent event = createMouseEvent(dragData);
723 if (localRoot.eventHandler().updateDragAndDrop(event, dataTransfer) == 730 if (localRoot.eventHandler().updateDragAndDrop(event, dataTransfer) ==
724 WebInputEventResult::NotHandled) { 731 WebInputEventResult::NotHandled) {
725 dataTransfer->setAccessPolicy( 732 dataTransfer->setAccessPolicy(
726 DataTransferNumb); // invalidate clipboard here for security 733 DataTransferNumb); // invalidate clipboard here for security
727 return false; 734 return false;
728 } 735 }
729 736
730 operation = dataTransfer->destinationOperation(); 737 operation = dataTransfer->destinationOperation();
731 if (dataTransfer->dropEffectIsUninitialized()) { 738 if (dataTransfer->dropEffectIsUninitialized()) {
732 operation = defaultOperationForDrag(srcOpMask); 739 operation = defaultOperationForDrag(srcOpMask);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 IntSize size = dragImage ? dragImage->size() : IntSize(); 1050 IntSize size = dragImage ? dragImage->size() : IntSize();
1044 IntPoint dragImageOffset(-size.width() / 2, -LinkDragBorderInset); 1051 IntPoint dragImageOffset(-size.width() / 2, -LinkDragBorderInset);
1045 dragLoc = IntPoint(mouseDraggedPoint.x() + dragImageOffset.x(), 1052 dragLoc = IntPoint(mouseDraggedPoint.x() + dragImageOffset.x(),
1046 mouseDraggedPoint.y() + dragImageOffset.y()); 1053 mouseDraggedPoint.y() + dragImageOffset.y());
1047 1054
1048 return dragImage; 1055 return dragImage;
1049 } 1056 }
1050 1057
1051 bool DragController::startDrag(LocalFrame* src, 1058 bool DragController::startDrag(LocalFrame* src,
1052 const DragState& state, 1059 const DragState& state,
1053 const PlatformMouseEvent& dragEvent, 1060 const WebMouseEvent& dragEvent,
1054 const IntPoint& dragOrigin) { 1061 const IntPoint& dragOrigin) {
1055 #if DCHECK_IS_ON() 1062 #if DCHECK_IS_ON()
1056 DCHECK(dragTypeIsValid(state.m_dragType)); 1063 DCHECK(dragTypeIsValid(state.m_dragType));
1057 #endif 1064 #endif
1058 DCHECK(src); 1065 DCHECK(src);
1059 if (!src->view() || src->contentLayoutItem().isNull()) 1066 if (!src->view() || src->contentLayoutItem().isNull())
1060 return false; 1067 return false;
1061 1068
1062 HitTestResult hitTestResult = 1069 HitTestResult hitTestResult =
1063 src->eventHandler().hitTestResultAtPoint(dragOrigin); 1070 src->eventHandler().hitTestResultAtPoint(dragOrigin);
1064 if (!state.m_dragSrc->isShadowIncludingInclusiveAncestorOf( 1071 if (!state.m_dragSrc->isShadowIncludingInclusiveAncestorOf(
1065 hitTestResult.innerNode())) { 1072 hitTestResult.innerNode())) {
1066 // The original node being dragged isn't under the drag origin anymore... 1073 // The original node being dragged isn't under the drag origin anymore...
1067 // maybe it was hidden or moved out from under the cursor. Regardless, we 1074 // maybe it was hidden or moved out from under the cursor. Regardless, we
1068 // don't want to start a drag on something that's not actually under the 1075 // don't want to start a drag on something that's not actually under the
1069 // drag origin. 1076 // drag origin.
1070 return false; 1077 return false;
1071 } 1078 }
1072 const KURL& linkURL = hitTestResult.absoluteLinkURL(); 1079 const KURL& linkURL = hitTestResult.absoluteLinkURL();
1073 const KURL& imageURL = hitTestResult.absoluteImageURL(); 1080 const KURL& imageURL = hitTestResult.absoluteImageURL();
1074 1081
1075 IntPoint mouseDraggedPoint = 1082 IntPoint mouseDraggedPoint = src->view()->rootFrameToContents(
1076 src->view()->rootFrameToContents(dragEvent.position()); 1083 flooredIntPoint(dragEvent.positionInRootFrame()));
1077 1084
1078 IntPoint dragLocation; 1085 IntPoint dragLocation;
1079 IntPoint dragOffset; 1086 IntPoint dragOffset;
1080 1087
1081 DataTransfer* dataTransfer = state.m_dragDataTransfer.get(); 1088 DataTransfer* dataTransfer = state.m_dragDataTransfer.get();
1082 // We allow DHTML/JS to set the drag image, even if its a link, image or text 1089 // We allow DHTML/JS to set the drag image, even if its a link, image or text
1083 // we're dragging. This is in the spirit of the IE API, which allows 1090 // we're dragging. This is in the spirit of the IE API, which allows
1084 // overriding of pasteboard data and DragOp. 1091 // overriding of pasteboard data and DragOp.
1085 std::unique_ptr<DragImage> dragImage = 1092 std::unique_ptr<DragImage> dragImage =
1086 dataTransfer->createDragImage(dragOffset, src); 1093 dataTransfer->createDragImage(dragOffset, src);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 } 1231 }
1225 1232
1226 DEFINE_TRACE(DragController) { 1233 DEFINE_TRACE(DragController) {
1227 visitor->trace(m_page); 1234 visitor->trace(m_page);
1228 visitor->trace(m_documentUnderMouse); 1235 visitor->trace(m_documentUnderMouse);
1229 visitor->trace(m_dragInitiator); 1236 visitor->trace(m_dragInitiator);
1230 visitor->trace(m_fileInputElementUnderMouse); 1237 visitor->trace(m_fileInputElementUnderMouse);
1231 } 1238 }
1232 1239
1233 } // namespace blink 1240 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/DragController.h ('k') | third_party/WebKit/Source/core/page/EventWithHitTestResults.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698