Cache RenderLayer::isRootLayer for better performance
authorjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2012 22:27:32 +0000 (22:27 +0000)
committerjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2012 22:27:32 +0000 (22:27 +0000)
commit3a4527f36a82f93f3e40ca3b6b756bce4f3f2fc0
tree1987e1de89a6cae75e64d8e4df9000de322209fd
parent395e6ce52b5f21e6b3e72bfafafa1d366e84e901
Cache RenderLayer::isRootLayer for better performance
https://bugs.webkit.org/show_bug.cgi?id=88570

Reviewed by Ojan Vafai.

Caching covered by existing tests.

RenderLayer::isRootLayer()'s answer will be the same during the RenderLayer's
lifetime as a RenderLayer is tied to a RenderBoxModelObject. This change caches
isRootLayer value in the constructor.

On http://dglazkov.github.com/performance-tests/biggrid.html with a 100,000 rows
by 100 columns table, it saves about 10% on the paint time during scrolling on
my machine (going from 50ms to 45ms). It would expect all code paths to see some
improvement as checking renderer()->isRenderView() was pretty common.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
Added code to cache the result of renderer()->isRenderView() here.

(WebCore::RenderLayer::stackingContext):
(WebCore::isPositionedContainer):
(WebCore::isFixedPositionedContainer):
(WebCore::RenderLayer::enclosingTransformedAncestor):
(WebCore::RenderLayer::clippingRootForPainting):
(WebCore::shouldSuppressPaintingLayer):
(WebCore::RenderLayer::hitTest):
(WebCore::RenderLayer::intersectsDamageRect):
* rendering/RenderLayer.h:
(WebCore::RenderLayer::isStackingContext):
Updated all the call sites to use isRootLayer() instead of renderer()->isRenderView()
as it is faster.

(WebCore::RenderLayer::isRootLayer):
Added our caching here. Also made m_canSkipRepaintRectsUpdateOnScroll to follow
m_isRootLayer example.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119761 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h