Changeset 21605 in webkit


Ignore:
Timestamp:
May 19, 2007 5:16:53 PM (17 years ago)
Author:
bdash
Message:

2007-05-19 Mitz Pettel <mitz@webkit.org>

Reviewed by Dave Hyatt.

Tests: fast/repaint/box-shadow-dynamic.html

fast/repaint/box-shadow-h.html
fast/repaint/box-shadow-v.html

  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::placeBoxesHorizontally): Factor in box shadow. (WebCore::InlineFlowBox::placeBoxesVertically): Ditto. (WebCore::InlineFlowBox::paint): Account for box shadow when checking if the damage rect intersects.
  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::overflowHeight): For overflow areas, when asked for the "exterior" overflow, add box shadow overflow. (WebCore::RenderBlock::overflowWidth): Ditto. (WebCore::RenderBlock::overflowLeft): Ditto. (WebCore::RenderBlock::overflowTop): Ditto. (WebCore::RenderBlock::overflowRect): Ditto. (WebCore::RenderBlock::layoutBlock): Factor box shadow into visual overflow.
  • rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::layoutBlock): Ditto.
  • rendering/RenderFlow.cpp: (WebCore::RenderFlow::lowestPosition): For overflow areas, when asked for the "exterior" extreme position, add box shadow. (WebCore::RenderFlow::rightmostPosition): Ditto. (WebCore::RenderFlow::leftmostPosition): Ditto.
  • rendering/RenderLayer.cpp: (WebCore::RenderLayer::calculateRects): Avoid clipping out box shadow.
  • rendering/RenderObject.cpp: (WebCore::RenderObject::repaintAfterLayoutIfNeeded): Make sure to paint the box shadow when an edge with a shadow moves. (WebCore::RenderObject::adjustRectForOutlineAndShadow): Helper function that expands a given rectangle to encompass outline and box shadow. (WebCore::RenderObject::absoluteOutlineBox): Changed to include box shadow.
  • rendering/RenderObject.h:

2007-05-19 Mitz Pettel <mitz@webkit.org>

Reviewed by Dave Hyatt.

  • fast/box-shadow/basic-shadows-expected.checksum:
  • fast/box-shadow/basic-shadows-expected.png:
  • fast/box-shadow/basic-shadows-expected.txt:
  • fast/repaint/box-shadow-dynamic-expected.checksum: Added.
  • fast/repaint/box-shadow-dynamic-expected.png: Added.
  • fast/repaint/box-shadow-dynamic-expected.txt: Added.
  • fast/repaint/box-shadow-dynamic.html: Added.
  • fast/repaint/box-shadow-h-expected.checksum: Added.
  • fast/repaint/box-shadow-h-expected.png: Added.
  • fast/repaint/box-shadow-h-expected.txt: Added.
  • fast/repaint/box-shadow-h.html: Added.
  • fast/repaint/box-shadow-v-expected.checksum: Added.
  • fast/repaint/box-shadow-v-expected.png: Added.
  • fast/repaint/box-shadow-v-expected.txt: Added.
  • fast/repaint/box-shadow-v.html: Added.
