Bug 97357 - Respect -webkit-overflow-scrolling:touch if it is safe to do so
Summary: Respect -webkit-overflow-scrolling:touch if it is safe to do so
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: vollick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-21 13:33 PDT by vollick
Modified: 2014-02-05 10:58 PST (History)
12 users (show)

See Also:


Attachments
Patch (1.42 KB, patch)
2012-09-21 13:36 PDT, vollick
no flags Details | Formatted Diff | Diff
Patch (13.63 KB, patch)
2012-09-22 16:52 PDT, vollick
no flags Details | Formatted Diff | Diff
Patch (13.58 KB, patch)
2012-09-22 17:10 PDT, vollick
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vollick 2012-09-21 13:33:45 PDT
If a render layer is composited, and is therefore a stacking context, there is no risk in putting it on the fast scrolling path. So in this case, RenderLayer::usesCompositedScrolling() should return true.
Comment 1 vollick 2012-09-21 13:36:34 PDT
Created attachment 165179 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-09-21 13:47:01 PDT
Comment on attachment 165179 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=165179&action=review

> Source/WebCore/ChangeLog:9
> +        If the scrolling render layer is composited, then RenderLayer::usesCompositedScrolling
> +        will return true.

Might be nice to describe what this does. :)  Even if it's obvious to the compositor folks.
Comment 3 Simon Fraser (smfr) 2012-09-21 13:51:24 PDT
Comment on attachment 165179 [details]
Patch

I don't follow this at all. It's quite possible to have a <div> be in a compositing layer, but to not have set up the inner scrolling layers that make it scroll compositedly.
Comment 4 Build Bot 2012-09-21 13:56:49 PDT
Comment on attachment 165179 [details]
Patch

Attachment 165179 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13950752

New failing tests:
compositing/overflow/overflow-scrollbar-layers.html
compositing/geometry/limit-layer-bounds-transformed-overflow.html
compositing/overflow/content-gains-scrollbars.html
compositing/layer-creation/overflow-scroll-overlap.html
Comment 5 James Robinson 2012-09-21 14:03:53 PDT
If we do have a layer that is set up to scroll we should throw it down this path without needing the webkit-overflow-scroll property.  What other internal setup is required, Simon?
Comment 6 Simon Fraser (smfr) 2012-09-21 14:06:44 PDT
It doesn't follow that being composited means that something is a stacking context.
Comment 7 James Robinson 2012-09-21 14:11:05 PDT
(In reply to comment #6)
> It doesn't follow that being composited means that something is a stacking context.

Huh?  What do we make composited that's not a stacking context?
Comment 8 Simon Fraser (smfr) 2012-09-21 14:12:33 PDT
Layers that are composited because of overlap, for example.
Comment 9 James Robinson 2012-09-21 15:02:30 PDT
If the layer is a stacking context (for whatever reason) we should be able to go down this path, though.
Comment 10 WebKit Review Bot 2012-09-21 15:31:21 PDT
Comment on attachment 165179 [details]
Patch

Attachment 165179 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13950786

New failing tests:
compositing/overflow/scrollbars-with-clipped-owner.html
compositing/geometry/limit-layer-bounds-transformed-overflow.html
compositing/overflow/content-gains-scrollbars.html
compositing/repaint/newly-composited-repaint-rect.html
compositing/overflow/overflow-scrollbar-layers.html
compositing/overflow/clip-content-under-overflow-controls.html
WebFilterOperationsTest.saveAndRestore
compositing/layer-creation/overflow-scroll-overlap.html
Comment 11 vollick 2012-09-22 16:38:53 PDT
In light of the previous comments, I tried returning true in RenderLayer::usesCompositedScrolling if isComposited() and isStackingContext() were both true, but this caused some problems in the layout tests. The problem is that when composited scrolling is used, the scrolling contents are rendered behind transparent scroll controls rather than being clipped. Hopefully this behavior can be changed, but at present, automatically opting into composited scrolling will cause correctness issues.

Respecting -webkit-overflow-scrolling:touch is also currently dangerous, because it creates a stacking context and the promotion to a composited layer can affect anti-aliasing, so we will break the z-ordering and anti-aliasing of some existing pages.

Given these facts, I propose the following:
 - We respect -webkit-overflow-scrolling:touch *if*
   a) We're already a stacking context, and
   b) We're already composited.

