Bug 53902 - CSS relative height in % wrong (testcase)
Summary: CSS relative height in % wrong (testcase)
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml renderer (show other bugs)
Version: 4.0
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-02 14:20 UTC by Moritz Moeller-Herrmann
Modified: 2003-11-15 16:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
The pasted example as file for earsier access... (791 bytes, text/html)
2003-06-08 15:54 UTC, Moritz Moeller-Herrmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Moeller-Herrmann 2003-02-02 14:20:00 UTC
Version:           4.0 (using KDE 3.1.0)
Installed from:    SuSE
Compiler:          gcc version 3.2
OS:          Linux (i686) release 2.4.19-4GB

In the following example, the navbar does not get 100% of the viewport, the height is just enough to hold the contents.

http://dhtmlkitchen.com/experiment/safari/css/height2.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>height: 100%</title>


	<style type="text/css" media="screen">

html, body{
	height: 100%;
	margin: 0;
	padding: 0;
}
#nav{
	height: 100%;
 	background: moccasin;
 	width: 100px;
 	position: relative;
 	color: brown;
}

#contents{
	position: absolute;
	left: 150px;
	left: 130px;
	top: 10px;
	margin: 20px;
}

</style>
</head>
<body>
<div id="nav">
#nav{
	height: 100%;
 	background: moccasin;
 	width: 100px;
 	<b>position: relative;</b>
 	color: brown;
}
	
</div>
<div id="contents">
	
	<h1>Testing height: 100%</h1>
	<h2>Relative Demo</h2>
	<p>
		The nav should fill the viewport, and it does in safari.
		(<a href="height2.gif">pic</a>)
	</p>
</div>
</body>
</html>
Comment 1 Moritz Moeller-Herrmann 2003-06-08 15:54:10 UTC
Created attachment 1748 [details]
The pasted example as file for earsier access...

The bug still appears in khtml-2003-06-03.
Comment 2 Zack Rusin 2003-11-15 16:22:53 UTC
Subject: kdelibs/khtml

CVS commit by zrusin: 

correctly compue the height for relatively positioned objects with percentage based
dimensions - pretty much a merge from safari

CCMAIL: 53902-done@bugs.kde.org


  M +5 -0      ChangeLog   1.93
  M +22 -5     rendering/render_box.cpp   1.221


--- kdelibs/khtml/rendering/render_box.cpp  #1.220:1.221
@@ -782,6 +782,24 @@ void RenderBox::calcHeight()
                 fh = h.value() + borderTop() + paddingTop() + borderBottom() + paddingBottom();
             else if (h.isPercent()) {
+                // Handle a common case: nested 100% height <div>s.
+                // This is kind of a one-off hack rather than doing it right.
+                // Makes dbaron's z-index root bg testcases work. Bad dave. - dwh
+                RenderBlock* cb = containingBlock();
                 Length ch = containingBlock()->style()->height();
-                if (ch.isFixed())
+                while (cb && !cb->isTableCell() && ch.isPercent() && ch.value() == 100) {
+                    cb = cb->containingBlock();
+                    ch = cb->style()->height();
+                }
+
+                if (cb->isCanvas()) {
+                    // Don't allow this to affect the canvas' m_height member variable, since this
+                    // can get called while the canvas is still laying out its kids.
+                    // e.g., <html style="height:100%">etc. -dwh
+                    int oldHeight = cb->height();
+                    static_cast<RenderCanvas*>(cb)->calcHeight();
+                    fh = h.width(cb->height()) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
+                    cb->setHeight(oldHeight);
+                }
+                else if (ch.isFixed())
                     fh = h.width(ch.value()) + borderTop() + paddingTop() + borderBottom() + paddingBottom();
             }
@@ -1189,6 +1207,5 @@ void RenderBox::calcAbsoluteVertical()
     m_y = t + mt;
 
-    //qDebug("v: h=%d, t=%d, b=%d, mt=%d, mb=%d, m_y=%d",h,t,b,mt,mb,m_y);
-
+    //qDebug("v: m_height = %d, h=%d, t=%d, b=%d, mt=%d, mb=%d, m_y=%d",m_height,h,t,b,mt,mb,m_y);
 }
 

--- kdelibs/khtml/ChangeLog  #1.92:1.93
@@ -1,2 +1,7 @@
+2003-11-15  Zack Rusin  <zack@kde.org>
+
+        * rendering/render_box.cpp (calcHeight): correctly compute the
+        height for relatively positioned object with percentage based
+        dimensions - pretty much a merge from safari (#53902) 
 
 2003-11-14  Germain Garand  <germain@ebooksfrance.org>