| 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 // static |
| 1085 std::unique_ptr<DragImage> DragController::DragImageForSelection( |
| 1086 const LocalFrame& frame, |
| 1087 float opacity) { |
| 1088 if (!frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) |
| 1089 return nullptr; |
| 1090 |
| 1091 frame.View()->UpdateAllLifecyclePhasesExceptPaint(); |
| 1092 DCHECK(frame.GetDocument()->IsActive()); |
| 1093 |
| 1094 FloatRect painting_rect = FloatRect(frame.Selection().Bounds()); |
| 1095 GlobalPaintFlags paint_flags = |
| 1096 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; |
| 1097 |
| 1098 PaintRecordBuilder builder( |
| 1099 DataTransfer::DeviceSpaceBounds(painting_rect, frame)); |
| 1100 frame.View()->PaintContents(builder.Context(), paint_flags, |
| 1101 EnclosingIntRect(painting_rect)); |
| 1102 return DataTransfer::CreateDragImageForFrame( |
| 1103 frame, opacity, kDoNotRespectImageOrientation, painting_rect, builder, |
| 1104 PropertyTreeState::Root()); |
| 1105 } |
| 1106 |
| 1083 bool DragController::StartDrag(LocalFrame* src, | 1107 bool DragController::StartDrag(LocalFrame* src, |
| 1084 const DragState& state, | 1108 const DragState& state, |
| 1085 const WebMouseEvent& drag_event, | 1109 const WebMouseEvent& drag_event, |
| 1086 const IntPoint& drag_origin) { | 1110 const IntPoint& drag_origin) { |
| 1087 #if DCHECK_IS_ON() | 1111 #if DCHECK_IS_ON() |
| 1088 DCHECK(DragTypeIsValid(state.drag_type_)); | 1112 DCHECK(DragTypeIsValid(state.drag_type_)); |
| 1089 #endif | 1113 #endif |
| 1090 DCHECK(src); | 1114 DCHECK(src); |
| 1091 if (!src->View() || src->ContentLayoutItem().IsNull()) | 1115 if (!src->View() || src->ContentLayoutItem().IsNull()) |
| 1092 return false; | 1116 return false; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 | 1293 |
| 1270 DEFINE_TRACE(DragController) { | 1294 DEFINE_TRACE(DragController) { |
| 1271 visitor->Trace(page_); | 1295 visitor->Trace(page_); |
| 1272 visitor->Trace(document_under_mouse_); | 1296 visitor->Trace(document_under_mouse_); |
| 1273 visitor->Trace(drag_initiator_); | 1297 visitor->Trace(drag_initiator_); |
| 1274 visitor->Trace(drag_state_); | 1298 visitor->Trace(drag_state_); |
| 1275 visitor->Trace(file_input_element_under_mouse_); | 1299 visitor->Trace(file_input_element_under_mouse_); |
| 1276 } | 1300 } |
| 1277 | 1301 |
| 1278 } // namespace blink | 1302 } // namespace blink |
| OLD | NEW |