--===============1937682463== Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit [31912] trunk
Revision
31912
Author
hyatt@apple.com
Date
2008-04-15 11:15:06 -0700 (Tue, 15 Apr 2008)

Log Message

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (31911 => 31912)


--- trunk/LayoutTests/ChangeLog	2008-04-15 17:54:18 UTC (rev 31911)
+++ trunk/LayoutTests/ChangeLog	2008-04-15 18:15:06 UTC (rev 31912)
@@ -1,3 +1,15 @@
+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

Added: trunk/LayoutTests/fast/backgrounds/background-origin-root-element.html (0 => 31912)


--- trunk/LayoutTests/fast/backgrounds/background-origin-root-element.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/background-origin-root-element.html	2008-04-15 18:15:06 UTC (rev 31912)
@@ -0,0 +1,16 @@
+<!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
Property changes on: trunk/LayoutTests/fast/backgrounds/background-origin-root-element.html
___________________________________________________________________
Name: allow-tabs
   + true

Added: trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.checksum (0 => 31912)


--- trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.checksum	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.checksum	2008-04-15 18:15:06 UTC (rev 31912)
@@ -0,0 +1 @@
+1759a97cc985fef5fc30fef9def8ebce
\ No newline at end of file

Added: trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream

Added: trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.txt (0 => 31912)


--- trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/backgrounds/background-origin-root-element-expected.txt	2008-04-15 18:15:06 UTC (rev 31912)
@@ -0,0 +1,10 @@
+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."

Modified: trunk/LayoutTests/platform/mac/fast/backgrounds/size/backgroundSize18-expected.checksum (31911 => 31912)


--- trunk/LayoutTests/platform/mac/fast/backgrounds/size/backgroundSize18-expected.checksum	2008-04-15 17:54:18 UTC (rev 31911)
+++ trunk/LayoutTests/platform/mac/fast/backgrounds/size/backgroundSize18-expected.checksum	2008-04-15 18:15:06 UTC (rev 31912)
@@ -1 +1 @@
-3fc0e927df258ed742fa657acffba46d
\ No newline at end of file
+2f70b81328f41ce5c03fc1753b70d817
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac/fast/backgrounds/size/backgroundSize18-expected.png


(Binary files differ)

Modified: trunk/WebCore/ChangeLog (31911 => 31912)


--- trunk/WebCore/ChangeLog	2008-04-15 17:54:18 UTC (rev 31911)
+++ trunk/WebCore/ChangeLog	2008-04-15 18:15:06 UTC (rev 31912)
@@ -1,3 +1,17 @@
+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

Modified: trunk/WebCore/rendering/RenderBox.cpp (31911 => 31912)


--- trunk/WebCore/rendering/RenderBox.cpp	2008-04-15 17:54:18 UTC (rev 31911)
+++ trunk/WebCore/rendering/RenderBox.cpp	2008-04-15 18:15:06 UTC (rev 31912)
@@ -346,15 +346,14 @@
         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 @@
             // 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 @@
     int bottom = 0;
     int cx;
     int cy;
+    int rw = 0;
+    int rh = 0;
 
     // CSS2 chapter 14.2.1
 
@@ -554,6 +555,18 @@
                 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 @@
     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 @@
         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;
--===============1937682463== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo/webkit-changes --===============1937682463==--