Bug 13670 - Table misrender when one of the TDs has width=100%
Summary: Table misrender when one of the TDs has width=100%
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tables (show other bugs)
Version: 523.x (Safari 3)
Hardware: Macintosh OS X 10.4
: P2 Major
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2007-05-10 17:35 PDT by Bhagyalaxmi Dash
Modified: 2007-08-11 11:28 PDT (History)
4 users (show)

See Also:


Attachments
Reduction for the issue. (404 bytes, text/html)
2007-05-10 17:37 PDT, Bhagyalaxmi Dash
no flags Details
Change the cap from 99% to >99.99% (177.08 KB, patch)
2007-08-10 07:09 PDT, mitz
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bhagyalaxmi Dash 2007-05-10 17:35:52 PDT
Table misrenders, assumes some arbitrary width when one of the TDs has width=100%. Please see the reduction given below.

In the reduction , the first TD has the width=100% and the second TD is blank(&nbsp). But, the table takes its width between 376 to 858 depending on the size of the browser window.

In Firefox, table is occupying the entire width available to the browser window. In addition to that it is not taking any arbitrary value.

This issue affects the rendering of certain tables in SAP NetWeaver portal that works perfectly in Firefox.


<html>
<head>
<script>
function f1()
{
  var tab1=document.getElementById("table1");
  alert("Table Width "+tab1.offsetWidth);
  var x=document.getElementById("tdid1");
  alert("Width of first TD "+x.offsetWidth);
}
</script>
</head>
<body onload="javascript:f1()">
<table bgcolor="Red" border="1" id="table1">
<tr>
<td id="tdid1" width="100%">&nbsp;</td>
<td >&nbsp;</td>
</tr>
</table>
</body>
</html>
Comment 1 Bhagyalaxmi Dash 2007-05-10 17:37:39 PDT
Created attachment 14479 [details]
Reduction for the issue.

This attachment contains the reduction for this issue.
Comment 2 Dave Hyatt 2007-05-11 00:12:35 PDT
What does WinIE do?  What Firefox does is irrelevant when it comes to tables.

Comment 3 Bhagyalaxmi Dash 2007-05-14 17:39:28 PDT
In IE, the table is occupying the entire width available to the browser window. This is the same behavior as Firefox.
Comment 4 Darin Adler 2007-08-09 15:17:23 PDT
<rdar://problem/5399619>
Comment 5 mitz 2007-08-09 15:59:25 PDT
The problem can be "made to go away" for most practical cases (i.e. as long as the container is not extremely wide) by taking advantage of the new support for non-integral percentage values. Currently anything above 99% is clamped down to 99%, but this can be changed to a much higher threshold. In AutoTableLayout::calcPrefWidths:

maxNonPercent = (maxNonPercent * 100 + 50) * percentScaleFactor / max(remainingPercent, percentScaleFactor);

can be changed to say 1 in the end instead of percentScaleFactor (currently 128), bringing the threshold to >99.99%.

I will try to post a patch soon.
Comment 6 mitz 2007-08-10 07:09:44 PDT
Created attachment 15906 [details]
Change the cap from 99% to >99.99%

The patch also removes the "+ 50" which has been in the code since <http://trac.webkit.org/projects/webkit/changeset/3351>. This fixes a bug that has become even more apparent by raising the cap from 99% closer to 100%, and causes no regressions. I've included a test for the bug, where the new results match WinIE.

I have a version that tests directly for the "0%" cases and uses INT_MAX as max width in those cases. It gives the same results in testing, but I think using INT_MAX is still a hack, and is perhaps more risky than this patch's approach.
Comment 7 Beth Dakin 2007-08-10 14:18:15 PDT
This looks good to me, but Hyatt should probably take a look too.
Comment 8 Darin Adler 2007-08-11 10:37:49 PDT
Comment on attachment 15906 [details]
Change the cap from 99% to >99.99%

r=me
Comment 9 Darin Adler 2007-08-11 10:39:24 PDT
I'll land this.
Comment 10 mitz 2007-08-11 11:28:00 PDT
(In reply to comment #9)
> I'll land this.

<http://trac.webkit.org/projects/webkit/changeset/25011>.