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

Unified Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 1602513004: Remove PaintInfo's paintingRoot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
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)
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698