<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[236459] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/236459">236459</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2018-09-25 08:49:20 -0700 (Tue, 25 Sep 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up code around RenderLayer's "has accelerated scrolling" functions
https://bugs.webkit.org/show_bug.cgi?id=189932

Reviewed by Zalan Bujtas.

RenderLayer had:

bool hasAcceleratedTouchScrolling()
bool hasTouchScrollableOverflow()
bool usesAcceleratedScrolling()
bool usesCompositedScrolling()
bool usesAsyncScrolling()

which are hard to keep in your head. Removed usesAcceleratedScrolling() since it just returns hasTouchScrollableOverflow().
Renamed hasAcceleratedTouchScrolling() to canUseAcceleratedTouchScrolling() to indicate that it just looks at style,
not whether layout has given the layer scrollable overflow yet. Tidy up some #ifdefs.

usesCompositedScrolling() and usesAsyncScrolling() are ScrollableArea overrides, and
look at backing layers, so require that compositing has run already. Note this in comments.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::canUseAcceleratedTouchScrolling const):
(WebCore::RenderLayer::hasTouchScrollableOverflow const):
(WebCore::RenderLayer::handleTouchEvent):
(WebCore::RenderLayer::usesAsyncScrolling const):
(WebCore::RenderLayer::showsOverflowControls const):
(WebCore::RenderLayer::calculateClipRects const):
(WebCore::RenderLayer::hasAcceleratedTouchScrolling const): Deleted.
(WebCore::RenderLayer::usesAcceleratedScrolling const): Deleted.
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
(WebCore::RenderLayerBacking::updateConfiguration):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::useCoordinatedScrollingForLayer const):
(WebCore::RenderLayerCompositor::requiresCompositingForOverflowScrolling const):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerh">trunk/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingcpp">trunk/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (236458 => 236459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-09-25 15:45:42 UTC (rev 236458)
+++ trunk/Source/WebCore/ChangeLog      2018-09-25 15:49:20 UTC (rev 236459)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2018-09-25  Simon Fraser  <simon.fraser@apple.com>
+
+        Clean up code around RenderLayer's "has accelerated scrolling" functions
+        https://bugs.webkit.org/show_bug.cgi?id=189932
+
+        Reviewed by Zalan Bujtas.
+        
+        RenderLayer had:
+        
+        bool hasAcceleratedTouchScrolling()
+        bool hasTouchScrollableOverflow()
+        bool usesAcceleratedScrolling()
+        bool usesCompositedScrolling()
+        bool usesAsyncScrolling()
+        
+        which are hard to keep in your head. Removed usesAcceleratedScrolling() since it just returns hasTouchScrollableOverflow().
+        Renamed hasAcceleratedTouchScrolling() to canUseAcceleratedTouchScrolling() to indicate that it just looks at style,
+        not whether layout has given the layer scrollable overflow yet. Tidy up some #ifdefs.
+        
+        usesCompositedScrolling() and usesAsyncScrolling() are ScrollableArea overrides, and
+        look at backing layers, so require that compositing has run already. Note this in comments.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::canUseAcceleratedTouchScrolling const):
+        (WebCore::RenderLayer::hasTouchScrollableOverflow const):
+        (WebCore::RenderLayer::handleTouchEvent):
+        (WebCore::RenderLayer::usesAsyncScrolling const):
+        (WebCore::RenderLayer::showsOverflowControls const):
+        (WebCore::RenderLayer::calculateClipRects const):
+        (WebCore::RenderLayer::hasAcceleratedTouchScrolling const): Deleted.
+        (WebCore::RenderLayer::usesAcceleratedScrolling const): Deleted.
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::useCoordinatedScrollingForLayer const):
+        (WebCore::RenderLayerCompositor::requiresCompositingForOverflowScrolling const):
+
</ins><span class="cx"> 2018-09-24  Fujii Hironori  <Hironori.Fujii@sony.com>
</span><span class="cx"> 
</span><span class="cx">         Rename WTF_COMPILER_GCC_OR_CLANG to WTF_COMPILER_GCC_COMPATIBLE
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (236458 => 236459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp   2018-09-25 15:45:42 UTC (rev 236458)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp      2018-09-25 15:49:20 UTC (rev 236459)
</span><span class="lines">@@ -1948,14 +1948,10 @@
</span><span class="cx">     return toLayoutSize(convertToLayerCoords(ancestorLayer, LayoutPoint(), adjustForColumns));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-bool RenderLayer::hasAcceleratedTouchScrolling() const
</del><ins>+bool RenderLayer::canUseAcceleratedTouchScrolling() const
</ins><span class="cx"> {
</span><del>-#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
-    if (!scrollsOverflow())
-        return false;
-
-    return renderer().style().useTouchOverflowScrolling() || renderer().settings().alwaysUseAcceleratedOverflowScroll();
</del><ins>+#if PLATFORM(IOS) && ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
+    return scrollsOverflow() && (renderer().style().useTouchOverflowScrolling() || renderer().settings().alwaysUseAcceleratedOverflowScroll());
</ins><span class="cx"> #else
</span><span class="cx">     return false;
</span><span class="cx"> #endif
</span><span class="lines">@@ -1963,31 +1959,19 @@
</span><span class="cx"> 
</span><span class="cx"> bool RenderLayer::hasTouchScrollableOverflow() const
</span><span class="cx"> {
</span><del>-    return hasAcceleratedTouchScrolling() && (hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
</del><ins>+    return canUseAcceleratedTouchScrolling() && (hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(TOUCH_EVENTS)
</del><ins>+#if ENABLE(IOS_TOUCH_EVENTS)
</ins><span class="cx"> bool RenderLayer::handleTouchEvent(const PlatformTouchEvent& touchEvent)
</span><span class="cx"> {
</span><span class="cx">     // If we have accelerated scrolling, let the scrolling be handled outside of WebKit.
</span><del>-    if (usesAcceleratedScrolling())
</del><ins>+    if (hasTouchScrollableOverflow())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     return ScrollableArea::handleTouchEvent(touchEvent);
</span><span class="cx"> }
</span><del>-#endif
-#endif // PLATFORM(IOS)
</del><span class="cx"> 
</span><del>-bool RenderLayer::usesAcceleratedScrolling() const
-{
-#if PLATFORM(IOS)
-    return hasTouchScrollableOverflow();
-#else
-    return false;
-#endif
-}
-
-#if ENABLE(IOS_TOUCH_EVENTS)
</del><span class="cx"> void RenderLayer::registerAsTouchEventListenerForScrolling()
</span><span class="cx"> {
</span><span class="cx">     if (!renderer().element() || m_registeredAsTouchEventListenerForScrolling)
</span><span class="lines">@@ -2007,14 +1991,16 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx"> 
</span><ins>+// FIXME: this is only valid after we've made layers.
</ins><span class="cx"> bool RenderLayer::usesCompositedScrolling() const
</span><span class="cx"> {
</span><span class="cx">     return isComposited() && backing()->hasScrollingLayer();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// FIXME: this is only valid after we've made layers.
</ins><span class="cx"> bool RenderLayer::usesAsyncScrolling() const
</span><span class="cx"> {
</span><del>-    return hasAcceleratedTouchScrolling() && usesCompositedScrolling();
</del><ins>+    return canUseAcceleratedTouchScrolling() && usesCompositedScrolling();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline int adjustedScrollDelta(int beginningDelta)
</span><span class="lines">@@ -3388,7 +3374,7 @@
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // Don't render (custom) scrollbars if we have accelerated scrolling.
</span><del>-    if (hasAcceleratedTouchScrolling())
</del><ins>+    if (canUseAcceleratedTouchScrolling())
</ins><span class="cx">         return false;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -6080,7 +6066,7 @@
</span><span class="cx">         || renderer.hasReflection()
</span><span class="cx">         || renderer.style().hasIsolation()
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-        || layer.hasAcceleratedTouchScrolling()
</del><ins>+        || layer.canUseAcceleratedTouchScrolling()
</ins><span class="cx"> #endif
</span><span class="cx">         || (renderer.style().willChange() && renderer.style().willChange()->canCreateStackingContext());
</span><span class="cx"> }
</span><span class="lines">@@ -6414,7 +6400,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(IOS_TOUCH_EVENTS)
</span><span class="cx">     if (addedOrRemoved) {
</span><del>-        if (isScrollable && !hasAcceleratedTouchScrolling())
</del><ins>+        if (isScrollable && !canUseAcceleratedTouchScrolling())
</ins><span class="cx">             registerAsTouchEventListenerForScrolling();
</span><span class="cx">         else {
</span><span class="cx">             // We only need the touch listener for unaccelerated overflow scrolling, so if we became
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.h (236458 => 236459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.h     2018-09-25 15:45:42 UTC (rev 236458)
+++ trunk/Source/WebCore/rendering/RenderLayer.h        2018-09-25 15:49:20 UTC (rev 236459)
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-#if ENABLE(TOUCH_EVENTS)
</del><ins>+#if ENABLE(IOS_TOUCH_EVENTS)
</ins><span class="cx">     bool handleTouchEvent(const PlatformTouchEvent&) override;
</span><span class="cx"> #endif
</span><span class="cx">     
</span><span class="lines">@@ -264,16 +264,12 @@
</span><span class="cx"> 
</span><span class="cx">     bool requiresScrollBoundsOriginUpdate() const { return m_requiresScrollBoundsOriginUpdate; }
</span><span class="cx">     void setRequiresScrollBoundsOriginUpdate(bool requiresUpdate = true) { m_requiresScrollBoundsOriginUpdate = requiresUpdate; }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx">     // Returns true when the layer could do touch scrolling, but doesn't look at whether there is actually scrollable overflow.
</span><del>-    bool hasAcceleratedTouchScrolling() const;
</del><ins>+    bool canUseAcceleratedTouchScrolling() const;
</ins><span class="cx">     // Returns true when there is actually scrollable overflow (requires layout to be up-to-date).
</span><span class="cx">     bool hasTouchScrollableOverflow() const;
</span><del>-#else
-    bool hasAcceleratedTouchScrolling() const { return false; }
-    bool hasTouchScrollableOverflow() const { return false; }
-#endif
-    bool usesAcceleratedScrolling() const;
</del><span class="cx"> 
</span><span class="cx">     int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
</span><span class="cx">     int horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
</span><span class="lines">@@ -896,7 +892,7 @@
</span><span class="cx">     bool usesMockScrollAnimator() const override;
</span><span class="cx">     void logMockScrollAnimatorMessage(const String&) const override;
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
</del><ins>+#if ENABLE(IOS_TOUCH_EVENTS)
</ins><span class="cx">     void registerAsTouchEventListenerForScrolling();
</span><span class="cx">     void unregisterAsTouchEventListenerForScrolling();
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (236458 => 236459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp    2018-09-25 15:45:42 UTC (rev 236458)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp       2018-09-25 15:49:20 UTC (rev 236459)
</span><span class="lines">@@ -560,7 +560,7 @@
</span><span class="cx"> static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer)
</span><span class="cx"> {
</span><span class="cx">     for (auto* curr = &layer; curr; curr = curr->parent()) {
</span><del>-        if (curr->hasTransform() || curr->usesAcceleratedScrolling())
</del><ins>+        if (curr->hasTransform() || curr->hasTouchScrollableOverflow())
</ins><span class="cx">             return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -686,7 +686,7 @@
</span><span class="cx">     bool needsDescendantsClippingLayer = compositor().clipsCompositingDescendants(m_owningLayer);
</span><span class="cx"> 
</span><span class="cx">     if (!renderer().view().needsLayout()) {
</span><del>-        bool usesCompositedScrolling = m_owningLayer.usesAcceleratedScrolling();
</del><ins>+        bool usesCompositedScrolling = m_owningLayer.hasTouchScrollableOverflow();
</ins><span class="cx"> 
</span><span class="cx">         // Our scrolling layer will clip.
</span><span class="cx">         if (usesCompositedScrolling)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (236458 => 236459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-09-25 15:45:42 UTC (rev 236458)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp    2018-09-25 15:49:20 UTC (rev 236459)
</span><span class="lines">@@ -2663,7 +2663,7 @@
</span><span class="cx">     if (layer.isRenderViewLayer() && hasCoordinatedScrolling())
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><del>-    return layer.usesAcceleratedScrolling();
</del><ins>+    return layer.hasTouchScrollableOverflow();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderLayerCompositor::requiresCompositingForPosition(RenderLayerModelObject& renderer, const RenderLayer& layer, RenderLayer::ViewportConstrainedNotCompositedReason* viewportConstrainedNotCompositedReason) const
</span><span class="lines">@@ -2748,7 +2748,7 @@
</span><span class="cx"> bool RenderLayerCompositor::requiresCompositingForOverflowScrolling(const RenderLayer& layer) const
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    if (!layer.hasAcceleratedTouchScrolling())
</del><ins>+    if (!layer.canUseAcceleratedTouchScrolling())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (!m_inPostLayoutUpdate) {
</span></span></pre>
</div>
</div>

</body>
</html>