Bug 169608

Summary: Background-attachment: scroll should scroll within the containing block, not within the viewport
Product: [Applications] konqueror Reporter: Gérard Talbot (no longer involved) <browserbugs2>
Component: khtml rendererAssignee: Konqueror Developers <konq-bugs>
Status: VERIFIED FIXED    
Severity: normal CC: germain
Priority: NOR    
Version: 4.1.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:

Description Gérard Talbot (no longer involved) 2008-08-22 20:43:55 UTC
Version:            (using KDE 4.1.0)
Compiler:          cc 
OS:                Linux
Installed from:    Debian stable Packages

According to CSS 1, section 5.3.5 and CSS 2.1, section 14.2.1, when background-attachment is scroll, then an image should scroll within its containing block, not within the viewport.

Instructions: resize vertically the browser window to change the vertical dimension of the viewport.

Expected results: the lime squared + image should remain vertically in the middle of its containining block, which is the body which has a lime border. The lime squared + image should not scroll up and down.

Relevant URLs:

http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/#bug7

http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/BackgroundCenterOfBodyBugInIE7.html

https://bugs.webkit.org/show_bug.cgi?id=10794

Regards, Gérard
Comment 1 Gérard Talbot (no longer involved) 2008-08-23 23:10:14 UTC
Konqueror 4.1 / Windows XP screenshot:

http://browsershots.org/http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/BackgroundCenterOfBodyBugInIE7.html

http://browsershots.org/screenshots/c499d76efbc8944534c54e66b90adf49/

http://api.browsershots.org/png/original/c4/c499d76efbc8944534c54e66b90adf49.png

In such screenshot, the lime square [+] image should be vertically in the middle of the lime bordered <body> element, at all times, regardless of browser window viewport vertical dimension/height.
Comment 2 Gérard Talbot (no longer involved) 2008-08-31 18:48:01 UTC
CSS 2.1, section 14.2 The Background states:
"
The background of the root element becomes the background of the canvas and covers the entire canvas, anchored (for 'background-position') at the same point as it would be if it was painted only for the root element itself. The root element does not paint this background again. 
"
http://www.w3.org/TR/CSS21/colors.html#background

indicating that the background-origin to be considered for background-position is relative to the root element, not the canvas. 
Comment 3 Germain Garand 2008-09-01 02:07:34 UTC
SVN commit 855521 by ggarand:

Consider the real root background box when computing some background
properties - not the one that is extended on the whole canvas.

Patch based on work by Anatoli Papirovski <apapirovski mac dot com>

BUG: 169608


 M  +15 -2     render_box.cpp  


--- trunk/KDE/kdelibs/khtml/rendering/render_box.cpp #855520:855521
@@ -575,8 +575,21 @@
                 }
             }
 
-            int pw = w - hpab;
-            int ph = h - vpab;
+            int pw, ph;
+            if (isRoot()) {
+                // the root's background box 'spills out' to cover the whole canvas, so we have to
+                // go back to its true edge for the purpose of computing background-size
+                // and honouring background-origin
+                pw = width() - hpab;
+                ph = height() - vpab; 
+                left += marginLeft();
+                hpab += marginLeft() + marginRight();
+                vpab += marginTop() + marginBottom();
+                top += marginTop();
+            } else {
+                pw = w - hpab;
+                ph = h - vpab;
+            }
             scaledImageWidth = pw;
             scaledImageHeight = ph;
             calculateBackgroundSize(bgLayer, scaledImageWidth, scaledImageHeight);
Comment 4 Gérard Talbot (no longer involved) 2009-01-26 12:19:52 UTC
I get expected results with Konqueror 4.1.3 for Windows.
Marking as VERIFIED