Changeset 238727 in webkit


Ignore:
Timestamp:
Nov 29, 2018 10:35:36 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Separate paint and scroll offsets for RenderLayerBacking::m_scrollingContentsLayer
https://bugs.webkit.org/show_bug.cgi?id=183040

Source/WebCore:

Currently, scroll offset of RenderLayerBacking::m_scrollingContentsLayer is stored in the
GraphicsLayer::m_offsetFromRenderer member used for paint offset. This patch separates these
two concept by introducing a new GraphicsLayer::m_scrollOffset for the scroll offset. This
makes the API a little bit cleaner, the code easier to understand and might avoid unnecessary
repaints in composited scroll.

Patch by Frederic Wang <fwang@igalia.com> on 2018-11-29
Reviewed by Simon Fraser.

No new tests, already covered by existing tests.

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::setScrollOffset): Setter function to update the scroll offset
of the content layer inside its scrolling parent layer. Ask a repaint if it has changed and
is requested by the caller.
(WebCore::GraphicsLayer::paintGraphicsLayerContents): Take into account the scroll offset
when painting.
(WebCore::GraphicsLayer::dumpProperties const): Dump the scroll offset property.

  • platform/graphics/GraphicsLayer.h: Include ScrollableArea for the ScrollOffset typedef.

Add member for the scroll offset of the content layer inside its scrolling parent layer.
(WebCore::GraphicsLayer::scrollOffset const): Getter function.

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateGeometry): Do not include the scroll offset in the
paint offset of m_scrollingContentsLayer since it is now taken into account in
paintGraphicsLayerContents. Update the scroll offset of m_scrollingContentsLayer separately.
Leave the paint offset of m_foregroundLayer unchanged.
(WebCore::RenderLayerBacking::setContentsNeedDisplayInRect): Take into account the scroll
offset of m_scrollingContentsLayer when calculating the dirty rect.

LayoutTests:

Patch by Frederic Wang <fwang@igalia.com> on 2018-11-29
Reviewed by Simon Fraser.

