Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ jobs:

- name: Run Tests
if: runner.os != 'Windows'
run: dotnet test Source/Test/**/*.Test.csproj --configuration Release --no-build --logger trx --results-directory ${{ github.workspace }}/TestResults
run: |
$failed = $false
Get-ChildItem -Path Source/Test -Recurse -Filter *.Test.csproj | ForEach-Object {
dotnet test $_.FullName --configuration Release --no-build --logger trx --results-directory ${{ github.workspace }}/TestResults
if ($LASTEXITCODE -ne 0) { $failed = $true }
}
if ($failed) { exit 1 }
env:
PDF_OUTPUT_DIRECTORY: ${{ github.workspace }}/pdf-artifacts/${{ matrix.platform.name }}-${{ matrix.dotnet.name }}

Expand Down
3 changes: 3 additions & 0 deletions Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Features and Benefits:
<ItemGroup>
<ProjectReference Include="..\HtmlRenderer\HtmlRenderer.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="HtmlRenderer.PdfSharp.Test" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
Comment thread
jhaygood86 marked this conversation as resolved.
Outdated
<PackageReference Include="PDFsharp" Version="6.2.4" />
Expand Down
3 changes: 3 additions & 0 deletions Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ Features and Benefits:
<ItemGroup>
<ProjectReference Include="..\HtmlRenderer\HtmlRenderer.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="HtmlRenderer.IntegrationTest" />
</ItemGroup>
</Project>
17 changes: 16 additions & 1 deletion Source/HtmlRenderer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{E508FA78-D
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.PdfSharp.Test", "Test\HtmlRenderer.PdfSharp.Test\HtmlRenderer.PdfSharp.Test.csproj", "{AF39851E-37B9-409E-A34D-CE091A098C86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Test", "Test\HtmlRenderer.IntegrationTest\HtmlRenderer.IntegrationTest.csproj", "{A12F4432-337B-4030-B834-5D312A9FB16C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.IntegrationTest", "Test\HtmlRenderer.IntegrationTest\HtmlRenderer.IntegrationTest.csproj", "{A12F4432-337B-4030-B834-5D312A9FB16C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Test", "Test\HtmlRenderer.Test\HtmlRenderer.Test.csproj", "{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -129,6 +131,18 @@ Global
{A12F4432-337B-4030-B834-5D312A9FB16C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A12F4432-337B-4030-B834-5D312A9FB16C}.Release|x86.ActiveCfg = Release|Any CPU
{A12F4432-337B-4030-B834-5D312A9FB16C}.Release|x86.Build.0 = Release|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Debug|x86.ActiveCfg = Debug|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Debug|x86.Build.0 = Debug|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Release|Any CPU.Build.0 = Release|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Release|x86.ActiveCfg = Release|Any CPU
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -139,6 +153,7 @@ Global
{F02E0216-4AE3-474F-9381-FCB93411CDB0} = {E263EA16-2E6A-4269-A319-AA2F97ADA8E1}
{AF39851E-37B9-409E-A34D-CE091A098C86} = {E508FA78-D57E-492F-9BF7-23640001848A}
{A12F4432-337B-4030-B834-5D312A9FB16C} = {E508FA78-D57E-492F-9BF7-23640001848A}
{7427E12F-1524-4405-AAD1-5AF8ACB3BBBC} = {E508FA78-D57E-492F-9BF7-23640001848A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {902788D6-3165-491D-B860-DF2F74E66C1D}
Expand Down
4 changes: 4 additions & 0 deletions Source/HtmlRenderer/HtmlRenderer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ For existing implementations see: HtmlRenderer.WinForms, HtmlRenderer.WPF and Ht
<EmbeddedResource Include="Core\Utils\ImageError.png" />
<EmbeddedResource Include="Core\Utils\ImageLoad.png" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="HtmlRenderer.Test" />
<InternalsVisibleTo Include="HtmlRenderer.IntegrationTest" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using HtmlRenderer.IntegrationTest.TestSupport;

namespace HtmlRenderer.IntegrationTest.BoxModel;

/// <summary>
/// DomParser's "block inside inline" DOM-correction pass (CorrectBlockInsideInline) should never look through an
/// inline-level box that establishes its own independent formatting context (inline-block/inline-table both do)
/// when deciding whether an ANCESTOR box needs splitting - DomUtils.ContainsInlinesOnly is meant to make such a
/// box opaque for that purpose. A child whose own resolved display is "none" (not "inline") should not make the
/// correction pass misclassify the box's content as containing a "block", incorrectly splitting the child out of
/// its real parent entirely.
/// </summary>
/// <remarks>
/// The triage note for this file claimed both cases already pass on this fork. Direct testing shows otherwise
/// for the inline-block case: dumping the box tree for the &lt;select&gt;/&lt;option&gt; markup below shows
/// <c>opt1</c> (the FIRST display:none &lt;option&gt;) gets hoisted out from under &lt;select&gt; entirely and
/// becomes a sibling of the anonymous block box CorrectInlineBoxesParent wraps &lt;select&gt; in, while
/// <c>opt2</c> (the second, otherwise-identical &lt;option&gt;) correctly stays nested. That first-child-only
/// asymmetry is exactly the atomic-inline-level gap the class doc describes - it just was not caught by the
/// triage pass. The inline-table case genuinely does pass, so only the inline-block test method is ignored
/// (with the real, faithfully-ported assertions kept, to document the target behavior).
/// </remarks>
[DoNotParallelize]
[TestClass]
public sealed class AtomicInlineLevelBoxCorrectionTests
{
[Ignore("Confirmed real bug on this fork, not a porting mistake: dumping the box tree shows opt1 (the " +
"FIRST display:none <option> child of an inline-block <select>) gets hoisted out from under " +
"<select> and becomes a sibling of the anonymous block wrapper CorrectInlineBoxesParent creates, " +
"while opt2 (second, otherwise-identical child) stays correctly nested. DomUtils.ContainsInlinesOnly " +
"does not treat inline-block as opaque the way an atomic-inline-level check should.")]
[TestMethod]
public void DisplayNoneChildOfInlineBlockBox_StaysNestedUnderItsRealParent()
{
var html = LayoutHarness.Wrap(
"<select id='sel'>" +
"<option id='opt1' style='display:none'>Red</option>" +
"<option id='opt2' style='display:none'>Green</option>" +
"</select>");

var (root, _) = LayoutHarness.Layout(html);
var select = LayoutHarness.FindById(root, "sel")!;
var opt1 = LayoutHarness.FindById(root, "opt1")!;
var opt2 = LayoutHarness.FindById(root, "opt2")!;

Assert.IsTrue(IsDescendantOf(opt1, select), "opt1 (display:none) must stay nested under its real <select> parent.");
Assert.IsTrue(IsDescendantOf(opt2, select), "opt2 must stay nested under its real <select> parent.");
}

[TestMethod]
public void DisplayNoneChildOfInlineTableBox_StaysNestedUnderItsRealParent()
{
var html = LayoutHarness.Wrap(
"<div id='wrap'>" +
"<div id='it' style='display:inline-table'>" +
"<div style='display:table-row'><div id='cell' style='display:table-cell'>cell</div></div>" +
"<div id='hidden' style='display:none'>hidden</div>" +
"</div>" +
"</div>");

var (root, _) = LayoutHarness.Layout(html);
var inlineTable = LayoutHarness.FindById(root, "it")!;
var hidden = LayoutHarness.FindById(root, "hidden")!;

Assert.IsTrue(IsDescendantOf(hidden, inlineTable), "a display:none sibling inside an inline-table must stay nested under it.");
}

// PeachPDF's source file also has a "DisplayNoneChildOfInlineFlexBox_StillStaysNestedUnderItsRealParent"
// regression case, guarding pre-existing display:inline-flex handling. HTML-Renderer (this fork) implements
// no flexbox layout at all - "flex"/"inline-flex" are not recognized display values anywhere in
// TheArtOfDev.HtmlRenderer.Core (confirmed: no "flex" hits in the Core source tree) - so there is no such
// pre-existing handling to guard, and porting that case would document a feature this fork doesn't have.
// Intentionally dropped rather than ported under a false premise.

private static bool IsDescendantOf(TheArtOfDev.HtmlRenderer.Core.Dom.CssBox box, TheArtOfDev.HtmlRenderer.Core.Dom.CssBox ancestor)
{
var current = box.ParentBox;
while (current != null)
{
if (ReferenceEquals(current, ancestor)) return true;
current = current.ParentBox;
}
return false;
}
}
Loading
Loading