Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #309, avoid adding AnonymousBlockBox on TableCells. Additionally build a TableCellBox instead of a BlockBox if it's a floating element #415

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ private static BlockBox createBlockBox(
BlockBox result;
if (style.isTable() || style.isInlineTable()) {
result = new TableBox();
} else if (style.isTableCell()) {
info.setContainsTableContent(true);
result = new TableCellBox();
} else {
result = new BlockBox();
}
Expand Down Expand Up @@ -1357,7 +1360,9 @@ private static void insertAnonymousBlocks(

for (Styleable child : children) {
if (child.getStyle().isLayedOutInInlineContext() &&
! (layoutRunningBlocks && child.getStyle().isRunning())) {
! (layoutRunningBlocks && child.getStyle().isRunning()) &&
!child.getStyle().isTableCell() //see issue https://github.com/danfickle/openhtmltopdf/issues/309
) {
inline.add(child);

if (child.getStyle().isInline()) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><body><table><tr><td>a</td><td style="float:left">x</td></tr></table></body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public void testListCounterAfterPageBreak() throws IOException {
public void testMissingHtml5BlockElements() throws IOException {
assertTrue(vt.runTest("html5-missing-block-elements"));
}

/**
* Tests that a paginated table doesn't add header and footer with no rows
* on a page.
Expand Down Expand Up @@ -943,6 +943,16 @@ public void testIssue420JustifyTextWhiteSpacePre() throws IOException {
assertTrue(vt.runTest("issue-420-justify-text-white-space-pre"));
}

/**
* Don't launch a ClassCastException if a td in a table is floated.
*
* See issue: https://github.com/danfickle/openhtmltopdf/issues/309
*/
@Test
public void testIssue309ClassCastExceptionOnFloatTd() throws IOException {
assertTrue(vt.runTest("issue-309-classcastexception-on-float-td"));
}

// TODO:
// + Elements that appear just on generated overflow pages.
// + content property (page counters, etc)
Expand Down