Changeset 167970 in webkit


Ignore:
Timestamp:
Apr 29, 2014 4:53:57 PM (10 years ago)
Author:
Simon Fraser
Message:

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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167969 r167970  
     12014-04-29  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Remove some PLATFORM(IOS) #ifdefs related to hasAcceleratedTouchScrolling()
     4        https://bugs.webkit.org/show_bug.cgi?id=132353
     5
     6        Reviewed by Tim Horton & Darin Adler.
     7
     8        Minor cleanup and refactoring to remove #idefs.
     9
     10        * rendering/RenderLayer.cpp:
     11        (WebCore::RenderLayer::scrollTo): No need for this #ifdef, usesCompositedScrolling()
     12        gives the right answser already.
     13        (WebCore::RenderLayer::visibleContentRectInternal): Use showsOverflowControls() to
     14        avoid #ifdef.
     15        (WebCore::RenderLayer::invalidateScrollbarRect): Ditto.
     16        (WebCore::RenderLayer::invalidateScrollCornerRect): Ditto.
     17        (WebCore::RenderLayer::verticalScrollbarWidth): Ditto.
     18        (WebCore::RenderLayer::horizontalScrollbarHeight): Ditto.
     19        (WebCore::RenderLayer::showsOverflowControls): Return false on iOS.
     20        (WebCore::RenderLayer::paintOverflowControls): Ditto.
     21        (WebCore::RenderLayer::calculateClipRects): Ditto.
     22        * rendering/RenderLayer.h:
     23        * rendering/RenderLayerBacking.cpp:
     24        (WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
     25        Just #ifdef in side of this function rather than having two similar functions.
     26        (WebCore::RenderLayerBacking::shouldClipCompositedBounds):
     27        (WebCore::hasNonZeroTransformOrigin):
     28        (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Use a local bool
     29        to reduce #ifdefs.
     30        (WebCore::layerOrAncestorIsTransformedOrScrolling): Deleted.
     31
    1322014-04-29  Simon Fraser  <simon.fraser@apple.com>
    233
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r167965 r167970  
    23652365
    23662366    // Just schedule a full repaint of our object.
    2367 #if PLATFORM(IOS)
    2368     if (!hasAcceleratedTouchScrolling())
    2369 #else
    23702367    if (requiresRepaint)
    2371 #endif
    23722368        renderer().repaintUsingContainer(repaintContainer, m_repaintRect);
    23732369
     
    26962692    int verticalScrollbarWidth = 0;
    26972693    int horizontalScrollbarHeight = 0;
    2698     if (scrollbarInclusion == IncludeScrollbars) {
     2694    if (showsOverflowControls() && scrollbarInclusion == IncludeScrollbars) {
    26992695        verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar()->width() : 0;
    27002696        horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0;
    2701 
    2702 #if PLATFORM(IOS)
    2703         if (hasAcceleratedTouchScrolling()) {
    2704             verticalScrollbarWidth = 0;
    2705             horizontalScrollbarHeight = 0;
    2706         }
    2707 #endif
    27082697    }
    27092698   
     
    29252914void RenderLayer::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
    29262915{
    2927 #if PLATFORM(IOS)
    2928     // No need to invalidate scrollbars if we're using accelerated scrolling.
    2929     if (hasAcceleratedTouchScrolling())
    2930         return;
    2931 #endif
     2916    if (!showsOverflowControls())
     2917        return;
    29322918
    29332919    if (scrollbar == m_vBar.get()) {
     
    29612947void RenderLayer::invalidateScrollCornerRect(const IntRect& rect)
    29622948{
    2963 #if PLATFORM(IOS)
    2964     // No need to invalidate the scroll corner if we're using accelerated scrolling.
    2965     if (hasAcceleratedTouchScrolling())
    2966         return;
    2967 #endif
     2949    if (!showsOverflowControls())
     2950        return;
    29682951
    29692952    if (GraphicsLayer* layer = layerForScrollCorner()) {
     
    30853068int RenderLayer::verticalScrollbarWidth(OverlayScrollbarSizeRelevancy relevancy) const
    30863069{
    3087     if (!m_vBar || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_vBar->shouldParticipateInHitTesting())))
     3070    if (!m_vBar
     3071        || !showsOverflowControls()
     3072        || (m_vBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_vBar->shouldParticipateInHitTesting())))
    30883073        return 0;
    30893074
    3090 #if PLATFORM(IOS)
    3091     if (hasAcceleratedTouchScrolling())
     3075    return m_vBar->width();
     3076}
     3077
     3078int RenderLayer::horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy relevancy) const
     3079{
     3080    if (!m_hBar
     3081        || !showsOverflowControls()
     3082        || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_hBar->shouldParticipateInHitTesting())))
    30923083        return 0;
    3093 #endif
    3094 
    3095     return m_vBar->width();
    3096 }
    3097 
    3098 int RenderLayer::horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy relevancy) const
    3099 {
    3100     if (!m_hBar || (m_hBar->isOverlayScrollbar() && (relevancy == IgnoreOverlayScrollbarSize || !m_hBar->shouldParticipateInHitTesting())))
    3101         return 0;
    3102 
    3103 #if PLATFORM(IOS)
    3104     if (hasAcceleratedTouchScrolling())
    3105         return 0;
    3106 #endif
    31073084
    31083085    return m_hBar->height();
     
    33753352}
    33763353
    3377 void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls)
    3378 {
    3379     // Don't do anything if we have no overflow.
    3380     if (!renderer().hasOverflowClip())
    3381         return;
    3382 
     3354bool RenderLayer::showsOverflowControls() const
     3355{
    33833356#if PLATFORM(IOS)
    33843357    // Don't render (custom) scrollbars if we have accelerated scrolling.
    33853358    if (hasAcceleratedTouchScrolling())
    3386         return;
     3359        return false;
    33873360#endif
     3361
     3362    return true;
     3363}
     3364
     3365void RenderLayer::paintOverflowControls(GraphicsContext* context, const IntPoint& paintOffset, const IntRect& damageRect, bool paintingOverlayControls)
     3366{
     3367    // Don't do anything if we have no overflow.
     3368    if (!renderer().hasOverflowClip())
     3369        return;
     3370
     3371    if (!showsOverflowControls())
     3372        return;
    33883373
    33893374    // Overlay scrollbars paint in a second pass through the layer tree so that they will paint
     
    64266411#endif
    64276412#if PLATFORM(IOS)
    6428             && !hasAcceleratedTouchScrolling()
     6413        && !hasAcceleratedTouchScrolling()
    64296414#endif
    64306415#if ENABLE(CSS_COMPOSITING)
     
    64336418        && !isTransparent()
    64346419        && !needsCompositedScrolling()
    6435         && !renderer().style().hasFlowFrom()
    6436         ;
     6420        && !renderer().style().hasFlowFrom();
    64376421}
    64386422
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r167796 r167970  
    459459    void setRequiresScrollBoundsOriginUpdate(bool requiresUpdate = true) { m_requiresScrollBoundsOriginUpdate = requiresUpdate; }
    460460
     461    // Returns true when the layer could do touch scrolling, but doesn't look at whether there is actually scrollable overflow.
    461462    bool hasAcceleratedTouchScrolling() const;
    462 
    463463#endif
    464464
     
    10581058    bool hasScrollableHorizontalOverflow() const;
    10591059    bool hasScrollableVerticalOverflow() const;
     1060
     1061    bool showsOverflowControls() const;
    10601062
    10611063    bool shouldBeNormalFlowOnly() const;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r167965 r167970  
    401401#endif
    402402
     403// FIXME: the hasAcceleratedTouchScrolling()/needsCompositedScrolling() concepts need to be merged.
     404static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer)
     405{
     406    for (RenderLayer* curr = &layer; curr; curr = curr->parent()) {
     407        if (curr->hasTransform()
     408#if PLATFORM(IOS)
     409            || curr->hasAcceleratedTouchScrolling()
     410#else
     411            || curr->needsCompositedScrolling()
     412#endif
     413            )
     414            return true;
     415    }
     416
     417    return false;
     418}
     419
     420bool RenderLayerBacking::shouldClipCompositedBounds() const
     421{
     422#if !PLATFORM(IOS)
     423    // Scrollbar layers use this layer for relative positioning, so don't clip.
     424    if (layerForHorizontalScrollbar() || layerForVerticalScrollbar())
     425        return false;
     426#endif
     427
     428    if (m_usingTiledCacheLayer)
     429        return false;
     430
     431    if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer))
     432        return false;
     433
     434    if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions())
     435        return false;
     436
     437    return true;
     438}
     439
    403440static bool hasNonZeroTransformOrigin(const RenderObject& renderer)
    404441{
     
    406443    return (style.transformOriginX().type() == Fixed && style.transformOriginX().value())
    407444        || (style.transformOriginY().type() == Fixed && style.transformOriginY().value());
    408 }
    409 
    410 #if PLATFORM(IOS)
    411 // FIXME: We should merge the concept of RenderLayer::{hasAcceleratedTouchScrolling, needsCompositedScrolling}()
    412 // so that we can remove this iOS-specific variant.
    413 static bool layerOrAncestorIsTransformedOrScrolling(RenderLayer& layer)
    414 {
    415     for (RenderLayer* curr = &layer; curr; curr = curr->parent()) {
    416         if (curr->hasTransform() || curr->hasAcceleratedTouchScrolling())
    417             return true;
    418     }
    419 
    420     return false;
    421 }
    422 #else
    423 static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer)
    424 {
    425     for (RenderLayer* curr = &layer; curr; curr = curr->parent()) {
    426         if (curr->hasTransform() || curr->needsCompositedScrolling())
    427             return true;
    428     }
    429 
    430     return false;
    431 }
    432 #endif
    433    
    434 bool RenderLayerBacking::shouldClipCompositedBounds() const
    435 {
    436 #if !PLATFORM(IOS)
    437     // Scrollbar layers use this layer for relative positioning, so don't clip.
    438     if (layerForHorizontalScrollbar() || layerForVerticalScrollbar())
    439         return false;
    440 #endif
    441 
    442     if (m_usingTiledCacheLayer)
    443         return false;
    444 
    445 #if !PLATFORM(IOS)
    446     if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer))
    447         return false;
    448 #else
    449     if (layerOrAncestorIsTransformedOrScrolling(m_owningLayer))
    450         return false;
    451 #endif
    452 
    453     if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions())
    454         return false;
    455 
    456     return true;
    457445}
    458446
     
    549537   
    550538    bool needsDescendentsClippingLayer = compositor().clipsCompositingDescendants(m_owningLayer);
    551 
     539    bool usesCompositedScrolling;
    552540#if PLATFORM(IOS)
     541    usesCompositedScrolling = m_owningLayer.hasAcceleratedTouchScrolling();
     542#else
     543    usesCompositedScrolling = m_owningLayer.needsCompositedScrolling();
     544#endif
     545
    553546    // Our scrolling layer will clip.
    554     if (m_owningLayer.hasAcceleratedTouchScrolling())
     547    if (usesCompositedScrolling)
    555548        needsDescendentsClippingLayer = false;
    556 #else
    557     // Our scrolling layer will clip.
    558     if (m_owningLayer.needsCompositedScrolling())
    559         needsDescendentsClippingLayer = false;
    560 #endif // PLATFORM(IOS)
    561549
    562550    if (updateAncestorClippingLayer(compositor().clippedByAncestor(m_owningLayer)))
     
    569557        layerConfigChanged = true;
    570558
    571 #if PLATFORM(IOS)
    572     if (updateScrollingLayers(m_owningLayer.hasAcceleratedTouchScrolling()))
     559    if (updateScrollingLayers(usesCompositedScrolling))
    573560        layerConfigChanged = true;
    574 #else
    575     if (updateScrollingLayers(m_owningLayer.needsCompositedScrolling()))
    576         layerConfigChanged = true;
    577 #endif // PLATFORM(IOS)
    578561
    579562    if (layerConfigChanged)
Note: See TracChangeset for help on using the changeset viewer.