Remove some PLATFORM(IOS) #ifdefs related to hasAcceleratedTouchScrolling()
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Apr 2014 23:53:57 +0000 (23:53 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Apr 2014 23:53:57 +0000 (23:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132353

Reviewed by Tim Horton & Darin Adler.

Minor cleanup and refactoring to remove #idefs.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo): No need for this #ifdef, usesCompositedScrolling()
gives the right answser already.
(WebCore::RenderLayer::visibleContentRectInternal): Use showsOverflowControls() to
avoid #ifdef.
(WebCore::RenderLayer::invalidateScrollbarRect): Ditto.
(WebCore::RenderLayer::invalidateScrollCornerRect): Ditto.
(WebCore::RenderLayer::verticalScrollbarWidth): Ditto.
(WebCore::RenderLayer::horizontalScrollbarHeight): Ditto.
(WebCore::RenderLayer::showsOverflowControls): Return false on iOS.
(WebCore::RenderLayer::paintOverflowControls): Ditto.
(WebCore::RenderLayer::calculateClipRects): Ditto.
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
Just #ifdef in side of this function rather than having two similar functions.
(WebCore::RenderLayerBacking::shouldClipCompositedBounds):
(WebCore::hasNonZeroTransformOrigin):
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Use a local bool
to reduce #ifdefs.
(WebCore::layerOrAncestorIsTransformedOrScrolling): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167970 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp

index c46726e..d9d9444 100644 (file)
@@ -1,5 +1,36 @@
 2014-04-29  Simon Fraser  <simon.fraser@apple.com>
 
+        Remove some PLATFORM(IOS) #ifdefs related to hasAcceleratedTouchScrolling()
+        https://bugs.webkit.org/show_bug.cgi?id=132353
+
+        Reviewed by Tim Horton & Darin Adler.
+
+        Minor cleanup and refactoring to remove #idefs.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollTo): No need for this #ifdef, usesCompositedScrolling()
+        gives the right answser already.
+        (WebCore::RenderLayer::visibleContentRectInternal): Use showsOverflowControls() to
+        avoid #ifdef.
+        (WebCore::RenderLayer::invalidateScrollbarRect): Ditto.
+        (WebCore::RenderLayer::invalidateScrollCornerRect): Ditto.
+        (WebCore::RenderLayer::verticalScrollbarWidth): Ditto.
+        (WebCore::RenderLayer::horizontalScrollbarHeight): Ditto.
+        (WebCore::RenderLayer::showsOverflowControls): Return false on iOS.
+        (WebCore::RenderLayer::paintOverflowControls): Ditto.
+        (WebCore::RenderLayer::calculateClipRects): Ditto.
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
+        Just #ifdef in side of this function rather than having two similar functions.
+        (WebCore::RenderLayerBacking::shouldClipCompositedBounds):
+        (WebCore::hasNonZeroTransformOrigin):
+        (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Use a local bool
+        to reduce #ifdefs.
+        (WebCore::layerOrAncestorIsTransformedOrScrolling): Deleted.
+
+2014-04-29  Simon Fraser  <simon.fraser@apple.com>
+
         Remove Settings::compositedScrollingForFramesEnabled
         https://bugs.webkit.org/show_bug.cgi?id=132352
 
index 6cc2c65..b1c896f 100644 (file)
@@ -2364,11 +2364,7 @@ void RenderLayer::scrollTo(int x, int y)
         requiresRepaint = false;
 
     // Just schedule a full repaint of our object.
-#if PLATFORM(IOS)
-    if (!hasAcceleratedTouchScrolling())
-#else
     if (requiresRepaint)
-#endif
         renderer().repaintUsingContainer(repaintContainer, m_repaintRect);
 
     // Schedule the scroll and scroll-related DOM events.
@@ -2695,16 +2691,9 @@ IntRect RenderLayer::visibleContentRectInternal(VisibleContentRectIncludesScroll
 {
     int verticalScrollbarWidth = 0;
     int horizontalScrollbarHeight = 0;
-    if (scrollbarInclusion == IncludeScrollbars) {
+    if (showsOverflowControls() && scrollbarInclusion == IncludeScrollbars) {
         verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar()->width() : 0;
         horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0;
-
-#if PLATFORM(IOS)
-        if (hasAcceleratedTouchScrolling()) {
-            verticalScrollbarWidth = 0;
-            horizontalScrollbarHeight = 0;
-        }
-#endif
     }
     
     return IntRect(IntPoint(scrollXOffset(), scrollYOffset()),
@@ -2924,11 +2913,8 @@ IntSize RenderLayer::scrollbarOffset(const Scrollbar* scrollbar) const
 
 void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
 {
-#if PLATFORM(IOS)
-    // No need to invalidate scrollbars if we're using accelerated scrolling.
-    if (hasAcceleratedTouchScrolling())
+    if (!showsOverflowControls())
         return;
-#endif
 
     if (scrollbar == m_vBar.get()) {
         if (GraphicsLayer* layer = layerForVerticalScrollbar()) {
@@ -2960,11 +2946,8 @@ void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& r
 
 void RenderLayer::invalidateScrollCornerRect(const IntRect& rect)
 {
-#if PLATFORM(IOS)
-    // No need to invalidate the scroll corner if we're using accelerated scrolling.
-    if (hasAcceleratedTouchScrolling())
+    if (!showsOverflowControls())
         return;
-#endif
 
     if (GraphicsLayer* layer = layerForScrollCorner()) {
         layer->setNeedsDisplayInRect(rect);
@@ -3084,27 +3067,21 @@ ScrollableArea* RenderLayer::enclosingScrollableArea() const
 
 int RenderLayer::verticalScrollbarWidth(OverlayScrollbarSizeRelevancy relevancy) const
 {
-    if (!m_vBar || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_vBar->shouldParticipateInHitTesting())))
+    if (!m_vBar
+        || !showsOverflowControls()
+        || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_vBar->shouldParticipateInHitTesting())))
         return 0;
 
-#if PLATFORM(IOS)
-    if (hasAcceleratedTouchScrolling()) 
-        return 0;
-#endif
-
     return m_vBar->width();
 }
 
 int RenderLayer::horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy relevancy) const
 {
-    if (!m_hBar || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_hBar->shouldParticipateInHitTesting())))
+    if (!m_hBar
+        || !showsOverflowControls()
+        || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_hBar->shouldParticipateInHitTesting())))
         return 0;
 
-#if PLATFORM(IOS)
-    if (hasAcceleratedTouchScrolling()) 
-        return 0;
-#endif
-
     return m_hBar->height();
 }
 
@@ -3374,17 +3351,25 @@ bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const
     return false;
 }
 
+bool RenderLayer::showsOverflowControls() const
+{
+#if PLATFORM(IOS)
+    // Don't render (custom) scrollbars if we have accelerated scrolling.
+    if (hasAcceleratedTouchScrolling())
+        return false;
+#endif
+
+    return true;
+}
+
 void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls)
 {
     // Don't do anything if we have no overflow.
     if (!renderer().hasOverflowClip())
         return;
 
-#if PLATFORM(IOS)
-    // Don't render (custom) scrollbars if we have accelerated scrolling.
-    if (hasAcceleratedTouchScrolling())
+    if (!showsOverflowControls())
         return;
-#endif
 
     // Overlay scrollbars paint in a second pass through the layer tree so that they will paint
     // on top of everything else. If this is the normal painting pass, paintingOverlayControls
@@ -6425,15 +6410,14 @@ bool RenderLayer::shouldBeNormalFlowOnly() const
         && !renderer().hasFilter()
 #endif
 #if PLATFORM(IOS)
-            && !hasAcceleratedTouchScrolling()
+        && !hasAcceleratedTouchScrolling()
 #endif
 #if ENABLE(CSS_COMPOSITING)
         && !renderer().hasBlendMode()
 #endif
         && !isTransparent()
         && !needsCompositedScrolling()
-        && !renderer().style().hasFlowFrom()
-        ;
+        && !renderer().style().hasFlowFrom();
 }
 
 bool RenderLayer::shouldBeSelfPaintingLayer() const
index 00f6dd2..20a3184 100644 (file)
@@ -458,8 +458,8 @@ public:
     bool requiresScrollBoundsOriginUpdate() const { return m_requiresScrollBoundsOriginUpdate; }
     void setRequiresScrollBoundsOriginUpdate(bool requiresUpdate = true) { m_requiresScrollBoundsOriginUpdate = requiresUpdate; }
 
+    // Returns true when the layer could do touch scrolling, but doesn't look at whether there is actually scrollable overflow.
     bool hasAcceleratedTouchScrolling() const;
-
 #endif
 
     int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
@@ -1058,6 +1058,8 @@ private:
     bool hasScrollableHorizontalOverflow() const;
     bool hasScrollableVerticalOverflow() const;
 
+    bool showsOverflowControls() const;
+
     bool shouldBeNormalFlowOnly() const;
 
     bool shouldBeSelfPaintingLayer() const;
index 6e8450d..af58308 100644 (file)
@@ -400,37 +400,23 @@ void RenderLayerBacking::updateBlendMode(const RenderStyle* style)
 }
 #endif
 
-static bool hasNonZeroTransformOrigin(const RenderObject& renderer)
-{
-    const RenderStyle& style = renderer.style();
-    return (style.transformOriginX().type() == Fixed && style.transformOriginX().value())
-        || (style.transformOriginY().type() == Fixed && style.transformOriginY().value());
-}
-
-#if PLATFORM(IOS)
-// FIXME: We should merge the concept of RenderLayer::{hasAcceleratedTouchScrolling, needsCompositedScrolling}()
-// so that we can remove this iOS-specific variant.
-static bool layerOrAncestorIsTransformedOrScrolling(RenderLayer& layer)
-{
-    for (RenderLayer* curr = &layer; curr; curr = curr->parent()) {
-        if (curr->hasTransform() || curr->hasAcceleratedTouchScrolling())
-            return true;
-    }
-
-    return false;
-}
-#else
+// FIXME: the hasAcceleratedTouchScrolling()/needsCompositedScrolling() concepts need to be merged.
 static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer)
 {
     for (RenderLayer* curr = &layer; curr; curr = curr->parent()) {
-        if (curr->hasTransform() || curr->needsCompositedScrolling())
+        if (curr->hasTransform()
+#if PLATFORM(IOS)
+            || curr->hasAcceleratedTouchScrolling()
+#else
+            || curr->needsCompositedScrolling()
+#endif
+            )
             return true;
     }
 
     return false;
 }
