Changeset 168190 in webkit


Ignore:
Timestamp:
May 2, 2014, 2:24:54 PM (12 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] Don't create backing store for -webkit-overflow-scrolling:touch that can't scroll
https://bugs.webkit.org/show_bug.cgi?id=132487
<rdar://problem/16758041>

Reviewed by Sam Weinig.

Source/WebCore:

Previously, -webkit-overflow-scrolling:touch would cause us to make compositing
layers for any element that had overflow: auto or scroll on either axis. This
created lots of backing store when not required.

Improve this to only create compositing for scrolling when there is actually
scrollable overflow. This makes things slightly more complex, because we can
only know when layout is up to date.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computeRectForRepaint): usesCompositedScrolling() tells
us if we're actually doing composited overflow.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::hasTouchScrollableOverflow):
(WebCore::RenderLayer::handleTouchEvent):

  • rendering/RenderLayer.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Only update
scrolling and clipping layers if layout is not pending.
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::updateScrollingLayers): The caller calls
updateInternalHierarchy(), so no need to do it here.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::requiresCompositingForScrolling): We
can only determine that we're scrollable after layout.
(WebCore::isStickyInAcceleratedScrollingLayerOrViewport):
(WebCore::isMainFrameScrollingOrOverflowScrolling):

LayoutTests:

