Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8fd5b2b

Browse files
author
Arthur
committed
Merge pull request ArthurHub#15 from configurator/master
Bugfix in CssLayoutEngine where an exception was thrown.
2 parents 98471cc + c03e1ca commit 8fd5b2b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Source/HtmlRenderer/Core/Dom/CssLayoutEngine.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,10 @@ private static void ApplyCenterAlignment(RGraphics g, CssLineBox line)
624624
word.Left += diff;
625625
}
626626

627-
foreach (CssBox b in line.Rectangles.Keys)
627+
foreach (CssBox b in ToList(line.Rectangles.Keys))
628628
{
629-
RRect r = b.Rectangles[line];
630-
b.Rectangles[line] = new RRect(r.X + diff, r.Y, r.Width, r.Height);
629+
RRect r = line.Rectangles[b];
630+
line.Rectangles[b] = new RRect(r.X + diff, r.Y, r.Width, r.Height);
631631
}
632632
}
633633
}
@@ -654,10 +654,10 @@ private static void ApplyRightAlignment(RGraphics g, CssLineBox line)
654654
word.Left += diff;
655655
}
656656

657-
foreach (CssBox b in line.Rectangles.Keys)
657+
foreach (CssBox b in ToList(line.Rectangles.Keys))
658658
{
659-
RRect r = b.Rectangles[line];
660-
b.Rectangles[line] = new RRect(r.X + diff, r.Y, r.Width, r.Height);
659+
RRect r = line.Rectangles[b];
660+
line.Rectangles[b] = new RRect(r.X + diff, r.Y, r.Width, r.Height);
661661
}
662662
}
663663
}
@@ -687,6 +687,16 @@ private static void ApplyLeftAlignment(RGraphics g, CssLineBox line)
687687
//}
688688
}
689689

690+
private static List<T> ToList<T>(IEnumerable<T> collection)
691+
{
692+
List<T> result = new List<T>();
693+
foreach (T item in collection)
694+
{
695+
result.Add(item);
696+
}
697+
return result;
698+
}
699+
690700
#endregion
691701
}
692702
}

0 commit comments

Comments
 (0)