OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Simon Hausmann <hausmann@kde.org> | 5 * 2000 Simon Hausmann <hausmann@kde.org> |
6 * 2000 Stefan Schimanski <1Stein@gmx.de> | 6 * 2000 Stefan Schimanski <1Stein@gmx.de> |
7 * 2001 George Staikos <staikos@kde.org> | 7 * 2001 George Staikos <staikos@kde.org> |
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
9 * rights reserved. | 9 * rights reserved. |
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 #include "core/inspector/ConsoleMessage.h" | 60 #include "core/inspector/ConsoleMessage.h" |
61 #include "core/layout/HitTestResult.h" | 61 #include "core/layout/HitTestResult.h" |
62 #include "core/layout/LayoutView.h" | 62 #include "core/layout/LayoutView.h" |
63 #include "core/layout/api/LayoutEmbeddedContentItem.h" | 63 #include "core/layout/api/LayoutEmbeddedContentItem.h" |
64 #include "core/layout/api/LayoutViewItem.h" | 64 #include "core/layout/api/LayoutViewItem.h" |
65 #include "core/layout/compositing/PaintLayerCompositor.h" | 65 #include "core/layout/compositing/PaintLayerCompositor.h" |
66 #include "core/loader/DocumentLoader.h" | 66 #include "core/loader/DocumentLoader.h" |
67 #include "core/loader/FrameLoadRequest.h" | 67 #include "core/loader/FrameLoadRequest.h" |
68 #include "core/loader/NavigationScheduler.h" | 68 #include "core/loader/NavigationScheduler.h" |
69 #include "core/page/ChromeClient.h" | 69 #include "core/page/ChromeClient.h" |
70 #include "core/page/DragController.h" | |
70 #include "core/page/FocusController.h" | 71 #include "core/page/FocusController.h" |
71 #include "core/page/Page.h" | 72 #include "core/page/Page.h" |
72 #include "core/page/scrolling/ScrollingCoordinator.h" | 73 #include "core/page/scrolling/ScrollingCoordinator.h" |
73 #include "core/paint/ObjectPainter.h" | 74 #include "core/paint/ObjectPainter.h" |
74 #include "core/paint/PaintInfo.h" | 75 #include "core/paint/PaintInfo.h" |
75 #include "core/paint/PaintLayer.h" | 76 #include "core/paint/PaintLayer.h" |
76 #include "core/paint/PaintLayerPainter.h" | 77 #include "core/paint/PaintLayerPainter.h" |
77 #include "core/paint/TransformRecorder.h" | 78 #include "core/paint/TransformRecorder.h" |
78 #include "core/plugins/PluginView.h" | 79 #include "core/plugins/PluginView.h" |
79 #include "core/probe/CoreProbes.h" | 80 #include "core/probe/CoreProbes.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
106 #include "public/platform/InterfaceRegistry.h" | 107 #include "public/platform/InterfaceRegistry.h" |
107 #include "public/platform/WebScreenInfo.h" | 108 #include "public/platform/WebScreenInfo.h" |
108 #include "public/platform/WebURLRequest.h" | 109 #include "public/platform/WebURLRequest.h" |
109 #include "third_party/skia/include/core/SkImage.h" | 110 #include "third_party/skia/include/core/SkImage.h" |
110 #include "third_party/skia/include/core/SkSurface.h" | 111 #include "third_party/skia/include/core/SkSurface.h" |
111 | 112 |
112 namespace blink { | 113 namespace blink { |
113 | 114 |
114 using namespace HTMLNames; | 115 using namespace HTMLNames; |
115 | 116 |
116 namespace { | |
117 | |
118 // Converts from bounds in CSS space to device space based on the given | 117 // Converts from bounds in CSS space to device space based on the given |
Xiaocheng
2017/06/16 18:10:48
nit: It's better to add a note here to indicate th
tanvir
2017/06/19 07:01:33
Done.
| |
119 // frame. | 118 // frame. |
120 // TODO(tanvir.rizvi): DeviceSpaceBounds is used for drag related functionality | 119 // TODO(tanvir.rizvi): DeviceSpaceBounds is used for drag related functionality |
121 // and is irrelevant to core functionality of LocalFrame. This should be moved | 120 // and is irrelevant to core functionality of LocalFrame. This should be moved |
122 // out of LocalFrame to appropriate place. | 121 // out of LocalFrame to appropriate place. |
123 static FloatRect DeviceSpaceBounds(const FloatRect css_bounds, | 122 FloatRect DataTransfer::DeviceSpaceBounds(const FloatRect css_bounds, |
124 const LocalFrame& frame) { | 123 const LocalFrame& frame) { |
125 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); | 124 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); |
126 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); | 125 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); |
127 FloatRect device_bounds(css_bounds); | 126 FloatRect device_bounds(css_bounds); |
128 device_bounds.SetWidth(css_bounds.Width() * device_scale_factor * | 127 device_bounds.SetWidth(css_bounds.Width() * device_scale_factor * |
129 page_scale_factor); | 128 page_scale_factor); |
130 device_bounds.SetHeight(css_bounds.Height() * device_scale_factor * | 129 device_bounds.SetHeight(css_bounds.Height() * device_scale_factor * |
131 page_scale_factor); | 130 page_scale_factor); |
132 return device_bounds; | 131 return device_bounds; |
133 } | 132 } |
134 | 133 |
135 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled | 134 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled |
136 // in device space. | 135 // in device space. |
137 // TODO(tanvir.rizvi): CreateDragImageForFrame is used for drag related | 136 // TODO(tanvir.rizvi): CreateDragImageForFrame is used for drag related |
138 // functionality and is irrelevant to core functionality of LocalFrame. This | 137 // functionality and is irrelevant to core functionality of LocalFrame. This |
139 // should be moved out of LocalFrame to appropriate place. | 138 // should be moved out of LocalFrame to appropriate place. |
140 static std::unique_ptr<DragImage> CreateDragImageForFrame( | 139 std::unique_ptr<DragImage> DataTransfer::CreateDragImageForFrame( |
Xiaocheng
2017/06/16 18:10:48
Ditto.
tanvir
2017/06/19 07:01:33
Done.
| |
141 const LocalFrame& frame, | 140 const LocalFrame& frame, |
142 float opacity, | 141 float opacity, |
143 RespectImageOrientationEnum image_orientation, | 142 RespectImageOrientationEnum image_orientation, |
144 const FloatRect& css_bounds, | 143 const FloatRect& css_bounds, |
145 PaintRecordBuilder& builder, | 144 PaintRecordBuilder& builder, |
146 const PropertyTreeState& property_tree_state) { | 145 const PropertyTreeState& property_tree_state) { |
147 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); | 146 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); |
148 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); | 147 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); |
149 | 148 |
150 FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame); | 149 FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame); |
(...skipping 16 matching lines...) Expand all Loading... | |
167 | 166 |
168 RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot()); | 167 RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot()); |
169 float screen_device_scale_factor = | 168 float screen_device_scale_factor = |
170 frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor; | 169 frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor; |
171 | 170 |
172 return DragImage::Create(image.Get(), image_orientation, | 171 return DragImage::Create(image.Get(), image_orientation, |
173 screen_device_scale_factor, kInterpolationHigh, | 172 screen_device_scale_factor, kInterpolationHigh, |
174 opacity); | 173 opacity); |
175 } | 174 } |
176 | 175 |
176 namespace { | |
177 | |
177 // TODO(tanvir.rizvi): DraggedNodeImageBuilder is used for drag related | 178 // TODO(tanvir.rizvi): DraggedNodeImageBuilder is used for drag related |
178 // functionality and is irrelevant to core functionality of LocalFrame. This | 179 // functionality and is irrelevant to core functionality of LocalFrame. This |
179 // should be moved out of LocalFrame to appropriate place. | 180 // should be moved out of LocalFrame to appropriate place. |
180 class DraggedNodeImageBuilder { | 181 class DraggedNodeImageBuilder { |
181 STACK_ALLOCATED(); | 182 STACK_ALLOCATED(); |
182 | 183 |
183 public: | 184 public: |
184 DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node) | 185 DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node) |
185 : local_frame_(&local_frame), | 186 : local_frame_(&local_frame), |
186 node_(&node) | 187 node_(&node) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 layer->GetLayoutObject() | 224 layer->GetLayoutObject() |
224 .AbsoluteToLocalQuad(FloatQuad(absolute_bounding_box), | 225 .AbsoluteToLocalQuad(FloatQuad(absolute_bounding_box), |
225 kUseTransforms) | 226 kUseTransforms) |
226 .BoundingBox(); | 227 .BoundingBox(); |
227 PaintLayerPaintingInfo painting_info(layer, LayoutRect(bounding_box), | 228 PaintLayerPaintingInfo painting_info(layer, LayoutRect(bounding_box), |
228 kGlobalPaintFlattenCompositingLayers, | 229 kGlobalPaintFlattenCompositingLayers, |
229 LayoutSize()); | 230 LayoutSize()); |
230 PaintLayerFlags flags = kPaintLayerHaveTransparency | | 231 PaintLayerFlags flags = kPaintLayerHaveTransparency | |
231 kPaintLayerAppliedTransform | | 232 kPaintLayerAppliedTransform | |
232 kPaintLayerUncachedClipRects; | 233 kPaintLayerUncachedClipRects; |
233 PaintRecordBuilder builder(DeviceSpaceBounds(bounding_box, *local_frame_)); | 234 PaintRecordBuilder builder( |
235 DataTransfer::DeviceSpaceBounds(bounding_box, *local_frame_)); | |
234 PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags); | 236 PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags); |
235 PropertyTreeState border_box_properties = PropertyTreeState::Root(); | 237 PropertyTreeState border_box_properties = PropertyTreeState::Root(); |
236 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { | 238 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { |
237 border_box_properties = | 239 border_box_properties = |
238 *layer->GetLayoutObject().LocalBorderBoxProperties(); | 240 *layer->GetLayoutObject().LocalBorderBoxProperties(); |
239 } | 241 } |
240 return CreateDragImageForFrame( | 242 return DataTransfer::CreateDragImageForFrame( |
241 *local_frame_, 1.0f, | 243 *local_frame_, 1.0f, |
242 LayoutObject::ShouldRespectImageOrientation(dragged_layout_object), | 244 LayoutObject::ShouldRespectImageOrientation(dragged_layout_object), |
243 bounding_box, builder, border_box_properties); | 245 bounding_box, builder, border_box_properties); |
244 } | 246 } |
245 | 247 |
246 private: | 248 private: |
247 const Member<const LocalFrame> local_frame_; | 249 const Member<const LocalFrame> local_frame_; |
248 const Member<Node> node_; | 250 const Member<Node> node_; |
249 #if DCHECK_IS_ON() | 251 #if DCHECK_IS_ON() |
250 const uint64_t dom_tree_version_; | 252 const uint64_t dom_tree_version_; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 return 0; | 757 return 0; |
756 | 758 |
757 double ratio = page_->DeviceScaleFactorDeprecated(); | 759 double ratio = page_->DeviceScaleFactorDeprecated(); |
758 ratio *= PageZoomFactor(); | 760 ratio *= PageZoomFactor(); |
759 return ratio; | 761 return ratio; |
760 } | 762 } |
761 | 763 |
762 // TODO(tanvir.rizvi): NodeImage is used only by DataTransfer, | 764 // TODO(tanvir.rizvi): NodeImage is used only by DataTransfer, |
763 // and is irrelevant to LocalFrame core functionality, so it can be moved to | 765 // and is irrelevant to LocalFrame core functionality, so it can be moved to |
764 // DataTransfer. | 766 // DataTransfer. |
765 std::unique_ptr<DragImage> LocalFrame::NodeImage(Node& node) { | 767 std::unique_ptr<DragImage> DataTransfer::NodeImage(const LocalFrame& frame, |
Xiaocheng
2017/06/16 18:10:47
Ditto.
tanvir
2017/06/19 07:01:33
Done.
tanvir
2017/06/19 07:01:33
Done.
| |
766 DraggedNodeImageBuilder image_node(*this, node); | 768 Node& node) { |
769 DraggedNodeImageBuilder image_node(frame, node); | |
767 return image_node.CreateImage(); | 770 return image_node.CreateImage(); |
768 } | 771 } |
769 | 772 |
770 // TODO(tanvir.rizvi): DragImageForSelection is used only by DragController, | 773 // TODO(tanvir.rizvi): DragImageForSelection is used only by DragController, |
771 // and is irrelevant to LocalFrame core functionality, so it can be moved to | 774 // and is irrelevant to LocalFrame core functionality, so it can be moved to |
772 // DragController. | 775 // DragController. |
773 std::unique_ptr<DragImage> LocalFrame::DragImageForSelection(float opacity) { | 776 std::unique_ptr<DragImage> DragController::DragImageForSelection( |
Xiaocheng
2017/06/16 18:10:47
Ditto.
tanvir
2017/06/19 07:01:33
Done.
| |
774 if (!Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) | 777 const LocalFrame& frame, |
778 float opacity) { | |
779 if (!frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) | |
775 return nullptr; | 780 return nullptr; |
776 | 781 |
777 view_->UpdateAllLifecyclePhasesExceptPaint(); | 782 frame.View()->UpdateAllLifecyclePhasesExceptPaint(); |
778 DCHECK(GetDocument()->IsActive()); | 783 DCHECK(frame.GetDocument()->IsActive()); |
779 | 784 |
780 FloatRect painting_rect = FloatRect(Selection().Bounds()); | 785 FloatRect painting_rect = FloatRect(frame.Selection().Bounds()); |
781 GlobalPaintFlags paint_flags = | 786 GlobalPaintFlags paint_flags = |
782 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; | 787 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; |
783 | 788 |
784 PaintRecordBuilder builder(DeviceSpaceBounds(painting_rect, *this)); | 789 PaintRecordBuilder builder( |
785 view_->PaintContents(builder.Context(), paint_flags, | 790 DataTransfer::DeviceSpaceBounds(painting_rect, frame)); |
786 EnclosingIntRect(painting_rect)); | 791 frame.View()->PaintContents(builder.Context(), paint_flags, |
787 return CreateDragImageForFrame(*this, opacity, kDoNotRespectImageOrientation, | 792 EnclosingIntRect(painting_rect)); |
788 painting_rect, builder, | 793 return DataTransfer::CreateDragImageForFrame( |
789 PropertyTreeState::Root()); | 794 frame, opacity, kDoNotRespectImageOrientation, painting_rect, builder, |
795 PropertyTreeState::Root()); | |
790 } | 796 } |
791 | 797 |
792 String LocalFrame::SelectedText() const { | 798 String LocalFrame::SelectedText() const { |
793 return Selection().SelectedText(); | 799 return Selection().SelectedText(); |
794 } | 800 } |
795 | 801 |
796 String LocalFrame::SelectedTextForClipboard() const { | 802 String LocalFrame::SelectedTextForClipboard() const { |
797 if (!GetDocument()) | 803 if (!GetDocument()) |
798 return g_empty_string; | 804 return g_empty_string; |
799 DCHECK(!GetDocument()->NeedsLayoutTreeUpdate()); | 805 DCHECK(!GetDocument()->NeedsLayoutTreeUpdate()); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 void LocalFrame::SetViewportIntersectionFromParent( | 1240 void LocalFrame::SetViewportIntersectionFromParent( |
1235 const IntRect& viewport_intersection) { | 1241 const IntRect& viewport_intersection) { |
1236 if (remote_viewport_intersection_ != viewport_intersection) { | 1242 if (remote_viewport_intersection_ != viewport_intersection) { |
1237 remote_viewport_intersection_ = viewport_intersection; | 1243 remote_viewport_intersection_ = viewport_intersection; |
1238 if (View()) | 1244 if (View()) |
1239 View()->ScheduleAnimation(); | 1245 View()->ScheduleAnimation(); |
1240 } | 1246 } |
1241 } | 1247 } |
1242 | 1248 |
1243 } // namespace blink | 1249 } // namespace blink |
OLD | NEW |