Update expectations containing layer trees of RenderLayerBacking::m_scrollingContentsLayer, to separate offsetFromRenderer and
scrollOffset. We have OLD offsetFromRenderer = NEW offsetFromRenderer - scrollOffset.

  • compositing/ios/overflow-scroll-touch-tiles-expected.txt:
  • fast/scrolling/ios/overflow-scroll-touch-expected.txt:
  • fast/scrolling/ios/subpixel-overflow-scrolling-with-ancestor-expected.txt:
  • platform/ios/compositing/overflow/scrolling-without-painting-expected.txt:
  • platform/ios/compositing/overflow/textarea-scroll-touch-expected.txt:
  • platform/ios/compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
  • platform/ios/fast/scrolling/ios/overflow-scrolling-ancestor-clip-expected.txt:
  • platform/ios/fast/scrolling/ios/overflow-scrolling-ancestor-clip-size-expected.txt:
  • platform/ios/fast/scrolling/ios/textarea-scroll-touch-expected.txt:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r238725 r238727  
     12018-11-29  Frederic Wang  <fwang@igalia.com>
     2
     3        Separate paint and scroll offsets for RenderLayerBacking::m_scrollingContentsLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=183040
     5
     6        Reviewed by Simon Fraser.
     7
     8        Update expectations containing layer trees of RenderLayerBacking::m_scrollingContentsLayer, to separate offsetFromRenderer and
     9        scrollOffset. We have OLD offsetFromRenderer = NEW offsetFromRenderer - scrollOffset.
     10
     11        * compositing/ios/overflow-scroll-touch-tiles-expected.txt:
     12        * fast/scrolling/ios/overflow-scroll-touch-expected.txt:
     13        * fast/scrolling/ios/subpixel-overflow-scrolling-with-ancestor-expected.txt:
     14        * platform/ios/compositing/overflow/scrolling-without-painting-expected.txt:
     15        * platform/ios/compositing/overflow/textarea-scroll-touch-expected.txt:
     16        * platform/ios/compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt:
     17        * platform/ios/fast/scrolling/ios/overflow-scrolling-ancestor-clip-expected.txt:
     18        * platform/ios/fast/scrolling/ios/overflow-scrolling-ancestor-clip-size-expected.txt:
     19        * platform/ios/fast/scrolling/ios/textarea-scroll-touch-expected.txt:
     20
    1212018-11-29  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/LayoutTests/compositing/ios/overflow-scroll-touch-tiles-expected.txt

    r225897 r238727  
    6363              (children 1
    6464                (GraphicsLayer
    65                   (offsetFromRenderer width=2 height=-238)
     65                  (offsetFromRenderer width=2 height=2)
     66                  (scrollOffset (0,240))
    6667                  (bounds 400.00 2002.00)
    6768                  (usingTiledLayer 1)
  • trunk/LayoutTests/fast/scrolling/ios/overflow-scroll-touch-expected.txt

    r225897 r238727  
    2222              (children 1
    2323                (GraphicsLayer
    24                   (offsetFromRenderer width=1 height=-49)
     24                  (offsetFromRenderer width=1 height=1)
     25                  (scrollOffset (0,50))
    2526                  (bounds 200.00 400.00)
    2627                  (drawsContent 1)
     
    4243              (children 1
    4344                (GraphicsLayer
    44                   (offsetFromRenderer width=1 height=-49)
     45                  (offsetFromRenderer width=1 height=1)
     46                  (scrollOffset (0,50))
    4547                  (bounds 200.00 400.00)
    4648                  (drawsContent 1)
  • trunk/LayoutTests/fast/scrolling/ios/subpixel-overflow-scrolling-with-ancestor-expected.txt

    r225897 r238727  
    1616              (children 1
    1717                (GraphicsLayer
    18                   (offsetFromRenderer width=0 height=-30)
     18                  (scrollOffset (0,30))
    1919                  (bounds 300.00 900.00)
    2020                  (drawsContent 1)
  • trunk/LayoutTests/platform/ios/compositing/overflow/scrolling-without-painting-expected.txt

    r236428 r238727  
    1919              (children 1
    2020                (GraphicsLayer
    21                   (offsetFromRenderer width=1 height=-24)
     21                  (offsetFromRenderer width=1 height=1)
     22                  (scrollOffset (0,25))
    2223                  (bounds 200.00 1025.00)
    2324                )
  • trunk/LayoutTests/platform/ios/compositing/overflow/textarea-scroll-touch-expected.txt

    r236428 r238727  
    2020              (children 1
    2121                (GraphicsLayer
    22                   (offsetFromRenderer width=1 height=-49)
     22                  (offsetFromRenderer width=1 height=1)
     23                  (scrollOffset (0,50))
    2324                  (bounds 204.00 270.00)
    2425                  (drawsContent 1)
     
    4142              (children 1
    4243                (GraphicsLayer
    43                   (offsetFromRenderer width=1 height=-49)
     44                  (offsetFromRenderer width=1 height=1)
     45                  (scrollOffset (0,50))
    4446                  (bounds 204.00 270.00)
    4547                  (drawsContent 1)
  • trunk/LayoutTests/platform/ios/compositing/rtl/rtl-scrolling-with-transformed-descendants-expected.txt

    r225897 r238727  
    2020              (children 1
    2121                (GraphicsLayer
    22                   (offsetFromRenderer width=-364 height=2)
     22                  (offsetFromRenderer width=2 height=2)
     23                  (scrollOffset (366,0))
    2324                  (bounds 766.00 205.00)
    2425                  (drawsContent 1)
  • trunk/LayoutTests/platform/ios/fast/scrolling/ios/overflow-scrolling-ancestor-clip-expected.txt

    r225897 r238727  
    1919              (children 1
    2020                (GraphicsLayer
    21                   (offsetFromRenderer width=1 height=-29)
     21                  (offsetFromRenderer width=1 height=1)
     22                  (scrollOffset (0,30))
    2223                  (bounds 300.00 900.00)
    2324                  (drawsContent 1)
  • trunk/LayoutTests/platform/ios/fast/scrolling/ios/overflow-scrolling-ancestor-clip-size-expected.txt

    r225897 r238727  
    1919              (children 1
    2020                (GraphicsLayer
    21                   (offsetFromRenderer width=11 height=-19)
     21                  (offsetFromRenderer width=11 height=11)
     22                  (scrollOffset (0,30))
    2223                  (bounds 300.00 900.00)
    2324                  (drawsContent 1)
  • trunk/LayoutTests/platform/ios/fast/scrolling/ios/textarea-scroll-touch-expected.txt

    r225897 r238727  
    2020              (children 1
    2121                (GraphicsLayer
    22                   (offsetFromRenderer width=1 height=-49)
     22                  (offsetFromRenderer width=1 height=1)
     23                  (scrollOffset (0,50))
    2324                  (bounds 204.00 270.00)
    2425                  (drawsContent 1)
     
    4142              (children 1
    4243                (GraphicsLayer
    43                   (offsetFromRenderer width=1 height=-49)
     44                  (offsetFromRenderer width=1 height=1)
     45                  (scrollOffset (0,50))
    4446                  (bounds 204.00 270.00)
    4547                  (drawsContent 1)
  • trunk/Source/WebCore/ChangeLog

    r238725 r238727  
     12018-11-29  Frederic Wang  <fwang@igalia.com>
     2
     3        Separate paint and scroll offsets for RenderLayerBacking::m_scrollingContentsLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=183040
     5
     6        Currently, scroll offset of RenderLayerBacking::m_scrollingContentsLayer is stored in the
     7        GraphicsLayer::m_offsetFromRenderer member used for paint offset. This patch separates these
     8        two concept by introducing a new GraphicsLayer::m_scrollOffset for the scroll offset. This
     9        makes the API a little bit cleaner, the code easier to understand and might avoid unnecessary
     10        repaints in composited scroll.
     11
     12        Reviewed by Simon Fraser.
     13
     14        No new tests, already covered by existing tests.
     15
     16        * platform/graphics/GraphicsLayer.cpp:
     17        (WebCore::GraphicsLayer::setScrollOffset): Setter function to update the scroll offset
     18        of the content layer inside its scrolling parent layer. Ask a repaint if it has changed and
     19        is requested by the caller.
     20        (WebCore::GraphicsLayer::paintGraphicsLayerContents): Take into account the scroll offset
     21        when painting.
     22        (WebCore::GraphicsLayer::dumpProperties const): Dump the scroll offset property.
     23        * platform/graphics/GraphicsLayer.h: Include ScrollableArea for the ScrollOffset typedef.
     24        Add member for the scroll offset of the content layer inside its scrolling parent layer.
     25        (WebCore::GraphicsLayer::scrollOffset const): Getter function.
     26        * rendering/RenderLayerBacking.cpp:
     27        (WebCore::RenderLayerBacking::updateGeometry): Do not include the scroll offset in the
     28        paint offset of m_scrollingContentsLayer since it is now taken into account in
     29        paintGraphicsLayerContents. Update the scroll offset of m_scrollingContentsLayer separately.
     30        Leave the paint offset of m_foregroundLayer unchanged.
     31        (WebCore::RenderLayerBacking::setContentsNeedDisplayInRect): Take into account the scroll
     32        offset of m_scrollingContentsLayer when calculating the dirty rect.
     33
    1342018-11-29  Simon Fraser  <simon.fraser@apple.com>
    235
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r238108 r238727  
    457457}
    458458
     459void GraphicsLayer::setScrollOffset(const ScrollOffset& offset, ShouldSetNeedsDisplay shouldSetNeedsDisplay)
     460{
     461    if (offset == m_scrollOffset)
     462        return;
     463
     464    m_scrollOffset = offset;
     465
     466    // If the compositing layer offset changes, we need to repaint.
     467    if (shouldSetNeedsDisplay == SetNeedsDisplay)
     468        setNeedsDisplay();
     469}
     470
    459471void GraphicsLayer::setSize(const FloatSize& size)
    460472{
     
    475487void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const FloatRect& clip, GraphicsLayerPaintBehavior layerPaintBehavior)
    476488{
    477     FloatSize offset = offsetFromRenderer();
     489    FloatSize offset = offsetFromRenderer() - toFloatSize(scrollOffset());
    478490    context.translate(-offset);
    479491
     
    781793        ts << indent << "(offsetFromRenderer " << m_offsetFromRenderer << ")\n";
    782794
     795    if (!m_scrollOffset.isZero())
     796        ts << indent << "(scrollOffset " << m_scrollOffset << ")\n";
     797
    783798    if (m_position != FloatPoint())
    784799        ts << indent << "(position " << m_position.x() << " " << m_position.y() << ")\n";
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r238108 r238727  
    3636#include "Path.h"
    3737#include "PlatformLayer.h"
     38#include "ScrollableArea.h"
    3839#include "TransformOperations.h"
    3940#include "WindRule.h"
     
    314315    void setOffsetFromRenderer(const FloatSize&, ShouldSetNeedsDisplay = SetNeedsDisplay);
    315316
     317    // Scroll offset of the content layer inside its scrolling parent layer.
     318    ScrollOffset scrollOffset() const { return m_scrollOffset; }
     319    void setScrollOffset(const ScrollOffset&, ShouldSetNeedsDisplay = SetNeedsDisplay);
     320
    316321    // The position of the layer (the location of its top-left corner in its parent)
    317322    const FloatPoint& position() const { return m_position; }
     
    652657    FloatSize m_offsetFromRenderer;
    653658   
     659    // Scroll offset of the content layer inside its scrolling parent layer.
     660    ScrollOffset m_scrollOffset;
     661
    654662    // Position is relative to the parent GraphicsLayer
    655663    FloatPoint m_position;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r238715 r238727  
    12071207        m_scrollingContentsLayer->setSize(scrollSize);
    12081208        // Scrolling the content layer does not need to trigger a repaint. The offset will be compensated away during painting.
    1209         // FIXME: The paint offset and the scroll offset should really be separate concepts.
    1210         LayoutSize scrollingContentsOffset = toLayoutSize(paddingBox.location() - toLayoutSize(scrollOffset));
    1211         m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay);
     1209        m_scrollingContentsLayer->setScrollOffset(scrollOffset, GraphicsLayer::DontSetNeedsDisplay);
     1210        m_scrollingContentsLayer->setOffsetFromRenderer(toLayoutSize(paddingBox.location()), GraphicsLayer::DontSetNeedsDisplay);
    12121211#else
    12131212        m_scrollingContentsLayer->setPosition(-scrollOffset);
     
    12281227            m_scrollingContentsLayer->setNeedsDisplay();
    12291228
    1230         LayoutSize scrollingContentsOffset = toLayoutSize(paddingBox.location() - toLayoutSize(scrollOffset));
    1231         if (scrollingContentsOffset != m_scrollingContentsLayer->offsetFromRenderer() || scrollSize != m_scrollingContentsLayer->size())
     1229        if (toLayoutSize(paddingBox.location()) != m_scrollingContentsLayer->offsetFromRenderer() || scrollOffset != m_scrollingContentsLayer->scrollOffset() || scrollSize != m_scrollingContentsLayer->size())
    12321230            compositor().scrollingLayerDidChange(m_owningLayer);
    12331231
    12341232        m_scrollingContentsLayer->setSize(scrollSize);
    1235         // FIXME: The paint offset and the scroll offset should really be separate concepts.
    1236         m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, GraphicsLayer::DontSetNeedsDisplay);
     1233        m_scrollingContentsLayer->setScrollOffset(scrollOffset, GraphicsLayer::DontSetNeedsDisplay);
     1234        m_scrollingContentsLayer->setOffsetFromRenderer(toLayoutSize(paddingBox.location()), GraphicsLayer::DontSetNeedsDisplay);
    12371235#endif
    12381236
    12391237        if (m_foregroundLayer) {
    12401238            m_foregroundLayer->setSize(m_scrollingContentsLayer->size());
    1241             m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offsetFromRenderer());
     1239            m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offsetFromRenderer() - toLayoutSize(m_scrollingContentsLayer->scrollOffset()));
    12421240        }
    12431241    }
     
    25102508    if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent()) {
    25112509        FloatRect layerDirtyRect = pixelSnappedRectForPainting;
    2512         layerDirtyRect.move(-m_scrollingContentsLayer->offsetFromRenderer() - m_subpixelOffsetFromRenderer);
     2510        layerDirtyRect.move(-m_scrollingContentsLayer->offsetFromRenderer() + toLayoutSize(m_scrollingContentsLayer->scrollOffset()) - m_subpixelOffsetFromRenderer);
    25132511#if PLATFORM(IOS_FAMILY)
    25142512        // Account for the fact that RenderLayerBacking::updateGeometry() bakes scrollOffset into offsetFromRenderer on iOS,
Note: See TracChangeset for help on using the changeset viewer.