| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 #include "third_party/skia/include/core/SkSurface.h" | 110 #include "third_party/skia/include/core/SkSurface.h" |
| 111 | 111 |
| 112 namespace blink { | 112 namespace blink { |
| 113 | 113 |
| 114 using namespace HTMLNames; | 114 using namespace HTMLNames; |
| 115 | 115 |
| 116 namespace { | 116 namespace { |
| 117 | 117 |
| 118 // Converts from bounds in CSS space to device space based on the given | 118 // Converts from bounds in CSS space to device space based on the given |
| 119 // frame. | 119 // frame. |
| 120 // TODO(tanvir.rizvi): DeviceSpaceBounds is used for drag related functionality |
| 121 // and is irrelevant to core functionality of LocalFrame. This should be moved |
| 122 // out of LocalFrame to appropriate place. |
| 120 static FloatRect DeviceSpaceBounds(const FloatRect css_bounds, | 123 static FloatRect DeviceSpaceBounds(const FloatRect css_bounds, |
| 121 const LocalFrame& frame) { | 124 const LocalFrame& frame) { |
| 122 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); | 125 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); |
| 123 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); | 126 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); |
| 124 FloatRect device_bounds(css_bounds); | 127 FloatRect device_bounds(css_bounds); |
| 125 device_bounds.SetWidth(css_bounds.Width() * device_scale_factor * | 128 device_bounds.SetWidth(css_bounds.Width() * device_scale_factor * |
| 126 page_scale_factor); | 129 page_scale_factor); |
| 127 device_bounds.SetHeight(css_bounds.Height() * device_scale_factor * | 130 device_bounds.SetHeight(css_bounds.Height() * device_scale_factor * |
| 128 page_scale_factor); | 131 page_scale_factor); |
| 129 return device_bounds; | 132 return device_bounds; |
| 130 } | 133 } |
| 131 | 134 |
| 132 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled | 135 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled |
| 133 // in device space. | 136 // in device space. |
| 134 static std::unique_ptr<DragImage> CreateDragImage( | 137 // TODO(tanvir.rizvi): CreateDragImageForFrame is used for drag related |
| 138 // functionality and is irrelevant to core functionality of LocalFrame. This |
| 139 // should be moved out of LocalFrame to appropriate place. |
| 140 static std::unique_ptr<DragImage> CreateDragImageForFrame( |
| 135 const LocalFrame& frame, | 141 const LocalFrame& frame, |
| 136 float opacity, | 142 float opacity, |
| 137 RespectImageOrientationEnum image_orientation, | 143 RespectImageOrientationEnum image_orientation, |
| 138 const FloatRect& css_bounds, | 144 const FloatRect& css_bounds, |
| 139 PaintRecordBuilder& builder, | 145 PaintRecordBuilder& builder, |
| 140 const PropertyTreeState& property_tree_state) { | 146 const PropertyTreeState& property_tree_state) { |
| 141 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); | 147 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); |
| 142 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); | 148 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); |
| 143 | 149 |
| 144 FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame); | 150 FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 161 | 167 |
| 162 RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot()); | 168 RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot()); |
| 163 float screen_device_scale_factor = | 169 float screen_device_scale_factor = |
| 164 frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor; | 170 frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor; |
| 165 | 171 |
| 166 return DragImage::Create(image.Get(), image_orientation, | 172 return DragImage::Create(image.Get(), image_orientation, |
| 167 screen_device_scale_factor, kInterpolationHigh, | 173 screen_device_scale_factor, kInterpolationHigh, |
| 168 opacity); | 174 opacity); |
| 169 } | 175 } |
| 170 | 176 |
| 177 // TODO(tanvir.rizvi): DraggedNodeImageBuilder is used for drag related |
| 178 // functionality and is irrelevant to core functionality of LocalFrame. This |
| 179 // should be moved out of LocalFrame to appropriate place. |
| 171 class DraggedNodeImageBuilder { | 180 class DraggedNodeImageBuilder { |
| 172 STACK_ALLOCATED(); | 181 STACK_ALLOCATED(); |
| 173 | 182 |
| 174 public: | 183 public: |
| 175 DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node) | 184 DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node) |
| 176 : local_frame_(&local_frame), | 185 : local_frame_(&local_frame), |
| 177 node_(&node) | 186 node_(&node) |
| 178 #if DCHECK_IS_ON() | 187 #if DCHECK_IS_ON() |
| 179 , | 188 , |
| 180 dom_tree_version_(node.GetDocument().DomTreeVersion()) | 189 dom_tree_version_(node.GetDocument().DomTreeVersion()) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 PaintLayerFlags flags = kPaintLayerHaveTransparency | | 230 PaintLayerFlags flags = kPaintLayerHaveTransparency | |
| 222 kPaintLayerAppliedTransform | | 231 kPaintLayerAppliedTransform | |
| 223 kPaintLayerUncachedClipRects; | 232 kPaintLayerUncachedClipRects; |
| 224 PaintRecordBuilder builder(DeviceSpaceBounds(bounding_box, *local_frame_)); | 233 PaintRecordBuilder builder(DeviceSpaceBounds(bounding_box, *local_frame_)); |
| 225 PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags); | 234 PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags); |
| 226 PropertyTreeState border_box_properties = PropertyTreeState::Root(); | 235 PropertyTreeState border_box_properties = PropertyTreeState::Root(); |
| 227 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { | 236 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { |
| 228 border_box_properties = | 237 border_box_properties = |
| 229 *layer->GetLayoutObject().LocalBorderBoxProperties(); | 238 *layer->GetLayoutObject().LocalBorderBoxProperties(); |
| 230 } | 239 } |
| 231 return CreateDragImage( | 240 return CreateDragImageForFrame( |
| 232 *local_frame_, 1.0f, | 241 *local_frame_, 1.0f, |
| 233 LayoutObject::ShouldRespectImageOrientation(dragged_layout_object), | 242 LayoutObject::ShouldRespectImageOrientation(dragged_layout_object), |
| 234 bounding_box, builder, border_box_properties); | 243 bounding_box, builder, border_box_properties); |
| 235 } | 244 } |
| 236 | 245 |
| 237 private: | 246 private: |
| 238 const Member<const LocalFrame> local_frame_; | 247 const Member<const LocalFrame> local_frame_; |
| 239 const Member<Node> node_; | 248 const Member<Node> node_; |
| 240 #if DCHECK_IS_ON() | 249 #if DCHECK_IS_ON() |
| 241 const uint64_t dom_tree_version_; | 250 const uint64_t dom_tree_version_; |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 751 |
| 743 double LocalFrame::DevicePixelRatio() const { | 752 double LocalFrame::DevicePixelRatio() const { |
| 744 if (!page_) | 753 if (!page_) |
| 745 return 0; | 754 return 0; |
| 746 | 755 |
| 747 double ratio = page_->DeviceScaleFactorDeprecated(); | 756 double ratio = page_->DeviceScaleFactorDeprecated(); |
| 748 ratio *= PageZoomFactor(); | 757 ratio *= PageZoomFactor(); |
| 749 return ratio; | 758 return ratio; |
| 750 } | 759 } |
| 751 | 760 |
| 761 // TODO(tanvir.rizvi): NodeImage is used only by DataTransfer, |
| 762 // and is irrelevant to LocalFrame core functionality, so it can be moved to |
| 763 // DataTransfer. |
| 752 std::unique_ptr<DragImage> LocalFrame::NodeImage(Node& node) { | 764 std::unique_ptr<DragImage> LocalFrame::NodeImage(Node& node) { |
| 753 DraggedNodeImageBuilder image_node(*this, node); | 765 DraggedNodeImageBuilder image_node(*this, node); |
| 754 return image_node.CreateImage(); | 766 return image_node.CreateImage(); |
| 755 } | 767 } |
| 756 | 768 |
| 769 // TODO(tanvir.rizvi): DragImageForSelection is used only by DragController, |
| 770 // and is irrelevant to LocalFrame core functionality, so it can be moved to |
| 771 // DragController. |
| 757 std::unique_ptr<DragImage> LocalFrame::DragImageForSelection(float opacity) { | 772 std::unique_ptr<DragImage> LocalFrame::DragImageForSelection(float opacity) { |
| 758 if (!Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) | 773 if (!Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) |
| 759 return nullptr; | 774 return nullptr; |
| 760 | 775 |
| 761 view_->UpdateAllLifecyclePhasesExceptPaint(); | 776 view_->UpdateAllLifecyclePhasesExceptPaint(); |
| 762 DCHECK(GetDocument()->IsActive()); | 777 DCHECK(GetDocument()->IsActive()); |
| 763 | 778 |
| 764 FloatRect painting_rect = FloatRect(Selection().Bounds()); | 779 FloatRect painting_rect = FloatRect(Selection().Bounds()); |
| 765 GlobalPaintFlags paint_flags = | 780 GlobalPaintFlags paint_flags = |
| 766 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; | 781 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; |
| 767 | 782 |
| 768 PaintRecordBuilder builder(DeviceSpaceBounds(painting_rect, *this)); | 783 PaintRecordBuilder builder(DeviceSpaceBounds(painting_rect, *this)); |
| 769 view_->PaintContents(builder.Context(), paint_flags, | 784 view_->PaintContents(builder.Context(), paint_flags, |
| 770 EnclosingIntRect(painting_rect)); | 785 EnclosingIntRect(painting_rect)); |
| 771 return CreateDragImage(*this, opacity, kDoNotRespectImageOrientation, | 786 return CreateDragImageForFrame(*this, opacity, kDoNotRespectImageOrientation, |
| 772 painting_rect, builder, PropertyTreeState::Root()); | 787 painting_rect, builder, |
| 788 PropertyTreeState::Root()); |
| 773 } | 789 } |
| 774 | 790 |
| 775 String LocalFrame::SelectedText() const { | 791 String LocalFrame::SelectedText() const { |
| 776 return Selection().SelectedText(); | 792 return Selection().SelectedText(); |
| 777 } | 793 } |
| 778 | 794 |
| 779 String LocalFrame::SelectedTextForClipboard() const { | 795 String LocalFrame::SelectedTextForClipboard() const { |
| 780 if (!GetDocument()) | 796 if (!GetDocument()) |
| 781 return g_empty_string; | 797 return g_empty_string; |
| 782 DCHECK(!GetDocument()->NeedsLayoutTreeUpdate()); | 798 DCHECK(!GetDocument()->NeedsLayoutTreeUpdate()); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 void LocalFrame::SetViewportIntersectionFromParent( | 1233 void LocalFrame::SetViewportIntersectionFromParent( |
| 1218 const IntRect& viewport_intersection) { | 1234 const IntRect& viewport_intersection) { |
| 1219 if (remote_viewport_intersection_ != viewport_intersection) { | 1235 if (remote_viewport_intersection_ != viewport_intersection) { |
| 1220 remote_viewport_intersection_ = viewport_intersection; | 1236 remote_viewport_intersection_ = viewport_intersection; |
| 1221 if (View()) | 1237 if (View()) |
| 1222 View()->ScheduleAnimation(); | 1238 View()->ScheduleAnimation(); |
| 1223 } | 1239 } |
| 1224 } | 1240 } |
| 1225 | 1241 |
| 1226 } // namespace blink | 1242 } // namespace blink |
| OLD | NEW |