These are all progressions, and show that we make layers in fewer cases.

  • platform/ios-sim/compositing/overflow/iframe-inside-overflow-clipping-expected.txt:
  • platform/ios-sim/compositing/overflow/overflow-auto-with-touch-no-overflow-expected.txt:
  • platform/ios-sim/compositing/overflow/overflow-overlay-with-touch-no-overflow-expected.txt:
  • platform/ios-sim/compositing/overflow/overflow-scroll-with-touch-no-overflow-expected.txt:
  • platform/ios-sim/compositing/overflow/subpixel-overflow-expected.txt:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r168173 r168190  
     12014-05-02  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Don't create backing store for -webkit-overflow-scrolling:touch that can't scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=132487
     5        <rdar://problem/16758041>
     6
     7        Reviewed by Sam Weinig.
     8       
     9        These are all progressions, and show that we make layers in fewer cases.
     10
     11        * platform/ios-sim/compositing/overflow/iframe-inside-overflow-clipping-expected.txt:
     12        * platform/ios-sim/compositing/overflow/overflow-auto-with-touch-no-overflow-expected.txt:
     13        * platform/ios-sim/compositing/overflow/overflow-overlay-with-touch-no-overflow-expected.txt:
     14        * platform/ios-sim/compositing/overflow/overflow-scroll-with-touch-no-overflow-expected.txt:
     15        * platform/ios-sim/compositing/overflow/subpixel-overflow-expected.txt:
     16
    1172014-05-02  Commit Queue  <commit-queue@webkit.org>
    218
  • trunk/LayoutTests/platform/ios-sim/compositing/overflow/iframe-inside-overflow-clipping-expected.txt

    r167372 r168190  
    22
    33
     4
  • trunk/LayoutTests/platform/ios-sim/compositing/overflow/overflow-auto-with-touch-no-overflow-expected.txt

    r167371 r168190  
    1 (GraphicsLayer
    2   (bounds 800.00 600.00)
    3   (children 1
    4     (GraphicsLayer
    5       (bounds 800.00 600.00)
    6       (children 1
    7         (GraphicsLayer
    8           (position 8.00 8.00)
    9           (bounds 300.00 300.00)
    10           (children 1
    11             (GraphicsLayer
    12               (bounds 300.00 300.00)
    13               (children 1
    14                 (GraphicsLayer
    15                   (bounds 300.00 300.00)
    16                   (drawsContent 1)
    17                 )
    18               )
    19             )
    20           )
    21         )
    22       )
    23     )
    24   )
    25 )
    261
  • trunk/LayoutTests/platform/ios-sim/compositing/overflow/overflow-overlay-with-touch-no-overflow-expected.txt

    r167371 r168190  
    1 (GraphicsLayer
    2   (bounds 800.00 600.00)
    3   (children 1
    4     (GraphicsLayer
    5       (bounds 800.00 600.00)
    6       (children 1
    7         (GraphicsLayer
    8           (position 8.00 8.00)
    9           (bounds 300.00 300.00)
    10           (children 1
    11             (GraphicsLayer
    12               (bounds 300.00 300.00)
    13               (children 1
    14                 (GraphicsLayer
    15                   (bounds 300.00 300.00)
    16                   (drawsContent 1)
    17                 )
    18               )
    19             )
    20           )
    21         )
    22       )
    23     )
    24   )
    25 )
    261
  • trunk/LayoutTests/platform/ios-sim/compositing/overflow/overflow-scroll-with-touch-no-overflow-expected.txt

    r167371 r168190  
    1 (GraphicsLayer
    2   (bounds 800.00 600.00)
    3   (children 1
    4     (GraphicsLayer
    5       (bounds 800.00 600.00)
    6       (children 1
    7         (GraphicsLayer
    8           (position 8.00 8.00)
    9           (bounds 300.00 300.00)
    10           (children 1
    11             (GraphicsLayer
    12               (bounds 300.00 300.00)
    13               (children 1
    14                 (GraphicsLayer
    15                   (bounds 300.00 300.00)
    16                   (drawsContent 1)
    17                 )
    18               )
    19             )
    20           )
    21         )
    22       )
    23     )
    24   )
    25 )
    261
  • trunk/LayoutTests/platform/ios-sim/compositing/overflow/subpixel-overflow-expected.txt

    r168078 r168190  
    44 
    55Content
    6  (GraphicsLayer
    7   (bounds 800.00 600.00)
    8   (children 1
    9     (GraphicsLayer
    10       (bounds 800.00 600.00)
    11       (children 3
    12         (GraphicsLayer
    13           (position 18.00 18.00)
    14           (bounds 202.00 202.50)
    15           (drawsContent 1)
    16           (children 1
    17             (GraphicsLayer
    18               (position 1.00 1.00)
    19               (bounds 200.00 200.00)
    20               (children 1
    21                 (GraphicsLayer
    22                   (bounds 200.00 200.00)
    23                   (drawsContent 1)
    24                 )
    25               )
    26             )
    27           )
    28         )
    29         (GraphicsLayer
    30           (position 244.00 18.00)
    31           (bounds 202.00 202.50)
    32           (drawsContent 1)
    33           (children 1
    34             (GraphicsLayer
    35               (position 1.00 1.00)
    36               (bounds 200.00 201.00)
    37               (children 1
    38                 (GraphicsLayer
    39                   (bounds 200.00 201.00)
    40                   (drawsContent 1)
    41                 )
    42               )
    43             )
    44           )
    45         )
    46         (GraphicsLayer
    47           (position 470.00 18.00)
    48           (bounds 202.00 203.00)
    49           (drawsContent 1)
    50           (children 1
    51             (GraphicsLayer
    52               (position 1.00 1.00)
    53               (bounds 200.00 201.00)
    54               (children 1
    55                 (GraphicsLayer
    56                   (bounds 200.00 201.00)
    57                   (drawsContent 1)
    58                 )
    59               )
    60             )
    61           )
    62         )
    63       )
    64     )
    65   )
    66 )
    676
  • trunk/Source/WebCore/ChangeLog

    r168188 r168190  
     12014-05-02  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] Don't create backing store for -webkit-overflow-scrolling:touch that can't scroll
     4        https://bugs.webkit.org/show_bug.cgi?id=132487
     5        <rdar://problem/16758041>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Previously, -webkit-overflow-scrolling:touch would cause us to make compositing
     10        layers for any element that had overflow: auto or scroll on either axis. This
     11        created lots of backing store when not required.
     12       
     13        Improve this to only create compositing for scrolling when there is actually
     14        scrollable overflow. This makes things slightly more complex, because we can
     15        only know when layout is up to date.
     16
     17        * rendering/RenderBox.cpp:
     18        (WebCore::RenderBox::computeRectForRepaint): usesCompositedScrolling() tells
     19        us if we're actually doing composited overflow.
     20        * rendering/RenderLayer.cpp:
     21        (WebCore::RenderLayer::hasTouchScrollableOverflow):
     22        (WebCore::RenderLayer::handleTouchEvent):
     23        * rendering/RenderLayer.h:
     24        * rendering/RenderLayerBacking.cpp:
     25        (WebCore::layerOrAncestorIsTransformedOrUsingCompositedScrolling):
     26        (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Only update
     27        scrolling and clipping layers if layout is not pending.
     28        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
     29        (WebCore::RenderLayerBacking::updateScrollingLayers): The caller calls
     30        updateInternalHierarchy(), so no need to do it here.
     31        * rendering/RenderLayerCompositor.cpp:
     32        (WebCore::RenderLayerCompositor::requiresCompositingForScrolling): We
     33        can only determine that we're scrollable after layout.
     34        (WebCore::isStickyInAcceleratedScrollingLayerOrViewport):
     35        (WebCore::isMainFrameScrollingOrOverflowScrolling):
     36
    1372014-05-02  Anders Carlsson  <andersca@apple.com>
    238
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r167988 r168190  
    21772177        RenderBox* containerBox = toRenderBox(o);
    21782178#if PLATFORM(IOS)
    2179         if (!containerBox->layer() || !containerBox->layer()->hasAcceleratedTouchScrolling()) {
     2179        if (!containerBox->layer() || !containerBox->layer()->usesCompositedScrolling()) {
    21802180#endif
    21812181        containerBox->applyCachedClipAndScrollOffsetForRepaint(rect);
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r168119 r168190  
    21162116}
    21172117
    2118 #if PLATFORM(IOS) && ENABLE(TOUCH_EVENTS)
     2118bool RenderLayer::hasTouchScrollableOverflow() const
     2119{
     2120    return hasAcceleratedTouchScrolling() && (hasScrollableHorizontalOverflow() || hasScrollableVerticalOverflow());
     2121}
     2122
     2123#if ENABLE(TOUCH_EVENTS)
    21192124bool RenderLayer::handleTouchEvent(const PlatformTouchEvent& touchEvent)
    21202125{
    21212126    // If we have accelerated scrolling, let the scrolling be handled outside of WebKit.
    2122     if (hasAcceleratedTouchScrolling())
     2127    if (hasTouchScrollableOverflow())
    21232128        return false;
    21242129
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r168119 r168190  
    461461    // Returns true when the layer could do touch scrolling, but doesn't look at whether there is actually scrollable overflow.
    462462    bool hasAcceleratedTouchScrolling() const;
     463    // Returns true when there is actually scrollable overflow (requires layout to be up-to-date).
     464    bool hasTouchScrollableOverflow() const;
    463465#endif
    464466
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r168079 r168190  
    407407        if (curr->hasTransform()
    408408#if PLATFORM(IOS)
    409             || curr->hasAcceleratedTouchScrolling()
     409            || curr->hasTouchScrollableOverflow()
    410410#else
    411411            || curr->needsCompositedScrolling()
     
    537537   
    538538    bool needsDescendentsClippingLayer = compositor().clipsCompositingDescendants(m_owningLayer);
    539     bool usesCompositedScrolling;
     539
     540    if (!renderer().view().needsLayout()) {
     541        bool usesCompositedScrolling;
    540542#if PLATFORM(IOS)
    541     usesCompositedScrolling = m_owningLayer.hasAcceleratedTouchScrolling();
     543        usesCompositedScrolling = m_owningLayer.hasTouchScrollableOverflow();
    542544#else
    543     usesCompositedScrolling = m_owningLayer.needsCompositedScrolling();
    544 #endif
    545 
    546     // Our scrolling layer will clip.
    547     if (usesCompositedScrolling)
    548         needsDescendentsClippingLayer = false;
     545        usesCompositedScrolling = m_owningLayer.needsCompositedScrolling();
     546#endif
     547        // Our scrolling layer will clip.
     548        if (usesCompositedScrolling)
     549            needsDescendentsClippingLayer = false;
     550
     551        if (updateScrollingLayers(usesCompositedScrolling))
     552            layerConfigChanged = true;
     553
     554        if (updateDescendantClippingLayer(needsDescendentsClippingLayer))
     555            layerConfigChanged = true;
     556    }
    549557
    550558    if (updateAncestorClippingLayer(compositor().clippedByAncestor(m_owningLayer)))
    551559        layerConfigChanged = true;
    552560
    553     if (updateDescendantClippingLayer(needsDescendentsClippingLayer))
    554         layerConfigChanged = true;
    555 
    556561    if (updateOverflowControlsLayers(requiresHorizontalScrollbarLayer(), requiresVerticalScrollbarLayer(), requiresScrollCornerLayer()))
    557         layerConfigChanged = true;
    558 
    559     if (updateScrollingLayers(usesCompositedScrolling))
    560562        layerConfigChanged = true;
    561563
     
    753755
    754756#if PLATFORM(IOS)
    755     if (compAncestor && compAncestor->hasAcceleratedTouchScrolling()) {
     757    if (compAncestor && compAncestor->hasTouchScrollableOverflow()) {
    756758        RenderBox* renderBox = toRenderBox(&compAncestor->renderer());
    757759        LayoutRect paddingBox(renderBox->borderLeft(), renderBox->borderTop(),
     
    14411443    }
    14421444
    1443     updateInternalHierarchy();
    14441445    m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
    14451446    m_graphicsLayer->setNeedsDisplay(); // Because painting phases changed.
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r168119 r168190  
    24772477bool RenderLayerCompositor::requiresCompositingForScrolling(const RenderLayer& layer) const
    24782478{
    2479     return layer.hasAcceleratedTouchScrolling();
     2479    if (!layer.hasAcceleratedTouchScrolling())
     2480        return false;
     2481
     2482    if (!m_inPostLayoutUpdate) {
     2483        m_reevaluateCompositingAfterLayout = true;
     2484        return layer.isComposited();
     2485    }
     2486
     2487    return layer.hasTouchScrollableOverflow();
    24802488}
    24812489#endif
     
    25002508
    25012509    RenderLayer* enclosingOverflowLayer = layer.enclosingOverflowClipLayer(ExcludeSelf);
    2502     if (enclosingOverflowLayer && enclosingOverflowLayer->hasAcceleratedTouchScrolling()) {
     2510    if (enclosingOverflowLayer && enclosingOverflowLayer->hasTouchScrollableOverflow()) {
    25032511        if (enclosingAcceleratedOverflowLayer)
    25042512            *enclosingAcceleratedOverflowLayer = enclosingOverflowLayer;
     
    25382546
    25392547#if PLATFORM(IOS)
    2540     return layer.hasAcceleratedTouchScrolling();
     2548    return layer.hasTouchScrollableOverflow();
    25412549#else
    25422550    return layer.needsCompositedScrolling();
Note: See TracChangeset for help on using the changeset viewer.