Commit 54328434 authored by hyatt@apple.com's avatar hyatt@apple.com

WebCore:

2008-04-15  Anatoli Papirovski  <apapirovski@mac.com>

        Reviewed by hyatt

        [CSS1, CSS3] Fixed the background-origin calculation for root elements
        (background-size and background-position are affected), r10794
        [CSS3] Fixed the background-size transformation where width is specified in percentage and height is left to auto

        Test: fast/backgrounds/background-origin-root-element.html

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::calculateBackgroundSize):
        (WebCore::RenderBox::calculateBackgroundImageGeometry):

LayoutTests:

2008-04-15  Anatoli Papirovski  <apapirovski@mac.com>

        Reviewed by hyatt

        Added test case for background-origin calculation on root elements
        (background-repeat and background-size), r10794 [CSS1 + CSS3]

        * fast/backgrounds/background-origin-root-element.html: Added.
        * platform/mac/fast/backgrounds/background-origin-root-element-expected.checksum: Added.
        * platform/mac/fast/backgrounds/background-origin-root-element-expected.png: Added.
        * platform/mac/fast/backgrounds/background-origin-root-element-expected.txt: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 69fa075b
2008-04-15 Anatoli Papirovski <apapirovski@mac.com>
Reviewed by hyatt
Added test case for background-origin calculation on root elements
(background-repeat and background-size), r10794 [CSS1 + CSS3]
* fast/backgrounds/background-origin-root-element.html: Added.
* platform/mac/fast/backgrounds/background-origin-root-element-expected.checksum: Added.
* platform/mac/fast/backgrounds/background-origin-root-element-expected.png: Added.
* platform/mac/fast/backgrounds/background-origin-root-element-expected.txt: Added.
2008-04-15 Brady Eidson <beidson@apple.com>
Reviewed by Anders
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Root Element Background Origin</title>
<style type="text/css">
body { border: solid black; background: #fff url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAIAAAC0Ujn1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ%20bWFnZVJlYWR5ccllPAAAAClJREFUeNrszEENAAAIBKDT/p21g5s/CEBl8qQTtVqtVqvVarX6agUY%20AOiTATvieSECAAAAAElFTkSuQmCC) no-repeat 50% 50%; color: #000; -webkit-background-size: 100% 100%;}
html { border: solid blue; background: transparent; color: yellow; padding: 1em;}
* {margin: 1em; padding: 1em;}
p {margin: 0; padding: 0 0 5em;}
</style>
</head>
<body>
<p>The HTML box, the one with a blue border should be fully filled with lime green. The BODY box, the one with black border, should also be fully filled with lime green. The lime green color should not spill out outside the blue border.</p>
</body>
</html>
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (16,16) size 768x242
RenderBlock {HTML} at (16,16) size 768x242 [color=#FFFF00] [border: (3px solid #0000FF)]
RenderBody {BODY} at (35,35) size 698x172 [color=#000000] [bgcolor=#FFFFFF] [border: (3px solid #000000)]
RenderBlock {P} at (19,19) size 660x134
RenderText {#text} at (0,0) size 651x54
text run at (0,0) width 651: "The HTML box, the one with a blue border should be fully filled with lime green. The BODY box, the"
text run at (0,18) width 646: "one with black border, should also be fully filled with lime green. The lime green color should not spill"
text run at (0,36) width 172: "out outside the blue border."
3fc0e927df258ed742fa657acffba46d
\ No newline at end of file
2f70b81328f41ce5c03fc1753b70d817
\ No newline at end of file
2008-04-15 Anatoli Papirovski <apapirovski@mac.com>
Reviewed by hyatt
[CSS1, CSS3] Fixed the background-origin calculation for root elements
(background-size and background-position are affected), r10794
[CSS3] Fixed the background-size transformation where width is specified in percentage and height is left to auto
Test: fast/backgrounds/background-origin-root-element.html
* rendering/RenderBox.cpp:
(WebCore::RenderBox::calculateBackgroundSize):
(WebCore::RenderBox::calculateBackgroundImageGeometry):
2008-04-15 Timothy Hatcher <timothy@apple.com>
Fixes the regression where the error and warning counts did not show up in the Resources
......@@ -346,15 +346,14 @@ void RenderBox::paintRootBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
rh = view()->height();
}
// CSS2 14.2:
// The background of the box generated by the root element covers the entire canvas including
// its margins.
int bx = tx - marginLeft();
int by = ty - marginTop();
int bw = max(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw);
int bh = max(h + marginTop() + marginBottom() + borderTop() + borderBottom(), rh);
// CSS2 14.2:
// " The background of the box generated by the root element covers the entire canvas."
// hence, paint the background even in the margin areas (unlike for every other element!)
// I just love these little inconsistencies .. :-( (Dirk)
int my = max(by, paintInfo.rect.y());
paintBackgrounds(paintInfo, bgColor, bgLayer, my, paintInfo.rect.height(), bx, by, bw, bh);
......@@ -459,7 +458,7 @@ IntSize RenderBox::calculateBackgroundSize(const BackgroundLayer* bgLayer, int s
// If the height is auto and the width is not, we have to use the appropriate
// scale to maintain our aspect ratio.
if (bgWidth.isPercent())
h = bg->imageSize(style()->effectiveZoom()).height() * scaledWidth / bg->imageSize(style()->effectiveZoom()).width();
h = bg->imageSize(style()->effectiveZoom()).height() * w / bg->imageSize(style()->effectiveZoom()).width();
else if (bgWidth.isFixed())
h = bg->imageSize(style()->effectiveZoom()).height() * bgWidth.value() / bg->imageSize(style()->effectiveZoom()).width();
else if (bgWidth.isAuto()) {
......@@ -537,6 +536,8 @@ void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer,
int bottom = 0;
int cx;
int cy;
int rw = 0;
int rh = 0;
// CSS2 chapter 14.2.1
......@@ -554,6 +555,18 @@ void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer,
bottom += paddingBottom();
}
}
// The background of the box generated by the root element covers the entire canvas including
// its margins. Since those were added in already, we have to factor them out when computing the
// box used by background-origin/size/position.
if (isRoot()) {
rw = width() - left - right;
rh = height() - top - bottom;
left += marginLeft();
right += marginRight();
top += marginTop();
bottom += marginBottom();
}
cx = tx;
cy = ty;
pw = w - left - right;
......@@ -572,13 +585,22 @@ void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer,
int cw;
int ch;
IntSize scaledImageSize = calculateBackgroundSize(bgLayer, pw, ph);
IntSize scaledImageSize;
if (isRoot() && bgLayer->backgroundAttachment())
scaledImageSize = calculateBackgroundSize(bgLayer, rw, rh);
else
scaledImageSize = calculateBackgroundSize(bgLayer, pw, ph);
int scaledImageWidth = scaledImageSize.width();
int scaledImageHeight = scaledImageSize.height();
EBackgroundRepeat backgroundRepeat = bgLayer->backgroundRepeat();
int xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth, true);
int xPosition;
if (isRoot() && bgLayer->backgroundAttachment())
xPosition = bgLayer->backgroundXPosition().calcMinValue(rw - scaledImageWidth, true);
else
xPosition = bgLayer->backgroundXPosition().calcMinValue(pw - scaledImageWidth, true);
if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_X) {
cw = pw + left + right;
sx = scaledImageWidth ? scaledImageWidth - (xPosition + left) % scaledImageWidth : 0;
......@@ -587,8 +609,12 @@ void RenderBox::calculateBackgroundImageGeometry(const BackgroundLayer* bgLayer,
sx = -min(xPosition + left, 0);
cw = scaledImageWidth + min(xPosition + left, 0);
}
int yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight, true);
int yPosition;
if (isRoot() && bgLayer->backgroundAttachment())
yPosition = bgLayer->backgroundYPosition().calcMinValue(rh - scaledImageHeight, true);
else
yPosition = bgLayer->backgroundYPosition().calcMinValue(ph - scaledImageHeight, true);
if (backgroundRepeat == REPEAT || backgroundRepeat == REPEAT_Y) {
ch = ph + top + bottom;
sy = scaledImageHeight ? scaledImageHeight - (yPosition + top) % scaledImageHeight : 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment