Changeset 262133 in webkit


Ignore:
Timestamp:
May 25, 2020 5:27:12 PM (4 years ago)
Author:
Simon Fraser
Message:

Use an Optional<> for LayerFragment::boundingBox
https://bugs.webkit.org/show_bug.cgi?id=212358

Reviewed by Zalan Bujtas.

Replace a bool + LayoutRect with Optional<LayoutRect>.

  • rendering/LayerFragment.h:

(WebCore::LayerFragment::setRects):
(WebCore::LayerFragment::moveBy):
(WebCore::LayerFragment::intersect):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::collectFragments):
(WebCore::RenderLayer::updatePaintingInfoForFragments):
(WebCore::RenderLayer::calculateClipRects const):

  • rendering/RenderLayer.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r262132 r262133  
     12020-05-25  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Use an Optional<> for LayerFragment::boundingBox
     4        https://bugs.webkit.org/show_bug.cgi?id=212358
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Replace a bool + LayoutRect with Optional<LayoutRect>.
     9
     10        * rendering/LayerFragment.h:
     11        (WebCore::LayerFragment::setRects):
     12        (WebCore::LayerFragment::moveBy):
     13        (WebCore::LayerFragment::intersect):
     14        * rendering/RenderLayer.cpp:
     15        (WebCore::RenderLayer::collectFragments):
     16        (WebCore::RenderLayer::updatePaintingInfoForFragments):
     17        (WebCore::RenderLayer::calculateClipRects const):
     18        * rendering/RenderLayer.h:
     19
    1202020-05-25  Simon Fraser  <simon.fraser@apple.com>
    221
  • trunk/Source/WebCore/rendering/LayerFragment.h

    r208668 r262133  
    3434    LayerFragment() = default;
    3535   
    36     void setRects(const LayoutRect& bounds, const ClipRect& background, const ClipRect& foreground, const LayoutRect* bbox)
     36    void setRects(const LayoutRect& bounds, const ClipRect& background, const ClipRect& foreground, const Optional<LayoutRect>& bbox)
    3737    {
    3838        layerBounds = bounds;
    3939        backgroundRect = background;
    4040        foregroundRect = foreground;
    41         if (bbox) {
    42             boundingBox = *bbox;
    43             hasBoundingBox = true;
    44         }
     41        boundingBox = bbox;
    4542    }
    4643   
     
    5148        foregroundRect.moveBy(offset);
    5249        paginationClip.moveBy(offset);
    53         boundingBox.moveBy(offset);
     50        if (boundingBox)
     51            boundingBox->moveBy(offset);
    5452    }
    5553   
     
    5856        backgroundRect.intersect(rect);
    5957        foregroundRect.intersect(rect);
    60         boundingBox.intersect(rect);
     58        if (boundingBox)
     59            boundingBox->intersect(rect);
    6160    }
    6261   
     
    6867
    6968    bool shouldPaintContent = false;
    70     bool hasBoundingBox = false;
     69    Optional<LayoutRect> boundingBox;
     70
    7171    LayoutRect layerBounds;
    7272    ClipRect backgroundRect;
    7373    ClipRect foregroundRect;
    74     LayoutRect boundingBox;
    7574   
    7675    // Unique to paginated fragments. The physical translation to apply to shift the layer when painting/hit-testing.
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r262128 r262133  
    48754875               
    48764876                // Set our four rects with all clipping applied that was internal to the flow thread.
    4877                 fragment.setRects(layerBoundsInFragmentedFlow, backgroundRectInFragmentedFlow, foregroundRectInFragmentedFlow, &layerBoundingBoxInFragmentedFlow);
     4877                fragment.setRects(layerBoundsInFragmentedFlow, backgroundRectInFragmentedFlow, foregroundRectInFragmentedFlow, layerBoundingBoxInFragmentedFlow);
    48784878               
    48794879                // Shift to the root-relative physical position used when painting the flow thread in this fragment.
     
    49184918    for (auto& fragment : fragments) {
    49194919        // Set our four rects with all clipping applied that was internal to the flow thread.
    4920         fragment.setRects(layerBoundsInFragmentedFlow, backgroundRectInFragmentedFlow, foregroundRectInFragmentedFlow, &layerBoundingBoxInFragmentedFlow);
     4920        fragment.setRects(layerBoundsInFragmentedFlow, backgroundRectInFragmentedFlow, foregroundRectInFragmentedFlow, layerBoundingBoxInFragmentedFlow);
    49214921       
    49224922        // Shift to the root-relative physical position used when painting the flow thread in this fragment.
     
    49434943        if (this != localPaintingInfo.rootLayer || !(localPaintFlags & PaintLayerPaintingOverflowContents)) {
    49444944            LayoutSize newOffsetFromRoot = offsetFromRoot + fragment.paginationOffset;
    4945             fragment.shouldPaintContent &= intersectsDamageRect(fragment.layerBounds, fragment.backgroundRect.rect(), localPaintingInfo.rootLayer, newOffsetFromRoot, fragment.hasBoundingBox ? &fragment.boundingBox : 0);
     4945            fragment.shouldPaintContent &= intersectsDamageRect(fragment.layerBounds, fragment.backgroundRect.rect(), localPaintingInfo.rootLayer, newOffsetFromRoot, fragment.boundingBox);
    49464946        }
    49474947    }
     
    59965996}
    59975997
    5998 bool RenderLayer::intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer, const LayoutSize& offsetFromRoot, const LayoutRect* cachedBoundingBox) const
     5998bool RenderLayer::intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer, const LayoutSize& offsetFromRoot, const Optional<LayoutRect>& cachedBoundingBox) const
    59995999{
    60006000    // Always examine the canvas and the root.
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r261575 r262133  
    734734
    735735    // Pass offsetFromRoot if known.
    736     bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer, const LayoutSize& offsetFromRoot, const LayoutRect* cachedBoundingBox = nullptr) const;
     736    bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer, const LayoutSize& offsetFromRoot, const Optional<LayoutRect>& cachedBoundingBox = WTF::nullopt) const;
    737737
    738738    enum CalculateLayerBoundsFlag {
Note: See TracChangeset for help on using the changeset viewer.