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

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

Issue 2266103002: Repaint when background switches painting from/to scrolling contents layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update flag and use setNeedsDisplay to dirty scrollingContentsLayer. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return (!page) ? nullptr : page->scrollingCoordinator(); 166 return (!page) ? nullptr : page->scrollingCoordinator();
167 } 167 }
168 168
169 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer) 169 CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
170 : m_owningLayer(layer) 170 : m_owningLayer(layer)
171 , m_contentOffsetInCompositingLayerDirty(false) 171 , m_contentOffsetInCompositingLayerDirty(false)
172 , m_pendingUpdateScope(GraphicsLayerUpdateNone) 172 , m_pendingUpdateScope(GraphicsLayerUpdateNone)
173 , m_isMainFrameLayoutViewLayer(false) 173 , m_isMainFrameLayoutViewLayer(false)
174 , m_backgroundLayerPaintsFixedRootBackground(false) 174 , m_backgroundLayerPaintsFixedRootBackground(false)
175 , m_scrollingContentsAreEmpty(false) 175 , m_scrollingContentsAreEmpty(false)
176 , m_backgroundPaintsOntoScrollingContentsLayer(false)
176 { 177 {
177 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame()) 178 if (layer.isRootLayer() && layoutObject()->frame()->isMainFrame())
178 m_isMainFrameLayoutViewLayer = true; 179 m_isMainFrameLayoutViewLayer = true;
179 180
180 createPrimaryGraphicsLayer(); 181 createPrimaryGraphicsLayer();
181 } 182 }
182 183
183 CompositedLayerMapping::~CompositedLayerMapping() 184 CompositedLayerMapping::~CompositedLayerMapping()
184 { 185 {
185 // Hits in compositing/squashing/squash-onto-nephew.html. 186 // Hits in compositing/squashing/squash-onto-nephew.html.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 void CompositedLayerMapping::updateIsRootForIsolatedGroup() 287 void CompositedLayerMapping::updateIsRootForIsolatedGroup()
287 { 288 {
288 bool isolate = m_owningLayer.shouldIsolateCompositedDescendants(); 289 bool isolate = m_owningLayer.shouldIsolateCompositedDescendants();
289 290
290 // non stacking context layers should never isolate 291 // non stacking context layers should never isolate
291 ASSERT(m_owningLayer.stackingNode()->isStackingContext() || !isolate); 292 ASSERT(m_owningLayer.stackingNode()->isStackingContext() || !isolate);
292 293
293 m_graphicsLayer->setIsRootForIsolatedGroup(isolate); 294 m_graphicsLayer->setIsRootForIsolatedGroup(isolate);
294 } 295 }
295 296
297 void CompositedLayerMapping::updateBackgroundPaintingLayer()
298 {
299 bool backgroundLayerPaintsOntoScrollingContentsLayer = shouldPaintBackground OntoScrollingContentsLayer();
300 if (backgroundLayerPaintsOntoScrollingContentsLayer != m_backgroundPaintsOnt oScrollingContentsLayer) {
301 // If the background is no longer painted onto the scrolling contents
302 // layer the scrolling contents layer needs to be updated. If it is
303 // going to be painted onto the scrolling contents layer this update
304 // will be triggered by LayoutBoxModelObject::setBackingNeedsPaintInvali dationInRect
305 if (!backgroundLayerPaintsOntoScrollingContentsLayer)
306 m_scrollingContentsLayer->setNeedsDisplay();
307 m_backgroundPaintsOntoScrollingContentsLayer = backgroundLayerPaintsOnto ScrollingContentsLayer;
308 }
309 }
310
296 void CompositedLayerMapping::updateContentsOpaque() 311 void CompositedLayerMapping::updateContentsOpaque()
297 { 312 {
298 ASSERT(m_isMainFrameLayoutViewLayer || !m_backgroundLayer);
299 if (isAcceleratedCanvas(layoutObject())) { 313 if (isAcceleratedCanvas(layoutObject())) {
300 // Determine whether the rendering context's external texture layer is o paque. 314 // Determine whether the rendering context's external texture layer is o paque.
301 CanvasRenderingContext* context = toHTMLCanvasElement(layoutObject()->no de())->renderingContext(); 315 CanvasRenderingContext* context = toHTMLCanvasElement(layoutObject()->no de())->renderingContext();
302 if (!context->hasAlpha()) 316 if (!context->hasAlpha())
303 m_graphicsLayer->setContentsOpaque(true); 317 m_graphicsLayer->setContentsOpaque(true);
304 else if (WebLayer* layer = context->platformLayer()) 318 else if (WebLayer* layer = context->platformLayer())
305 m_graphicsLayer->setContentsOpaque(!Color(layer->backgroundColor()). hasAlpha()); 319 m_graphicsLayer->setContentsOpaque(!Color(layer->backgroundColor()). hasAlpha());
306 else 320 else
307 m_graphicsLayer->setContentsOpaque(false); 321 m_graphicsLayer->setContentsOpaque(false);
308 } else if (m_backgroundLayer) { 322 } else if (m_backgroundLayer) {
309 m_graphicsLayer->setContentsOpaque(false); 323 m_graphicsLayer->setContentsOpaque(false);
310 m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBe OpaqueInRect(compositedBounds())); 324 m_backgroundLayer->setContentsOpaque(m_owningLayer.backgroundIsKnownToBe OpaqueInRect(compositedBounds()));
311 } else { 325 } else {
312 // For non-root layers, background is painted by the scrolling contents layer if all backgrounds 326 // For non-root layers, background is painted by the scrolling contents layer if all backgrounds
313 // are background attachment local, otherwise background is painted by t he primary graphics layer. 327 // are background attachment local, otherwise background is painted by t he primary graphics layer.
314 if (hasScrollingLayer() && shouldPaintBackgroundOntoScrollingContentsLay er()) { 328 if (hasScrollingLayer() && m_backgroundPaintsOntoScrollingContentsLayer) {
315 // Backgrounds painted onto the foreground are clipped by the paddin g box rect. 329 // Backgrounds painted onto the foreground are clipped by the paddin g box rect.
316 // TODO(flackr): This should actually check the entire overflow rect within the 330 // TODO(flackr): This should actually check the entire overflow rect within the
317 // scrolling contents layer but since we currently only trigger this for solid 331 // scrolling contents layer but since we currently only trigger this for solid
318 // color backgrounds the answer will be the same. 332 // color backgrounds the answer will be the same.
319 m_scrollingContentsLayer->setContentsOpaque(m_owningLayer.background IsKnownToBeOpaqueInRect(toLayoutBox(layoutObject())->paddingBoxRect())); 333 m_scrollingContentsLayer->setContentsOpaque(m_owningLayer.background IsKnownToBeOpaqueInRect(toLayoutBox(layoutObject())->paddingBoxRect()));
320 334
321 // When we paint the background onto the scrolling contents layer we are going 335 // When we paint the background onto the scrolling contents layer we are going
322 // to leave a hole in the m_graphicsLayer where the background is so it is 336 // to leave a hole in the m_graphicsLayer where the background is so it is
323 // not opaque. 337 // not opaque.
324 m_graphicsLayer->setContentsOpaque(false); 338 m_graphicsLayer->setContentsOpaque(false);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 775
762 if (m_owningLayer.getScrollableArea() && m_owningLayer.getScrollableArea()-> scrollsOverflow()) 776 if (m_owningLayer.getScrollableArea() && m_owningLayer.getScrollableArea()-> scrollsOverflow())
763 m_owningLayer.getScrollableArea()->positionOverflowControls(); 777 m_owningLayer.getScrollableArea()->positionOverflowControls();
764 778
765 updateLayerBlendMode(layoutObject()->styleRef()); 779 updateLayerBlendMode(layoutObject()->styleRef());
766 updateIsRootForIsolatedGroup(); 780 updateIsRootForIsolatedGroup();
767 updateContentsRect(); 781 updateContentsRect();
768 updateBackgroundColor(); 782 updateBackgroundColor();
769 updateDrawsContent(); 783 updateDrawsContent();
770 updateElementIdAndCompositorMutableProperties(); 784 updateElementIdAndCompositorMutableProperties();
785 updateBackgroundPaintingLayer();
771 updateContentsOpaque(); 786 updateContentsOpaque();
772 updateAfterPartResize(); 787 updateAfterPartResize();
773 updateRenderingContext(); 788 updateRenderingContext();
774 updateShouldFlattenTransform(); 789 updateShouldFlattenTransform();
775 updateChildrenTransform(); 790 updateChildrenTransform();
776 updateScrollParent(scrollParent()); 791 updateScrollParent(scrollParent());
777 registerScrollingLayers(); 792 registerScrollingLayers();
778 793
779 updateCompositingReasons(); 794 updateCompositingReasons();
780 } 795 }
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLay er()) 2468 else if (compositor()->fixedRootBackgroundLayer() && m_owningLayer.isRootLay er())
2454 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 2469 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
2455 2470
2456 if (graphicsLayer == m_graphicsLayer.get() 2471 if (graphicsLayer == m_graphicsLayer.get()
2457 || graphicsLayer == m_foregroundLayer.get() 2472 || graphicsLayer == m_foregroundLayer.get()
2458 || graphicsLayer == m_backgroundLayer.get() 2473 || graphicsLayer == m_backgroundLayer.get()
2459 || graphicsLayer == m_maskLayer.get() 2474 || graphicsLayer == m_maskLayer.get()
2460 || graphicsLayer == m_childClippingMaskLayer.get() 2475 || graphicsLayer == m_childClippingMaskLayer.get()
2461 || graphicsLayer == m_scrollingContentsLayer.get()) { 2476 || graphicsLayer == m_scrollingContentsLayer.get()) {
2462 2477
2463 bool paintRootBackgroundOntoScrollingContentsLayer = shouldPaintBackgrou ndOntoScrollingContentsLayer(); 2478 bool paintRootBackgroundOntoScrollingContentsLayer = m_backgroundPaintsO ntoScrollingContentsLayer;
2464 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || (!m_backgroundL ayer && !m_foregroundLayer)); 2479 DCHECK(!paintRootBackgroundOntoScrollingContentsLayer || (!m_backgroundL ayer && !m_foregroundLayer));
2465 if (paintRootBackgroundOntoScrollingContentsLayer) { 2480 if (paintRootBackgroundOntoScrollingContentsLayer) {
2466 if (graphicsLayer == m_scrollingContentsLayer.get()) 2481 if (graphicsLayer == m_scrollingContentsLayer.get())
2467 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground; 2482 paintLayerFlags &= ~PaintLayerPaintingSkipRootBackground;
2468 else 2483 else
2469 paintLayerFlags |= PaintLayerPaintingSkipRootBackground; 2484 paintLayerFlags |= PaintLayerPaintingSkipRootBackground;
2470 } 2485 }
2471 GraphicsLayerPaintInfo paintInfo; 2486 GraphicsLayerPaintInfo paintInfo;
2472 paintInfo.paintLayer = &m_owningLayer; 2487 paintInfo.paintLayer = &m_owningLayer;
2473 paintInfo.compositedBounds = compositedBounds(); 2488 paintInfo.compositedBounds = compositedBounds();
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2693 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2708 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2694 name = "Scrolling Contents Layer"; 2709 name = "Scrolling Contents Layer";
2695 } else { 2710 } else {
2696 ASSERT_NOT_REACHED(); 2711 ASSERT_NOT_REACHED();
2697 } 2712 }
2698 2713
2699 return name; 2714 return name;
2700 } 2715 }
2701 2716
2702 } // namespace blink 2717 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698