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

Side by Side Diff: Source/core/rendering/RenderLayerCompositor.cpp

Issue 22419002: Set up clip and scroll parents on the blink side. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 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 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, 1739 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips,
1740 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented 1740 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented
1741 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. 1741 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy.
1742 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, 1742 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy,
1743 // but a sibling in the z-order hierarchy. 1743 // but a sibling in the z-order hierarchy.
1744 bool RenderLayerCompositor::clippedByAncestor(RenderLayer* layer) const 1744 bool RenderLayerCompositor::clippedByAncestor(RenderLayer* layer) const
1745 { 1745 {
1746 if (!layer->isComposited() || !layer->parent()) 1746 if (!layer->isComposited() || !layer->parent())
1747 return false; 1747 return false;
1748 1748
1749 RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); 1749 // Scroll children use their scrolling ancestor as their clip root.
1750 RenderLayer* compositingAncestor = clippedByScrollingAncestor(layer)
1751 ? layer->ancestorScrollingLayer()
1752 : layer->ancestorCompositingLayer();
1753
1750 if (!compositingAncestor) 1754 if (!compositingAncestor)
1751 return false; 1755 return false;
1752 1756
1753 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), 1757 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(),
1754 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), 1758 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot),
1755 // and layer. 1759 // and layer.
1756 RenderLayer* computeClipRoot = 0; 1760 RenderLayer* computeClipRoot = 0;
1757 RenderLayer* curr = layer; 1761 RenderLayer* curr = layer;
1758 while (curr) { 1762 while (curr) {
1759 RenderLayer* next = curr->parent(); 1763 RenderLayer* next = curr->parent();
1760 if (next == compositingAncestor) { 1764 if (next == compositingAncestor) {
1761 computeClipRoot = curr; 1765 computeClipRoot = curr;
1762 break; 1766 break;
1763 } 1767 }
1764 curr = next; 1768 curr = next;
1765 } 1769 }
1766 1770
1767 if (!computeClipRoot || computeClipRoot == layer) 1771 if (!computeClipRoot || computeClipRoot == layer)
1768 return false; 1772 return false;
1769 1773
1770 return layer->backgroundClipRect(RenderLayer::ClipRectsContext(computeClipRo ot, 0, TemporaryClipRects)).rect() != PaintInfo::infiniteRect(); // FIXME: Incor rect for CSS regions. 1774 return layer->backgroundClipRect(RenderLayer::ClipRectsContext(computeClipRo ot, 0, TemporaryClipRects)).rect() != PaintInfo::infiniteRect(); // FIXME: Incor rect for CSS regions.
1771 } 1775 }
1772 1776
1777 bool RenderLayerCompositor::clippedByScrollingAncestor(RenderLayer* layer) const
1778 {
1779 if (!layer->isComposited() || !layer->parent())
1780 return false;
1781
1782 if (!requiresCompositingForOverflowScrollingParent(layer))
1783 return false;
1784
1785 RenderLayer* compositingAncestor = layer->ancestorCompositingLayer();
1786 if (!compositingAncestor)
1787 return false;
1788
1789 RenderLayer* scrollingAncestor = layer->ancestorScrollingLayer();
1790 if (!scrollingAncestor)
1791 return false;
1792
1793 if (!scrollingAncestor->hasAncestor(compositingAncestor))
1794 return false;
1795
1796 // FIXME: Incorrect for CSS regions.
1797 RenderLayer::ClipRectsContext clipRectsContext(compositingAncestor, 0, Tempo raryClipRects, IgnoreOverlayScrollbarSize, IgnoreOverflowClip, scrollingAncestor );
1798 LayoutRect clipRect = layer->backgroundClipRect(clipRectsContext).rect();
1799 return clipRect != PaintInfo::infiniteRect() && !clipRect.isEmpty();
1800 }
1801
1773 // Return true if the given layer is a stacking context and has compositing chil d 1802 // Return true if the given layer is a stacking context and has compositing chil d
1774 // layers that it needs to clip. In this case we insert a clipping GraphicsLayer 1803 // layers that it needs to clip. In this case we insert a clipping GraphicsLayer
1775 // into the hierarchy between this layer and its children in the z-order hierarc hy. 1804 // into the hierarchy between this layer and its children in the z-order hierarc hy.
1776 bool RenderLayerCompositor::clipsCompositingDescendants(const RenderLayer* layer ) const 1805 bool RenderLayerCompositor::clipsCompositingDescendants(const RenderLayer* layer ) const
1777 { 1806 {
1778 return layer->hasCompositingDescendant() && layer->renderer()->hasClipOrOver flowClip(); 1807 return layer->hasCompositingDescendant() && layer->renderer()->hasClipOrOver flowClip();
1779 } 1808 }
1780 1809
1781 bool RenderLayerCompositor::requiresCompositingForScrollableFrame() const 1810 bool RenderLayerCompositor::requiresCompositingForScrollableFrame() const
1782 { 1811 {
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 2740
2712 Page* RenderLayerCompositor::page() const 2741 Page* RenderLayerCompositor::page() const
2713 { 2742 {
2714 if (Frame* frame = m_renderView->frameView()->frame()) 2743 if (Frame* frame = m_renderView->frameView()->frame())
2715 return frame->page(); 2744 return frame->page();
2716 2745
2717 return 0; 2746 return 0;
2718 } 2747 }
2719 2748
2720 } // namespace WebCore 2749 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698