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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 1835843002: WIP: Fix foreignObject cullrect Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/layout/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 42c5d329f5468042daab32c27a1ff15c5329b456..28d365f076a9eb0ee209af792e8623e503575678 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -64,7 +64,9 @@
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/paint/ClipDisplayItem.h"
#include "platform/graphics/paint/CullRect.h"
+#include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/PaintController.h"
+#include "platform/graphics/paint/SkPictureBuilder.h"
#include "platform/graphics/paint/TransformDisplayItem.h"
#include "wtf/CurrentTime.h"
#include "wtf/text/StringBuilder.h"
@@ -2312,7 +2314,8 @@ bool CompositedLayerMapping::needsRepaint() const
return m_owningLayer.needsRepaint();
}
-void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const
+void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context,
+ GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const
{
// https://code.google.com/p/chromium/issues/detail?id=343772
DisableCompositingQueryAsserts disabler;
@@ -2360,15 +2363,8 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
} else if (graphicsLayer == m_squashingLayer.get()) {
for (size_t i = 0; i < m_squashedLayers.size(); ++i)
doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, context, interestRect);
- } else if (graphicsLayer == layerForHorizontalScrollbar()) {
- paintScrollbar(m_owningLayer.getScrollableArea()->horizontalScrollbar(), context, interestRect);
- } else if (graphicsLayer == layerForVerticalScrollbar()) {
- paintScrollbar(m_owningLayer.getScrollableArea()->verticalScrollbar(), context, interestRect);
- } else if (graphicsLayer == layerForScrollCorner()) {
- IntPoint scrollCornerAndResizerLocation = m_owningLayer.getScrollableArea()->scrollCornerAndResizerRect().location();
- CullRect cullRect(enclosingIntRect(interestRect));
- ScrollableAreaPainter(*m_owningLayer.getScrollableArea()).paintScrollCorner(context, -scrollCornerAndResizerLocation, cullRect);
- ScrollableAreaPainter(*m_owningLayer.getScrollableArea()).paintResizer(context, -scrollCornerAndResizerLocation, cullRect);
+ } else if (isScrollableAreaLayer(graphicsLayer)) {
+ paintScrollableArea(graphicsLayer, context, interestRect);
}
InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLayer, context, LayoutRect(interestRect));
#if ENABLE(ASSERT)
@@ -2377,6 +2373,42 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
#endif
}
+void CompositedLayerMapping::paintScrollableArea(const GraphicsLayer* graphicsLayer,
+ GraphicsContext& context, const IntRect& interestRect) const
+{
+ // Note the composited scrollable area painted here is never associated with a frame. For
+ // painting frame ScrollableAreas, see PaintLayerCompositor::paintContents.
+
+ FloatRect layerBounds(FloatPoint(), graphicsLayer->size());
+ SkPictureBuilder pictureBuilder(layerBounds, nullptr, &context);
+
+ PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableArea();
+ if (graphicsLayer == layerForHorizontalScrollbar()) {
+ paintScrollbar(scrollableArea->horizontalScrollbar(), pictureBuilder.context(), interestRect);
+ } else if (graphicsLayer == layerForVerticalScrollbar()) {
+ paintScrollbar(scrollableArea->verticalScrollbar(), pictureBuilder.context(), interestRect);
+ } else if (graphicsLayer == layerForScrollCorner()) {
+ // Note that scroll corners always paint into local space, whereas scrollbars paint in the space of their containing frame.
+ IntPoint scrollCornerAndResizerLocation = scrollableArea->scrollCornerAndResizerRect().location();
+ CullRect cullRect(enclosingIntRect(interestRect));
+ ScrollableAreaPainter(*scrollableArea).paintScrollCorner(pictureBuilder.context(), -scrollCornerAndResizerLocation, cullRect);
+ ScrollableAreaPainter(*scrollableArea).paintResizer(pictureBuilder.context(), -scrollCornerAndResizerLocation, cullRect);
+ }
+
+ // Replay the painted scrollbar content with the GraphicsLayer backing as the DisplayItemClient
+ // in order for the resulting DrawingDisplayItem to produce the correct visualRect (i.e., the
+ // bounds of the involved GraphicsLayer).
+ DrawingRecorder drawingRecorder(context, *graphicsLayer, DisplayItem::ScrollbarCompositedScrollbar, layerBounds);
+ pictureBuilder.endRecording()->playback(context.canvas());
+}
+
+bool CompositedLayerMapping::isScrollableAreaLayer(const GraphicsLayer* graphicsLayer) const
+{
+ return graphicsLayer == layerForHorizontalScrollbar()
+ || graphicsLayer == layerForVerticalScrollbar()
+ || graphicsLayer == layerForScrollCorner();
+}
+
bool CompositedLayerMapping::isTrackingPaintInvalidations() const
{
GraphicsLayerClient* client = compositor();

Powered by Google App Engine
This is Rietveld 408576698