Changeset 95239 in webkit


Ignore:
Timestamp:
Sep 15, 2011 3:53:54 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=50072

Make overflow clipping to border-radius work across layers. This patch makes painting
work but does not attempt to fix hit testing. It also doesn't work when a composited
layer is clipped by a non-composited ancestor.

Add a new ClipRect class (used by ClipRects and RenderLayer) that is basically just tracking
a rect and a border radius taint. At the time we set a clip, if the rectangle is listed
as also being clipped by a radius, then we walk up the layer tree and push those inner border
rounded rect clips for any overflow areas in the containing block chain.

Reviewed by Beth Dakin.

Source/WebCore:

Added new tests in fast/clip.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::pushContentsClip):

  • rendering/RenderLayer.cpp:

(WebCore::inContainingBlockChain):
(WebCore::RenderLayer::clipToRect):
(WebCore::RenderLayer::restoreClip):
(WebCore::RenderLayer::paintLayer):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::calculateClipRects):
(WebCore::RenderLayer::backgroundClipRect):
(WebCore::RenderLayer::calculateRects):
(WebCore::RenderLayer::childrenClipRect):
(WebCore::RenderLayer::selfClipRect):

  • rendering/RenderLayer.h:

(WebCore::ClipRect::ClipRect):
(WebCore::ClipRect::rect):
(WebCore::ClipRect::setRect):
(WebCore::ClipRect::hasRadius):
(WebCore::ClipRect::setHasRadius):
(WebCore::ClipRect::operator==):
(WebCore::ClipRect::intersect):
(WebCore::ClipRect::move):
(WebCore::ClipRect::isEmpty):
(WebCore::ClipRect::intersects):
(WebCore::intersection):
(WebCore::ClipRects::overflowClipRect):
(WebCore::ClipRects::setOverflowClipRect):
(WebCore::ClipRects::fixedClipRect):
(WebCore::ClipRects::setFixedClipRect):
(WebCore::ClipRects::posClipRect):
(WebCore::ClipRects::setPosClipRect):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateCompositedBounds):
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::paintIntoLayer):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::addToOverlapMap):
(WebCore::RenderLayerCompositor::clippedByAncestor):

  • rendering/RenderTreeAsText.cpp:

(WebCore::writeLayers):

LayoutTests:

  • fast/clip/overflow-border-radius-combinations.html: Added.
  • fast/clip/overflow-border-radius-composited.html: Added.
  • fast/clip/overflow-border-radius-transformed.html: Added.
  • platform/mac/fast/clip/overflow-border-radius-combinations-expected.png: Added.
  • platform/mac/fast/clip/overflow-border-radius-combinations-expected.txt: Added.
  • platform/mac/fast/clip/overflow-border-radius-composited-expected.png: Added.
  • platform/mac/fast/clip/overflow-border-radius-composited-expected.txt: Added.
  • platform/mac/fast/clip/overflow-border-radius-transformed-expected.png: Added.
  • platform/mac/fast/clip/overflow-border-radius-transformed-expected.txt: Added.
