Chromium Code Reviews| 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 eca2f188fe6f8acee6e9ae4fb8fdd189606af2ad..bf27b50bd42a5a2cd20ae876e79b466a6f8a744a 100644 |
| --- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp |
| +++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp |
| @@ -60,6 +60,8 @@ |
| #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/TransformRecorder.h" |
| #include "core/svg/SVGDocumentExtensions.h" |
| @@ -101,7 +103,6 @@ public: |
| { |
| if (node && node->layoutObject()) |
| node->layoutObject()->updateDragState(false); |
| - frame->view()->setNodeToDraw(0); |
| } |
| RawPtrWillBeMember<LocalFrame> frame; |
| @@ -653,18 +654,41 @@ PassOwnPtr<DragImage> LocalFrame::nodeImage(Node& node) |
| const ScopedFramePaintingState state(this, &node); |
| m_view->updateAllLifecyclePhases(); |
| - |
| - m_view->setNodeToDraw(&node); // Enable special sub-tree drawing mode. |
| - |
| - // Document::updateLayout may have blown away the original LayoutObject. |
| LayoutObject* layoutObject = node.layoutObject(); |
| if (!layoutObject) |
| return nullptr; |
| - IntRect rect; |
| + // Directly paint boxes as if they are a stacking context. |
| + if (layoutObject->isBox() && layoutObject->container()) { |
| + IntRect boundingBox = layoutObject->absoluteBoundingBoxRectIncludingDescendants(); |
| + LayoutPoint paintOffset = boundingBox.location(); |
| + paintOffset -= layoutObject->offsetFromContainer(layoutObject->container(), LayoutPoint()); |
| + |
| + float deviceScaleFactor = m_host->deviceScaleFactor(); |
| + boundingBox.scale(deviceScaleFactor); |
| + SkPictureBuilder pictureBuilder(SkRect::MakeIWH(boundingBox.width(), boundingBox.height())); |
| + { |
| + PaintInfo paintInfo(pictureBuilder.context(), boundingBox, PaintPhase::PaintPhaseForeground, GlobalPaintFlattenCompositingLayers, 0); |
| + |
| + AffineTransform transform; |
| + transform.scale(deviceScaleFactor, deviceScaleFactor); |
| + transform.translate(-boundingBox.x(), -boundingBox.y()); |
| + TransformRecorder transformRecorder(pictureBuilder.context(), *this, transform); |
|
chrishtr
2016/01/19 18:29:21
The code here looks like it duplicates paintIntoDr
pdr.
2016/01/19 23:29:21
Good idea. This required some invasive refactoring
|
| + |
| + ObjectPainter(*layoutObject).paintAsPseudoStackingContext(paintInfo, LayoutPoint(paintOffset)); |
| + } |
| + RefPtr<const SkPicture> recording = pictureBuilder.endRecording(); |
| + RefPtr<SkImage> skImage = adoptRef(SkImage::NewFromPicture(recording.get(), |
| + SkISize::Make(boundingBox.width(), boundingBox.height()), nullptr, nullptr)); |
| + RefPtr<Image> image = StaticBitmapImage::create(skImage.release()); |
| + return DragImage::create(image.get(), LayoutObject::shouldRespectImageOrientation(layoutObject), deviceScaleFactor, InterpolationHigh); |
| + } |
| + // FIXME(pdr): This will also paint the background if the object contains transparency. We can |
| + // directly call layoutObject->paint(...) (see: ObjectPainter::paintAsPseudoStackingContext) but |
| + // painters are inconsistent about which transform space they expect (see: svg, inlines, etc.) |
| return paintIntoDragImage(*layoutObject, LayoutObject::shouldRespectImageOrientation(layoutObject), |
| - GlobalPaintFlattenCompositingLayers, layoutObject->paintingRootRect(rect)); |
| + GlobalPaintFlattenCompositingLayers, layoutObject->absoluteBoundingBoxRectIncludingDescendants()); |
| } |
| PassOwnPtr<DragImage> LocalFrame::dragImageForSelection(float opacity) |