Source/WebCore: [chromium] Automatically use composited scrolling
authorvollick@chromium.org <vollick@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2012 02:07:57 +0000 (02:07 +0000)
committervollick@chromium.org <vollick@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Dec 2012 02:07:57 +0000 (02:07 +0000)
commit6978dc5c6d824c99c2939df03b310c1da6b068e0
tree4bd3bb2a464e66835b5d6d7d13842634c16ba80a
parent3fad33f6396d1ac79f998b4f94d006de0d6b8ff6
Source/WebCore: [chromium] Automatically use composited scrolling
https://bugs.webkit.org/show_bug.cgi?id=94743

Reviewed by Adrienne Walker.

We currently use the composited scrolling facilities provided by
wkb.ug/91117 if the overflow scroll block element is styled with
-webkit-overflow-scrolling: touch. Ideally, we could automatically
opt into composited scrolling if it is safe to do so. This can affect
antialiasing, so it is important that automatically opting in is only
enabled via a setting.

The way I determine if it is safe is by checking that z-ordering will
not be affected if the overflow scrollable element were promoted to a
stacking context (details below), and that clipping our scrolling
descendants will not affect rendering.

To check the first condition (that z-ordering will not be affected).
I ensure that the candidate element and all its descendants appear as a
contiguous block in the candidate's stacking context. That is, if no
other elements are 'between' any of the candidates descendants when we
sort in paint order, then we're safe. This is overly conservative,
however. We could, in future, only consider stacking problems between
elements that actually overlap.

To ensure that clipping will not cause a rendering change, I ensure
that the layer has no out of flow positioned descendant whose
containing block is not also a descendant of ours.

Test: compositing/overflow/automatically-opt-into-compositing-scrolling.html

(WebCore):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::acceleratedCompositingForOverflowScrollEnabled):
(WebCore):
(WebCore::RenderLayer::updateDescendantsAreContiguousInStackingOrder):
(WebCore::RenderLayer::updateDescendantsAreContiguousInStackingOrderRecursive):
(WebCore::RenderLayer::positionNewlyCreatedOverflowControls):
(WebCore::RenderLayer::canSafelyEstablishAStackingContext):
  Returns true if the RenderLayer could become a stacking context without
  affecting the stacking order.
(WebCore::RenderLayer::updateDescendantDependentFlags):
  We now need to keep track of out of flow positioned descendants.
(WebCore::RenderLayer::addChild):
(WebCore::RenderLayer::removeChild):
(WebCore::RenderLayer::usesCompositedScrolling):
  Returns true if the layer actually is using composited scrolling.
  This function may return false, even when needsCompositedScrolling
  returns true.
(WebCore::RenderLayer::needsCompositedScrolling):
  This function returns true if we would like to use composited
  scrolling and it is safe to turn it on.
(WebCore::RenderLayer::updateNeedsCompositedScrolling):
(WebCore::RenderLayer::scrollTo):
(WebCore::RenderLayer::dirtyZOrderLists):
(WebCore::RenderLayer::dirtyNormalFlowList):
  Since these could affect opting into composited scrolling, we must
  request that the RenderLayerCompositor reevaluate compositing.
(WebCore::RenderLayer::updateLayerListsIfNeeded):
  We call updateCanSafelyEstablishStackingContext here, if necessary.
(WebCore::RenderLayer::shouldBeNormalFlowOnly):
(WebCore::RenderLayer::shouldBeSelfPaintingLayer):
  usesCompositedScrolling -> needsCompositedScrolling
(WebCore::RenderLayer::setAncestorChainHasOutOfFlowPositionedDescendant):
(WebCore::RenderLayer::dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus):
(WebCore::RenderLayer::updateOutOfFlowPositioned):
  Dirties and sets the out of flow positioned descendant state.
(WebCore::RenderLayer::styleChanged):
* rendering/RenderLayer.h:
(RenderLayer):
(WebCore::RenderLayer::hasOutOfFlowPositionedDescendant):
* rendering/RenderLayerBacking.cpp:
(WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::hasUnpositionedOverflowControlsLayers):
(WebCore):
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
(WebCore::RenderLayerCompositor::requiresCompositingForOverflowScrolling):
* rendering/RenderLayerCompositor.h:
(WebCore::RenderLayerCompositor::setShouldReevaluateCompositingAfterLayout):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setEnableCompositingForOverflowScroll):
  Allows enabling the setting in layout tests.
(WebCore):
* testing/InternalSettings.h:
(InternalSettings):
* testing/InternalSettings.idl:

LayoutTests: Automatically use composited scrolling
https://bugs.webkit.org/show_bug.cgi?id=94743

Reviewed by Adrienne Walker.

Tests various configurations of elements to ensure that we only automatically opt into
composited scrolling when it is safe to do so.

* compositing/overflow/automatically-opt-into-composited-scrolling-expected.txt: Added.
* compositing/overflow/automatically-opt-into-composited-scrolling.html: Added.
* platform/chromium/TestExpectations:
 The test platform/chromium/virtual/gpu/compositedscrolling/scrollbars/custom-scrollbar-with-incomplete-style.html
 is failing due to wkb.ug/103156

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/overflow/automatically-opt-into-composited-scrolling-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/automatically-opt-into-composited-scrolling.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl