Skip to content

Commit 93acf5f

Browse files
author
ArthurHub
committed
* fix collection use CorrectBlockInsideInline
1 parent c8bbe98 commit 93acf5f

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

Source/HtmlRenderer/Dom/CssBox.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,19 @@ public void SetBeforeBox(CssBox before)
470470
_parentBox.Boxes.Insert(index, this);
471471
}
472472

473+
/// <summary>
474+
/// Move all child boxes from <paramref name="fromBox"/> to this box.
475+
/// </summary>
476+
/// <param name="fromBox">the box to move all its child boxes from</param>
477+
public void SetAllBoxes(CssBox fromBox)
478+
{
479+
foreach(var childBox in fromBox._boxes)
480+
childBox._parentBox = this;
481+
482+
_boxes.AddRange(fromBox._boxes);
483+
fromBox._boxes.Clear();
484+
}
485+
473486
/// <summary>
474487
/// Splits the text into words and saves the result
475488
/// </summary>

Source/HtmlRenderer/Parse/DomParser.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ private static void CorrectBlockInsideInlineImp(CssBox box)
695695
if( DomUtils.ContainsInlinesOnly(tempRightBox) && !ContainsInlinesOnlyDeep(tempRightBox) )
696696
CorrectBlockInsideInlineImp(tempRightBox);
697697

698-
while( tempRightBox.Boxes.Count > 0 )
699-
tempRightBox.Boxes[0].ParentBox = tempRightBox.ParentBox;
698+
tempRightBox.ParentBox.SetAllBoxes(tempRightBox);
700699
tempRightBox.ParentBox = null;
701700
}
702701

@@ -763,8 +762,7 @@ private static void CorrectBlockSplitBadBox(CssBox parentBox, CssBox badBox, Css
763762
rightBox = parentBox.Boxes[2];
764763
}
765764

766-
while (badBox.Boxes.Count > 0)
767-
badBox.Boxes[0].ParentBox = rightBox;
765+
rightBox.SetAllBoxes(badBox);
768766
}
769767
else if (splitBox.ParentBox != null && parentBox.Boxes.Count > 1)
770768
{

0 commit comments

Comments
 (0)