Changeset 248604 in webkit


Ignore:
Timestamp:
Aug 13, 2019 12:26:22 PM (5 years ago)
Author:
Antti Koivisto
Message:

Source/WebCore:
Event region collection should take clipping into account
https://bugs.webkit.org/show_bug.cgi?id=200668
<rdar://problem/53826561>

Reviewed by Simon Fraser.

Test: pointerevents/ios/touch-action-region-clip-and-transform.html

  • rendering/EventRegion.cpp:

(WebCore::EventRegionContext::pushClip):
(WebCore::EventRegionContext::popClip):

Maintain clip rect stack.

(WebCore::EventRegionContext::unite):

Apply both transforms and clipping.

  • rendering/EventRegion.h:
  • rendering/RenderBlock.cpp:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::pushContentsClip):
(WebCore::RenderBox::popContentsClip):

Update clip for non-self-painting layers.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::clipToRect):
(WebCore::RenderLayer::restoreClip):

Update clip for self-painting layers.

LayoutTests:
Event regions collection should take clipping into account
https://bugs.webkit.org/show_bug.cgi?id=200668
<rdar://problem/53826561>

Reviewed by Simon Fraser.

  • pointerevents/ios/touch-action-region-clip-and-transform-expected.txt: Added.
  • pointerevents/ios/touch-action-region-clip-and-transform.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r248602 r248604  
     12019-08-13  Antti Koivisto  <antti@apple.com>
     2
     3        Event regions collection should take clipping into account
     4        https://bugs.webkit.org/show_bug.cgi?id=200668
     5        <rdar://problem/53826561>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * pointerevents/ios/touch-action-region-clip-and-transform-expected.txt: Added.
     10        * pointerevents/ios/touch-action-region-clip-and-transform.html: Added.
     11
    1122019-08-13  Devin Rousso  <drousso@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r248602 r248604  
     12019-08-13  Antti Koivisto  <antti@apple.com>
     2
     3        Event region collection should take clipping into account
     4        https://bugs.webkit.org/show_bug.cgi?id=200668
     5        <rdar://problem/53826561>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Test: pointerevents/ios/touch-action-region-clip-and-transform.html
     10
     11        * rendering/EventRegion.cpp:
     12        (WebCore::EventRegionContext::pushClip):
     13        (WebCore::EventRegionContext::popClip):
     14
     15        Maintain clip rect stack.
     16
     17        (WebCore::EventRegionContext::unite):
     18
     19        Apply both transforms and clipping.
     20
     21        * rendering/EventRegion.h:
     22        * rendering/RenderBlock.cpp:
     23        * rendering/RenderBox.cpp:
     24        (WebCore::RenderBox::pushContentsClip):
     25        (WebCore::RenderBox::popContentsClip):
     26
     27        Update clip for non-self-painting layers.
     28
     29        * rendering/RenderLayer.cpp:
     30        (WebCore::RenderLayer::clipToRect):
     31        (WebCore::RenderLayer::restoreClip):
     32
     33        Update clip for self-painting layers.
     34
    1352019-08-13  Devin Rousso  <drousso@apple.com>
    236
  • trunk/Source/WebCore/rendering/EventRegion.cpp

    r246301 r248604  
    4646void EventRegionContext::popTransform()
    4747{
     48    if (m_transformStack.isEmpty()) {
     49        ASSERT_NOT_REACHED();
     50        return;
     51    }
    4852    m_transformStack.removeLast();
    4953}
    5054
     55void EventRegionContext::pushClip(const IntRect& clipRect)
     56{
     57    auto transformedClip = m_transformStack.isEmpty() ? clipRect : m_transformStack.last().mapRect(clipRect);
     58
     59    if (m_clipStack.isEmpty())
     60        m_clipStack.append(transformedClip);
     61    else
     62        m_clipStack.append(intersection(m_clipStack.last(), transformedClip));
     63}
     64
     65void EventRegionContext::popClip()
     66{
     67    if (m_clipStack.isEmpty()) {
     68        ASSERT_NOT_REACHED();
     69        return;
     70    }
     71    m_clipStack.removeLast();
     72}
     73
    5174void EventRegionContext::unite(const Region& region, const RenderStyle& style)
    5275{
    53     if (m_transformStack.isEmpty())
     76    if (m_transformStack.isEmpty() && m_clipStack.isEmpty()) {
    5477        m_eventRegion.unite(region, style);
    55     else
    56         m_eventRegion.unite(m_transformStack.last().mapRegion(region), style);
     78        return;
     79    }
     80
     81    auto transformedAndClippedRegion = m_transformStack.isEmpty() ? region : m_transformStack.last().mapRegion(region);
     82
     83    if (!m_clipStack.isEmpty())
     84        transformedAndClippedRegion.intersect(m_clipStack.last());
     85
     86    m_eventRegion.unite(transformedAndClippedRegion, style);
    5787}
    5888
  • trunk/Source/WebCore/rendering/EventRegion.h

    r246301 r248604  
    4444    void popTransform();
    4545
     46    void pushClip(const IntRect&);
     47    void popClip();
     48
    4649    void unite(const Region&, const RenderStyle&);
    4750    bool contains(const IntRect&) const;
     
    5053    EventRegion& m_eventRegion;
    5154    Vector<AffineTransform> m_transformStack;
     55    Vector<IntRect> m_clipStack;
    5256};
    5357
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r247256 r248604  
    18051805        paintInfo.context().clipRoundedRect(style().getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size())).pixelSnappedRoundedRectForPainting(deviceScaleFactor));
    18061806    paintInfo.context().clip(clipRect);
     1807
     1808    if (paintInfo.phase == PaintPhase::EventRegion)
     1809        paintInfo.eventRegionContext->pushClip(enclosingIntRect(clipRect));
     1810
    18071811    return true;
    18081812}
     
    18111815{
    18121816    ASSERT(hasControlClip() || (hasOverflowClip() && !layer()->isSelfPaintingLayer()));
     1817
     1818    if (paintInfo.phase == PaintPhase::EventRegion)
     1819        paintInfo.eventRegionContext->popClip();
    18131820
    18141821    paintInfo.context().restore();
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r247912 r248604  
    40114011        LayoutRect adjustedClipRect = clipRect.rect();
    40124012        adjustedClipRect.move(paintingInfo.subpixelOffset);
    4013         context.clip(snapRectToDevicePixels(adjustedClipRect, deviceScaleFactor));
     4013        auto snappedClipRect = snapRectToDevicePixels(adjustedClipRect, deviceScaleFactor);
     4014        context.clip(snappedClipRect);
     4015
     4016        if (paintingInfo.eventRegionContext)
     4017            paintingInfo.eventRegionContext->pushClip(enclosingIntRect(snappedClipRect));
    40144018    }
    40154019
     
    40374041void RenderLayer::restoreClip(GraphicsContext& context, const LayerPaintingInfo& paintingInfo, const ClipRect& clipRect)
    40384042{
    4039     if ((!clipRect.isInfinite() && clipRect.rect() != paintingInfo.paintDirtyRect) || clipRect.affectedByRadius())
     4043    if ((!clipRect.isInfinite() && clipRect.rect() != paintingInfo.paintDirtyRect) || clipRect.affectedByRadius()) {
    40404044        context.restore();
     4045
     4046        if (paintingInfo.eventRegionContext)
     4047            paintingInfo.eventRegionContext->popClip();
     4048    }
    40414049}
    40424050
Note: See TracChangeset for help on using the changeset viewer.