Reviewed by Dave Hyatt.
- fix http://bugs.webkit.org/show_bug.cgi?id=5399
no-repeat on negatively positioned background images are ignored
Test: fast/backgrounds/repeat/negative-offset-repeat.html
- fix http://bugs.webkit.org/show_bug.cgi?id=5821
Changing background of <col> doesn't repaint the column
Test: fast/repaint/table-col-background.html
- fix http://bugs.webkit.org/show_bug.cgi?id=11720
REGRESSION: large amounts of CPU consumed viewing this site
* 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.
- pixel test and updated results for http://bugs.webkit.org/show_bug.cgi?id=5399
no-repeat on negatively positioned background images are ignored
- repaint test for http://bugs.webkit.org/show_bug.cgi?id=5821
Changing background of <col> doesn't repaint the column
* 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:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@19490
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-02-07 Mitz Pettel <mitz@webkit.org>
+
+ Reviewed by Dave Hyatt.
+
+ - pixel test and updated results for http://bugs.webkit.org/show_bug.cgi?id=5399
+ no-repeat on negatively positioned background images are ignored
+
+ - repaint test for http://bugs.webkit.org/show_bug.cgi?id=5821
+ Changing background of <col> doesn't repaint the column
+
+ * 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:
+
2007-02-07 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
--- /dev/null
+0ccc9539337d80ee8c4c134fad5860c2
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x484
+ RenderBlock {HTML} at (0,0) size 800x484
+ RenderBody {BODY} at (8,16) size 784x452
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 53x18
+ text run at (0,0) width 53: "Test for "
+ RenderInline {I} at (0,0) size 722x18
+ RenderInline {A} at (0,0) size 293x18 [color=#0000EE]
+ RenderText {#text} at (53,0) size 293x18
+ text run at (53,0) width 293: "http://bugs.webkit.org/show_bug.cgi?id=5399"
+ RenderText {#text} at (346,0) size 429x18
+ text run at (346,0) width 4: " "
+ text run at (350,0) width 425: "no-repeat on negatively positioned background images are ignored"
+ RenderText {#text} at (775,0) size 4x18
+ text run at (775,0) width 4: "."
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {#text} at (0,0) size 454x18
+ text run at (0,0) width 454: "Element with background image starting at (-13, -13) with no-repeat set:"
+ RenderBlock (floating) {DIV} at (6,74) size 34x34 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (52,74) size 29x29 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (93,74) size 24x24 [border: (1px dotted #008000)]
+ RenderBlock {P} at (0,114) size 784x18
+ RenderText {#text} at (0,0) size 446x18
+ text run at (0,0) width 446: "Element with background image starting at (-13, -13) with repeat-y set:"
+ RenderBlock (floating) {DIV} at (6,154) size 34x34 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (52,154) size 29x29 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (93,154) size 24x24 [border: (1px dotted #008000)]
+ RenderBlock {P} at (0,194) size 784x18
+ RenderText {#text} at (0,0) size 446x18
+ text run at (0,0) width 446: "Element with background image starting at (-13, -13) with repeat-x set:"
+ RenderBlock (floating) {DIV} at (6,234) size 34x34 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (52,234) size 29x29 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (93,234) size 24x24 [border: (1px dotted #008000)]
+ RenderBlock {P} at (0,274) size 784x18
+ RenderText {#text} at (0,0) size 444x18
+ text run at (0,0) width 444: "Element with background image starting at (13, 13) with no-repeat set:"
+ RenderBlock (floating) {DIV} at (6,314) size 34x34 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (52,314) size 29x29 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (93,314) size 24x24 [border: (1px dotted #008000)]
+ RenderBlock {P} at (0,354) size 784x18
+ RenderText {#text} at (0,0) size 436x18
+ text run at (0,0) width 436: "Element with background image starting at (13, 13) with repeat-y set:"
+ RenderBlock (floating) {DIV} at (6,394) size 34x34 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (52,394) size 29x29 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (93,394) size 24x24 [border: (1px dotted #008000)]
+ RenderBlock {P} at (0,434) size 784x18
+ RenderText {#text} at (0,0) size 436x18
+ text run at (0,0) width 436: "Element with background image starting at (13, 13) with repeat-x set:"
+ RenderBlock (floating) {DIV} at (6,474) size 34x34 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (52,474) size 29x29 [border: (1px dotted #008000)]
+ RenderBlock (floating) {DIV} at (93,474) size 24x24 [border: (1px dotted #008000)]
--- /dev/null
+<!DOCTYPE HTML>
+<html>
+ <style type="text/css">
+ .s300
+ {
+ width: 30px;
+ height: 30px;
+ }
+
+ .s250
+ {
+ width: 25px;
+ height: 25px;
+ }
+
+ .s200
+ {
+ width: 20px;
+ height: 20px;
+ }
+
+ div
+ {
+ margin: 6px;
+ border: 1px dotted green;
+ background-image: url(resources/gradient.gif);
+ }
+
+ div
+ {
+ padding: 1px;
+ float: left;
+ }
+
+ p
+ {
+ clear: both;
+ }
+
+ .negative
+ {
+ background-position: -13px -13px;
+ }
+
+ .positive
+ {
+ background-position: 13px 13px;
+ }
+ </style>
+</head>
+<body>
+ <p>
+ Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=5399">http://bugs.webkit.org/show_bug.cgi?id=5399</a>
+ no-repeat on negatively positioned background images are ignored</i>.
+ </p>
+ <p>Element with background image starting at (-13, -13) with no-repeat set:</p>
+ <div class="negative s300" style="background-repeat: no-repeat;"></div>
+ <div class="negative s250" style="background-repeat: no-repeat;"></div>
+ <div class="negative s200" style="background-repeat: no-repeat;"></div>
+
+ <p>Element with background image starting at (-13, -13) with repeat-y set:</p>
+ <div class="negative s300" style="background-repeat: repeat-y"></div>
+ <div class="negative s250" style="background-repeat: repeat-y"></div>
+ <div class="negative s200" style="background-repeat: repeat-y"></div>
+
+ <p>Element with background image starting at (-13, -13) with repeat-x set:</p>
+ <div class="negative s300" style="background-repeat: repeat-x"></div>
+ <div class="negative s250" style="background-repeat: repeat-x"></div>
+ <div class="negative s200" style="background-repeat: repeat-x"></div>
+
+ <p>Element with background image starting at (13, 13) with no-repeat set:</p>
+ <div class="positive s300" style="background-repeat: no-repeat;"></div>
+ <div class="positive s250" style="background-repeat: no-repeat;"></div>
+ <div class="positive s200" style="background-repeat: no-repeat;"></div>
+
+ <p>Element with background image starting at (13, 13) with repeat-y set:</p>
+ <div class="positive s300" style="background-repeat: repeat-y"></div>
+ <div class="positive s250" style="background-repeat: repeat-y"></div>
+ <div class="positive s200" style="background-repeat: repeat-y"></div>
+
+ <p>Element with background image starting at (13, 13) with repeat-x set:</p>
+ <div class="positive s300" style="background-repeat: repeat-x"></div>
+ <div class="positive s250" style="background-repeat: repeat-x"></div>
+ <div class="positive s200" style="background-repeat: repeat-x"></div>
+</body>
+</html>
--- /dev/null
+1d234ba80f6452b47a7d3239562c5013
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderTable {TABLE} at (0,0) size 106x104
+ RenderTableCol {COL} at (0,0) size 0x0 [bgcolor=#008000]
+ RenderTableSection {TBODY} at (0,0) size 106x104
+ RenderTableRow {TR} at (0,2) size 106x100
+ RenderTableCell {TD} at (2,51) size 102x2 [r=0 c=0 rs=1 cs=1]
--- /dev/null
+<html>
+<head>
+ <title>Test for http://bugs.webkit.org/show_bug.cgi?id=5821</title>
+ <script src="repaint.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ function repaintTest()
+ {
+ document.getElementById("col").style.backgroundColor = "green";
+ }
+ </script>
+</head>
+<body onload="runRepaintTest()">
+ <table>
+ <col id="col" style="background-color: red;">
+ <tr>
+ <td style="width: 100px; height: 100px;">
+ </td>
+ </tr>
+ </table>
+</body>
+</html>
-9e3bb79bd78b9e3f580b82a67a517568
\ No newline at end of file
+5519b5e5b59e2a89e024454517cea5cf
\ No newline at end of file
-22c2723ce3a4adbae647d381624b3354
\ No newline at end of file
+458734e62651b4448337609d062a0e10
\ No newline at end of file
-11aea40d8a088c218ed398d957ee1c5a
\ No newline at end of file
+cdbda5a78e1964e60f21648b73388051
\ No newline at end of file
-326429d1e845d9bae9bee3ff4aecee25
\ No newline at end of file
+2c513897f4b2f38e5d71ce752abaccbb
\ No newline at end of file
-715622c45c202d32e3e284afe39929cd
\ No newline at end of file
+6164e3920fee6daf534001d09b8b1d20
\ No newline at end of file
-a75e93da1f5ed6b01c46b8ed88697ae3
\ No newline at end of file
+ced700275e441bb9b08fe0ab7db91963
\ No newline at end of file
-7b159e701e21d2d453eb2ef92874f219
\ No newline at end of file
+15da77d84da3c0558385b9e4e97ae354
\ No newline at end of file
-667d2ee93ca7429127e70d9caa1e17c8
\ No newline at end of file
+df9e46da604c984ee32a918df09269fc
\ No newline at end of file
-a26e01a730c98c275267ceee4c855ca3
\ No newline at end of file
+46a01c8f7c24f6284a293f0baabde796
\ No newline at end of file
-b010fa8dc84034bcb186cf1c06e818b9
\ No newline at end of file
+71854b1c335328d0415e9cbf6a6935ba
\ No newline at end of file
-6ef0eed3530895985cca2fc0d24782d9
\ No newline at end of file
+cb14cac94a051aeb2e8a28c16d2d116a
\ No newline at end of file
-f42af1e7f26dbd3bf20765eb812a81f7
\ No newline at end of file
+15b5ea713f96342e30dfc4b3cf96634b
\ No newline at end of file
-03e42de19426feaa0ea9869ca5f8c554
\ No newline at end of file
+f815e51edd7e3de490df9c2b4e08ffe2
\ No newline at end of file
+2007-02-07 Mitz Pettel <mitz@webkit.org>
+
+ Reviewed by Dave Hyatt.
+
+ - fix http://bugs.webkit.org/show_bug.cgi?id=5399
+ no-repeat on negatively positioned background images are ignored
+
+ Test: fast/backgrounds/repeat/negative-offset-repeat.html
+
+ - fix http://bugs.webkit.org/show_bug.cgi?id=5821
+ Changing background of <col> doesn't repaint the column
+
+ Test: fast/repaint/table-col-background.html
+
+ - fix http://bugs.webkit.org/show_bug.cgi?id=11720
+ REGRESSION: large amounts of CPU consumed viewing this site
+
+ * 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 Anders Carlsson <acarlsson@apple.com>
Reviewed by Maciej.
}
}
+void RenderBox::imageChanged(CachedImage* image)
+{
+ if (!image || !image->canRender() || !parent())
+ return;
+
+ if (isInlineFlow() || style()->borderImage().image() == image) {
+ repaint();
+ return;
+ }
+
+ bool didFullRepaint = false;
+ IntRect absoluteRect;
+ RenderBox* backgroundRenderer;
+
+ if (view() && (isBody() || isRoot())) {
+ // Our background propagates to the root.
+ backgroundRenderer = view();
+
+ int rw;
+ int rh;
+
+ if (FrameView* frameView = static_cast<RenderView*>(backgroundRenderer)->frameView()) {
+ rw = frameView->contentsWidth();
+ rh = frameView->contentsHeight();
+ } else {
+ rw = backgroundRenderer->width();
+ rh = backgroundRenderer->height();
+ }
+ absoluteRect = IntRect(-backgroundRenderer->marginLeft(),
+ -backgroundRenderer->marginTop(),
+ max(backgroundRenderer->width() + backgroundRenderer->marginLeft() + backgroundRenderer->marginRight() + backgroundRenderer->borderLeft() + backgroundRenderer->borderRight(), rw),
+ max(backgroundRenderer->height() + backgroundRenderer->marginTop() + backgroundRenderer->marginBottom() + backgroundRenderer->borderTop() + backgroundRenderer->borderBottom(), rh));
+ } else {
+ backgroundRenderer = this;
+ absoluteRect = borderBox();
+ }
+
+ backgroundRenderer->computeAbsoluteRepaintRect(absoluteRect);
+
+ for (const BackgroundLayer* bgLayer = style()->backgroundLayers(); bgLayer && !didFullRepaint; bgLayer = bgLayer->next()) {
+ if (image == bgLayer->backgroundImage()) {
+ IntRect repaintRect;
+ IntPoint phase;
+ IntSize tileSize;
+ backgroundRenderer->calculateBackgroundImageGeometry(bgLayer, absoluteRect.x(), absoluteRect.y(), absoluteRect.width(), absoluteRect.height(), repaintRect, phase, tileSize);
+ view()->repaintViewRectangle(repaintRect);
+ if (repaintRect == absoluteRect)
+ didFullRepaint = true;
+ }
+ }
+}
+
+void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer, int tx, int ty, int w, int h, IntRect& destRect, IntPoint& phase, IntSize& tileSize)
+{
+ int pw;
+ int ph;
+ int left = 0;
+ int right = 0;
+ int top = 0;
+ int bottom = 0;
+ int cx;
+ int cy;
+
+ // CSS2 chapter 14.2.1
+
+ if (bgLayer->backgroundAttachment()) {
+ // Scroll
+ if (bgLayer->backgroundOrigin() != BGBORDER) {
+ left = borderLeft();
+ right = borderRight();
+ top = borderTop();
+ bottom = borderBottom();
+ if (bgLayer->backgroundOrigin() == BGCONTENT) {
+ left += paddingLeft();
+ right += paddingRight();
+ top += paddingTop();
+ bottom += paddingBottom();
+ }
+ }
+ cx = tx;
+ cy = ty;
+ pw = w - left - right;
+ ph = h - top - bottom;
+ } else {
+ // Fixed
+ IntRect vr = viewRect();
+ cx = vr.x();
+ cy = vr.y();
+ pw = vr.width();
+ ph = vr.height();
+ }
+
+ int sx = 0;
+ int sy = 0;
+ int cw;
+ int ch;
+ int scaledImageWidth = pw;
+ int scaledImageHeight = ph;
+
+ cacluateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
+
+ EBackgroundRepeat backgroundRepeat = bgLayer->backgroundRepeat();
+
+ int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
+ if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_X) {
+ cw = pw + left + right;
+ sx = scaledImageWidth ? scaledImageWidth - (xPosition + left) % scaledImageWidth : 0;
+ } else {
+ cx += max(xPosition + left, 0);
+ sx = -min(xPosition + left, 0);
+ cw = scaledImageWidth + min(xPosition + left, 0);
+ }
+
+ int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
+ if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_Y) {
+ ch = ph + top + bottom;
+ sy = scaledImageHeight ? scaledImageHeight - (yPosition + top) % scaledImageHeight : 0;
+ } else {
+ cy += max(yPosition + top, 0);
+ sy = -min(yPosition + top, 0);
+ ch = scaledImageHeight + min(yPosition + top, 0);
+ }
+
+ if (!bgLayer->backgroundAttachment()) {
+ sx += max(tx - cx, 0);
+ sy += max(ty - cy, 0);
+ }
+
+ destRect = IntRect(cx, cy, cw, ch);
+ destRect.intersect(IntRect(tx, ty, w, h));
+ phase = IntPoint(sx, sy);
+ tileSize = IntSize(scaledImageWidth, scaledImageHeight);
+}
+
void RenderBox::paintBackgroundExtended(GraphicsContext* context, const Color& c, const BackgroundLayer* bgLayer, int clipY, int clipH,
int tx, int ty, int w, int h, bool includeLeftEdge, bool includeRightEdge)
{
// no progressive loading of the background image
if (shouldPaintBackgroundImage) {
- int sx = 0;
- int sy = 0;
- int cw;
- int ch;
- int cx;
- int cy;
- int scaledImageWidth;
- int scaledImageHeight;
-
- // CSS2 chapter 14.2.1
-
- if (bgLayer->backgroundAttachment()) {
- // scroll
- int horizontalPaddingPlusBorder = 0;
- int verticalPaddingPlusBorder = 0;
- int left = 0;
- int top = 0; // Init to 0 for background-origin of 'border'
- if (bgLayer->backgroundOrigin() != BGBORDER) {
- horizontalPaddingPlusBorder += bLeft + bRight;
- verticalPaddingPlusBorder += borderTop() + borderBottom();
- left += bLeft;
- top += borderTop();
- if (bgLayer->backgroundOrigin() == BGCONTENT) {
- horizontalPaddingPlusBorder += pLeft + pRight;
- verticalPaddingPlusBorder += paddingTop() + paddingBottom();
- left += pLeft;
- top += paddingTop();
- }
- }
-
- int pw = w - horizontalPaddingPlusBorder;
- int ph = h - verticalPaddingPlusBorder;
- scaledImageWidth = pw;
- scaledImageHeight = ph;
- cacluateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
-
- EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
- if ((bgr == NO_REPEAT || bgr == REPEAT_Y) && w > scaledImageWidth) {
- cw = scaledImageWidth;
- int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
- if (xPosition >= 0)
- cx = tx + xPosition;
- else {
- cx = tx;
- if (scaledImageWidth > 0) {
- sx = -xPosition;
- cw += xPosition;
- }
- }
- cx += left;
- } else {
- // repeat over x or background is wider than box
- cw = w;
- cx = tx;
- if (scaledImageWidth > 0) {
- int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
- if ((xPosition > 0) && (bgr == NO_REPEAT)) {
- cx += xPosition;
- cw -= xPosition;
- } else {
- sx = scaledImageWidth - (xPosition % scaledImageWidth);
- sx -= left % scaledImageWidth;
- }
- }
- }
+ IntRect destRect;
+ IntPoint phase;
+ IntSize tileSize;
- if ((bgr == NO_REPEAT || bgr == REPEAT_X) && h > scaledImageHeight) {
- ch = scaledImageHeight;
- int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
- if (yPosition >= 0)
- cy = ty + yPosition;
- else {
- cy = ty;
- if (scaledImageHeight > 0) {
- sy = -yPosition;
- ch += yPosition;
- }
- }
-
- cy += top;
- } else {
- // repeat over y or background is taller than box
- ch = h;
- cy = ty;
- if (scaledImageHeight > 0) {
- int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
- if ((yPosition > 0) && (bgr == NO_REPEAT)) {
- cy += yPosition;
- ch -= yPosition;
- } else {
- sy = scaledImageHeight - (yPosition % scaledImageHeight);
- sy -= top % scaledImageHeight;
- }
- }
- }
- } else {
- // fixed
- IntRect vr = viewRect();
- int pw = vr.width();
- int ph = vr.height();
- scaledImageWidth = pw;
- scaledImageHeight = ph;
- cacluateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
- EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
-
- if ((bgr == NO_REPEAT || bgr == REPEAT_Y) && pw > scaledImageWidth) {
- cw = scaledImageWidth;
- cx = vr.x() + bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth);
- } else {
- cw = pw;
- cx = vr.x();
- if (scaledImageWidth > 0)
- sx = scaledImageWidth - bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth) % scaledImageWidth;
- }
-
- if ((bgr == NO_REPEAT || bgr == REPEAT_X) && ph > scaledImageHeight) {
- ch = scaledImageHeight;
- cy = vr.y() + bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight);
- } else {
- ch = ph;
- cy = vr.y();
- if (scaledImageHeight > 0)
- sy = scaledImageHeight - bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight) % scaledImageHeight;
- }
-
- IntRect b = intersection(IntRect(cx, cy, cw, ch), IntRect(tx, ty, w, h));
- sx += b.x() - cx;
- sy += b.y() - cy;
- cx = b.x();
- cy = b.y();
- cw = b.width();
- ch = b.height();
- }
-
- if (cw > 0 && ch > 0) {
- context->drawTiledImage(bg->image(), IntRect(cx, cy, cw, ch), IntPoint(sx, sy), IntSize(scaledImageWidth, scaledImageHeight),
- bgLayer->backgroundComposite());
- }
+ calculateBackgroundImageGeometry(bgLayer, tx, ty, w, h, destRect, phase, tileSize);
+ if (!destRect.isEmpty())
+ context->drawTiledImage(bg->image(), destRect, phase, tileSize, bgLayer->backgroundComposite());
}
if (bgLayer->backgroundClip() != BGBORDER)
virtual IntRect getClipRect(int tx, int ty);
virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
+ virtual void imageChanged(CachedImage*);
protected:
void paintBackground(GraphicsContext*, const Color&, const BackgroundLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height);
private:
void paintRootBoxDecorations(PaintInfo&, int tx, int ty);
+ void calculateBackgroundImageGeometry(const BackgroundLayer*, int tx, int ty, int w, int h, IntRect& destRect, IntPoint& phase, IntSize& tileSize);
void paintBackgrounds(GraphicsContext*, const Color&, const BackgroundLayer*, int clipY, int clipHeight, int tx, int ty, int width, int height);
int containingBlockWidthForPositioned(const RenderObject* containingBlock) const;
return '\\';
}
-void RenderObject::imageChanged(CachedImage* image)
-{
- // Repaint when the background image or border image finishes loading.
- // This is needed for RenderBox objects, and also for table objects that hold
- // backgrounds that are then respected by the table cells (which are RenderBox
- // subclasses). It would be even better to find a more elegant way of doing this that
- // would avoid putting this function and the CachedResourceClient base class into RenderObject.
- if (image && image->canRender() && parent()) {
- if (view() && element() && (element()->hasTagName(htmlTag) || element()->hasTagName(bodyTag)))
- // repaint the entire canvas since the background gets propagated up
- view()->repaint();
- else
- // repaint object, which is a box or a container with boxes inside it
- repaint();
- }
-}
-
bool RenderObject::willRenderImage(CachedImage*)
{
// Without visibility we won't render (and therefore don't care about animation).
virtual int previousOffset(int current) const;
virtual int nextOffset(int current) const;
- virtual void imageChanged(CachedImage*);
+ virtual void imageChanged(CachedImage*) { }
virtual bool willRenderImage(CachedImage*);
virtual void selectionStartEnd(int& spos, int& epos) const;
#include "config.h"
#include "RenderTableCol.h"
+#include "CachedImage.h"
#include "HTMLNames.h"
#include "HTMLTableColElement.h"
#include "TextStream.h"
return style()->display() == TABLE_COLUMN_GROUP;
}
+IntRect RenderTableCol::getAbsoluteRepaintRect()
+{
+ // For now, just repaint the whole table.
+ // FIXME: Find a better way to do this, e.g., need to repaint all the cells that we
+ // might have propagated a background color or borders into.
+ RenderObject* table = parent();
+ if (table && !table->isTable())
+ table = table->parent();
+ if (table && table->isTable())
+ return table->getAbsoluteRepaintRect();
+
+ return IntRect();
+}
+
+void RenderTableCol::imageChanged(CachedImage* image)
+{
+ if (!image || !image->canRender() || !parent())
+ return;
+
+ // FIXME: Repaint only the rect the image paints in.
+ repaint();
+}
+
#ifndef NDEBUG
void RenderTableCol::dump(TextStream* stream, DeprecatedString ind) const
{
virtual bool canHaveChildren() const;
virtual bool requiresLayer() { return false; }
+ virtual IntRect getAbsoluteRepaintRect();
+ virtual void imageChanged(CachedImage*);
+
#ifndef NDEBUG
virtual void dump(TextStream*, DeprecatedString) const;
#endif
#include "config.h"
#include "RenderTableRow.h"
+#include "CachedImage.h"
#include "Document.h"
#include "HTMLNames.h"
#include "RenderTableCell.h"
}
}
+void RenderTableRow::imageChanged(CachedImage* image)
+{
+ if (!image || !image->canRender() || !parent())
+ return;
+
+ // FIXME: Examine cells and repaint only the rect the image paints in.
+ repaint();
+}
+
} // namespace WebCore
virtual bool requiresLayer() { return isTransparent() || hasOverflowClip(); }
virtual void paint(PaintInfo&, int tx, int ty);
+ virtual void imageChanged(CachedImage*);
};
} // namespace WebCore
#include "config.h"
#include "RenderTableSection.h"
+#include "CachedImage.h"
#include "Document.h"
#include "HTMLNames.h"
#include "RenderTableCell.h"
}
}
+void RenderTableSection::imageChanged(CachedImage* image)
+{
+ if (!image || !image->canRender() || !parent())
+ return;
+
+ // FIXME: Examine cells and repaint only the rect the image paints in.
+ repaint();
+}
+
void RenderTableSection::recalcCells()
{
m_cCol = 0;
int outerBorderRight() const { return m_outerBorderRight; }
virtual void paint(PaintInfo&, int tx, int ty);
+ virtual void imageChanged(CachedImage*);
int numRows() const { return m_gridRows; }
int numColumns() const;