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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2934233002: In-place modification of drag related functionality present in LocalFrame (Closed)
Patch Set: updatedPS Created 3 years, 6 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) 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
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
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 // static
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 120 // TODO(tanvir.rizvi): DeviceSpaceBounds is used for drag related functionality
121 // and is irrelevant to core functionality of LocalFrame. This should be moved 121 // and is irrelevant to core functionality of LocalFrame. This should be moved
122 // out of LocalFrame to appropriate place. 122 // out of LocalFrame to appropriate place.
123 static FloatRect DeviceSpaceBounds(const FloatRect css_bounds, 123 FloatRect DataTransfer::DeviceSpaceBounds(const FloatRect css_bounds,
124 const LocalFrame& frame) { 124 const LocalFrame& frame) {
125 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); 125 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated();
126 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); 126 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale();
127 FloatRect device_bounds(css_bounds); 127 FloatRect device_bounds(css_bounds);
128 device_bounds.SetWidth(css_bounds.Width() * device_scale_factor * 128 device_bounds.SetWidth(css_bounds.Width() * device_scale_factor *
129 page_scale_factor); 129 page_scale_factor);
130 device_bounds.SetHeight(css_bounds.Height() * device_scale_factor * 130 device_bounds.SetHeight(css_bounds.Height() * device_scale_factor *
131 page_scale_factor); 131 page_scale_factor);
132 return device_bounds; 132 return device_bounds;
133 } 133 }
134 134
135 // static
135 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled 136 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled
136 // in device space. 137 // in device space.
137 // TODO(tanvir.rizvi): CreateDragImageForFrame is used for drag related 138 // TODO(tanvir.rizvi): CreateDragImageForFrame is used for drag related
138 // functionality and is irrelevant to core functionality of LocalFrame. This 139 // functionality and is irrelevant to core functionality of LocalFrame. This
139 // should be moved out of LocalFrame to appropriate place. 140 // should be moved out of LocalFrame to appropriate place.
140 static std::unique_ptr<DragImage> CreateDragImageForFrame( 141 std::unique_ptr<DragImage> DataTransfer::CreateDragImageForFrame(
141 const LocalFrame& frame, 142 const LocalFrame& frame,
142 float opacity, 143 float opacity,
143 RespectImageOrientationEnum image_orientation, 144 RespectImageOrientationEnum image_orientation,
144 const FloatRect& css_bounds, 145 const FloatRect& css_bounds,
145 PaintRecordBuilder& builder, 146 PaintRecordBuilder& builder,
146 const PropertyTreeState& property_tree_state) { 147 const PropertyTreeState& property_tree_state) {
147 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated(); 148 float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated();
148 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale(); 149 float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale();
149 150
150 FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame); 151 FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame);
(...skipping 16 matching lines...) Expand all
167 168
168 RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot()); 169 RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot());
169 float screen_device_scale_factor = 170 float screen_device_scale_factor =
170 frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor; 171 frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor;
171 172
172 return DragImage::Create(image.Get(), image_orientation, 173 return DragImage::Create(image.Get(), image_orientation,
173 screen_device_scale_factor, kInterpolationHigh, 174 screen_device_scale_factor, kInterpolationHigh,
174 opacity); 175 opacity);
175 } 176 }
176 177
178 namespace {
179
177 // TODO(tanvir.rizvi): DraggedNodeImageBuilder is used for drag related 180 // TODO(tanvir.rizvi): DraggedNodeImageBuilder is used for drag related
178 // functionality and is irrelevant to core functionality of LocalFrame. This 181 // functionality and is irrelevant to core functionality of LocalFrame. This
179 // should be moved out of LocalFrame to appropriate place. 182 // should be moved out of LocalFrame to appropriate place.
180 class DraggedNodeImageBuilder { 183 class DraggedNodeImageBuilder {
181 STACK_ALLOCATED(); 184 STACK_ALLOCATED();
182 185
183 public: 186 public:
184 DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node) 187 DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node)
185 : local_frame_(&local_frame), 188 : local_frame_(&local_frame),
186 node_(&node) 189 node_(&node)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 layer->GetLayoutObject() 226 layer->GetLayoutObject()
224 .AbsoluteToLocalQuad(FloatQuad(absolute_bounding_box), 227 .AbsoluteToLocalQuad(FloatQuad(absolute_bounding_box),
225 kUseTransforms) 228 kUseTransforms)
226 .BoundingBox(); 229 .BoundingBox();
227 PaintLayerPaintingInfo painting_info(layer, LayoutRect(bounding_box), 230 PaintLayerPaintingInfo painting_info(layer, LayoutRect(bounding_box),
228 kGlobalPaintFlattenCompositingLayers, 231 kGlobalPaintFlattenCompositingLayers,
229 LayoutSize()); 232 LayoutSize());
230 PaintLayerFlags flags = kPaintLayerHaveTransparency | 233 PaintLayerFlags flags = kPaintLayerHaveTransparency |
231 kPaintLayerAppliedTransform | 234 kPaintLayerAppliedTransform |
232 kPaintLayerUncachedClipRects; 235 kPaintLayerUncachedClipRects;
233 PaintRecordBuilder builder(DeviceSpaceBounds(bounding_box, *local_frame_)); 236 PaintRecordBuilder builder(
237 DataTransfer::DeviceSpaceBounds(bounding_box, *local_frame_));
234 PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags); 238 PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags);
235 PropertyTreeState border_box_properties = PropertyTreeState::Root(); 239 PropertyTreeState border_box_properties = PropertyTreeState::Root();
236 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) { 240 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
237 border_box_properties = 241 border_box_properties =
238 *layer->GetLayoutObject().LocalBorderBoxProperties(); 242 *layer->GetLayoutObject().LocalBorderBoxProperties();
239 } 243 }
240 return CreateDragImageForFrame( 244 return DataTransfer::CreateDragImageForFrame(
241 *local_frame_, 1.0f, 245 *local_frame_, 1.0f,
242 LayoutObject::ShouldRespectImageOrientation(dragged_layout_object), 246 LayoutObject::ShouldRespectImageOrientation(dragged_layout_object),
243 bounding_box, builder, border_box_properties); 247 bounding_box, builder, border_box_properties);
244 } 248 }
245 249
246 private: 250 private:
247 const Member<const LocalFrame> local_frame_; 251 const Member<const LocalFrame> local_frame_;
248 const Member<Node> node_; 252 const Member<Node> node_;
249 #if DCHECK_IS_ON() 253 #if DCHECK_IS_ON()
250 const uint64_t dom_tree_version_; 254 const uint64_t dom_tree_version_;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 756
753 double LocalFrame::DevicePixelRatio() const { 757 double LocalFrame::DevicePixelRatio() const {
754 if (!page_) 758 if (!page_)
755 return 0; 759 return 0;
756 760
757 double ratio = page_->DeviceScaleFactorDeprecated(); 761 double ratio = page_->DeviceScaleFactorDeprecated();
758 ratio *= PageZoomFactor(); 762 ratio *= PageZoomFactor();
759 return ratio; 763 return ratio;
760 } 764 }
761 765
766 // static
762 // TODO(tanvir.rizvi): NodeImage is used only by DataTransfer, 767 // TODO(tanvir.rizvi): NodeImage is used only by DataTransfer,
763 // and is irrelevant to LocalFrame core functionality, so it can be moved to 768 // and is irrelevant to LocalFrame core functionality, so it can be moved to
764 // DataTransfer. 769 // DataTransfer.
765 std::unique_ptr<DragImage> LocalFrame::NodeImage(Node& node) { 770 std::unique_ptr<DragImage> DataTransfer::NodeImage(const LocalFrame& frame,
766 DraggedNodeImageBuilder image_node(*this, node); 771 Node& node) {
772 DraggedNodeImageBuilder image_node(frame, node);
767 return image_node.CreateImage(); 773 return image_node.CreateImage();
768 } 774 }
769 775
776 // static
770 // TODO(tanvir.rizvi): DragImageForSelection is used only by DragController, 777 // TODO(tanvir.rizvi): DragImageForSelection is used only by DragController,
771 // and is irrelevant to LocalFrame core functionality, so it can be moved to 778 // and is irrelevant to LocalFrame core functionality, so it can be moved to
772 // DragController. 779 // DragController.
773 std::unique_ptr<DragImage> LocalFrame::DragImageForSelection(float opacity) { 780 std::unique_ptr<DragImage> DragController::DragImageForSelection(
774 if (!Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) 781 const LocalFrame& frame,
782 float opacity) {
783 if (!frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange())
775 return nullptr; 784 return nullptr;
776 785
777 view_->UpdateAllLifecyclePhasesExceptPaint(); 786 frame.View()->UpdateAllLifecyclePhasesExceptPaint();
778 DCHECK(GetDocument()->IsActive()); 787 DCHECK(frame.GetDocument()->IsActive());
779 788
780 FloatRect painting_rect = FloatRect(Selection().Bounds()); 789 FloatRect painting_rect = FloatRect(frame.Selection().Bounds());
781 GlobalPaintFlags paint_flags = 790 GlobalPaintFlags paint_flags =
782 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; 791 kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers;
783 792
784 PaintRecordBuilder builder(DeviceSpaceBounds(painting_rect, *this)); 793 PaintRecordBuilder builder(
785 view_->PaintContents(builder.Context(), paint_flags, 794 DataTransfer::DeviceSpaceBounds(painting_rect, frame));
786 EnclosingIntRect(painting_rect)); 795 frame.View()->PaintContents(builder.Context(), paint_flags,
787 return CreateDragImageForFrame(*this, opacity, kDoNotRespectImageOrientation, 796 EnclosingIntRect(painting_rect));
788 painting_rect, builder, 797 return DataTransfer::CreateDragImageForFrame(
789 PropertyTreeState::Root()); 798 frame, opacity, kDoNotRespectImageOrientation, painting_rect, builder,
799 PropertyTreeState::Root());
790 } 800 }
791 801
792 String LocalFrame::SelectedText() const { 802 String LocalFrame::SelectedText() const {
793 return Selection().SelectedText(); 803 return Selection().SelectedText();
794 } 804 }
795 805
796 String LocalFrame::SelectedTextForClipboard() const { 806 String LocalFrame::SelectedTextForClipboard() const {
797 if (!GetDocument()) 807 if (!GetDocument())
798 return g_empty_string; 808 return g_empty_string;
799 DCHECK(!GetDocument()->NeedsLayoutTreeUpdate()); 809 DCHECK(!GetDocument()->NeedsLayoutTreeUpdate());
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 void LocalFrame::SetViewportIntersectionFromParent( 1244 void LocalFrame::SetViewportIntersectionFromParent(
1235 const IntRect& viewport_intersection) { 1245 const IntRect& viewport_intersection) {
1236 if (remote_viewport_intersection_ != viewport_intersection) { 1246 if (remote_viewport_intersection_ != viewport_intersection) {
1237 remote_viewport_intersection_ = viewport_intersection; 1247 remote_viewport_intersection_ = viewport_intersection;
1238 if (View()) 1248 if (View())
1239 View()->ScheduleAnimation(); 1249 View()->ScheduleAnimation();
1240 } 1250 }
1241 } 1251 }
1242 1252
1243 } // namespace blink 1253 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.h ('k') | third_party/WebKit/Source/core/frame/LocalFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698