Chromium Code Reviews| Index: Source/core/rendering/compositing/CompositedLayerMapping.cpp |
| diff --git a/Source/core/rendering/compositing/CompositedLayerMapping.cpp b/Source/core/rendering/compositing/CompositedLayerMapping.cpp |
| index 6ef931465ca5ec2478a3b9b03b3f81c2d50b8031..4a8c17cd3a676c9db6eed80ab26312b7f3ea0774 100644 |
| --- a/Source/core/rendering/compositing/CompositedLayerMapping.cpp |
| +++ b/Source/core/rendering/compositing/CompositedLayerMapping.cpp |
| @@ -169,6 +169,7 @@ CompositedLayerMapping::CompositedLayerMapping(RenderLayer& layer) |
| , m_backgroundLayerPaintsFixedRootBackground(false) |
| , m_needToUpdateGraphicsLayer(false) |
| , m_needToUpdateGraphicsLayerOfAllDecendants(false) |
| + , m_scrollingContentsAreEmpty(false) |
| { |
| if (layer.isRootLayer() && renderer()->frame()->isMainFrame()) |
| m_isMainFrameRenderViewLayer = true; |
| @@ -252,6 +253,7 @@ void CompositedLayerMapping::destroyGraphicsLayers() |
| m_scrollingLayer = nullptr; |
| m_scrollingContentsLayer = nullptr; |
| + m_scrollingBlockSelectionLayer = nullptr; |
| } |
| void CompositedLayerMapping::updateOpacity(const RenderStyle* style) |
| @@ -858,6 +860,8 @@ void CompositedLayerMapping::updateScrollingLayerGeometry(const IntRect& localCo |
| m_foregroundLayer->setNeedsDisplay(); |
| m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offsetFromRenderer()); |
| } |
| + |
| + updateScrollingBlockSelection(); |
| } |
| void CompositedLayerMapping::updateChildClippingMaskLayerGeometry() |
| @@ -1006,6 +1010,7 @@ void CompositedLayerMapping::updatePaintingPhases() |
| if (!m_foregroundLayer) |
| paintPhase |= GraphicsLayerPaintForeground; |
| m_scrollingContentsLayer->setPaintingPhase(paintPhase); |
| + m_scrollingBlockSelectionLayer->setPaintingPhase(paintPhase); |
| } |
| } |
| @@ -1014,6 +1019,31 @@ void CompositedLayerMapping::updateContentsRect() |
| m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox())); |
| } |
| +void CompositedLayerMapping::updateScrollingBlockSelection() |
| +{ |
| + if (!m_scrollingBlockSelectionLayer) |
| + return; |
| + |
| + if (!m_scrollingContentsAreEmpty) { |
| + m_scrollingBlockSelectionLayer->setDrawsContent(false); |
|
Ian Vollick
2014/06/12 14:54:57
A comment explaining that the selection will be pa
hartmanng
2014/06/13 14:51:38
Done.
|
| + return; |
| + } |
| + |
| + const IntRect blockSelectionGapsBounds = m_owningLayer.blockSelectionGapsBounds(); |
| + const bool shouldDrawContent = !blockSelectionGapsBounds.isEmpty(); |
| + m_scrollingBlockSelectionLayer->setDrawsContent(shouldDrawContent); |
| + if (!shouldDrawContent) |
| + return; |
| + |
| + const IntPoint position = blockSelectionGapsBounds.location() + m_owningLayer.scrollableArea()->adjustedScrollOffset(); |
| + if (m_scrollingBlockSelectionLayer->size() == blockSelectionGapsBounds.size() && m_scrollingBlockSelectionLayer->position() == position) |
| + return; |
| + |
| + m_scrollingBlockSelectionLayer->setPosition(position); |
| + m_scrollingBlockSelectionLayer->setSize(blockSelectionGapsBounds.size()); |
| + m_scrollingBlockSelectionLayer->setOffsetFromRenderer(toIntSize(blockSelectionGapsBounds.location()), GraphicsLayer::SetNeedsDisplay); |
| +} |
| + |
| void CompositedLayerMapping::updateDrawsContent() |
| { |
| if (m_scrollingLayer) { |
| @@ -1026,6 +1056,9 @@ void CompositedLayerMapping::updateDrawsContent() |
| bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && (renderer()->hasBackground() || paintsChildren()); |
|
Ian Vollick
2014/06/12 14:54:57
I don't think you need the temporary if you're goi
hartmanng
2014/06/13 14:51:38
Done.
|
| m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); |
| + |
| + m_scrollingContentsAreEmpty = !hasScrollingPaintedContent; |
| + updateScrollingBlockSelection(); |
| return; |
| } |
| @@ -1409,6 +1442,10 @@ bool CompositedLayerMapping::updateScrollingLayers(bool needsScrollingLayers) |
| m_scrollingContentsLayer->setDrawsContent(true); |
| m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); |
| + m_scrollingBlockSelectionLayer = createGraphicsLayer(CompositingReasonLayerForScrollingBlockSelection); |
|
Ian Vollick
2014/06/12 14:54:57
Is it possible to create this only when we have a
hartmanng
2014/06/13 14:51:38
I'm not really sure. I tried for a while, but coul
|
| + m_scrollingBlockSelectionLayer->setDrawsContent(true); |
| + m_scrollingContentsLayer->addChild(m_scrollingBlockSelectionLayer.get()); |
| + |
| layerChanged = true; |
| if (scrollingCoordinator) |
| scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer.scrollableArea()); |
| @@ -1416,6 +1453,7 @@ bool CompositedLayerMapping::updateScrollingLayers(bool needsScrollingLayers) |
| } else if (m_scrollingLayer) { |
| m_scrollingLayer = nullptr; |
| m_scrollingContentsLayer = nullptr; |
| + m_scrollingBlockSelectionLayer = nullptr; |
| layerChanged = true; |
| if (scrollingCoordinator) |
| scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer.scrollableArea()); |
| @@ -2049,7 +2087,8 @@ void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G |
| || graphicsLayer == m_backgroundLayer.get() |
| || graphicsLayer == m_maskLayer.get() |
| || graphicsLayer == m_childClippingMaskLayer.get() |
| - || graphicsLayer == m_scrollingContentsLayer.get()) { |
| + || graphicsLayer == m_scrollingContentsLayer.get() |
| + || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
| GraphicsLayerPaintInfo paintInfo; |
| paintInfo.renderLayer = &m_owningLayer; |
| @@ -2211,6 +2250,8 @@ String CompositedLayerMapping::debugName(const GraphicsLayer* graphicsLayer) |
| name = "Scrolling Layer"; |
| } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| name = "Scrolling Contents Layer"; |
| + } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
| + name = "Scrolling Block Selection Layer"; |
| } else { |
| ASSERT_NOT_REACHED(); |
| } |