Skip to content

Commit 96f39f4

Browse files
author
ArthurHub
committed
* more table cells layout with given width handling
1 parent bb97a93 commit 96f39f4

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎Source/Demo/TestSamples/13.Tables.htm‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@
195195
<td style="WIDTH: 4.53mm; min-width: 4.53mm; background-color: green"></td>
196196
</tr>
197197
</table>
198+
<br/>
199+
<table cellspacing="0" cellpadding="0" border="1" cols="6" lang="en-US" class="r10" style="WIDTH: 175.1543mm; background-color: red">
200+
<tr>
201+
<td style="HEIGHT: 3mm; WIDTH: 12.00mm; background-color: yellow"></td>
202+
<td style="WIDTH: 6.05mm; min-width: 6.05mm; background-color: blue"></td>
203+
</tr>
204+
<tr>
205+
<td style="HEIGHT: 3mm; WIDTH: 12.00mm; background-color: yellow"></td>
206+
<td style="WIDTH: 18.05mm; background-color: blue"></td>
207+
</tr>
208+
</table>
198209
</blockquote>
199210
</body>
200211
</html>

‎Source/HtmlRenderer/Dom/CssLayoutEngineTable.cs‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,19 @@ private float CalculateCountAndWidth()
335335
//Check for column width in table-cell definitions
336336
for (int i = 0; i < _columnCount; i++)
337337
{
338-
if (float.IsNaN(_columnWidths[i]) && //Check if no width specified for column
339-
i < row.Boxes.Count && //And there's a box to check
340-
row.Boxes[i].Display == CssConstants.TableCell) //And the box is a table-cell
338+
if (i < 20 || float.IsNaN(_columnWidths[i])) // limit column width check
341339
{
342-
float len = CssValueParser.ParseLength(row.Boxes[i].Width, availCellSpace, row.Boxes[i]); //Get width as an absolute-pixel value
343-
if (len > 0) //If some width specified
340+
if (i < row.Boxes.Count && row.Boxes[i].Display == CssConstants.TableCell)
344341
{
345-
int colspan = GetColSpan(row.Boxes[i]);
346-
len /= Convert.ToSingle(colspan);
347-
for (int j = i; j < i + colspan; j++)
342+
float len = CssValueParser.ParseLength(row.Boxes[i].Width, availCellSpace, row.Boxes[i]);
343+
if (len > 0) //If some width specified
348344
{
349-
_columnWidths[j] = len;
345+
int colspan = GetColSpan(row.Boxes[i]);
346+
len /= Convert.ToSingle(colspan);
347+
for (int j = i; j < i + colspan; j++)
348+
{
349+
_columnWidths[j] = float.IsNaN(_columnWidths[j]) ? len : Math.Max(_columnWidths[j], len);
350+
}
350351
}
351352
}
352353
}

0 commit comments

Comments
 (0)