Changeset 19490 in webkit


Ignore:
Timestamp:
Feb 7, 2007 8:56:20 PM (17 years ago)
Author:
bdash
Message:

2007-02-07 Mitz Pettel <mitz@webkit.org>

Reviewed by Dave Hyatt.

Test: fast/backgrounds/repeat/negative-offset-repeat.html

Test: fast/repaint/table-col-background.html

  • rendering/RenderBox.cpp: (WebCore::RenderBox::imageChanged): Added. Finds the border and/or background layer(s) that use the image and invalidates only the rect in which the image actually paints. There are two special cases in this function: 1) for the body element, the background is propagated to the root; 2) inline flows do a full repaint. (WebCore::RenderBox::calculateBackgroundImageGeometry): Added. Factored out, simplified and corrected the calculation of the rectangle into which the background image paints, the tile size and the pattern phase. (WebCore::RenderBox::paintBackgroundExtended):
  • rendering/RenderBox.h:
  • rendering/RenderObject.cpp:
  • rendering/RenderObject.h: (WebCore::RenderObject::imageChanged): Moved the implementation to RenderBox.
  • rendering/RenderTableCol.cpp: (WebCore::RenderTableCol::getAbsoluteRepaintRect): Overridden to return the table's repaint rect. (WebCore::RenderTableCol::imageChanged): Overridden to do a full repaint, which currently repaints the entire table.
  • rendering/RenderTableCol.h:
  • rendering/RenderTableRow.cpp: (WebCore::RenderTableRow::imageChanged): Overridden to do a full repaint of the row, since the backgrounds are painted by the cells.
  • rendering/RenderTableRow.h:
  • rendering/RenderTableSection.cpp: (WebCore::RenderTableSection::imageChanged): Overridden to do a full repaint of the section, since the backgrounds are painted by the cells.
  • rendering/RenderTableSection.h:

2007-02-07 Mitz Pettel <mitz@webkit.org>

Reviewed by Dave Hyatt.


  • fast/backgrounds/repeat/negative-offset-repeat-expected.checksum: Added.
  • fast/backgrounds/repeat/negative-offset-repeat-expected.png: Added.
  • fast/backgrounds/repeat/negative-offset-repeat-expected.txt: Added.
  • fast/backgrounds/repeat/negative-offset-repeat.html: Added. Based on a test by Mark Rowe.
  • fast/backgrounds/repeat/resources/gradient.gif: Added.
  • fast/repaint/table-col-background-expected.checksum: Added.
  • fast/repaint/table-col-background-expected.png: Added.
  • fast/repaint/table-col-background-expected.txt: Added.
  • fast/repaint/table-col-background.html: Added.
  • tables/mozilla/marvin/backgr_position-table-expected.checksum:
  • tables/mozilla/marvin/backgr_position-table-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.png:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.checksum:
  • tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.png:
Location:
trunk
Files:
6 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19467 r19490  
     12007-02-07  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - pixel test and updated results for http://bugs.webkit.org/show_bug.cgi?id=5399
     6          no-repeat on negatively positioned background images are ignored
     7
     8        - repaint test for http://bugs.webkit.org/show_bug.cgi?id=5821
     9          Changing background of <col> doesn't repaint the column
     10       
     11        * fast/backgrounds/repeat/negative-offset-repeat-expected.checksum: Added.
     12        * fast/backgrounds/repeat/negative-offset-repeat-expected.png: Added.
     13        * fast/backgrounds/repeat/negative-offset-repeat-expected.txt: Added.
     14        * fast/backgrounds/repeat/negative-offset-repeat.html: Added. Based on a test by Mark Rowe.
     15        * fast/backgrounds/repeat/resources/gradient.gif: Added.
     16        * fast/repaint/table-col-background-expected.checksum: Added.
     17        * fast/repaint/table-col-background-expected.png: Added.
     18        * fast/repaint/table-col-background-expected.txt: Added.
     19        * fast/repaint/table-col-background.html: Added.
     20        * tables/mozilla/marvin/backgr_position-table-expected.checksum:
     21        * tables/mozilla/marvin/backgr_position-table-expected.png:
     22        * tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.checksum:
     23        * tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.png:
     24        * tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.checksum:
     25        * tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.png:
     26        * tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.checksum:
     27        * tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.png:
     28        * tables/mozilla_expected_failures/marvin/backgr_border-table-expected.checksum:
     29        * tables/mozilla_expected_failures/marvin/backgr_border-table-expected.png:
     30        * tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.checksum:
     31        * tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.png:
     32        * tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.checksum:
     33        * tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.png:
     34        * tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.checksum:
     35        * tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.png:
     36        * tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.checksum:
     37        * tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.png:
     38        * tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.checksum:
     39        * tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.png:
     40        * tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.checksum:
     41        * tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.png:
     42        * tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.checksum:
     43        * tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.png:
     44        * tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.checksum:
     45        * tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.png:
     46
    1472007-02-07  Alexey Proskuryakov  <ap@webkit.org>
    248
  • trunk/LayoutTests/tables/mozilla/marvin/backgr_position-table-expected.checksum

    r14661 r19490  
    1 9e3bb79bd78b9e3f580b82a67a517568
     15519b5e5b59e2a89e024454517cea5cf
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_border-table-cell-expected.checksum

    r14661 r19490  
    1 22c2723ce3a4adbae647d381624b3354
     1458734e62651b4448337609d062a0e10
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_border-table-column-expected.checksum

    r14661 r19490  
    1 11aea40d8a088c218ed398d957ee1c5a
     1cdbda5a78e1964e60f21648b73388051
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_border-table-column-group-expected.checksum

    r14661 r19490  
    1 326429d1e845d9bae9bee3ff4aecee25
     12c513897f4b2f38e5d71ce752abaccbb
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_border-table-expected.checksum

    r14661 r19490  
    1 715622c45c202d32e3e284afe39929cd
     16164e3920fee6daf534001d09b8b1d20
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_border-table-row-expected.checksum

    r14661 r19490  
    1 a75e93da1f5ed6b01c46b8ed88697ae3
     1ced700275e441bb9b08fe0ab7db91963
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_border-table-row-group-expected.checksum

    r14661 r19490  
    1 7b159e701e21d2d453eb2ef92874f219
     115da77d84da3c0558385b9e4e97ae354
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_layers-hide-expected.checksum

    r14661 r19490  
    1 667d2ee93ca7429127e70d9caa1e17c8
     1df9e46da604c984ee32a918df09269fc
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_position-table-cell-expected.checksum

    r14661 r19490  
    1 a26e01a730c98c275267ceee4c855ca3
     146a01c8f7c24f6284a293f0baabde796
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_position-table-column-expected.checksum

    r14661 r19490  
    1 b010fa8dc84034bcb186cf1c06e818b9
     171854b1c335328d0415e9cbf6a6935ba
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_position-table-column-group-expected.checksum

    r14661 r19490  
    1 6ef0eed3530895985cca2fc0d24782d9
     1cb14cac94a051aeb2e8a28c16d2d116a
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_position-table-row-expected.checksum

    r14661 r19490  
    1 f42af1e7f26dbd3bf20765eb812a81f7
     115b5ea713f96342e30dfc4b3cf96634b
  • trunk/LayoutTests/tables/mozilla_expected_failures/marvin/backgr_position-table-row-group-expected.checksum

    r14661 r19490  
    1 03e42de19426feaa0ea9869ca5f8c554
     1f815e51edd7e3de490df9c2b4e08ffe2
  • trunk/WebCore/ChangeLog

    r19487 r19490  
     12007-02-07  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=5399
     6          no-repeat on negatively positioned background images are ignored
     7
     8        Test: fast/backgrounds/repeat/negative-offset-repeat.html
     9
     10        - fix http://bugs.webkit.org/show_bug.cgi?id=5821
     11          Changing background of <col> doesn't repaint the column
     12
     13        Test: fast/repaint/table-col-background.html
     14
     15        - fix http://bugs.webkit.org/show_bug.cgi?id=11720
     16          REGRESSION: large amounts of CPU consumed viewing this site
     17
     18        * rendering/RenderBox.cpp:
     19        (WebCore::RenderBox::imageChanged): Added. Finds the border and/or background
     20        layer(s) that use the image and invalidates only the rect in which the image
     21        actually paints. There are two special cases in this function: 1) for the body
     22        element, the background is propagated to the root; 2) inline flows do a full
     23        repaint.
     24        (WebCore::RenderBox::calculateBackgroundImageGeometry): Added. Factored out,
     25        simplified and corrected the calculation of the rectangle into which the background
     26        image paints, the tile size and the pattern phase.
     27        (WebCore::RenderBox::paintBackgroundExtended):
     28        * rendering/RenderBox.h:
     29        * rendering/RenderObject.cpp:
     30        * rendering/RenderObject.h:
     31        (WebCore::RenderObject::imageChanged): Moved the implementation to RenderBox.
     32        * rendering/RenderTableCol.cpp:
     33        (WebCore::RenderTableCol::getAbsoluteRepaintRect): Overridden to return the
     34        table's repaint rect.
     35        (WebCore::RenderTableCol::imageChanged): Overridden to do a full repaint, which
     36        currently repaints the entire table.
     37        * rendering/RenderTableCol.h:
     38        * rendering/RenderTableRow.cpp:
     39        (WebCore::RenderTableRow::imageChanged): Overridden to do a full repaint
     40        of the row, since the backgrounds are painted by the cells.
     41        * rendering/RenderTableRow.h:
     42        * rendering/RenderTableSection.cpp:
     43        (WebCore::RenderTableSection::imageChanged): Overridden to do a full
     44        repaint of the section, since the backgrounds are painted by the cells.
     45        * rendering/RenderTableSection.h:
     46
    1472007-02-07  Anders Carlsson  <acarlsson@apple.com>
    248
  • trunk/WebCore/rendering/RenderBox.cpp

    r19148 r19490  
    426426}
    427427
     428void RenderBox::imageChanged(CachedImage* image)
     429{
     430    if (!image || !image->canRender() || !parent())
     431        return;
     432
     433    if (isInlineFlow() || style()->borderImage().image() == image) {
     434        repaint();
     435        return;
     436    }
     437
     438    bool didFullRepaint = false;
     439    IntRect absoluteRect;
     440    RenderBox* backgroundRenderer;
     441
     442    if (view() && (isBody() || isRoot())) {
     443        // Our background propagates to the root.
     444        backgroundRenderer = view();
     445
     446        int rw;
     447        int rh;
     448
     449        if (FrameView* frameView = static_cast<RenderView*>(backgroundRenderer)->frameView()) {
     450            rw = frameView->contentsWidth();
     451            rh = frameView->contentsHeight();
     452        } else {
     453            rw = backgroundRenderer->width();
     454            rh = backgroundRenderer->height();
     455        }
     456        absoluteRect = IntRect(-backgroundRenderer->marginLeft(),
     457            -backgroundRenderer->marginTop(),
     458            max(backgroundRenderer->width() + backgroundRenderer->marginLeft() + backgroundRenderer->marginRight() + backgroundRenderer->borderLeft() + backgroundRenderer->borderRight(), rw),
     459            max(backgroundRenderer->height() + backgroundRenderer->marginTop() + backgroundRenderer->marginBottom() + backgroundRenderer->borderTop() + backgroundRenderer->borderBottom(), rh));
     460    } else {
     461        backgroundRenderer = this;
     462        absoluteRect = borderBox();
     463    }
     464
     465    backgroundRenderer->computeAbsoluteRepaintRect(absoluteRect);
     466
     467    for (const BackgroundLayer* bgLayer = style()->backgroundLayers(); bgLayer && !didFullRepaint; bgLayer = bgLayer->next()) {
     468        if (image == bgLayer->backgroundImage()) {
     469            IntRect repaintRect;
     470            IntPoint phase;
     471            IntSize tileSize;
     472            backgroundRenderer->calculateBackgroundImageGeometry(bgLayer, absoluteRect.x(), absoluteRect.y(), absoluteRect.width(), absoluteRect.height(), repaintRect, phase, tileSize);
     473            view()->repaintViewRectangle(repaintRect);
     474            if (repaintRect == absoluteRect)
     475                didFullRepaint = true;
     476        }
     477    }
     478}
     479
     480void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer, int tx, int ty, int w, int h, IntRect& destRect, IntPoint& phase, IntSize& tileSize)
     481{
     482    int pw;
     483    int ph;
     484    int left = 0;
     485    int right = 0;
     486    int top = 0;
     487    int bottom = 0;
     488    int cx;
     489    int cy;
     490
     491    // CSS2 chapter 14.2.1
     492
     493    if (bgLayer->backgroundAttachment()) {
     494        // Scroll
     495        if (bgLayer->backgroundOrigin() != BGBORDER) {
     496            left = borderLeft();
     497            right = borderRight();
     498            top = borderTop();
     499            bottom = borderBottom();
     500            if (bgLayer->backgroundOrigin() == BGCONTENT) {
     501                left += paddingLeft();
     502                right += paddingRight();
     503                top += paddingTop();
     504                bottom += paddingBottom();
     505            }
     506        }
     507        cx = tx;
     508        cy = ty;
     509        pw = w - left - right;
     510        ph = h - top - bottom;
     511    } else {
     512        // Fixed
     513        IntRect vr = viewRect();
     514        cx = vr.x();
     515        cy = vr.y();
     516        pw = vr.width();
     517        ph = vr.height();
     518    }
     519
     520    int sx = 0;
     521    int sy = 0;
     522    int cw;
     523    int ch;
     524    int scaledImageWidth = pw;
     525    int scaledImageHeight = ph;
     526
     527    cacluateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
     528
     529    EBackgroundRepeat backgroundRepeat = bgLayer->backgroundRepeat();
     530   
     531    int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
     532    if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_X) {
     533        cw = pw + left + right;
     534        sx = scaledImageWidth ? scaledImageWidth - (xPosition + left) % scaledImageWidth : 0;
     535    } else {
     536        cx += max(xPosition + left, 0);
     537        sx = -min(xPosition + left, 0);
     538        cw = scaledImageWidth + min(xPosition + left, 0);
     539    }
     540
     541    int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
     542    if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_Y) {
     543        ch = ph + top + bottom;
     544        sy = scaledImageHeight ? scaledImageHeight - (yPosition + top) % scaledImageHeight : 0;
     545    } else {
     546        cy += max(yPosition + top, 0);
     547        sy = -min(yPosition + top, 0);
     548        ch = scaledImageHeight + min(yPosition + top, 0);
     549    }
     550
     551    if (!bgLayer->backgroundAttachment()) {
     552        sx += max(tx - cx, 0);
     553        sy += max(ty - cy, 0);
     554    }
     555
     556    destRect = IntRect(cx, cy, cw, ch);
     557    destRect.intersect(IntRect(tx, ty, w, h));
     558    phase = IntPoint(sx, sy);
     559    tileSize = IntSize(scaledImageWidth, scaledImageHeight);
     560}
     561
    428562void RenderBox::paintBackgroundExtended(GraphicsContext* context, const Color& c, const BackgroundLayer* bgLayer, int clipY, int clipH,
    429563                                        int tx, int ty, int w, int h, bool includeLeftEdge, bool includeRightEdge)
     
    517651    // no progressive loading of the background image
    518652    if (shouldPaintBackgroundImage) {
    519         int sx = 0;
    520         int sy = 0;
    521         int cw;
    522         int ch;
    523         int cx;
    524         int cy;
    525         int scaledImageWidth;
    526         int scaledImageHeight;
    527 
    528         // CSS2 chapter 14.2.1
    529 
    530         if (bgLayer->backgroundAttachment()) {
    531             // scroll
    532             int horizontalPaddingPlusBorder = 0;
    533             int verticalPaddingPlusBorder = 0;
    534             int left = 0;
    535             int top = 0; // Init to 0 for background-origin of 'border'
    536             if (bgLayer->backgroundOrigin() != BGBORDER) {
    537                 horizontalPaddingPlusBorder += bLeft + bRight;
    538                 verticalPaddingPlusBorder += borderTop() + borderBottom();
    539                 left += bLeft;
    540                 top += borderTop();
    541                 if (bgLayer->backgroundOrigin() == BGCONTENT) {
    542                     horizontalPaddingPlusBorder += pLeft + pRight;
    543                     verticalPaddingPlusBorder += paddingTop() + paddingBottom();
    544                     left += pLeft;
    545                     top += paddingTop();
    546                 }
    547             }
    548 
    549             int pw = w - horizontalPaddingPlusBorder;
    550             int ph = h - verticalPaddingPlusBorder;
    551             scaledImageWidth = pw;
    552             scaledImageHeight = ph;
    553             cacluateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
    554 
    555             EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
    556             if ((bgr == NO_REPEAT || bgr == REPEAT_Y) && w > scaledImageWidth) {
    557                 cw = scaledImageWidth;
    558                 int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
    559                 if (xPosition >= 0)
    560                     cx = tx + xPosition;
    561                 else {
    562                     cx = tx;
    563                     if (scaledImageWidth > 0) {
    564                         sx = -xPosition;
    565                         cw += xPosition;
    566                     }
    567                 }
    568                 cx += left;
    569             } else {
    570                 // repeat over x or background is wider than box
    571                 cw = w;
    572                 cx = tx;
    573                 if (scaledImageWidth > 0) {
    574                     int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
    575                     if ((xPosition > 0) && (bgr == NO_REPEAT)) {
    576                         cx += xPosition;
    577                         cw -= xPosition;
    578                     } else {
    579                         sx = scaledImageWidth - (xPosition % scaledImageWidth);
    580                         sx -= left % scaledImageWidth;
    581                     }
    582                 }
    583             }
    584 
    585             if ((bgr == NO_REPEAT || bgr == REPEAT_X) && h > scaledImageHeight) {
    586                 ch = scaledImageHeight;
    587                 int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
    588                 if (yPosition >= 0)
    589                     cy = ty + yPosition;
    590                 else {
    591                     cy = ty;
    592                     if (scaledImageHeight > 0) {
    593                         sy = -yPosition;
    594                         ch += yPosition;
    595                     }
    596                 }
    597 
    598                 cy += top;
    599             } else {
    600                 // repeat over y or background is taller than box
    601                 ch = h;
    602                 cy = ty;
    603                 if (scaledImageHeight > 0) {
    604                     int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
    605                     if ((yPosition > 0) && (bgr == NO_REPEAT)) {
    606                         cy += yPosition;
    607                         ch -= yPosition;
    608                     } else {
    609                         sy = scaledImageHeight - (yPosition % scaledImageHeight);
    610                         sy -= top % scaledImageHeight;
    611                     }
    612                 }
    613             }
    614         } else {
    615             // fixed
    616             IntRect vr = viewRect();
    617             int pw = vr.width();
    618             int ph = vr.height();
    619             scaledImageWidth = pw;
    620             scaledImageHeight = ph;
    621             cacluateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
    622             EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
    623 
    624             if ((bgr == NO_REPEAT || bgr == REPEAT_Y) && pw > scaledImageWidth) {
    625                 cw = scaledImageWidth;
    626                 cx = vr.x() + bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
    627             } else {
    628                 cw = pw;
    629                 cx = vr.x();
    630                 if (scaledImageWidth > 0)
    631                     sx = scaledImageWidth - bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth) % scaledImageWidth;
    632             }
    633 
    634             if ((bgr == NO_REPEAT || bgr == REPEAT_X) && ph > scaledImageHeight) {
    635                 ch = scaledImageHeight;
    636                 cy = vr.y() + bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
    637             } else {
    638                 ch = ph;
    639                 cy = vr.y();
    640                 if (scaledImageHeight > 0)
    641                     sy = scaledImageHeight - bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight) % scaledImageHeight;
    642             }
    643 
    644             IntRect b = intersection(IntRect(cx, cy, cw, ch), IntRect(tx, ty, w, h));
    645             sx += b.x() - cx;
    646             sy += b.y() - cy;
    647             cx = b.x();
    648             cy = b.y();
    649             cw = b.width();
    650             ch = b.height();
    651         }
    652 
    653         if (cw > 0 && ch > 0) {
    654             context->drawTiledImage(bg->image(), IntRect(cx, cy, cw, ch), IntPoint(sx, sy), IntSize(scaledImageWidth, scaledImageHeight),
    655                 bgLayer->backgroundComposite());
    656         }
     653        IntRect destRect;
     654        IntPoint phase;
     655        IntSize tileSize;
     656
     657        calculateBackgroundImageGeometry(bgLayer, tx, ty, w, h, destRect, phase, tileSize);
     658        if (!destRect.isEmpty())
     659            context->drawTiledImage(bg->image(), destRect, phase, tileSize, bgLayer->backgroundComposite());
    657660    }
    658661
  • trunk/WebCore/rendering/RenderBox.h

    r19148 r19490  
    149149
    150150    virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
     151    virtual void imageChanged(CachedImage*);
    151152
    152153protected:
     
    161162    void paintRootBoxDecorations(PaintInfo&, int tx, int ty);
    162163
     164    void calculateBackgroundImageGeometry(const BackgroundLayer*, int tx, int ty, int w, int h, IntRect& destRect, IntPoint& phase, IntSize& tileSize);
    163165    void paintBackgrounds(GraphicsContext*, const Color&, const BackgroundLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height);
    164166
  • trunk/WebCore/rendering/RenderObject.cpp

    r19273 r19490  
    29332933}
    29342934
    2935 void RenderObject::imageChanged(CachedImage* image)
    2936 {
    2937     // Repaint when the background image or border image finishes loading.
    2938     // This is needed for RenderBox objects, and also for table objects that hold
    2939     // backgrounds that are then respected by the table cells (which are RenderBox
    2940     // subclasses). It would be even better to find a more elegant way of doing this that
    2941     // would avoid putting this function and the CachedResourceClient base class into RenderObject.
    2942     if (image && image->canRender() && parent()) {
    2943         if (view() && element() && (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
    2944             // repaint the entire canvas since the background gets propagated up
    2945             view()->repaint();
    2946         else
    2947             // repaint object, which is a box or a container with boxes inside it
    2948             repaint();
    2949     }
    2950 }
    2951 
    29522935bool RenderObject::willRenderImage(CachedImage*)
    29532936{
  • trunk/WebCore/rendering/RenderObject.h

    r19027 r19490  
    870870    virtual int nextOffset(int current) const;
    871871
    872     virtual void imageChanged(CachedImage*);
     872    virtual void imageChanged(CachedImage*) { }
    873873    virtual bool willRenderImage(CachedImage*);
    874874
  • trunk/WebCore/rendering/RenderTableCol.cpp

    r15253 r19490  
    2828#include "RenderTableCol.h"
    2929
     30#include "CachedImage.h"
    3031#include "HTMLNames.h"
    3132#include "HTMLTableColElement.h"
     
    6465}
    6566
     67IntRect RenderTableCol::getAbsoluteRepaintRect()
     68{
     69    // For now, just repaint the whole table.
     70    // FIXME: Find a better way to do this, e.g., need to repaint all the cells that we
     71    // might have propagated a background color or borders into.
     72    RenderObject* table = parent();
     73    if (table && !table->isTable())
     74        table = table->parent();
     75    if (table && table->isTable())
     76        return table->getAbsoluteRepaintRect();
     77
     78    return IntRect();
     79}
     80
     81void RenderTableCol::imageChanged(CachedImage* image)
     82{
     83    if (!image || !image->canRender() || !parent())
     84        return;
     85
     86    // FIXME: Repaint only the rect the image paints in.
     87    repaint();
     88}
     89
    6690#ifndef NDEBUG
    6791void RenderTableCol::dump(TextStream* stream, DeprecatedString ind) const
  • trunk/WebCore/rendering/RenderTableCol.h

    r18874 r19490  
    4444    virtual bool requiresLayer() { return false; }
    4545
     46    virtual IntRect getAbsoluteRepaintRect();
     47    virtual void imageChanged(CachedImage*);
     48
    4649#ifndef NDEBUG
    4750    virtual void dump(TextStream*, DeprecatedString) const;
  • trunk/WebCore/rendering/RenderTableRow.cpp

    r18758 r19490  
    2828#include "RenderTableRow.h"
    2929
     30#include "CachedImage.h"
    3031#include "Document.h"
    3132#include "HTMLNames.h"
     
    175176}
    176177
     178void RenderTableRow::imageChanged(CachedImage* image)
     179{
     180    if (!image || !image->canRender() || !parent())
     181        return;
     182   
     183    // FIXME: Examine cells and repaint only the rect the image paints in.
     184    repaint();
     185}
     186
    177187} // namespace WebCore
  • trunk/WebCore/rendering/RenderTableRow.h

    r18608 r19490  
    5757
    5858    virtual void paint(PaintInfo&, int tx, int ty);
     59    virtual void imageChanged(CachedImage*);
    5960};
    6061
  • trunk/WebCore/rendering/RenderTableSection.cpp

    r18834 r19490  
    2929#include "RenderTableSection.h"
    3030
     31#include "CachedImage.h"
    3132#include "Document.h"
    3233#include "HTMLNames.h"
     
    918919}
    919920
     921void RenderTableSection::imageChanged(CachedImage* image)
     922{
     923    if (!image || !image->canRender() || !parent())
     924        return;
     925   
     926    // FIXME: Examine cells and repaint only the rect the image paints in.
     927    repaint();
     928}
     929
    920930void RenderTableSection::recalcCells()
    921931{
  • trunk/WebCore/rendering/RenderTableSection.h

    r18634 r19490  
    100100
    101101    virtual void paint(PaintInfo&, int tx, int ty);
     102    virtual void imageChanged(CachedImage*);
    102103
    103104    int numRows() const { return m_gridRows; }
Note: See TracChangeset for help on using the changeset viewer.