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

Side by Side Diff: Source/core/rendering/compositing/CompositedLayerMapping.h

Issue 397713004: Overlay scrollbars must respect ancestor clip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // but this is likely to evolve soon. 83 // but this is likely to evolve soon.
84 class CompositedLayerMapping FINAL : public GraphicsLayerClient { 84 class CompositedLayerMapping FINAL : public GraphicsLayerClient {
85 WTF_MAKE_NONCOPYABLE(CompositedLayerMapping); WTF_MAKE_FAST_ALLOCATED; 85 WTF_MAKE_NONCOPYABLE(CompositedLayerMapping); WTF_MAKE_FAST_ALLOCATED;
86 public: 86 public:
87 explicit CompositedLayerMapping(RenderLayer&); 87 explicit CompositedLayerMapping(RenderLayer&);
88 virtual ~CompositedLayerMapping(); 88 virtual ~CompositedLayerMapping();
89 89
90 RenderLayer& owningLayer() const { return m_owningLayer; } 90 RenderLayer& owningLayer() const { return m_owningLayer; }
91 91
92 bool updateGraphicsLayerConfiguration(); 92 bool updateGraphicsLayerConfiguration();
93 void updateGraphicsLayerGeometry(const RenderLayer* compositingContainer, Ve ctor<RenderLayer*>& layersNeedingPaintInvalidation); 93 void updateGraphicsLayerGeometry(const RenderLayer* compositingContainer, co nst RenderLayer* compositingStackingContext, Vector<RenderLayer*>& layersNeeding PaintInvalidation);
94 94
95 // Update whether layer needs blending. 95 // Update whether layer needs blending.
96 void updateContentsOpaque(); 96 void updateContentsOpaque();
97 97
98 GraphicsLayer* mainGraphicsLayer() const { return m_graphicsLayer.get(); } 98 GraphicsLayer* mainGraphicsLayer() const { return m_graphicsLayer.get(); }
99 99
100 // Layer to clip children 100 // Layer to clip children
101 bool hasClippingLayer() const { return m_childContainmentLayer; } 101 bool hasClippingLayer() const { return m_childContainmentLayer; }
102 GraphicsLayer* clippingLayer() const { return m_childContainmentLayer.get(); } 102 GraphicsLayer* clippingLayer() const { return m_childContainmentLayer.get(); }
103 103
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 #if ENABLE(ASSERT) 178 #if ENABLE(ASSERT)
179 virtual void verifyNotPainting() OVERRIDE; 179 virtual void verifyNotPainting() OVERRIDE;
180 #endif 180 #endif
181 181
182 LayoutRect contentsBox() const; 182 LayoutRect contentsBox() const;
183 183
184 GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizo ntalScrollbar.get(); } 184 GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizo ntalScrollbar.get(); }
185 GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVertical Scrollbar.get(); } 185 GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVertical Scrollbar.get(); }
186 GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner. get(); } 186 GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner. get(); }
187 187
188 // Returns true if the overflow controls cannot be positioned within this
189 // CLM's internal hierarchy without incorrectly stacking under some
190 // scrolling content. If this returns true, these controls must be
191 // repositioned in the graphics layer tree to ensure that they stack above
192 // scrolling content.
193 bool needsToReparentOverflowControls() const;
194
188 // Removes the overflow controls host layer from its parent and positions it 195 // Removes the overflow controls host layer from its parent and positions it
189 // so that it can be inserted as a sibling to this CLM without changing 196 // so that it can be inserted as a sibling to this CLM without changing
190 // position. 197 // position.
191 GraphicsLayer* detachLayerForOverflowControls(const RenderLayer& enclosingLa yer); 198 GraphicsLayer* detachLayerForOverflowControls(const RenderLayer& enclosingLa yer);
192 199
193 void updateFilters(const RenderStyle*); 200 void updateFilters(const RenderStyle*);
194 201
195 void setBlendMode(blink::WebBlendMode); 202 void setBlendMode(blink::WebBlendMode);
196 203
197 bool needsGraphicsLayerUpdate() { return m_pendingUpdateScope > GraphicsLaye rUpdateNone; } 204 bool needsGraphicsLayerUpdate() { return m_pendingUpdateScope > GraphicsLaye rUpdateNone; }
(...skipping 21 matching lines...) Expand all
219 void updateScrollingBlockSelection(); 226 void updateScrollingBlockSelection();
220 227
221 private: 228 private:
222 static const GraphicsLayerPaintInfo* containingSquashedLayer(const RenderObj ect*, const Vector<GraphicsLayerPaintInfo>& layers); 229 static const GraphicsLayerPaintInfo* containingSquashedLayer(const RenderObj ect*, const Vector<GraphicsLayerPaintInfo>& layers);
223 230
224 // Helper methods to updateGraphicsLayerGeometry: 231 // Helper methods to updateGraphicsLayerGeometry:
225 void computeGraphicsLayerParentLocation(const RenderLayer* compositingContai ner, const IntRect& ancestorCompositingBounds, IntPoint& graphicsLayerParentLoca tion); 232 void computeGraphicsLayerParentLocation(const RenderLayer* compositingContai ner, const IntRect& ancestorCompositingBounds, IntPoint& graphicsLayerParentLoca tion);
226 void updateSquashingLayerGeometry(const LayoutPoint& offsetFromCompositedAnc estor, const IntPoint& graphicsLayerParentLocation, const RenderLayer& reference Layer, Vector<GraphicsLayerPaintInfo>& layers, GraphicsLayer*, LayoutPoint* offs etFromTransformedAncestor, Vector<RenderLayer*>& layersNeedingPaintInvalidation) ; 233 void updateSquashingLayerGeometry(const LayoutPoint& offsetFromCompositedAnc estor, const IntPoint& graphicsLayerParentLocation, const RenderLayer& reference Layer, Vector<GraphicsLayerPaintInfo>& layers, GraphicsLayer*, LayoutPoint* offs etFromTransformedAncestor, Vector<RenderLayer*>& layersNeedingPaintInvalidation) ;
227 void updateMainGraphicsLayerGeometry(const IntRect& relativeCompositingBound s, const IntRect& localCompositingBounds, IntPoint& graphicsLayerParentLocation) ; 234 void updateMainGraphicsLayerGeometry(const IntRect& relativeCompositingBound s, const IntRect& localCompositingBounds, IntPoint& graphicsLayerParentLocation) ;
228 void updateAncestorClippingLayerGeometry(const RenderLayer* compositingConta iner, const IntPoint& snappedOffsetFromCompositedAncestor, IntPoint& graphicsLay erParentLocation); 235 void updateAncestorClippingLayerGeometry(const RenderLayer* compositingConta iner, const IntPoint& snappedOffsetFromCompositedAncestor, IntPoint& graphicsLay erParentLocation);
236 void updateOverflowControlsHostLayerGeometry(const RenderLayer* compositingS tackingContext);
229 void updateChildContainmentLayerGeometry(const IntRect& clippingBox, const I ntRect& localCompositingBounds); 237 void updateChildContainmentLayerGeometry(const IntRect& clippingBox, const I ntRect& localCompositingBounds);
230 void updateChildTransformLayerGeometry(); 238 void updateChildTransformLayerGeometry();
231 void updateMaskLayerGeometry(); 239 void updateMaskLayerGeometry();
232 void updateTransformGeometry(const IntPoint& snappedOffsetFromCompositedAnce stor, const IntRect& relativeCompositingBounds); 240 void updateTransformGeometry(const IntPoint& snappedOffsetFromCompositedAnce stor, const IntRect& relativeCompositingBounds);
233 void updateForegroundLayerGeometry(const FloatSize& relativeCompositingBound sSize, const IntRect& clippingBox); 241 void updateForegroundLayerGeometry(const FloatSize& relativeCompositingBound sSize, const IntRect& clippingBox);
234 void updateBackgroundLayerGeometry(const FloatSize& relativeCompositingBound sSize); 242 void updateBackgroundLayerGeometry(const FloatSize& relativeCompositingBound sSize);
235 void updateReflectionLayerGeometry(Vector<RenderLayer*>& layersNeedingPaintI nvalidation); 243 void updateReflectionLayerGeometry(Vector<RenderLayer*>& layersNeedingPaintI nvalidation);
236 void updateScrollingLayerGeometry(const IntRect& localCompositingBounds); 244 void updateScrollingLayerGeometry(const IntRect& localCompositingBounds);
237 void updateChildClippingMaskLayerGeometry(); 245 void updateChildClippingMaskLayerGeometry();
238 246
239 void createPrimaryGraphicsLayer(); 247 void createPrimaryGraphicsLayer();
240 void destroyGraphicsLayers(); 248 void destroyGraphicsLayers();
241 249
242 PassOwnPtr<GraphicsLayer> createGraphicsLayer(CompositingReasons); 250 PassOwnPtr<GraphicsLayer> createGraphicsLayer(CompositingReasons);
243 bool toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&, bool needsLayer, C ompositingReasons); 251 bool toggleScrollbarLayerIfNeeded(OwnPtr<GraphicsLayer>&, bool needsLayer, C ompositingReasons);
244 252
245 RenderLayerModelObject* renderer() const { return m_owningLayer.renderer(); } 253 RenderLayerModelObject* renderer() const { return m_owningLayer.renderer(); }
246 RenderLayerCompositor* compositor() const { return m_owningLayer.compositor( ); } 254 RenderLayerCompositor* compositor() const { return m_owningLayer.compositor( ); }
247 255
248 void updateInternalHierarchy(); 256 void updateInternalHierarchy();
249 void updatePaintingPhases(); 257 void updatePaintingPhases();
250 bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip); 258 bool updateClippingLayers(bool needsAncestorClip, bool needsDescendantClip);
251 bool updateChildTransformLayer(bool needsChildTransformLayer); 259 bool updateChildTransformLayer(bool needsChildTransformLayer);
252 bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool n eedsVerticalScrollbarLayer, bool needsScrollCornerLayer); 260 bool updateOverflowControlsLayers(bool needsHorizontalScrollbarLayer, bool n eedsVerticalScrollbarLayer, bool needsScrollCornerLayer, bool needsAncestorClip) ;
253 bool updateForegroundLayer(bool needsForegroundLayer); 261 bool updateForegroundLayer(bool needsForegroundLayer);
254 bool updateBackgroundLayer(bool needsBackgroundLayer); 262 bool updateBackgroundLayer(bool needsBackgroundLayer);
255 bool updateMaskLayer(bool needsMaskLayer); 263 bool updateMaskLayer(bool needsMaskLayer);
256 bool updateClippingMaskLayers(bool needsChildClippingMaskLayer); 264 bool updateClippingMaskLayers(bool needsChildClippingMaskLayer);
257 bool requiresHorizontalScrollbarLayer() const { return m_owningLayer.scrolla bleArea() && m_owningLayer.scrollableArea()->horizontalScrollbar(); } 265 bool requiresHorizontalScrollbarLayer() const { return m_owningLayer.scrolla bleArea() && m_owningLayer.scrollableArea()->horizontalScrollbar(); }
258 bool requiresVerticalScrollbarLayer() const { return m_owningLayer.scrollabl eArea() && m_owningLayer.scrollableArea()->verticalScrollbar(); } 266 bool requiresVerticalScrollbarLayer() const { return m_owningLayer.scrollabl eArea() && m_owningLayer.scrollableArea()->verticalScrollbar(); }
259 bool requiresScrollCornerLayer() const { return m_owningLayer.scrollableArea () && !m_owningLayer.scrollableArea()->scrollCornerAndResizerRect().isEmpty(); } 267 bool requiresScrollCornerLayer() const { return m_owningLayer.scrollableArea () && !m_owningLayer.scrollableArea()->scrollCornerAndResizerRect().isEmpty(); }
260 bool updateScrollingLayers(bool scrollingLayers); 268 bool updateScrollingLayers(bool scrollingLayers);
261 void updateScrollParent(RenderLayer*); 269 void updateScrollParent(RenderLayer*);
262 void updateClipParent(); 270 void updateClipParent();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // clipping container for |m_owningLayer|. 321 // clipping container for |m_owningLayer|.
314 bool owningLayerClippedByLayerNotAboveCompositedAncestor(); 322 bool owningLayerClippedByLayerNotAboveCompositedAncestor();
315 323
316 RenderLayer& m_owningLayer; 324 RenderLayer& m_owningLayer;
317 325
318 // The hierarchy of layers that is maintained by the CompositedLayerMapping looks like this: 326 // The hierarchy of layers that is maintained by the CompositedLayerMapping looks like this:
319 // 327 //
320 // + m_ancestorClippingLayer [OPTIONAL] 328 // + m_ancestorClippingLayer [OPTIONAL]
321 // + m_graphicsLayer 329 // + m_graphicsLayer
322 // + m_childContainmentLayer [OPTIONAL] <-OR-> m_scrollingLayer [OPTI ONAL] <-OR-> m_childTransformLayer 330 // + m_childContainmentLayer [OPTIONAL] <-OR-> m_scrollingLayer [OPTI ONAL] <-OR-> m_childTransformLayer
323 // + m_scrollingContents Layer [Present iff m_scrollingLayer is present] 331 // | + m_scrollingContents Layer [Present iff m_scrollingLayer is present]
324 // + m_scrollingBlock SelectionLayer [Present iff m_scrollingLayer is present] 332 // | + m_scrollingBlock SelectionLayer [Present iff m_scrollingLayer is present]
333 // |
334 // + m_overflowControlsClippingLayer [OPTIONAL] // *The overflow cont rols may need to be repositioned in the
335 // + m_overflowControlsHostLayer // graphics layer tr ee by the RLC to ensure that they stack
336 // + m_layerForVerticalScrollbar // above scrolling c ontent.
337 // + m_layerForHorizontalScrollbar
338 // + m_layerForScrollCorner
325 // 339 //
326 // We need an ancestor clipping layer if our clipping ancestor is not our an cestor in the 340 // We need an ancestor clipping layer if our clipping ancestor is not our an cestor in the
327 // clipping tree. Here's what that might look like. 341 // clipping tree. Here's what that might look like.
328 // 342 //
329 // Let A = the clipping ancestor, 343 // Let A = the clipping ancestor,
330 // B = the clip descendant, and 344 // B = the clip descendant, and
331 // SC = the stacking context that is the ancestor of A and B in the stac king tree. 345 // SC = the stacking context that is the ancestor of A and B in the stac king tree.
332 // 346 //
333 // SC 347 // SC
334 // + A = m_graphicsLayer 348 // + A = m_graphicsLayer
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // + root content layer 392 // + root content layer
379 // 393 //
380 // With the hierarchy set up like this, the root content layer is able to sc roll without affecting 394 // With the hierarchy set up like this, the root content layer is able to sc roll without affecting
381 // the background layer (or repainting). 395 // the background layer (or repainting).
382 OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately. 396 OwnPtr<GraphicsLayer> m_foregroundLayer; // Only used in cases where we need to draw the foreground separately.
383 OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately. 397 OwnPtr<GraphicsLayer> m_backgroundLayer; // Only used in cases where we need to draw the background separately.
384 398
385 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar; 399 OwnPtr<GraphicsLayer> m_layerForHorizontalScrollbar;
386 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar; 400 OwnPtr<GraphicsLayer> m_layerForVerticalScrollbar;
387 OwnPtr<GraphicsLayer> m_layerForScrollCorner; 401 OwnPtr<GraphicsLayer> m_layerForScrollCorner;
402
403 // This layer exists to simplify the reparenting of overflow control that is occasionally required
404 // to ensure that scrollbars appear above scrolling content.
388 OwnPtr<GraphicsLayer> m_overflowControlsHostLayer; 405 OwnPtr<GraphicsLayer> m_overflowControlsHostLayer;
389 406
407 // The reparented overflow controls sometimes need to be clipped by a non-an cestor. In just the same
408 // way we need an ancestor clipping layer to clip this CLM's internal hierar chy, we add another layer
409 // to clip the overflow controls. It would be possible to make m_overflowCon trolsHostLayer be
410 // responsible for applying this clip, but that could require repositioning all of the overflow
411 // controls since the this clip may apply an offset. By using a separate lay er, the overflow controls
412 // can remain ignorant of the layers above them and still work correctly.
413 OwnPtr<GraphicsLayer> m_overflowControlsClippingLayer;
414
390 // A squashing CLM has two possible squashing-related structures. 415 // A squashing CLM has two possible squashing-related structures.
391 // 416 //
392 // If m_ancestorClippingLayer is present: 417 // If m_ancestorClippingLayer is present:
393 // 418 //
394 // m_ancestorClippingLayer 419 // m_ancestorClippingLayer
395 // + m_graphicsLayer 420 // + m_graphicsLayer
396 // + m_squashingLayer 421 // + m_squashingLayer
397 // 422 //
398 // If not: 423 // If not:
399 // 424 //
(...skipping 14 matching lines...) Expand all
414 unsigned m_isMainFrameRenderViewLayer : 1; 439 unsigned m_isMainFrameRenderViewLayer : 1;
415 unsigned m_requiresOwnBackingStoreForIntrinsicReasons : 1; 440 unsigned m_requiresOwnBackingStoreForIntrinsicReasons : 1;
416 unsigned m_requiresOwnBackingStoreForAncestorReasons : 1; 441 unsigned m_requiresOwnBackingStoreForAncestorReasons : 1;
417 unsigned m_backgroundLayerPaintsFixedRootBackground : 1; 442 unsigned m_backgroundLayerPaintsFixedRootBackground : 1;
418 unsigned m_scrollingContentsAreEmpty : 1; 443 unsigned m_scrollingContentsAreEmpty : 1;
419 }; 444 };
420 445
421 } // namespace blink 446 } // namespace blink
422 447
423 #endif // CompositedLayerMapping_h 448 #endif // CompositedLayerMapping_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698