OLD | NEW |
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #include "core/page/DragState.h" | 69 #include "core/page/DragState.h" |
70 #include "core/page/Page.h" | 70 #include "core/page/Page.h" |
71 #include "core/svg/graphics/SVGImageForContainer.h" | 71 #include "core/svg/graphics/SVGImageForContainer.h" |
72 #include "platform/DragImage.h" | 72 #include "platform/DragImage.h" |
73 #include "platform/SharedBuffer.h" | 73 #include "platform/SharedBuffer.h" |
74 #include "platform/geometry/IntRect.h" | 74 #include "platform/geometry/IntRect.h" |
75 #include "platform/geometry/IntSize.h" | 75 #include "platform/geometry/IntSize.h" |
76 #include "platform/graphics/BitmapImage.h" | 76 #include "platform/graphics/BitmapImage.h" |
77 #include "platform/graphics/Image.h" | 77 #include "platform/graphics/Image.h" |
78 #include "platform/graphics/ImageOrientation.h" | 78 #include "platform/graphics/ImageOrientation.h" |
| 79 #include "platform/graphics/paint/PaintRecordBuilder.h" |
79 #include "platform/loader/fetch/ResourceFetcher.h" | 80 #include "platform/loader/fetch/ResourceFetcher.h" |
80 #include "platform/loader/fetch/ResourceRequest.h" | 81 #include "platform/loader/fetch/ResourceRequest.h" |
81 #include "platform/weborigin/SecurityOrigin.h" | 82 #include "platform/weborigin/SecurityOrigin.h" |
82 #include "platform/wtf/Assertions.h" | 83 #include "platform/wtf/Assertions.h" |
83 #include "platform/wtf/CurrentTime.h" | 84 #include "platform/wtf/CurrentTime.h" |
84 #include "platform/wtf/PassRefPtr.h" | 85 #include "platform/wtf/PassRefPtr.h" |
85 #include "platform/wtf/RefPtr.h" | 86 #include "platform/wtf/RefPtr.h" |
86 #include "public/platform/WebCommon.h" | 87 #include "public/platform/WebCommon.h" |
87 #include "public/platform/WebDragData.h" | 88 #include "public/platform/WebDragData.h" |
88 #include "public/platform/WebDragOperation.h" | 89 #include "public/platform/WebDragOperation.h" |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 link_url, link_text, font_description, device_scale_factor); | 1074 link_url, link_text, font_description, device_scale_factor); |
1074 | 1075 |
1075 IntSize size = drag_image ? drag_image->Size() : IntSize(); | 1076 IntSize size = drag_image ? drag_image->Size() : IntSize(); |
1076 IntPoint drag_image_offset(-size.Width() / 2, -kLinkDragBorderInset); | 1077 IntPoint drag_image_offset(-size.Width() / 2, -kLinkDragBorderInset); |
1077 drag_loc = IntPoint(mouse_dragged_point.X() + drag_image_offset.X(), | 1078 drag_loc = IntPoint(mouse_dragged_point.X() + drag_image_offset.X(), |
1078 mouse_dragged_point.Y() + drag_image_offset.Y()); | 1079 mouse_dragged_point.Y() + drag_image_offset.Y()); |
1079 | 1080 |
1080 return drag_image; | 1081 return drag_image; |
1081 } | 1082 } |
1082 | 1083 |
| 1084 std::unique_ptr<DragImage> DragController::DragImageForSelection( |
| 1085 const LocalFrame& src, |
| 1086 float opacity) { |
| 1087 if (!src.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) |
| 1088 return nullptr; |
| 1089 |
| 1090 src.View()->UpdateAllLifecyclePhasesExceptPaint(); |
| 1091 DCHECK(src.GetDocument()->IsActive()); |
| 1092 |
| 1093 FloatRect painting_rect = FloatRect(src.Selection().Bounds()); |
| 1094 GlobalPaintFlags paint_flags = |
| 1095 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; |
| 1096 |
| 1097 PaintRecordBuilder builder( |
| 1098 DataTransfer::DeviceSpaceBounds(painting_rect, src)); |
| 1099 src.View()->PaintContents(builder.Context(), paint_flags, |
| 1100 EnclosingIntRect(painting_rect)); |
| 1101 return DataTransfer::CreateDragImageForFrame( |
| 1102 src, opacity, kDoNotRespectImageOrientation, painting_rect, builder, |
| 1103 PropertyTreeState::Root()); |
| 1104 } |
| 1105 |
1083 bool DragController::StartDrag(LocalFrame* src, | 1106 bool DragController::StartDrag(LocalFrame* src, |
1084 const DragState& state, | 1107 const DragState& state, |
1085 const WebMouseEvent& drag_event, | 1108 const WebMouseEvent& drag_event, |
1086 const IntPoint& drag_origin) { | 1109 const IntPoint& drag_origin) { |
1087 #if DCHECK_IS_ON() | 1110 #if DCHECK_IS_ON() |
1088 DCHECK(DragTypeIsValid(state.drag_type_)); | 1111 DCHECK(DragTypeIsValid(state.drag_type_)); |
1089 #endif | 1112 #endif |
1090 DCHECK(src); | 1113 DCHECK(src); |
1091 if (!src->View() || src->ContentLayoutItem().IsNull()) | 1114 if (!src->View() || src->ContentLayoutItem().IsNull()) |
1092 return false; | 1115 return false; |
(...skipping 24 matching lines...) Expand all Loading... |
1117 std::unique_ptr<DragImage> drag_image = | 1140 std::unique_ptr<DragImage> drag_image = |
1118 data_transfer->CreateDragImage(drag_offset, src); | 1141 data_transfer->CreateDragImage(drag_offset, src); |
1119 if (drag_image) { | 1142 if (drag_image) { |
1120 drag_location = DragLocationForDHTMLDrag(mouse_dragged_point, drag_origin, | 1143 drag_location = DragLocationForDHTMLDrag(mouse_dragged_point, drag_origin, |
1121 drag_offset, !link_url.IsEmpty()); | 1144 drag_offset, !link_url.IsEmpty()); |
1122 } | 1145 } |
1123 | 1146 |
1124 Node* node = state.drag_src_.Get(); | 1147 Node* node = state.drag_src_.Get(); |
1125 if (state.drag_type_ == kDragSourceActionSelection) { | 1148 if (state.drag_type_ == kDragSourceActionSelection) { |
1126 if (!drag_image) { | 1149 if (!drag_image) { |
1127 drag_image = src->DragImageForSelection(kDragImageAlpha); | 1150 drag_image = DragImageForSelection(*src, kDragImageAlpha); |
1128 drag_location = DragLocationForSelectionDrag(src); | 1151 drag_location = DragLocationForSelectionDrag(src); |
1129 } | 1152 } |
1130 DoSystemDrag(drag_image.get(), drag_location, drag_origin, data_transfer, | 1153 DoSystemDrag(drag_image.get(), drag_location, drag_origin, data_transfer, |
1131 src, false); | 1154 src, false); |
1132 } else if (state.drag_type_ == kDragSourceActionImage) { | 1155 } else if (state.drag_type_ == kDragSourceActionImage) { |
1133 if (image_url.IsEmpty() || !node || !node->IsElementNode()) | 1156 if (image_url.IsEmpty() || !node || !node->IsElementNode()) |
1134 return false; | 1157 return false; |
1135 Element* element = ToElement(node); | 1158 Element* element = ToElement(node); |
1136 Image* image = GetImage(element); | 1159 Image* image = GetImage(element); |
1137 if (!image || image->IsNull() || !image->Data() || !image->Data()->size()) | 1160 if (!image || image->IsNull() || !image->Data() || !image->Data()->size()) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 | 1292 |
1270 DEFINE_TRACE(DragController) { | 1293 DEFINE_TRACE(DragController) { |
1271 visitor->Trace(page_); | 1294 visitor->Trace(page_); |
1272 visitor->Trace(document_under_mouse_); | 1295 visitor->Trace(document_under_mouse_); |
1273 visitor->Trace(drag_initiator_); | 1296 visitor->Trace(drag_initiator_); |
1274 visitor->Trace(drag_state_); | 1297 visitor->Trace(drag_state_); |
1275 visitor->Trace(file_input_element_under_mouse_); | 1298 visitor->Trace(file_input_element_under_mouse_); |
1276 } | 1299 } |
1277 | 1300 |
1278 } // namespace blink | 1301 } // namespace blink |
OLD | NEW |