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

Side by Side Diff: sky/engine/core/rendering/RenderLayer.cpp

Issue 877043002: Remove RenderLayerScrollableArea (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 , m_next(0) 99 , m_next(0)
100 , m_first(0) 100 , m_first(0)
101 , m_last(0) 101 , m_last(0)
102 , m_staticInlinePosition(0) 102 , m_staticInlinePosition(0)
103 , m_staticBlockPosition(0) 103 , m_staticBlockPosition(0)
104 , m_clipper(*renderer) 104 , m_clipper(*renderer)
105 { 105 {
106 updateStackingNode(); 106 updateStackingNode();
107 107
108 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 108 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
109
110 updateScrollableArea();
111 } 109 }
112 110
113 RenderLayer::~RenderLayer() 111 RenderLayer::~RenderLayer()
114 { 112 {
115 removeFilterInfoIfNeeded(); 113 removeFilterInfoIfNeeded();
116 } 114 }
117 115
118 String RenderLayer::debugName() const 116 String RenderLayer::debugName() const
119 { 117 {
120 return renderer()->debugName(); 118 return renderer()->debugName();
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, lo cation); 791 currLayer = accumulateOffsetTowardsAncestor(currLayer, ancestorLayer, lo cation);
794 } 792 }
795 793
796 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR ect& rect) const 794 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR ect& rect) const
797 { 795 {
798 LayoutPoint delta; 796 LayoutPoint delta;
799 convertToLayerCoords(ancestorLayer, delta); 797 convertToLayerCoords(ancestorLayer, delta);
800 rect.move(-delta.x(), -delta.y()); 798 rect.move(-delta.x(), -delta.y());
801 } 799 }
802 800
803 void RenderLayer::didUpdateNeedsCompositedScrolling()
804 {
805 updateSelfPaintingLayer();
806 }
807
808 void RenderLayer::updateStackingNode() 801 void RenderLayer::updateStackingNode()
809 { 802 {
810 if (requiresStackingNode()) 803 if (requiresStackingNode())
811 m_stackingNode = adoptPtr(new RenderLayerStackingNode(this)); 804 m_stackingNode = adoptPtr(new RenderLayerStackingNode(this));
812 else 805 else
813 m_stackingNode = nullptr; 806 m_stackingNode = nullptr;
814 } 807 }
815 808
816 void RenderLayer::updateScrollableArea()
817 {
818 if (requiresScrollableArea())
819 m_scrollableArea = adoptPtr(new RenderLayerScrollableArea(*this));
820 else
821 m_scrollableArea = nullptr;
822 }
823
824 bool RenderLayer::hasOverflowControls() const
825 {
826 return m_scrollableArea && m_scrollableArea->hasScrollbar();
827 }
828
829 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, RenderObject* paintingRoot) 809 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, RenderObject* paintingRoot)
830 { 810 {
831 TRACE_EVENT0("blink", "RenderLayer::paint"); 811 TRACE_EVENT0("blink", "RenderLayer::paint");
832 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), LayoutSiz e(), paintingRoot); 812 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), LayoutSiz e(), paintingRoot);
833 paintLayer(context, paintingInfo, PaintContent); 813 paintLayer(context, paintingInfo, PaintContent);
834 } 814 }
835 815
836 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutR ect& damageRect, RenderObject* paintingRoot) 816 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutR ect& damageRect, RenderObject* paintingRoot)
837 { 817 {
838 if (!m_containsDirtyOverlayScrollbars) 818 if (!m_containsDirtyOverlayScrollbars)
(...skipping 27 matching lines...) Expand all
866 context->save(); 846 context->save();
867 context->clip(pixelSnappedIntRect(clipRect.rect())); 847 context->clip(pixelSnappedIntRect(clipRect.rect()));
868 848
869 if (!clipRect.hasRadius()) 849 if (!clipRect.hasRadius())
870 return; 850 return;
871 851
872 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from 852 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from
873 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our 853 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our
874 // containing block chain so we check that also. 854 // containing block chain so we check that also.
875 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? this : parent (); layer; layer = layer->parent()) { 855 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? this : parent (); layer; layer = layer->parent()) {
876 // Composited scrolling layers handle border-radius clip in the composit or via a mask layer. We do not
877 // want to apply a border-radius clip to the layer contents itself, beca use that would require re-rastering
878 // every frame to update the clip. We only want to make sure that the ma sk layer is properly clipped so
879 // that it can in turn clip the scrolled contents in the compositor.
880 if (layer->needsCompositedScrolling())
881 break;
882
883 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(this, layer)) { 856 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(this, layer)) {
884 LayoutPoint delta; 857 LayoutPoint delta;
885 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); 858 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta);
886 context->clipRoundedRect(layer->renderer()->style()->getRoundedI nnerBorderFor(LayoutRect(delta, layer->size()))); 859 context->clipRoundedRect(layer->renderer()->style()->getRoundedI nnerBorderFor(LayoutRect(delta, layer->size())));
887 } 860 }
888 861
889 if (layer == localPaintingInfo.rootLayer) 862 if (layer == localPaintingInfo.rootLayer)
890 break; 863 break;
891 } 864 }
892 } 865 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 LayoutRect rootRelativeBounds; 936 LayoutRect rootRelativeBounds;
964 bool rootRelativeBoundsComputed = false; 937 bool rootRelativeBoundsComputed = false;
965 938
966 // Apply clip-path to context. 939 // Apply clip-path to context.
967 GraphicsContextStateSaver clipStateSaver(*context, false); 940 GraphicsContextStateSaver clipStateSaver(*context, false);
968 RenderStyle* style = renderer()->style(); 941 RenderStyle* style = renderer()->style();
969 942
970 // Clip-path, like border radius, must not be applied to the contents of a c omposited-scrolling container. 943 // Clip-path, like border radius, must not be applied to the contents of a c omposited-scrolling container.
971 // It must, however, still be applied to the mask layer, so that the composi tor can properly mask the 944 // It must, however, still be applied to the mask layer, so that the composi tor can properly mask the
972 // scrolling contents and scrollbars. 945 // scrolling contents and scrollbars.
973 if (renderer()->hasClipPath() && style && !needsCompositedScrolling()) { 946 if (renderer()->hasClipPath() && style) {
974 ASSERT(style->clipPath()); 947 ASSERT(style->clipPath());
975 if (style->clipPath()->type() == ClipPathOperation::SHAPE) { 948 if (style->clipPath()->type() == ClipPathOperation::SHAPE) {
976 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style->c lipPath()); 949 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style->c lipPath());
977 if (clipPath->isValid()) { 950 if (clipPath->isValid()) {
978 clipStateSaver.save(); 951 clipStateSaver.save();
979 952
980 if (!rootRelativeBoundsComputed) { 953 if (!rootRelativeBoundsComputed) {
981 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); 954 rootRelativeBounds = physicalBoundingBoxIncludingReflectionA ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot);
982 rootRelativeBoundsComputed = true; 955 rootRelativeBoundsComputed = true;
983 } 956 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati on() + localPaintingInfo.subPixelAccumulation); 1017 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati on() + localPaintingInfo.subPixelAccumulation);
1045 1018
1046 if (shouldPaintContent) { 1019 if (shouldPaintContent) {
1047 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir tyRect, haveTransparency, 1020 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir tyRect, haveTransparency,
1048 localPaintingInfo, paintingRootForRenderer, layerLocation, foregroun dRect); 1021 localPaintingInfo, paintingRootForRenderer, layerLocation, foregroun dRect);
1049 } 1022 }
1050 1023
1051 paintOutline(context, localPaintingInfo, paintingRootForRenderer, layerLocat ion, outlineRect); 1024 paintOutline(context, localPaintingInfo, paintingRootForRenderer, layerLocat ion, outlineRect);
1052 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting Info, paintFlags); 1025 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting Info, paintFlags);
1053 1026
1054 if (isPaintingOverlayScrollbars)
1055 paintOverflowControls(context, localPaintingInfo, layerLocation, backgro undRect);
1056
1057 if (filterPainter.hasStartedFilterEffect()) { 1027 if (filterPainter.hasStartedFilterEffect()) {
1058 context = filterPainter.applyFilterEffect(); 1028 context = filterPainter.applyFilterEffect();
1059 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect, backgroundRect); 1029 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect, backgroundRect);
1060 } 1030 }
1061 1031
1062 // Make sure that we now use the original transparency context. 1032 // Make sure that we now use the original transparency context.
1063 ASSERT(transparencyLayerContext == context); 1033 ASSERT(transparencyLayerContext == context);
1064 1034
1065 if (shouldPaintContent && renderer()->hasMask()) 1035 if (shouldPaintContent && renderer()->hasMask())
1066 paintMask(context, localPaintingInfo, paintingRootForRenderer, layerLoca tion, backgroundRect); 1036 paintMask(context, localPaintingInfo, paintingRootForRenderer, layerLoca tion, backgroundRect);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1141
1172 // Paint the mask. 1142 // Paint the mask.
1173 // FIXME: Eventually we will collect the region from the fragment itself ins tead of just from the paint info. 1143 // FIXME: Eventually we will collect the region from the fragment itself ins tead of just from the paint info.
1174 PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect()) , PaintPhaseMask, paintingRootForRenderer, localPaintingInfo.rootLayer->renderer ()); 1144 PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect()) , PaintPhaseMask, paintingRootForRenderer, localPaintingInfo.rootLayer->renderer ());
1175 renderer()->paint(paintInfo, layerLocation); 1145 renderer()->paint(paintInfo, layerLocation);
1176 1146
1177 if (localPaintingInfo.clipToDirtyRect) 1147 if (localPaintingInfo.clipToDirtyRect)
1178 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRe ct); 1148 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRe ct);
1179 } 1149 }
1180 1150
1181 void RenderLayer::paintOverflowControls(GraphicsContext* context, const LayerPai ntingInfo& localPaintingInfo, LayoutPoint& layerLocation, ClipRect& layerBackgro undRect)
1182 {
1183 clipToRect(localPaintingInfo, context, layerBackgroundRect);
1184 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea())
1185 scrollableArea->paintOverflowControls(context, roundedIntPoint(layerLoca tion), pixelSnappedIntRect(layerBackgroundRect.rect()), true);
1186 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRect);
1187 }
1188
1189 static inline LayoutRect frameVisibleRect(RenderObject* renderer) 1151 static inline LayoutRect frameVisibleRect(RenderObject* renderer)
1190 { 1152 {
1191 FrameView* frameView = renderer->document().view(); 1153 FrameView* frameView = renderer->document().view();
1192 if (!frameView) 1154 if (!frameView)
1193 return LayoutRect(); 1155 return LayoutRect();
1194 1156
1195 return frameView->visibleContentRect(); 1157 return frameView->visibleContentRect();
1196 } 1158 }
1197 1159
1198 bool RenderLayer::hitTest(const HitTestRequest& request, HitTestResult& result) 1160 bool RenderLayer::hitTest(const HitTestRequest& request, HitTestResult& result)
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 } 1648 }
1687 1649
1688 bool RenderLayer::paintsWithTransform() const 1650 bool RenderLayer::paintsWithTransform() const
1689 { 1651 {
1690 // FIXME(sky): Remove 1652 // FIXME(sky): Remove
1691 return transform(); 1653 return transform();
1692 } 1654 }
1693 1655
1694 bool RenderLayer::shouldBeSelfPaintingLayer() const 1656 bool RenderLayer::shouldBeSelfPaintingLayer() const
1695 { 1657 {
1696 return m_layerType == NormalLayer 1658 return m_layerType == NormalLayer;
1697 || (m_scrollableArea && m_scrollableArea->hasOverlayScrollbars())
1698 || needsCompositedScrolling();
1699 } 1659 }
1700 1660
1701 void RenderLayer::updateSelfPaintingLayer() 1661 void RenderLayer::updateSelfPaintingLayer()
1702 { 1662 {
1703 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer(); 1663 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer();
1704 if (this->isSelfPaintingLayer() == isSelfPaintingLayer) 1664 if (this->isSelfPaintingLayer() == isSelfPaintingLayer)
1705 return; 1665 return;
1706 1666
1707 m_isSelfPaintingLayer = isSelfPaintingLayer; 1667 m_isSelfPaintingLayer = isSelfPaintingLayer;
1708 1668
(...skipping 20 matching lines...) Expand all
1729 return false; 1689 return false;
1730 } 1690 }
1731 1691
1732 bool RenderLayer::hasBoxDecorationsOrBackground() const 1692 bool RenderLayer::hasBoxDecorationsOrBackground() const
1733 { 1693 {
1734 return renderer()->style()->hasBoxDecorations() || renderer()->style()->hasB ackground(); 1694 return renderer()->style()->hasBoxDecorations() || renderer()->style()->hasB ackground();
1735 } 1695 }
1736 1696
1737 bool RenderLayer::hasVisibleBoxDecorations() const 1697 bool RenderLayer::hasVisibleBoxDecorations() const
1738 { 1698 {
1739 return hasBoxDecorationsOrBackground() || hasOverflowControls(); 1699 return hasBoxDecorationsOrBackground();
1740 } 1700 }
1741 1701
1742 bool RenderLayer::isVisuallyNonEmpty() const 1702 bool RenderLayer::isVisuallyNonEmpty() const
1743 { 1703 {
1744 if (hasNonEmptyChildRenderers()) 1704 if (hasNonEmptyChildRenderers())
1745 return true; 1705 return true;
1746 1706
1747 if (renderer()->isReplaced() || renderer()->hasMask()) 1707 if (renderer()->isReplaced() || renderer()->hasMask())
1748 return true; 1708 return true;
1749 1709
(...skipping 10 matching lines...) Expand all
1760 1720
1761 updateOrRemoveFilterClients(); 1721 updateOrRemoveFilterClients();
1762 updateOrRemoveFilterEffectRenderer(); 1722 updateOrRemoveFilterEffectRenderer();
1763 } 1723 }
1764 1724
1765 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle ) 1725 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle )
1766 { 1726 {
1767 m_stackingNode->updateIsNormalFlowOnly(); 1727 m_stackingNode->updateIsNormalFlowOnly();
1768 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle); 1728 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle);
1769 1729
1770 if (m_scrollableArea)
1771 m_scrollableArea->updateAfterStyleChange(oldStyle);
1772
1773 // Overlay scrollbars can make this layer self-painting so we need 1730 // Overlay scrollbars can make this layer self-painting so we need
1774 // to recompute the bit once scrollbars have been updated. 1731 // to recompute the bit once scrollbars have been updated.
1775 updateSelfPaintingLayer(); 1732 updateSelfPaintingLayer();
1776 1733
1777 updateTransform(oldStyle, renderer()->style()); 1734 updateTransform(oldStyle, renderer()->style());
1778 updateFilters(oldStyle, renderer()->style()); 1735 updateFilters(oldStyle, renderer()->style());
1779 } 1736 }
1780 1737
1781 bool RenderLayer::scrollsOverflow() const
1782 {
1783 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea())
1784 return scrollableArea->scrollsOverflow();
1785
1786 return false;
1787 }
1788
1789 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) 1738 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style)
1790 { 1739 {
1791 return style->filter(); 1740 return style->filter();
1792 } 1741 }
1793 1742
1794 void RenderLayer::updateOrRemoveFilterClients() 1743 void RenderLayer::updateOrRemoveFilterClients()
1795 { 1744 {
1796 if (!hasFilter()) { 1745 if (!hasFilter()) {
1797 removeFilterInfoIfNeeded(); 1746 removeFilterInfoIfNeeded();
1798 return; 1747 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 } 1796 }
1848 } 1797 }
1849 1798
1850 void showLayerTree(const blink::RenderObject* renderer) 1799 void showLayerTree(const blink::RenderObject* renderer)
1851 { 1800 {
1852 if (!renderer) 1801 if (!renderer)
1853 return; 1802 return;
1854 showLayerTree(renderer->enclosingLayer()); 1803 showLayerTree(renderer->enclosingLayer());
1855 } 1804 }
1856 #endif 1805 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | sky/engine/core/rendering/RenderLayerModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698