Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Source/HtmlRenderer/Core/Dom/CssLayoutEngineTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using TheArtOfDev.HtmlRenderer.Adapters;
using TheArtOfDev.HtmlRenderer.Adapters.Entities;
using TheArtOfDev.HtmlRenderer.Core.Entities;
Expand Down Expand Up @@ -293,8 +294,9 @@ private double CalculateCountAndWidth()
}
else
{
// A cell takes as many columns as its colspan, HTML 4.9.12.1
foreach (CssBox b in _allRows)
_columnCount = Math.Max(_columnCount, b.Boxes.Count);
_columnCount = Math.Max(_columnCount, b.Boxes.Sum(cell => Math.Max(GetColSpan(cell), 1)));
}

//Initialize column widths array with NaNs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using HtmlRenderer.IntegrationTest.TestSupport;

namespace HtmlRenderer.IntegrationTest.Tables;

[TestClass]
public sealed class ColspanIntegrationTests
{
private const double Delta = 1.0;

[TestMethod]
[Spec("html", "tables.html#forming-a-table")]
public void RowsWithDifferentCellCounts_ShareTheColumnsTheirColspansAddUpTo()
{
var (root, _) = LayoutHarness.Layout(LayoutHarness.Wrap(
"<table><tr><td id='a'>Test</td><td colspan='3'>8 570</td><td id='b'>Test</td></tr>"
+ "<tr><td colspan='4'>1 449</td><td id='c'>1 187</td></tr></table>"));
var a = LayoutHarness.FindById(root, "a")!;
var b = LayoutHarness.FindById(root, "b")!;
var c = LayoutHarness.FindById(root, "c")!;

Assert.IsGreaterThan(a.ActualBottom, c.Location.Y);
Assert.AreEqual(b.Location.X, c.Location.X, Delta);
}
}
2 changes: 0 additions & 2 deletions Source/Test/HtmlRenderer.Test/Html/TablesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public void Colspan_AboveAThousand_IsClampedToAThousand()
}

[TestMethod]
[Ignore("Gap, see Spec/html.yml")]
[Spec("html", "tables.html#forming-a-table")]
public void Colspan_AddsColumns()
{
Expand All @@ -143,7 +142,6 @@ public void Colspan_AddsColumns()
}

[TestMethod]
[Ignore("Gap, see Spec/html.yml")]
[Spec("html", "tables.html#forming-a-table")]
public void CellSpanningPastTheOtherRows_IsLaidOut()
{
Expand Down
2 changes: 0 additions & 2 deletions Spec/html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,6 @@ sections:
title: 4.9.12.1 Forming a table
status: partial
gaps:
- The column count is the highest number of cells in a row, colspan doesn't add columns, so a cell past it gets no width
- A cell spanning past that column count breaks the layout of the whole table
- Cells past the columns declared by col and colgroup aren't laid out
- A colspan of 0 or below breaks the layout of the whole table instead of counting as 1
- colspan isn't clamped to 1000
Expand Down
Loading