Location:
trunk
Files:
12 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r21604 r21605  
     12007-05-19  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - repaint tests and updated results for http://bugs.webkit.org/show_bug.cgi?id=12729
     6          box-shadow disappears when scrolling a div that it falls on/under
     7
     8        * fast/box-shadow/basic-shadows-expected.checksum:
     9        * fast/box-shadow/basic-shadows-expected.png:
     10        * fast/box-shadow/basic-shadows-expected.txt:
     11        * fast/repaint/box-shadow-dynamic-expected.checksum: Added.
     12        * fast/repaint/box-shadow-dynamic-expected.png: Added.
     13        * fast/repaint/box-shadow-dynamic-expected.txt: Added.
     14        * fast/repaint/box-shadow-dynamic.html: Added.
     15        * fast/repaint/box-shadow-h-expected.checksum: Added.
     16        * fast/repaint/box-shadow-h-expected.png: Added.
     17        * fast/repaint/box-shadow-h-expected.txt: Added.
     18        * fast/repaint/box-shadow-h.html: Added.
     19        * fast/repaint/box-shadow-v-expected.checksum: Added.
     20        * fast/repaint/box-shadow-v-expected.png: Added.
     21        * fast/repaint/box-shadow-v-expected.txt: Added.
     22        * fast/repaint/box-shadow-v.html: Added.
     23
    1242007-05-20  Mark Rowe  <mrowe@apple.com>
    225
  • trunk/LayoutTests/fast/box-shadow/basic-shadows-expected.checksum

    r18654 r21605  
    1 0ddb70bd830be6c8dc9c767648263ee4
     1da1cb4f18169068cdca839127a165969
  • trunk/LayoutTests/fast/box-shadow/basic-shadows-expected.txt

    r19696 r21605  
    1 layer at (0,0) size 785x671
     1layer at (0,0) size 785x681
    22  RenderView at (0,0) size 785x600
    3 layer at (0,0) size 785x671
     3layer at (0,0) size 785x681
    44  RenderBlock {HTML} at (0,0) size 785x658
    55    RenderBody {BODY} at (8,8) size 769x634
  • trunk/WebCore/ChangeLog

    r21603 r21605  
     12007-05-19  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=12729
     6          box-shadow disappears when scrolling a div that it falls on/under
     7
     8        Tests: fast/repaint/box-shadow-dynamic.html
     9               fast/repaint/box-shadow-h.html
     10               fast/repaint/box-shadow-v.html
     11
     12        * rendering/InlineFlowBox.cpp:
     13        (WebCore::InlineFlowBox::placeBoxesHorizontally): Factor in box shadow.
     14        (WebCore::InlineFlowBox::placeBoxesVertically): Ditto.
     15        (WebCore::InlineFlowBox::paint): Account for box shadow when checking if
     16        the damage rect intersects.
     17        * rendering/RenderBlock.cpp:
     18        (WebCore::RenderBlock::overflowHeight): For overflow areas, when asked
     19        for the "exterior" overflow, add box shadow overflow.
     20        (WebCore::RenderBlock::overflowWidth): Ditto.
     21        (WebCore::RenderBlock::overflowLeft): Ditto.
     22        (WebCore::RenderBlock::overflowTop): Ditto.
     23        (WebCore::RenderBlock::overflowRect): Ditto.
     24        (WebCore::RenderBlock::layoutBlock): Factor box shadow into visual overflow.
     25        * rendering/RenderFlexibleBox.cpp:
     26        (WebCore::RenderFlexibleBox::layoutBlock): Ditto.
     27        * rendering/RenderFlow.cpp:
     28        (WebCore::RenderFlow::lowestPosition): For overflow areas, when asked for
     29        the "exterior" extreme position, add box shadow.
     30        (WebCore::RenderFlow::rightmostPosition): Ditto.
     31        (WebCore::RenderFlow::leftmostPosition): Ditto.
     32        * rendering/RenderLayer.cpp:
     33        (WebCore::RenderLayer::calculateRects): Avoid clipping out box shadow.
     34        * rendering/RenderObject.cpp:
     35        (WebCore::RenderObject::repaintAfterLayoutIfNeeded): Make sure to paint
     36        the box shadow when an edge with a shadow moves.
     37        (WebCore::RenderObject::adjustRectForOutlineAndShadow): Helper function
     38        that expands a given rectangle to encompass outline and box shadow.
     39        (WebCore::RenderObject::absoluteOutlineBox): Changed to include box shadow.
     40        * rendering/RenderObject.h:
     41
    1422007-05-19  Mitz Pettel  <mitz@webkit.org>
    243
  • trunk/WebCore/rendering/InlineFlowBox.cpp

    r21397 r21605  
    247247    // Set our x position.
    248248    setXPos(x);
    249     leftPosition = min(x, leftPosition);
     249
     250    int boxShadowLeft = 0;
     251    int boxShadowRight = 0;
     252    if (ShadowData* boxShadow = object()->style(m_firstLine)->boxShadow()) {
     253        boxShadowLeft = min(boxShadow->x - boxShadow->blur, 0);
     254        boxShadowRight = max(boxShadow->x + boxShadow->blur, 0);
     255    }
     256    leftPosition = min(x + boxShadowLeft, leftPosition);
    250257
    251258    int startX = x;
     
    263270            text->setXPos(x);
    264271           
    265             // FIXME: Setting this as layout overflow is bad.  We need to have a separate concept of
    266             // visual overflow.
    267272            int strokeOverflow = static_cast<int>(ceilf(rt->style()->textStrokeWidth() / 2.0));
    268273           
     
    317322
    318323    x += borderRight() + paddingRight();
    319     setWidth(x-startX);
    320     rightPosition = max(xPos() + width(), rightPosition);
     324    setWidth(x - startX);
     325    rightPosition = max(xPos() + width() + boxShadowRight, rightPosition);
    321326
    322327    return x;
     
    478483                overflowBottom = max(overflowBottom, shadow->y + shadow->blur);
    479484            }
     485
     486            if (ShadowData* boxShadow = curr->object()->style(m_firstLine)->boxShadow()) {
     487                overflowTop = min(overflowTop, boxShadow->y - boxShadow->blur);
     488                overflowBottom = max(overflowBottom, boxShadow->y + boxShadow->blur);
     489            }
     490
    480491            if (curr->isInlineFlowBox()) {
    481492                newHeight += curr->object()->borderTop() + curr->object()->paddingTop() +
     
    484495                newBaseline += curr->object()->borderTop() + curr->object()->paddingTop();
    485496            }
    486         }
    487         else if (!curr->object()->isBR()) {
     497        } else if (!curr->object()->isBR()) {
    488498            newY += curr->object()->marginTop();
    489499            newHeight = curr->height() - (curr->object()->marginTop() + curr->object()->marginBottom());
     
    562572    int xPos = tx + m_x - object()->maximalOutlineSize(paintInfo.phase);
    563573    int w = width() + 2 * object()->maximalOutlineSize(paintInfo.phase);
     574    if (ShadowData* boxShadow = object()->style(m_firstLine)->boxShadow()) {
     575        int shadowLeft = min(boxShadow->x - boxShadow->blur, 0);
     576        xPos += shadowLeft;
     577        w += -shadowLeft + max(boxShadow->x + boxShadow->blur, 0);
     578    }
    564579    bool intersectsDamageRect = xPos < paintInfo.rect.right() && xPos + w > paintInfo.rect.x();
    565580
  • trunk/WebCore/rendering/RenderBlock.cpp

    r21405 r21605  
    379379int RenderBlock::overflowHeight(bool includeInterior) const
    380380{
    381     return (!includeInterior && hasOverflowClip()) ? m_height : m_overflowHeight;
     381    if (!includeInterior && hasOverflowClip()) {
     382        if (ShadowData* boxShadow = style()->boxShadow())
     383            return m_height + max(boxShadow->y + boxShadow->blur, 0);
     384        return m_height;
     385    }
     386    return m_overflowHeight;
    382387}
    383388
    384389int RenderBlock::overflowWidth(bool includeInterior) const
    385390{
    386     return (!includeInterior && hasOverflowClip()) ? m_width : m_overflowWidth;
    387 }
     391    if (!includeInterior && hasOverflowClip()) {
     392        if (ShadowData* boxShadow = style()->boxShadow())
     393            return m_width + max(boxShadow->x + boxShadow->blur, 0);
     394        return m_width;
     395    }
     396    return m_overflowWidth;
     397}
     398
    388399int RenderBlock::overflowLeft(bool includeInterior) const
    389400{
    390     return (!includeInterior && hasOverflowClip()) ? 0 : m_overflowLeft;
     401    if (!includeInterior && hasOverflowClip()) {
     402        if (ShadowData* boxShadow = style()->boxShadow())
     403            return min(boxShadow->x - boxShadow->blur, 0);
     404        return 0;
     405    }
     406    return m_overflowLeft;
    391407}
    392408
    393409int RenderBlock::overflowTop(bool includeInterior) const
    394410{
    395     return (!includeInterior && hasOverflowClip()) ? 0 : m_overflowTop;
     411    if (!includeInterior && hasOverflowClip()) {
     412        if (ShadowData* boxShadow = style()->boxShadow())
     413            return min(boxShadow->y - boxShadow->blur, 0);
     414        return 0;
     415    }
     416    return m_overflowTop;
    396417}
    397418
    398419IntRect RenderBlock::overflowRect(bool includeInterior) const
    399420{
     421    if (!includeInterior && hasOverflowClip()) {
     422        IntRect box = borderBox();
     423        if (ShadowData* boxShadow = style()->boxShadow()) {
     424            int shadowLeft = min(boxShadow->x - boxShadow->blur, 0);
     425            int shadowRight = max(boxShadow->x + boxShadow->blur, 0);
     426            int shadowTop = min(boxShadow->y - boxShadow->blur, 0);
     427            int shadowBottom = max(boxShadow->y + boxShadow->blur, 0);
     428            box.move(shadowLeft, shadowTop);
     429            box.setWidth(box.width() - shadowLeft + shadowRight);
     430            box.setHeight(box.height() - shadowTop + shadowBottom);
     431        }
     432        return box;
     433    }
     434
    400435    if (!includeInterior && hasOverflowClip())
    401436        return borderBox();
     
    592627    m_overflowWidth = max(m_overflowWidth, m_width);
    593628    m_overflowHeight = max(m_overflowHeight, m_height);
     629
     630    if (!hasOverflowClip()) {
     631        if (ShadowData* boxShadow = style()->boxShadow()) {
     632            m_overflowLeft = min(m_overflowLeft, boxShadow->x - boxShadow->blur);
     633            m_overflowWidth = max(m_overflowWidth, m_width + boxShadow->x + boxShadow->blur);
     634            m_overflowTop = min(m_overflowTop, boxShadow->y - boxShadow->blur);
     635            m_overflowHeight = max(m_overflowHeight, m_height + boxShadow->y + boxShadow->blur);
     636        }
     637    }
    594638
    595639    if (!hadColumns)
  • trunk/WebCore/rendering/RenderFlexibleBox.cpp

    r21183 r21605  
    288288    if (m_overflowWidth < m_width)
    289289        m_overflowWidth = m_width;
     290
     291    if (!hasOverflowClip()) {
     292        if (ShadowData* boxShadow = style()->boxShadow()) {
     293            m_overflowLeft = min(m_overflowLeft, boxShadow->x - boxShadow->blur);
     294            m_overflowWidth = max(m_overflowWidth, m_width + boxShadow->x + boxShadow->blur);
     295            m_overflowTop = min(m_overflowTop, boxShadow->y - boxShadow->blur);
     296            m_overflowHeight = max(m_overflowHeight, m_height + boxShadow->y + boxShadow->blur);
     297        }
     298    }
    290299
    291300    view()->popLayoutState();
  • trunk/WebCore/rendering/RenderFlow.cpp

    r21438 r21605  
    519519{
    520520    ASSERT(!isInlineFlow());
     521    if (!includeOverflowInterior && hasOverflowClip())
     522        return includeSelf && m_width > 0 ? overflowHeight(false) : 0;
     523
    521524    int bottom = includeSelf && m_width > 0 ? m_height : 0;
    522     if (!includeOverflowInterior && hasOverflowClip())
    523         return bottom;
    524 
    525525    if (!hasColumns()) {
    526526        // FIXME: Come up with a way to use the layer tree to avoid visiting all the kids.
     
    543543{
    544544    ASSERT(!isInlineFlow());
     545    if (!includeOverflowInterior && hasOverflowClip())
     546        return includeSelf && m_height > 0 ? overflowWidth(false) : 0;
     547
    545548    int right = includeSelf && m_height > 0 ? m_width : 0;
    546     if (!includeOverflowInterior && hasOverflowClip())
    547         return right;
    548 
    549549    if (!hasColumns()) {
    550550        // FIXME: Come up with a way to use the layer tree to avoid visiting all the kids.
     
    567567{
    568568    ASSERT(!isInlineFlow());
     569    if (!includeOverflowInterior && hasOverflowClip())
     570        return includeSelf && m_height > 0 ? overflowLeft(false) : m_width;
     571
    569572    int left = includeSelf && m_height > 0 ? 0 : m_width;
    570     if (!includeOverflowInterior && hasOverflowClip())
    571         return left;
    572 
    573573    if (!hasColumns()) {
    574574        // FIXME: Come up with a way to use the layer tree to avoid visiting all the kids.
  • trunk/WebCore/rendering/RenderLayer.cpp

    r21390 r21605  
    17871787        // If we establish a clip at all, then go ahead and make sure our background
    17881788        // rect is intersected with our layer's bounds.
    1789         backgroundRect.intersect(layerBounds);
     1789        if (ShadowData* boxShadow = renderer()->style()->boxShadow()) {
     1790            IntRect shadowRect = layerBounds;
     1791            shadowRect.move(boxShadow->x, boxShadow->y);
     1792            shadowRect.inflate(boxShadow->blur);
     1793            shadowRect.unite(layerBounds);
     1794            backgroundRect.intersect(shadowRect);
     1795        } else
     1796            backgroundRect.intersect(layerBounds);
    17901797    }
    17911798}
  • trunk/WebCore/rendering/RenderObject.cpp

    r21397 r21605  
    18311831    RenderStyle* outlineStyle = !isInline() && continuation() ? continuation()->style() : style();
    18321832    int ow = outlineStyle->outlineSize();
     1833    ShadowData* boxShadow = style()->boxShadow();
    18331834    int width = abs(newOutlineBox.width() - oldOutlineBox.width());
    18341835    if (width) {
    1835         int borderWidth = max(-outlineStyle->outlineOffset(), max(borderRight(), max(style()->borderTopRightRadius().width(), style()->borderBottomRightRadius().width()))) + ow;
     1836        int shadowRight = boxShadow ? max(boxShadow->x + boxShadow->blur, 0) : 0;
     1837        int borderWidth = max(-outlineStyle->outlineOffset(), max(borderRight(), max(style()->borderTopRightRadius().width(), style()->borderBottomRightRadius().width()))) + max(ow, shadowRight);
    18361838        IntRect rightRect(newOutlineBox.x() + min(newOutlineBox.width(), oldOutlineBox.width()) - borderWidth,
    18371839            newOutlineBox.y(),
     
    18461848    int height = abs(newOutlineBox.height() - oldOutlineBox.height());
    18471849    if (height) {
    1848         int borderHeight = max(-outlineStyle->outlineOffset(), max(borderBottom(), max(style()->borderBottomLeftRadius().height(), style()->borderBottomRightRadius().height()))) + ow;
     1850        int shadowBottom = boxShadow ? max(boxShadow->y + boxShadow->blur, 0) : 0;
     1851        int borderHeight = max(-outlineStyle->outlineOffset(), max(borderBottom(), max(style()->borderBottomLeftRadius().height(), style()->borderBottomRightRadius().height()))) + max(ow, shadowBottom);
    18491852        IntRect bottomRect(newOutlineBox.x(),
    18501853            min(newOutlineBox.bottom(), oldOutlineBox.bottom()) - borderHeight,
     
    30343037}
    30353038
     3039void RenderObject::adjustRectForOutlineAndShadow(IntRect& rect) const
     3040{
     3041    int outlineSize = !isInline() && continuation() ? continuation()->style()->outlineSize() : style()->outlineSize();
     3042    if (ShadowData* boxShadow = style()->boxShadow()) {
     3043        int shadowLeft = min(boxShadow->x - boxShadow->blur - outlineSize, 0);
     3044        int shadowRight = max(boxShadow->x + boxShadow->blur + outlineSize, 0);
     3045        int shadowTop = min(boxShadow->y - boxShadow->blur - outlineSize, 0);
     3046        int shadowBottom = max(boxShadow->y + boxShadow->blur + outlineSize, 0);
     3047        rect.move(shadowLeft, shadowTop);
     3048        rect.setWidth(rect.width() - shadowLeft + shadowRight);
     3049        rect.setHeight(rect.height() - shadowTop + shadowBottom);
     3050    } else
     3051        rect.inflate(outlineSize);
     3052}
     3053
    30363054IntRect RenderObject::absoluteOutlineBox() const
    30373055{
     
    30413059    box.move(x, y);
    30423060    box.move(view()->layoutDelta());
    3043     if (!isInline() && continuation())
    3044         box.inflate(continuation()->style()->outlineSize());
    3045     else
    3046         box.inflate(style()->outlineSize());
     3061    adjustRectForOutlineAndShadow(box);
    30473062    return box;
    30483063}
  • trunk/WebCore/rendering/RenderObject.h

    r21387 r21605  
    864864    virtual void removeLeftoverAnonymousBoxes();
    865865
     866    void adjustRectForOutlineAndShadow(IntRect&) const;
     867
    866868    void arenaDelete(RenderArena*, void* objectBase);
    867869
Note: See TracChangeset for help on using the changeset viewer.