Skip to content

Commit

Permalink
fixes #39 - Insert test to stop loop if we are never going to find a …
Browse files Browse the repository at this point in the history
…line to break on.
  • Loading branch information
danfickle committed Aug 8, 2015
1 parent 7499dd4 commit 9b9135f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ else if (width >= avail)
width = c.getTextRenderer().getWidth(c.getFontContext(), font, broken);
last--;
}

if (last == 0)
{
context.setUnbreakable(true);
}
}

context.setWidth(width);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static void layoutContent(final LayoutContext c, final BlockBox box, fina
if (lbContext.getStart() == 0) {
fit += pendingLeftMBP + pendingRightMBP;
}

boolean trimmedLeadingSpace = false;
if (hasTrimmableLeadingSpace(
currentLine, style, lbContext, zeroWidthInlineBlock)) {
Expand Down Expand Up @@ -205,6 +205,12 @@ public static void layoutContent(final LayoutContext c, final BlockBox box, fina
lbContext.saveEnd();
final InlineText inlineText = layoutText(
c, iB.getStyle(), remainingWidth - fit, lbContext, false);

if (lbContext.isUnbreakable() && lbContext.getWidth() >= maxAvailableWidth - fit)
{
break;
}

if (lbContext.isUnbreakable() && ! currentLine.isContainsContent()) {
final int delta = c.getBlockFormattingContext().getNextLineBoxDelta(c, currentLine, maxAvailableWidth);
if (delta > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ public void testListStyleTypeDisc()
pdf.assertContains(drawEllipseOperation);
}

@Test
@Ignore("Failing (infinite loop somewhere in code)")
@Test // Regression test
public void testInfiniteLoopBugOnTooWideContent()
{
PdfTest pdf = new PdfTest("InfiniteLoopBugOnTooWideContent");
Expand Down

0 comments on commit 9b9135f

Please sign in to comment.