Skip to content

Commit 90f3d36

Browse files
author
ArthurHub
committed
Fix links not working if defined with display:block
1 parent 007b566 commit 90f3d36

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

‎Source/HtmlRenderer/Utils/DomUtils.cs‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ namespace HtmlRenderer.Utils
2727
/// </summary>
2828
internal sealed class DomUtils
2929
{
30+
/// <summary>
31+
/// Check if the given location is inside the given box deep.<br/>
32+
/// Check inner boxes and all lines that the given box spans to.
33+
/// </summary>
34+
/// <param name="box">the box to check</param>
35+
/// <param name="location">the location to check</param>
36+
/// <returns>true - location inside the box, false - otherwise</returns>
37+
public static bool IsInBox(CssBox box, Point location)
38+
{
39+
foreach (var line in box.Rectangles)
40+
{
41+
if (line.Value.Contains(location))
42+
return true;
43+
}
44+
foreach (var childBox in box.Boxes)
45+
{
46+
if (IsInBox(childBox, location))
47+
return true;
48+
}
49+
return false;
50+
}
51+
3052
/// <summary>
3153
/// Check if the given box contains only inline child boxes.
3254
/// </summary>
@@ -218,13 +240,8 @@ public static CssBox GetLinkBox(CssBox box, Point location)
218240
{
219241
if(box.IsClickable && box.Visibility == CssConstants.Visible)
220242
{
221-
foreach (var line in box.Rectangles)
222-
{
223-
if (line.Value.Contains(location))
224-
{
225-
return box;
226-
}
227-
}
243+
if( IsInBox(box, location) )
244+
return box;
228245
}
229246

230247
if (box.ClientRectangle.IsEmpty || box.ClientRectangle.Contains(location))

0 commit comments

Comments
 (0)