| Index: third_party/WebKit/Source/core/frame/LocalFrame.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
|
| index f64499cace3090cb8a1f0c2b51782436600182e2..3f9bd309b1a7e9bdecd3ad3f58809e844bf69cfd 100644
|
| --- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
|
| @@ -52,7 +52,6 @@
|
| #include "core/frame/LocalFrameView.h"
|
| #include "core/frame/PerformanceMonitor.h"
|
| #include "core/frame/Settings.h"
|
| -#include "core/frame/VisualViewport.h"
|
| #include "core/html/HTMLFrameElementBase.h"
|
| #include "core/html/HTMLPlugInElement.h"
|
| #include "core/html/PluginDocument.h"
|
| @@ -66,32 +65,23 @@
|
| #include "core/loader/DocumentLoader.h"
|
| #include "core/loader/FrameLoadRequest.h"
|
| #include "core/loader/NavigationScheduler.h"
|
| -#include "core/page/ChromeClient.h"
|
| #include "core/page/DragController.h"
|
| #include "core/page/FocusController.h"
|
| -#include "core/page/Page.h"
|
| #include "core/page/scrolling/ScrollingCoordinator.h"
|
| #include "core/paint/ObjectPainter.h"
|
| -#include "core/paint/PaintInfo.h"
|
| -#include "core/paint/PaintLayer.h"
|
| -#include "core/paint/PaintLayerPainter.h"
|
| #include "core/paint/TransformRecorder.h"
|
| #include "core/plugins/PluginView.h"
|
| #include "core/probe/CoreProbes.h"
|
| #include "core/svg/SVGDocumentExtensions.h"
|
| #include "core/timing/Performance.h"
|
| -#include "platform/DragImage.h"
|
| #include "platform/Histogram.h"
|
| #include "platform/PluginScriptForbiddenScope.h"
|
| #include "platform/RuntimeEnabledFeatures.h"
|
| #include "platform/ScriptForbiddenScope.h"
|
| #include "platform/WebFrameScheduler.h"
|
| -#include "platform/graphics/GraphicsContext.h"
|
| -#include "platform/graphics/StaticBitmapImage.h"
|
| #include "platform/graphics/paint/ClipRecorder.h"
|
| #include "platform/graphics/paint/PaintCanvas.h"
|
| #include "platform/graphics/paint/PaintController.h"
|
| -#include "platform/graphics/paint/PaintRecordBuilder.h"
|
| #include "platform/graphics/paint/TransformDisplayItem.h"
|
| #include "platform/instrumentation/resource_coordinator/FrameResourceCoordinator.h"
|
| #include "platform/json/JSONValues.h"
|
| @@ -105,156 +95,14 @@
|
| #include "platform/wtf/StdLibExtras.h"
|
| #include "public/platform/InterfaceProvider.h"
|
| #include "public/platform/InterfaceRegistry.h"
|
| -#include "public/platform/WebScreenInfo.h"
|
| #include "public/platform/WebURLRequest.h"
|
| -#include "third_party/skia/include/core/SkImage.h"
|
| -#include "third_party/skia/include/core/SkSurface.h"
|
|
|
| namespace blink {
|
|
|
| using namespace HTMLNames;
|
|
|
| -// static
|
| -// Converts from bounds in CSS space to device space based on the given
|
| -// frame.
|
| -// TODO(tanvir.rizvi): DeviceSpaceBounds is used for drag related functionality
|
| -// and is irrelevant to core functionality of LocalFrame. This should be moved
|
| -// out of LocalFrame to appropriate place.
|
| -FloatRect DataTransfer::DeviceSpaceBounds(const FloatRect css_bounds,
|
| - const LocalFrame& frame) {
|
| - float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated();
|
| - float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale();
|
| - FloatRect device_bounds(css_bounds);
|
| - device_bounds.SetWidth(css_bounds.Width() * device_scale_factor *
|
| - page_scale_factor);
|
| - device_bounds.SetHeight(css_bounds.Height() * device_scale_factor *
|
| - page_scale_factor);
|
| - return device_bounds;
|
| -}
|
| -
|
| -// static
|
| -// Returns a DragImage whose bitmap contains |contents|, positioned and scaled
|
| -// in device space.
|
| -// TODO(tanvir.rizvi): CreateDragImageForFrame is used for drag related
|
| -// functionality and is irrelevant to core functionality of LocalFrame. This
|
| -// should be moved out of LocalFrame to appropriate place.
|
| -std::unique_ptr<DragImage> DataTransfer::CreateDragImageForFrame(
|
| - const LocalFrame& frame,
|
| - float opacity,
|
| - RespectImageOrientationEnum image_orientation,
|
| - const FloatRect& css_bounds,
|
| - PaintRecordBuilder& builder,
|
| - const PropertyTreeState& property_tree_state) {
|
| - float device_scale_factor = frame.GetPage()->DeviceScaleFactorDeprecated();
|
| - float page_scale_factor = frame.GetPage()->GetVisualViewport().Scale();
|
| -
|
| - FloatRect device_bounds = DeviceSpaceBounds(css_bounds, frame);
|
| -
|
| - AffineTransform transform;
|
| - transform.Scale(device_scale_factor * page_scale_factor);
|
| - transform.Translate(-device_bounds.X(), -device_bounds.Y());
|
| -
|
| - // Rasterize upfront, since DragImage::create() is going to do it anyway
|
| - // (SkImage::asLegacyBitmap).
|
| - SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry);
|
| - sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
|
| - device_bounds.Width(), device_bounds.Height(), &surface_props);
|
| - if (!surface)
|
| - return nullptr;
|
| -
|
| - SkiaPaintCanvas skia_paint_canvas(surface->getCanvas());
|
| - skia_paint_canvas.concat(AffineTransformToSkMatrix(transform));
|
| - builder.EndRecording(skia_paint_canvas, property_tree_state);
|
| -
|
| - RefPtr<Image> image = StaticBitmapImage::Create(surface->makeImageSnapshot());
|
| - float screen_device_scale_factor =
|
| - frame.GetPage()->GetChromeClient().GetScreenInfo().device_scale_factor;
|
| -
|
| - return DragImage::Create(image.Get(), image_orientation,
|
| - screen_device_scale_factor, kInterpolationHigh,
|
| - opacity);
|
| -}
|
| -
|
| namespace {
|
|
|
| -// TODO(tanvir.rizvi): DraggedNodeImageBuilder is used for drag related
|
| -// functionality and is irrelevant to core functionality of LocalFrame. This
|
| -// should be moved out of LocalFrame to appropriate place.
|
| -class DraggedNodeImageBuilder {
|
| - STACK_ALLOCATED();
|
| -
|
| - public:
|
| - DraggedNodeImageBuilder(const LocalFrame& local_frame, Node& node)
|
| - : local_frame_(&local_frame),
|
| - node_(&node)
|
| -#if DCHECK_IS_ON()
|
| - ,
|
| - dom_tree_version_(node.GetDocument().DomTreeVersion())
|
| -#endif
|
| - {
|
| - for (Node& descendant : NodeTraversal::InclusiveDescendantsOf(*node_))
|
| - descendant.SetDragged(true);
|
| - }
|
| -
|
| - ~DraggedNodeImageBuilder() {
|
| -#if DCHECK_IS_ON()
|
| - DCHECK_EQ(dom_tree_version_, node_->GetDocument().DomTreeVersion());
|
| -#endif
|
| - for (Node& descendant : NodeTraversal::InclusiveDescendantsOf(*node_))
|
| - descendant.SetDragged(false);
|
| - }
|
| -
|
| - std::unique_ptr<DragImage> CreateImage() {
|
| -#if DCHECK_IS_ON()
|
| - DCHECK_EQ(dom_tree_version_, node_->GetDocument().DomTreeVersion());
|
| -#endif
|
| - // Construct layout object for |m_node| with pseudo class "-webkit-drag"
|
| - local_frame_->View()->UpdateAllLifecyclePhasesExceptPaint();
|
| - LayoutObject* const dragged_layout_object = node_->GetLayoutObject();
|
| - if (!dragged_layout_object)
|
| - return nullptr;
|
| - // Paint starting at the nearest stacking context, clipped to the object
|
| - // itself. This will also paint the contents behind the object if the
|
| - // object contains transparency and there are other elements in the same
|
| - // stacking context which stacked below.
|
| - PaintLayer* layer = dragged_layout_object->EnclosingLayer();
|
| - if (!layer->StackingNode()->IsStackingContext())
|
| - layer = layer->StackingNode()->AncestorStackingContextNode()->Layer();
|
| - IntRect absolute_bounding_box =
|
| - dragged_layout_object->AbsoluteBoundingBoxRectIncludingDescendants();
|
| - FloatRect bounding_box =
|
| - layer->GetLayoutObject()
|
| - .AbsoluteToLocalQuad(FloatQuad(absolute_bounding_box),
|
| - kUseTransforms)
|
| - .BoundingBox();
|
| - PaintLayerPaintingInfo painting_info(layer, LayoutRect(bounding_box),
|
| - kGlobalPaintFlattenCompositingLayers,
|
| - LayoutSize());
|
| - PaintLayerFlags flags = kPaintLayerHaveTransparency |
|
| - kPaintLayerAppliedTransform |
|
| - kPaintLayerUncachedClipRects;
|
| - PaintRecordBuilder builder(
|
| - DataTransfer::DeviceSpaceBounds(bounding_box, *local_frame_));
|
| - PaintLayerPainter(*layer).Paint(builder.Context(), painting_info, flags);
|
| - PropertyTreeState border_box_properties = PropertyTreeState::Root();
|
| - if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
|
| - border_box_properties =
|
| - *layer->GetLayoutObject().LocalBorderBoxProperties();
|
| - }
|
| - return DataTransfer::CreateDragImageForFrame(
|
| - *local_frame_, 1.0f,
|
| - LayoutObject::ShouldRespectImageOrientation(dragged_layout_object),
|
| - bounding_box, builder, border_box_properties);
|
| - }
|
| -
|
| - private:
|
| - const Member<const LocalFrame> local_frame_;
|
| - const Member<Node> node_;
|
| -#if DCHECK_IS_ON()
|
| - const uint64_t dom_tree_version_;
|
| -#endif
|
| -};
|
| -
|
| inline float ParentPageZoomFactor(LocalFrame* frame) {
|
| Frame* parent = frame->Tree().Parent();
|
| if (!parent || !parent->IsLocalFrame())
|
| @@ -768,42 +616,6 @@ double LocalFrame::DevicePixelRatio() const {
|
| return ratio;
|
| }
|
|
|
| -// static
|
| -// TODO(tanvir.rizvi): NodeImage is used only by DataTransfer,
|
| -// and is irrelevant to LocalFrame core functionality, so it can be moved to
|
| -// DataTransfer.
|
| -std::unique_ptr<DragImage> DataTransfer::NodeImage(const LocalFrame& frame,
|
| - Node& node) {
|
| - DraggedNodeImageBuilder image_node(frame, node);
|
| - return image_node.CreateImage();
|
| -}
|
| -
|
| -// static
|
| -// TODO(tanvir.rizvi): DragImageForSelection is used only by DragController,
|
| -// and is irrelevant to LocalFrame core functionality, so it can be moved to
|
| -// DragController.
|
| -std::unique_ptr<DragImage> DragController::DragImageForSelection(
|
| - const LocalFrame& frame,
|
| - float opacity) {
|
| - if (!frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange())
|
| - return nullptr;
|
| -
|
| - frame.View()->UpdateAllLifecyclePhasesExceptPaint();
|
| - DCHECK(frame.GetDocument()->IsActive());
|
| -
|
| - FloatRect painting_rect = FloatRect(frame.Selection().Bounds());
|
| - GlobalPaintFlags paint_flags =
|
| - kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers;
|
| -
|
| - PaintRecordBuilder builder(
|
| - DataTransfer::DeviceSpaceBounds(painting_rect, frame));
|
| - frame.View()->PaintContents(builder.Context(), paint_flags,
|
| - EnclosingIntRect(painting_rect));
|
| - return DataTransfer::CreateDragImageForFrame(
|
| - frame, opacity, kDoNotRespectImageOrientation, painting_rect, builder,
|
| - PropertyTreeState::Root());
|
| -}
|
| -
|
| String LocalFrame::SelectedText() const {
|
| return Selection().SelectedText();
|
| }
|
|
|