Location:
trunk
Files:
9 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95235 r95239  
     12011-09-15  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=50072
     4       
     5        Make overflow clipping to border-radius work across layers. This patch makes painting
     6        work but does not attempt to fix hit testing. It also doesn't work when a composited
     7        layer is clipped by a non-composited ancestor.
     8
     9        Add a new ClipRect class (used by ClipRects and RenderLayer) that is basically just tracking
     10        a rect and a border radius taint. At the time we set a clip, if the rectangle is listed
     11        as also being clipped by a radius, then we walk up the layer tree and push those inner border
     12        rounded rect clips for any overflow areas in the containing block chain.
     13
     14        Reviewed by Beth Dakin.
     15
     16        * fast/clip/overflow-border-radius-combinations.html: Added.
     17        * fast/clip/overflow-border-radius-composited.html: Added.
     18        * fast/clip/overflow-border-radius-transformed.html: Added.
     19        * platform/mac/fast/clip/overflow-border-radius-combinations-expected.png: Added.
     20        * platform/mac/fast/clip/overflow-border-radius-combinations-expected.txt: Added.
     21        * platform/mac/fast/clip/overflow-border-radius-composited-expected.png: Added.
     22        * platform/mac/fast/clip/overflow-border-radius-composited-expected.txt: Added.
     23        * platform/mac/fast/clip/overflow-border-radius-transformed-expected.png: Added.
     24        * platform/mac/fast/clip/overflow-border-radius-transformed-expected.txt: Added.
     25
    1262011-09-15  Julien Chaffraix  <jchaffraix@webkit.org>
    227
  • trunk/Source/WebCore/ChangeLog

    r95235 r95239  
     12011-09-15  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=50072
     4       
     5        Make overflow clipping to border-radius work across layers. This patch makes painting
     6        work but does not attempt to fix hit testing. It also doesn't work when a composited
     7        layer is clipped by a non-composited ancestor.
     8
     9        Add a new ClipRect class (used by ClipRects and RenderLayer) that is basically just tracking
     10        a rect and a border radius taint. At the time we set a clip, if the rectangle is listed
     11        as also being clipped by a radius, then we walk up the layer tree and push those inner border
     12        rounded rect clips for any overflow areas in the containing block chain.
     13
     14        Reviewed by Beth Dakin.
     15
     16        Added new tests in fast/clip.
     17
     18        * rendering/RenderBox.cpp:
     19        (WebCore::RenderBox::pushContentsClip):
     20        * rendering/RenderLayer.cpp:
     21        (WebCore::inContainingBlockChain):
     22        (WebCore::RenderLayer::clipToRect):
     23        (WebCore::RenderLayer::restoreClip):
     24        (WebCore::RenderLayer::paintLayer):
     25        (WebCore::RenderLayer::hitTestLayer):
     26        (WebCore::RenderLayer::calculateClipRects):
     27        (WebCore::RenderLayer::backgroundClipRect):
     28        (WebCore::RenderLayer::calculateRects):
     29        (WebCore::RenderLayer::childrenClipRect):
     30        (WebCore::RenderLayer::selfClipRect):
     31        * rendering/RenderLayer.h:
     32        (WebCore::ClipRect::ClipRect):
     33        (WebCore::ClipRect::rect):
     34        (WebCore::ClipRect::setRect):
     35        (WebCore::ClipRect::hasRadius):
     36        (WebCore::ClipRect::setHasRadius):
     37        (WebCore::ClipRect::operator==):
     38        (WebCore::ClipRect::intersect):
     39        (WebCore::ClipRect::move):
     40        (WebCore::ClipRect::isEmpty):
     41        (WebCore::ClipRect::intersects):
     42        (WebCore::intersection):
     43        (WebCore::ClipRects::overflowClipRect):
     44        (WebCore::ClipRects::setOverflowClipRect):
     45        (WebCore::ClipRects::fixedClipRect):
     46        (WebCore::ClipRects::setFixedClipRect):
     47        (WebCore::ClipRects::posClipRect):
     48        (WebCore::ClipRects::setPosClipRect):
     49        * rendering/RenderLayerBacking.cpp:
     50        (WebCore::RenderLayerBacking::updateCompositedBounds):
     51        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
     52        (WebCore::RenderLayerBacking::paintIntoLayer):
     53        * rendering/RenderLayerCompositor.cpp:
     54        (WebCore::RenderLayerCompositor::addToOverlapMap):
     55        (WebCore::RenderLayerCompositor::clippedByAncestor):
     56        * rendering/RenderTreeAsText.cpp:
     57        (WebCore::writeLayers):
     58
    1592011-09-15  Julien Chaffraix  <jchaffraix@webkit.org>
    260
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r95235 r95239  
    11611161    paintInfo.context->save();
    11621162    if (style()->hasBorderRadius())
    1163         paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(LayoutRect(accumulatedOffset, size())));
     1163        paintInfo.context->addRoundedRectClip(style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, size())));
    11641164    paintInfo.context->clip(clipRect);
    11651165    return true;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r94912 r95239  
    25552555}
    25562556
    2557 static void setClip(GraphicsContext* p, const LayoutRect& paintDirtyRect, const LayoutRect& clipRect)
    2558 {
    2559     if (paintDirtyRect == clipRect)
    2560         return;
    2561     p->save();
    2562     p->clip(clipRect);
    2563 }
    2564 
    2565 static void restoreClip(GraphicsContext* p, const LayoutRect& paintDirtyRect, const LayoutRect& clipRect)
    2566 {
    2567     if (paintDirtyRect == clipRect)
     2557static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLayer)
     2558{
     2559    if (startLayer == endLayer)
     2560        return true;
     2561   
     2562    for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock; currentBlock = currentBlock->containingBlock()) {
     2563        if (currentBlock->layer() == endLayer)
     2564            return true;
     2565    }
     2566   
     2567    return false;
     2568}
     2569
     2570void RenderLayer::clipToRect(RenderLayer* rootLayer, GraphicsContext* context, const LayoutRect& paintDirtyRect, const ClipRect& clipRect,
     2571                             BorderRadiusClippingRule rule)
     2572{
     2573    if (clipRect.rect() == paintDirtyRect)
     2574        return;
     2575    context->save();
     2576    context->clip(clipRect.rect());
     2577   
     2578    if (!clipRect.hasRadius())
     2579        return;
     2580
     2581    // If the clip rect has been tainted by a border radius, then we have to walk up our layer chain applying the clips from
     2582    // any layers with overflow. The condition for being able to apply these clips is that the overflow object be in our
     2583    // containing block chain so we check that also.
     2584    for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? this : parent(); layer; layer = layer->parent()) {
     2585        if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->hasBorderRadius() && inContainingBlockChain(this, layer)) {
     2586                LayoutPoint delta;
     2587                layer->convertToLayerCoords(rootLayer, delta);
     2588                context->addRoundedRectClip(layer->renderer()->style()->getRoundedInnerBorderFor(LayoutRect(delta, layer->size())));
     2589        }
     2590
     2591        if (layer == rootLayer)
     2592            break;
     2593    }
     2594}
     2595
     2596void RenderLayer::restoreClip(GraphicsContext* p, const LayoutRect& paintDirtyRect, const ClipRect& clipRect)
     2597{
     2598    if (clipRect.rect() == paintDirtyRect)
    25682599        return;
    25692600    p->restore();
     
    26412672
    26422673        // Make sure the parent's clip rects have been calculated.
    2643         LayoutRect clipRect = paintDirtyRect;
     2674        ClipRect clipRect = paintDirtyRect;
    26442675        if (parent()) {
    26452676            clipRect = backgroundClipRect(rootLayer, paintFlags & PaintLayerTemporaryClipRects);
    26462677            clipRect.intersect(paintDirtyRect);
    2647         }
    26482678       
    2649         // Push the parent coordinate space's clip.
    2650         setClip(p, paintDirtyRect, clipRect);
     2679            // Push the parent coordinate space's clip.
     2680            parent()->clipToRect(rootLayer, p, paintDirtyRect, clipRect);
     2681        }
    26512682
    26522683        // Adjust the transform such that the renderer's upper left corner will paint at (0,0) in user space.
     
    26672698
    26682699        // Restore the clip.
    2669         restoreClip(p, paintDirtyRect, clipRect);
    2670        
     2700        if (parent())
     2701            parent()->restoreClip(p, paintDirtyRect, clipRect);
     2702
    26712703        return;
    26722704    }
     
    26842716
    26852717    // Calculate the clip rects we should use.
    2686     LayoutRect layerBounds, damageRect, clipRectToApply, outlineRect;
     2718    LayoutRect layerBounds;
     2719    ClipRect damageRect, clipRectToApply, outlineRect;
    26872720    calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect, localPaintFlags & PaintLayerTemporaryClipRects);
    26882721    LayoutPoint paintOffset = toPoint(layerBounds.location() - renderBoxLocation());
     
    27082741
    27092742    // We want to paint our layer, but only if we intersect the damage rect.
    2710     bool shouldPaint = intersectsDamageRect(layerBounds, damageRect, rootLayer) && m_hasVisibleContent && isSelfPaintingLayer();
     2743    bool shouldPaint = intersectsDamageRect(layerBounds, damageRect.rect(), rootLayer) && m_hasVisibleContent && isSelfPaintingLayer();
    27112744    if (shouldPaint && !selectionOnly && !damageRect.isEmpty() && !paintingOverlayScrollbars) {
    27122745        // Begin transparency layers lazily now that we know we have to paint something.
     
    27162749        // Paint our background first, before painting any child layers.
    27172750        // Establish the clip used to paint our background.
    2718         setClip(p, paintDirtyRect, damageRect);
     2751        clipToRect(rootLayer, p, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Background painting will handle clipping to self.
    27192752
    27202753        // Paint the background.
    2721         PaintInfo paintInfo(p, damageRect, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0);
     2754        PaintInfo paintInfo(p, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, 0);
    27222755        renderer()->paint(paintInfo, paintOffset);
    27232756
     
    27362769
    27372770        // Set up the clip used when painting our children.
    2738         setClip(p, paintDirtyRect, clipRectToApply);
    2739         PaintInfo paintInfo(p, clipRectToApply,
    2740                                           selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
    2741                                           forceBlackText, paintingRootForRenderer, 0);
     2771        clipToRect(rootLayer, p, paintDirtyRect, clipRectToApply);
     2772        PaintInfo paintInfo(p, clipRectToApply.rect(),
     2773                            selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
     2774                            forceBlackText, paintingRootForRenderer, 0);
    27422775        renderer()->paint(paintInfo, paintOffset);
    27432776        if (!selectionOnly) {
     
    27572790    if (!outlineRect.isEmpty() && isSelfPaintingLayer() && !paintingOverlayScrollbars) {
    27582791        // Paint our own outline
    2759         PaintInfo paintInfo(p, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0);
    2760         setClip(p, paintDirtyRect, outlineRect);
     2792        PaintInfo paintInfo(p, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, 0);
     2793        clipToRect(rootLayer, p, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
    27612794        renderer()->paint(paintInfo, paintOffset);
    27622795        restoreClip(p, paintDirtyRect, outlineRect);
     
    27702803       
    27712804    if (renderer()->hasMask() && shouldPaint && !selectionOnly && !damageRect.isEmpty() && !paintingOverlayScrollbars) {
    2772         setClip(p, paintDirtyRect, damageRect);
     2805        clipToRect(rootLayer, p, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self.
    27732806
    27742807        // Paint the mask.
    2775         PaintInfo paintInfo(p, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0);
     2808        PaintInfo paintInfo(p, damageRect.rect(), PaintPhaseMask, false, paintingRootForRenderer, 0);
    27762809        renderer()->paint(paintInfo, paintOffset);
    27772810       
     
    27812814
    27822815    if (paintingOverlayScrollbars) {
    2783         setClip(p, paintDirtyRect, damageRect);
    2784         paintOverflowControls(p, paintOffset, damageRect, true);
     2816        clipToRect(rootLayer, p, paintDirtyRect, damageRect);
     2817        paintOverflowControls(p, paintOffset, damageRect.rect(), true);
    27852818        restoreClip(p, paintDirtyRect, damageRect);
    27862819    }
     
    30613094        // Make sure the parent's clip rects have been calculated.
    30623095        if (parent()) {
    3063             LayoutRect clipRect = backgroundClipRect(rootLayer, useTemporaryClipRects, IncludeOverlayScrollbarSize);
     3096            ClipRect clipRect = backgroundClipRect(rootLayer, useTemporaryClipRects, IncludeOverlayScrollbarSize);
    30643097            // Go ahead and test the enclosing clip now.
    30653098            if (!clipRect.intersects(hitTestArea))
     
    31263159    // Calculate the clip rects we should use.
    31273160    LayoutRect layerBounds;
    3128     LayoutRect bgRect;
    3129     LayoutRect fgRect;
    3130     LayoutRect outlineRect;
     3161    ClipRect bgRect;
     3162    ClipRect fgRect;
     3163    ClipRect outlineRect;
    31313164    calculateRects(rootLayer, hitTestRect, layerBounds, bgRect, fgRect, outlineRect, useTemporaryClipRects, IncludeOverlayScrollbarSize);
    31323165   
     
    34323465        else
    34333466            parentLayer->calculateClipRects(rootLayer, clipRects);
    3434     }
    3435     else
     3467    } else
    34363468        clipRects.reset(PaintInfo::infiniteRect());
    34373469
     
    34603492       
    34613493        if (renderer()->hasOverflowClip()) {
    3462             LayoutRect newOverflowClip = toRenderBox(renderer())->overflowClipRect(offset, relevancy);
     3494            ClipRect newOverflowClip = toRenderBox(renderer())->overflowClipRect(offset, relevancy);
     3495            if (renderer()->style()->hasBorderRadius())
     3496                newOverflowClip.setHasRadius(true);
    34633497            clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.overflowClipRect()));
    34643498            if (renderer()->isPositioned() || renderer()->isRelPositioned())
     
    34863520}
    34873521
    3488 LayoutRect RenderLayer::backgroundClipRect(const RenderLayer* rootLayer, bool temporaryClipRects, OverlayScrollbarSizeRelevancy relevancy) const
    3489 {
    3490     LayoutRect backgroundRect;
     3522ClipRect RenderLayer::backgroundClipRect(const RenderLayer* rootLayer, bool temporaryClipRects, OverlayScrollbarSizeRelevancy relevancy) const
     3523{
     3524    ClipRect backgroundRect;
    34913525    if (parent()) {
    34923526        ClipRects parentRects;
     
    35043538
    35053539void RenderLayer::calculateRects(const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, LayoutRect& layerBounds,
    3506                                  LayoutRect& backgroundRect, LayoutRect& foregroundRect, LayoutRect& outlineRect, bool temporaryClipRects,
     3540                                 ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRect, bool temporaryClipRects,
    35073541                                 OverlayScrollbarSizeRelevancy relevancy) const
    35083542{
     
    35233557    if (renderer()->hasOverflowClip() || renderer()->hasClip()) {
    35243558        // This layer establishes a clip of some kind.
    3525         if (renderer()->hasOverflowClip())
     3559        if (renderer()->hasOverflowClip()) {
    35263560            foregroundRect.intersect(toRenderBox(renderer())->overflowClipRect(offset, relevancy));
     3561            if (renderer()->style()->hasBorderRadius())
     3562                foregroundRect.setHasRadius(true);
     3563        }
     3564
    35273565        if (renderer()->hasClip()) {
    35283566            // Clip applies to *us* as well, so go ahead and update the damageRect.
     
    35453583LayoutRect RenderLayer::childrenClipRect() const
    35463584{
     3585    // FIXME: border-radius not accounted for.
    35473586    RenderView* renderView = renderer()->view();
    35483587    RenderLayer* clippingRootLayer = clippingRoot();
    3549     LayoutRect layerBounds, backgroundRect, foregroundRect, outlineRect;
     3588    LayoutRect layerBounds;
     3589    ClipRect backgroundRect, foregroundRect, outlineRect;
    35503590    calculateRects(clippingRootLayer, renderView->unscaledDocumentRect(), layerBounds, backgroundRect, foregroundRect, outlineRect);
    3551     return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregroundRect)).enclosingBoundingBox();
     3591    return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregroundRect.rect())).enclosingBoundingBox();
    35523592}
    35533593
    35543594LayoutRect RenderLayer::selfClipRect() const
    35553595{
     3596    // FIXME: border-radius not accounted for.
    35563597    RenderView* renderView = renderer()->view();
    35573598    RenderLayer* clippingRootLayer = clippingRoot();
    3558     LayoutRect layerBounds, backgroundRect, foregroundRect, outlineRect;
     3599    LayoutRect layerBounds;
     3600    ClipRect backgroundRect, foregroundRect, outlineRect;
    35593601    calculateRects(clippingRootLayer, renderView->documentRect(), layerBounds, backgroundRect, foregroundRect, outlineRect);
    3560     return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgroundRect)).enclosingBoundingBox();
     3602    return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgroundRect.rect())).enclosingBoundingBox();
    35613603}
    35623604
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r94900 r95239  
    6969#endif
    7070
     71enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelfForBorderRadius };
     72
     73class ClipRect {
     74public:
     75    ClipRect()
     76    : m_hasRadius(false)
     77    { }
     78   
     79    ClipRect(const LayoutRect& rect)
     80    : m_rect(rect)
     81    , m_hasRadius(false)
     82    { }
     83   
     84    const LayoutRect& rect() const { return m_rect; }
     85    void setRect(const LayoutRect& rect) { m_rect = rect; }
     86
     87    bool hasRadius() const { return m_hasRadius; }
     88    void setHasRadius(bool hasRadius) { m_hasRadius = hasRadius; }
     89
     90    bool operator==(const ClipRect& other) const { return rect() == other.rect() && hasRadius() == other.hasRadius(); }
     91
     92    void intersect(const LayoutRect& other) { m_rect.intersect(other); }
     93    void intersect(const ClipRect& other)
     94    {
     95        m_rect.intersect(other.rect());
     96        if (other.hasRadius())
     97            m_hasRadius = true;
     98    }
     99    void move(LayoutUnit x, LayoutUnit y) { m_rect.move(x, y); }
     100
     101    bool isEmpty() const { return m_rect.isEmpty(); }
     102    bool intersects(const LayoutRect& rect) { return m_rect.intersects(rect); }
     103
     104private:
     105    LayoutRect m_rect;
     106    bool m_hasRadius;
     107};
     108
     109inline ClipRect intersection(const ClipRect& a, const ClipRect& b)
     110{
     111    ClipRect c = a;
     112    c.intersect(b);
     113    return c;
     114}
     115
    71116class ClipRects {
    72117public:
     
    103148    }
    104149   
    105     const LayoutRect& overflowClipRect() const { return m_overflowClipRect; }
    106     void setOverflowClipRect(const LayoutRect& r) { m_overflowClipRect = r; }
    107 
    108     const LayoutRect& fixedClipRect() const { return m_fixedClipRect; }
    109     void setFixedClipRect(const LayoutRect&r) { m_fixedClipRect = r; }
    110 
    111     const LayoutRect& posClipRect() const { return m_posClipRect; }
    112     void setPosClipRect(const LayoutRect& r) { m_posClipRect = r; }
     150    const ClipRect& overflowClipRect() const { return m_overflowClipRect; }
     151    void setOverflowClipRect(const ClipRect& r) { m_overflowClipRect = r; }
     152
     153    const ClipRect& fixedClipRect() const { return m_fixedClipRect; }
     154    void setFixedClipRect(const ClipRect&r) { m_fixedClipRect = r; }
     155
     156    const ClipRect& posClipRect() const { return m_posClipRect; }
     157    void setPosClipRect(const ClipRect& r) { m_posClipRect = r; }
    113158
    114159    bool fixed() const { return m_fixed; }
     
    148193
    149194private:
    150     LayoutRect m_overflowClipRect;
    151     LayoutRect m_fixedClipRect;
    152     LayoutRect m_posClipRect;
     195    ClipRect m_overflowClipRect;
     196    ClipRect m_fixedClipRect;
     197    ClipRect m_posClipRect;
    153198    unsigned m_refCnt : 31;
    154199    bool m_fixed : 1;
     
    381426    // for painting/event handling.
    382427    void calculateRects(const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, LayoutRect& layerBounds,
    383                         LayoutRect& backgroundRect, LayoutRect& foregroundRect, LayoutRect& outlineRect, bool temporaryClipRects = false,
    384                         OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
     428                        ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRect,
     429                        bool temporaryClipRects = false, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
    385430
    386431    // Compute and cache clip rects computed with the given layer as the root
     
    470515    void computeRepaintRects(IntPoint* offsetFromRoot = 0);
    471516    void clearRepaintRects();
     517
     518    void clipToRect(RenderLayer* rootLayer, GraphicsContext*, const LayoutRect& paintDirtyRect, const ClipRect&,
     519                    BorderRadiusClippingRule = IncludeSelfForBorderRadius);
     520    void restoreClip(GraphicsContext*, const LayoutRect& paintDirtyRect, const ClipRect&);
    472521
    473522    // The normal operator new is disallowed on all render objects.
     
    601650   
    602651    void parentClipRects(const RenderLayer* rootLayer, ClipRects&, bool temporaryClipRects = false, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
    603     LayoutRect backgroundClipRect(const RenderLayer* rootLayer, bool temporaryClipRects, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
     652    ClipRect backgroundClipRect(const RenderLayer* rootLayer, bool temporaryClipRects, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
    604653
    605654    RenderLayer* enclosingTransformedAncestor() const;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r93429 r95239  
    211211
    212212        if (m_owningLayer != rootLayer)
    213             clippingBounds.intersect(m_owningLayer->backgroundClipRect(rootLayer, true));
     213            clippingBounds.intersect(m_owningLayer->backgroundClipRect(rootLayer, true).rect());
    214214
    215215        LayoutPoint delta;
     
    396396        // layer. Note that we call it with temporaryClipRects = true because normally when computing clip rects
    397397        // for a compositing layer, rootLayer is the layer itself.
    398         LayoutRect parentClipRect = m_owningLayer->backgroundClipRect(compAncestor, true);
     398        LayoutRect parentClipRect = m_owningLayer->backgroundClipRect(compAncestor, true).rect();
    399399        ASSERT(parentClipRect != PaintInfo::infiniteRect());
    400400        m_ancestorClippingLayer->setPosition(FloatPoint() + (parentClipRect.location() - graphicsLayerParentLocation));
     
    10791079}
    10801080
    1081 static void setClip(GraphicsContext* p, const LayoutRect& paintDirtyRect, const LayoutRect& clipRect)
    1082 {
    1083     if (paintDirtyRect == clipRect)
    1084         return;
    1085     p->save();
    1086     p->clip(clipRect);
    1087 }
    1088 
    1089 static void restoreClip(GraphicsContext* p, const LayoutRect& paintDirtyRect, const LayoutRect& clipRect)
    1090 {
    1091     if (paintDirtyRect == clipRect)
    1092         return;
    1093     p->restore();
    1094 }
    1095 
    10961081// Share this with RenderLayer::paintLayer, which would have to be educated about GraphicsLayerPaintingPhase?
    10971082void RenderLayerBacking::paintIntoLayer(RenderLayer* rootLayer, GraphicsContext* context,
     
    11081093   
    11091094    // Calculate the clip rects we should use.
    1110     LayoutRect layerBounds, damageRect, clipRectToApply, outlineRect;
     1095    LayoutRect layerBounds;
     1096    ClipRect damageRect, clipRectToApply, outlineRect;
    11111097    m_owningLayer->calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect);
    11121098
     
    11261112        // Paint our background first, before painting any child layers.
    11271113        // Establish the clip used to paint our background.
    1128         setClip(context, paintDirtyRect, damageRect);
    1129        
    1130         PaintInfo info(context, damageRect, PaintPhaseBlockBackground, false, paintingRootForRenderer, 0);
     1114        m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius);
     1115       
     1116        PaintInfo info(context, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, 0);
    11311117        renderer()->paint(info, paintOffset);
    11321118
     
    11341120        // z-index.  We paint after we painted the background/border, so that the scrollbars will
    11351121        // sit above the background/border.
    1136         m_owningLayer->paintOverflowControls(context, layerBounds.location(), damageRect);
     1122        m_owningLayer->paintOverflowControls(context, layerBounds.location(), damageRect.rect());
    11371123       
    11381124        // Restore the clip.
    1139         restoreClip(context, paintDirtyRect, damageRect);
     1125        m_owningLayer->restoreClip(context, paintDirtyRect, damageRect);
    11401126
    11411127        // Now walk the sorted list of children with negative z-indices. Only RenderLayers without compositing layers will paint.
     
    11481134    if (shouldPaint && (paintingPhase & GraphicsLayerPaintForeground)) {
    11491135        // Set up the clip used when painting our children.
    1150         setClip(context, paintDirtyRect, clipRectToApply);
    1151         PaintInfo paintInfo(context, clipRectToApply,
    1152                                           selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
    1153                                           forceBlackText, paintingRootForRenderer, 0);
     1136        m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, clipRectToApply);
     1137        PaintInfo paintInfo(context, clipRectToApply.rect(),
     1138                            selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
     1139                            forceBlackText, paintingRootForRenderer, 0);
    11541140        renderer()->paint(paintInfo, paintOffset);
    11551141
     
    11661152
    11671153        // Now restore our clip.
    1168         restoreClip(context, paintDirtyRect, clipRectToApply);
     1154        m_owningLayer->restoreClip(context, paintDirtyRect, clipRectToApply);
    11691155
    11701156        if (!outlineRect.isEmpty()) {
    11711157            // Paint our own outline
    1172             PaintInfo paintInfo(context, outlineRect, PaintPhaseSelfOutline, false, paintingRootForRenderer, 0);
    1173             setClip(context, paintDirtyRect, outlineRect);
     1158            PaintInfo paintInfo(context, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, 0);
     1159            m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
    11741160            renderer()->paint(paintInfo, paintOffset);
    1175             restoreClip(context, paintDirtyRect, outlineRect);
     1161            m_owningLayer->restoreClip(context, paintDirtyRect, outlineRect);
    11761162        }
    11771163
     
    11851171    if (shouldPaint && (paintingPhase & GraphicsLayerPaintMask)) {
    11861172        if (renderer()->hasMask() && !selectionOnly && !damageRect.isEmpty()) {
    1187             setClip(context, paintDirtyRect, damageRect);
     1173            m_owningLayer->clipToRect(rootLayer, context, paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius);
    11881174
    11891175            // Paint the mask.
    1190             PaintInfo paintInfo(context, damageRect, PaintPhaseMask, false, paintingRootForRenderer, 0);
     1176            PaintInfo paintInfo(context, damageRect.rect(), PaintPhaseMask, false, paintingRootForRenderer, 0);
    11911177            renderer()->paint(paintInfo, paintOffset);
    11921178           
    11931179            // Restore the clip.
    1194             restoreClip(context, paintDirtyRect, damageRect);
     1180            m_owningLayer->restoreClip(context, paintDirtyRect, damageRect);
    11951181        }
    11961182    }
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r95158 r95239  
    574574    }
    575575
    576     LayoutRect clipRect = layer->backgroundClipRect(rootRenderLayer(), true);
     576    LayoutRect clipRect = layer->backgroundClipRect(rootRenderLayer(), true).rect();
    577577    clipRect.intersect(layerBounds);
    578578    overlapMap.add(layer, clipRect);
     
    13461346        return false;
    13471347
    1348     LayoutRect backgroundRect = layer->backgroundClipRect(computeClipRoot, true);
    1349     return backgroundRect != PaintInfo::infiniteRect();
     1348    return layer->backgroundClipRect(computeClipRoot, true).rect() != PaintInfo::infiniteRect();
    13501349}
    13511350
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r94640 r95239  
    705705   
    706706    // Calculate the clip rects we should use.
    707     IntRect layerBounds, damageRect, clipRectToApply, outlineRect;
     707    IntRect layerBounds;
     708    ClipRect damageRect, clipRectToApply, outlineRect;
    708709    l->calculateRects(rootLayer, paintDirtyRect, layerBounds, damageRect, clipRectToApply, outlineRect, true);
    709710
     
    712713    l->updateNormalFlowList();
    713714
    714     bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : l->intersectsDamageRect(layerBounds, damageRect, rootLayer);
     715    bool shouldPaint = (behavior & RenderAsTextShowAllLayers) ? true : l->intersectsDamageRect(layerBounds, damageRect.rect(), rootLayer);
    715716    Vector<RenderLayer*>* negList = l->negZOrderList();
    716717    bool paintsBackgroundSeparately = negList && negList->size() > 0;
    717718    if (shouldPaint && paintsBackgroundSeparately)
    718         write(ts, *l, layerBounds, damageRect, clipRectToApply, outlineRect, LayerPaintPhaseBackground, indent, behavior);
     719        write(ts, *l, layerBounds, damageRect.rect(), clipRectToApply.rect(), outlineRect.rect(), LayerPaintPhaseBackground, indent, behavior);
    719720
    720721    if (negList) {
     
    730731
    731732    if (shouldPaint)
    732         write(ts, *l, layerBounds, damageRect, clipRectToApply, outlineRect, paintsBackgroundSeparately ? LayerPaintPhaseForeground : LayerPaintPhaseAll, indent, behavior);
     733        write(ts, *l, layerBounds, damageRect.rect(), clipRectToApply.rect(), outlineRect.rect(), paintsBackgroundSeparately ? LayerPaintPhaseForeground : LayerPaintPhaseAll, indent, behavior);
    733734
    734735    if (Vector<RenderLayer*>* normalFlowList = l->normalFlowList()) {
Note: See TracChangeset for help on using the changeset viewer.