This would let us explicitly opt into composited scrolling in a way that prevents us from breaking the z-ordering and anti-aliasing of existing pages.

In future, if the problem of rendering the scrollable content behind the overflow scroll controls is addressed, we can look into automatically opting into this path without -webkit-overflow-scrolling:touch. We might also relax the isStackingContext restriction -- it should be sufficient that promotion to a stacking context would not affect z-ordering.

I will upload a patch that does this shortly. In that patch, if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) is defined, then -webkit-overflow-scrolling:touch will *force* us to use composited scrolling, otherwise that property will only turn on composited scrolling if we're already a composited stacking context.
Comment 12 vollick 2012-09-22 16:52:57 PDT
Created attachment 165271 [details]
Patch

Contains the changes mentioned in the previous comment.
Comment 13 WebKit Review Bot 2012-09-22 16:56:04 PDT
Attachment 165271 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
Source/WebCore/rendering/RenderLayer.cpp:1597:  Line contains only semicolon. If this should be an empty statement, use { } instead.  [whitespace/semicolon] [5]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 14 vollick 2012-09-22 17:10:38 PDT
Created attachment 165272 [details]
Patch

I apologize for the spam. This patch addresses the style issue.
Comment 15 Antonio Gomes 2012-09-23 07:08:28 PDT
So you are doing this for feature detection purposes?
Comment 16 vollick 2012-09-23 10:24:07 PDT
(In reply to comment #15)
> So you are doing this for feature detection purposes?

It's more that I'm trying to enabled a feature rather than detect it (but perhaps I'm misunderstanding your question). Composited scrolling is great -- it saves us some very costly painting -- but designers currently have no way to take advantage of it on browsers built without ACCELERATED_OVERFLOW_SCROLLING enabled. My hope was to provide *some* recourse for designers who want to use composited scrolling on all WebKit-based browsers, but do so in a way that doesn't break existing pages.

With this change, a designer can use -webkit-overflow-scrolling:touch in combination with -webkit-transform:translateZ(0px) to opt into composited scrolling.

I should stress that this isn't the end of the work on this, either. My hope is that we can use composited scrolling on more and more pages, eventually without using -webkit-overflow-scrolling at all.
Comment 17 Simon Fraser (smfr) 2012-09-24 09:47:58 PDT
(In reply to comment #16)
> With this change, a designer can use -webkit-overflow-scrolling:touch in combination with -webkit-transform:translateZ(0px) to opt into composited scrolling.

I really don't want more translateZ(0) cargo-cultism than already exists, especially when combined with the already mysterious -webkit-overflow-scrolling.
Comment 18 vollick 2012-09-24 11:28:10 PDT
(In reply to comment #17)
> (In reply to comment #16)
> > With this change, a designer can use -webkit-overflow-scrolling:touch in combination with -webkit-transform:translateZ(0px) to opt into composited scrolling.
> 
> I really don't want more translateZ(0) cargo-cultism than already exists, especially when combined with the already mysterious -webkit-overflow-scrolling.

I'm still working on a proper response, but in the meantime, I wanted to lists the tests that fail when composited scrolling is used because the scrolled contents are drawn behind/over the overflow controls. These are
compositing/overflow/clip-content-under-overflow-controls.html
compositing/overflow/scrollbars-with-clipped-owner.html
Comment 19 James Robinson 2012-09-24 21:21:00 PDT
usesCompositedScrolling() controls too many behaviors.  There are a few concepts here.  For the compositor tree setup it shouldn't make a different what this value is set to, although other parts of the rendering code do care about this property.

What I think we should do here is set up the RenderLayerBacking's GraphicsLayer hierarchy so that scrolling is only a matter of updating one layer's position and make sure clipping, etc, is correct.  Then it's a simple matter to hook up RenderLayer::scrollTo() to simply update this position and rely on the compositor to repaint content as needed.  Look at how RenderLayerCompositor's GraphicsLayer hierarchy is different to accomodate this.  The m_containmentLayer/m_scrollingLayer/m_scrollingContentsLayer fields on RLB appear to be partway there, but I think we should just make it part of the default setup and not rely on things like offsetFromRenderer.
Comment 20 Andreas Kling 2014-02-05 10:58:05 PST
Comment on attachment 165272 [details]
Patch

Clearing review flag on patches from before 2014. If this patch is still relevant, please reset the r? flag.