Add support for compositing the contents of overflow:scroll areas
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Aug 2012 00:35:34 +0000 (00:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Aug 2012 00:35:34 +0000 (00:35 +0000)
commit0633e061b828d0c5b1d4df34d6f10f2e29bdd33c
treec369b6f05a7cfac2c8cc369c00c3ced44801d01c
parent023a662e16f91ba55c24f3fa870c417c127b39ea
Add support for compositing the contents of overflow:scroll areas
https://bugs.webkit.org/show_bug.cgi?id=91117

Patch by Sami Kyostila <skyostil@chromium.org> on 2012-08-24
Reviewed by Simon Fraser.

Patch by Simon Fraser with modifications by Sami Kyostila and Ian Vollick.

Allow a RenderLayer which exists for overflow scrolling
to use a composited layer for the scrolled contents, which
allows for compositing-accelerated overflow scrolling.

Tests:
    compositing/overflow/clipping-ancestor-with-accelerated-scrolling-ancestor.html
    compositing/overflow/iframe-inside-overflow-clipping.html
    compositing/overflow/nested-scrolling.html
    compositing/overflow/overflow-auto-with-touch-no-overflow.html
    compositing/overflow/overflow-auto-with-touch.html
    compositing/overflow/overflow-clip-with-accelerated-scrolling-ancestor.html
    compositing/overflow/overflow-hidden-with-touch.html
    compositing/overflow/overflow-overlay-with-touch-no-overflow.html
    compositing/overflow/overflow-overlay-with-touch.html
    compositing/overflow/overflow-scroll-with-touch-no-overflow.html
    compositing/overflow/overflow-visible-with-touch.html
    compositing/overflow/remove-overflow-crash.html
    compositing/overflow/remove-overflow-crash2.html
    compositing/overflow/scrolling-content-clip-to-viewport.html
    compositing/overflow/textarea-scroll-touch.html

* platform/graphics/GraphicsLayerClient.h: New paint phase flag
used for scrolled contents. Provide a typedef for the flags
so that they can be ORed together.

* rendering/RenderLayer.h:
(WebCore::ClipRectsCache::ClipRectsCache):
(ClipRectsCache): In debug builds, store a m_respectingOverflowClip
flag so we can ASSERT later that we're fetching clip rects with the
same setting the rects were generated with.
Add new PaintLayerPaintingOverflowContents painting flag.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::usesCompositedScrolling): New method returns
true if this layer is using composited overflow scrolling.
(WebCore::RenderLayer::scrollTo): Don't repaint if we're doing
a composited scroll.
(WebCore::RenderLayer::paintLayer): Pass the right flags to backgroundClipRect();
if we're painting scrolled contents, we don't want to take the overflow clip rect
into account.
(WebCore::RenderLayer::paintLayerContents): Ditto. Also don't do the intersectsDamageRect()
check if we're painting scrolled contents.
(WebCore::RenderLayer::updateClipRects): New parameter to tell whether to respect overflow clipping.
Assert if we're fetching cached rects with a different 'respect clip' flag to the one they were generated
with.
(WebCore::RenderLayer::calculateClipRects): Take the 'respectOverflowClip' flag into account
when computing clip rects.
(WebCore::RenderLayer::parentClipRects): Ditto
(WebCore::RenderLayer::backgroundClipRect): Ditto
(WebCore::RenderLayer::calculateRects): Ditto
(WebCore::RenderLayer::childrenClipRect): This function is called from widget code, so may use a different
'respect clip rects' setting than that used for painting, so it has to compute clip rects on the fly.
(WebCore::RenderLayer::shouldBeNormalFlowOnly): Composited scrolling makes a layer not normal-flow only.

* rendering/RenderLayerBacking.h:
(RenderLayerBacking): New member variables for the layers for scrolled contents, and the scrolling
layer which handles the scroll offset.
(WebCore::RenderLayerBacking::hasScrollingLayer):
(WebCore::RenderLayerBacking::scrollingLayer):
(WebCore::RenderLayerBacking::scrollingContentsLayer):

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::~RenderLayerBacking):
(WebCore::RenderLayerBacking::destroyGraphicsLayers): Tear down the scrolling layers, if any.
(WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling): Renamed from layerOrAncestorIsTransformed,
since it has to look for composited scrolling layers too.
(WebCore::RenderLayerBacking::shouldClipCompositedBounds): We don't want the contents of scrolling layers
to get clipped to the viewport.
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Create scrolling layers if necessary.
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): Set scrolling layer geometry.
(WebCore::RenderLayerBacking::updateInternalHierarchy): Hook up scrolling layers.
(WebCore::RenderLayerBacking::updateDrawsContent): Scrolling layers affect whether the main graphics layer
needs to draw content.
(WebCore::RenderLayerBacking::updateScrollingLayers): Create or destroy scrolling layers.
(WebCore::RenderLayerBacking::paintingPhaseForPrimaryLayer): If we have a scrolled contents layer,
the main layer should not paint the foreground.
(WebCore::RenderLayerBacking::parentForSublayers): Sublayers are parented in the scrolling contents
layer if one exists.
(WebCore::RenderLayerBacking::setContentsNeedDisplay): Need to dirty the scrolling contents layer.
(WebCore::RenderLayerBacking::setContentsNeedDisplayInRect): Ditto.
(WebCore::RenderLayerBacking::paintIntoLayer): Set the right painting flags.
(WebCore::RenderLayerBacking::paintContents): Only clip to the bounds if we're not painting overflow contents.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
LayoutTests/compositing/overflow/clipping-ancestor-with-accelerated-scrolling-ancestor.html [new file with mode: 0644]
LayoutTests/compositing/overflow/iframe-inside-overflow-clipping-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/iframe-inside-overflow-clipping.html [new file with mode: 0644]
LayoutTests/compositing/overflow/nested-scrolling.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-auto-with-touch-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-auto-with-touch-no-overflow-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-auto-with-touch-no-overflow.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-auto-with-touch.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-clip-with-accelerated-scrolling-ancestor.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-hidden-with-touch-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-hidden-with-touch.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-overlay-with-touch-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-overlay-with-touch-no-overflow-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-overlay-with-touch-no-overflow.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-overlay-with-touch.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-scroll-with-touch-no-overflow-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-scroll-with-touch-no-overflow.html [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-visible-with-touch-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/overflow-visible-with-touch.html [new file with mode: 0644]
LayoutTests/compositing/overflow/remove-overflow-crash-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/remove-overflow-crash.html [new file with mode: 0644]
LayoutTests/compositing/overflow/remove-overflow-crash2.html [new file with mode: 0644]
LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/scrolling-content-clip-to-viewport.html [new file with mode: 0644]
LayoutTests/compositing/overflow/textarea-scroll-touch-expected.txt [new file with mode: 0644]
LayoutTests/compositing/overflow/textarea-scroll-touch.html [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/clipping-ancestor-with-accelerated-scrolling-ancestor-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/clipping-ancestor-with-accelerated-scrolling-ancestor-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/nested-scrolling-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/nested-scrolling-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/overflow-clip-with-accelerated-scrolling-ancestor-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/overflow-clip-with-accelerated-scrolling-ancestor-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/remove-overflow-crash2-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/compositing/overflow/remove-overflow-crash2-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayerClient.h
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