-#endif
-    
+
 bool RenderLayerBacking::shouldClipCompositedBounds() const
 {
 #if !PLATFORM(IOS)
@@ -442,13 +428,8 @@ bool RenderLayerBacking::shouldClipCompositedBounds() const
     if (m_usingTiledCacheLayer)
         return false;
 
-#if !PLATFORM(IOS)
     if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer))
         return false;
-#else
-    if (layerOrAncestorIsTransformedOrScrolling(m_owningLayer))
-        return false;
-#endif
 
     if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions())
         return false;
@@ -456,6 +437,13 @@ bool RenderLayerBacking::shouldClipCompositedBounds() const
     return true;
 }
 
+static bool hasNonZeroTransformOrigin(const RenderObject& renderer)
+{
+    const RenderStyle& style = renderer.style();
+    return (style.transformOriginX().type() == Fixed && style.transformOriginX().value())
+        || (style.transformOriginY().type() == Fixed && style.transformOriginY().value());
+}
+
 void RenderLayerBacking::updateCompositedBounds()
 {
     LayoutRect layerBounds = compositor().calculateCompositedBounds(m_owningLayer, m_owningLayer);
@@ -548,16 +536,16 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration()
         layerConfigChanged = true;
     
     bool needsDescendentsClippingLayer = compositor().clipsCompositingDescendants(m_owningLayer);
-
+    bool usesCompositedScrolling;
 #if PLATFORM(IOS)
-    // Our scrolling layer will clip.
-    if (m_owningLayer.hasAcceleratedTouchScrolling())
-        needsDescendentsClippingLayer = false;
+    usesCompositedScrolling = m_owningLayer.hasAcceleratedTouchScrolling();
 #else
+    usesCompositedScrolling = m_owningLayer.needsCompositedScrolling();
+#endif
+
     // Our scrolling layer will clip.
-    if (m_owningLayer.needsCompositedScrolling())
+    if (usesCompositedScrolling)
         needsDescendentsClippingLayer = false;
-#endif // PLATFORM(IOS)
 
     if (updateAncestorClippingLayer(compositor().clippedByAncestor(m_owningLayer)))
         layerConfigChanged = true;
@@ -568,13 +556,8 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration()
     if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), requiresVerticalScrollbarLayer(), requiresScrollCornerLayer()))
         layerConfigChanged = true;
 
-#if PLATFORM(IOS)
-    if (updateScrollingLayers(m_owningLayer.hasAcceleratedTouchScrolling()))
-        layerConfigChanged = true;
-#else
-    if (updateScrollingLayers(m_owningLayer.needsCompositedScrolling()))
+    if (updateScrollingLayers(usesCompositedScrolling))
         layerConfigChanged = true;
-#endif // PLATFORM(IOS)
 
     if (layerConfigChanged)
         updateInternalHierarchy();