Bug 134518

Summary: absolutely positioned descendants of relatively positioned root element misplaced for bottom offsets
Product: [Applications] konqueror Reporter: khtmltest <annavoy>
Component: khtmlAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: FreeBSD Ports   
OS: FreeBSD   
Latest Commit: Version Fixed In:
Attachments: testcase

Description khtmltest 2006-09-23 03:47:46 UTC
Version:            (using KDE KDE 3.5.4)
Installed from:    FreeBSD Ports
Compiler:          gcc 3.4.6 
OS:                FreeBSD

if the root element is relatively positioned, then for sufficiently high body child that overflows the viewport, the absolutely positioned descendant with the root as containing block will be mispositioned.

For bottom: 0 offset, it will be offset against the initial containing block, the viewport, and not its nearest positioned ancestor, in thsi case the root element.

This is a spec violation in KHTML 3.5.4. Testcase below.

<!DOCTYPE html>
<html>
<head>
<title>position: relative on root and bottom: 0 on positioned descendants</title>
<style type="text/css">
html {
	position: relative;
}
body {
	height: 2500px;
}
h1 {
	position: absolute;
	bottom: 0;
}
</style>
</head>

<body>
<h1>FAIL</h1>
<p>You should not be able to see the word FAIL without having to scroll.</p>
</body>
</html>
Comment 1 khtmltest 2006-09-23 03:51:12 UTC
Created attachment 17883 [details]
testcase
Comment 2 Germain Garand 2006-09-23 22:34:42 UTC
SVN commit 587726 by ggarand:

Remove incorrect special casing of root block.
Webcore needs this hack because it still uses the old root-is-initial-containing-block model,
but we don't, so there is no need to break the spec here.

BUG: 134518



 M  +2 -8      render_box.cpp  


--- branches/KDE/3.5/kdelibs/khtml/rendering/render_box.cpp #587725:587726
@@ -1628,11 +1628,8 @@
 
     // We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
     const RenderObject* containerBlock = container();
+    const int containerHeight = containerBlock->height() - containerBlock->borderTop() - containerBlock->borderBottom();
 
-    // Even in strict mode (where we don't grow the root to fill the viewport) other browsers
-    // position as though the root fills the viewport.
-    const int containerHeight = containerBlock->isRoot() ? containerBlock->availableHeight() : (containerBlock->height() - containerBlock->borderTop() - containerBlock->borderBottom());
-
     const int bordersPlusPadding = borderTop() + borderBottom() + paddingTop() + paddingBottom();
     const Length marginTop = style()->marginTop();
     const Length marginBottom = style()->marginBottom();
@@ -2031,11 +2028,8 @@
 
     // We don't use containingBlock(), since we may be positioned by an enclosing relpositioned inline.
     const RenderObject* containerBlock = container();
+    const int containerHeight = containerBlock->height() - containerBlock->borderTop() - containerBlock->borderBottom();
 
-    // Even in strict mode (where we don't grow the root to fill the viewport)
-    // other browsers position as though the root fills the viewport.
-    const int containerHeight = containerBlock->isRoot() ? containerBlock->availableHeight() : (containerBlock->height() - containerBlock->borderTop() - containerBlock->borderBottom());
-
     // Variables to solve.
     Length top = style()->top();
     Length bottom = style()->bottom();