Skip to content
Open
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
41 changes: 15 additions & 26 deletions external/HtmlRenderer/Core/Parse/DomParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,42 +648,31 @@ private static void CorrectImgBoxes(CssBox box)
/// move to a new line</param>
private static void CorrectLineBreaksBlocks(CssBox box, ref bool followingBlock)
{
followingBlock = followingBlock || box.IsBlock;
foreach (var childBox in box.Boxes)
{
CorrectLineBreaksBlocks(childBox, ref followingBlock);
followingBlock = childBox.Words.Count == 0 && (followingBlock || childBox.IsBlock);
}

int lastBr = -1;
CssBox brBox;
do
{
brBox = null;
for (int i = 0; i < box.Boxes.Count && brBox == null; i++)
if (childBox.IsBrElement)
{
if (i > lastBr && box.Boxes[i].IsBrElement)
{
brBox = box.Boxes[i];
lastBr = i;
}
else if (box.Boxes[i].Words.Count > 0)
{
followingBlock = false;
}
else if (box.Boxes[i].IsBlock)
childBox.Display = CssConstants.Block;

if (followingBlock)
{
followingBlock = true;
childBox.Height = ".95em"; // TODO:a check the height to min-height when it is supported
}
}

if (brBox != null)
// after <br>, treat as if we just had a block so consecutive <br> will also create empty lines
followingBlock = true;
}
else if (childBox.Words.Count > 0)
{
brBox.Display = CssConstants.Block;
if (followingBlock)
brBox.Height = ".95em"; // TODO:a check the height to min-height when it is supported
followingBlock = false;
}
} while (brBox != null);
else if (childBox.IsBlock)
{
followingBlock = true;
}
}
}

/// <summary>
Expand Down