Skip to content

Commit ea8e93b

Browse files
Merge branch 'float_splitting' into develop
# Conflicts: # src/test/java/com/itextpdf/html2pdf/css/FloatTest.java # src/test/java/com/itextpdf/html2pdf/css/media/print/SmashingTest.java # src/test/resources/com/itextpdf/html2pdf/css/FloatTest/cmp_float48Test.pdf # src/test/resources/com/itextpdf/html2pdf/css/FloatTest/cmp_float55Test.pdf # src/test/resources/com/itextpdf/html2pdf/css/FloatTest/cmp_responsiveIText.pdf # src/test/resources/com/itextpdf/html2pdf/css/FloatTest/cmp_responsiveIText_315.pdf # src/test/resources/com/itextpdf/html2pdf/css/FloatTest/cmp_responsiveIText_570.pdf # src/test/resources/com/itextpdf/html2pdf/css/FloatTest/float55Test.html # src/test/resources/com/itextpdf/html2pdf/css/bootstrap/Bootstrap3.3.7/examples/forms/cmp_formsTablets.pdf # src/test/resources/com/itextpdf/html2pdf/css/bootstrap/Bootstrap3.3.7/examples/glyphicon/cmp_glyphiconDesktops.pdf # src/test/resources/com/itextpdf/html2pdf/css/bootstrap/Bootstrap3.3.7/examples/glyphicon/cmp_glyphiconLargeDesktops.pdf # src/test/resources/com/itextpdf/html2pdf/css/bootstrap/Bootstrap3.3.7/examples/glyphicon/cmp_glyphiconPhones.pdf # src/test/resources/com/itextpdf/html2pdf/css/bootstrap/Bootstrap3.3.7/examples/glyphicon/cmp_glyphiconTablets.pdf # src/test/resources/com/itextpdf/html2pdf/css/media/print/WashingtonPostTest/cmp_trump.pdf # src/test/resources/com/itextpdf/html2pdf/css/media/print/WikiTest/cmp_css.big.wiki_simplified.pdf # src/test/resources/com/itextpdf/html2pdf/css/media/print/WikiTest/cmp_rock.wiki_simplified.pdf # src/test/resources/com/itextpdf/html2pdf/custom/divInTable001/cmp_divInTable001.pdf
2 parents 2e104ab + 820c801 commit ea8e93b

File tree

19 files changed

+176
-165
lines changed

19 files changed

+176
-165
lines changed

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/HtmlDocumentRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ public void addChild(IRenderer renderer) {
170170
@Override
171171
public void close() {
172172
if (waitingElement != null) {
173-
super.addChild(waitingElement);
173+
IRenderer r = this.waitingElement;
174+
waitingElement = null;
175+
super.addChild(r);
174176
}
175177
super.close();
176178
if (TRIM_LAST_BLANK_PAGE) {

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/AbstractFormFieldRenderer.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ This file is part of the iText (R) project.
5151
import com.itextpdf.layout.layout.LayoutResult;
5252
import com.itextpdf.layout.layout.MinMaxWidthLayoutResult;
5353
import com.itextpdf.layout.minmaxwidth.MinMaxWidth;
54+
import com.itextpdf.layout.property.FloatPropertyValue;
5455
import com.itextpdf.layout.property.Property;
5556
import com.itextpdf.layout.property.UnitValue;
56-
import com.itextpdf.layout.renderer.AbstractRenderer;
57-
import com.itextpdf.layout.renderer.BlockRenderer;
58-
import com.itextpdf.layout.renderer.DrawContext;
59-
import com.itextpdf.layout.renderer.ILeafElementRenderer;
60-
import com.itextpdf.layout.renderer.IRenderer;
57+
import com.itextpdf.layout.renderer.*;
6158
import org.slf4j.LoggerFactory;
6259

6360
/**
@@ -233,7 +230,22 @@ private LayoutResult layout(LayoutContext layoutContext, boolean minMaxWidth) {
233230
}
234231

235232
if (!Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT)) && (result.getStatus() != LayoutResult.FULL)) {
236-
setProperty(Property.FORCED_PLACEMENT, true);
233+
//@TODO investigate this tricky code a little more.
234+
FloatPropertyValue floatPropertyValue = this.<FloatPropertyValue>getProperty(Property.FLOAT);
235+
if (floatPropertyValue == null || floatPropertyValue == FloatPropertyValue.NONE) {
236+
setProperty(Property.FORCED_PLACEMENT, true);
237+
} else {
238+
flatRenderer = childRenderers.get(0);
239+
childRenderers.clear();
240+
LayoutArea flatRendererOccupiedArea = flatRenderer.getOccupiedArea();
241+
applyPaddings(flatRendererOccupiedArea.getBBox(), true);
242+
applyBorderBox(flatRendererOccupiedArea.getBBox(), true);
243+
applyMargins(flatRendererOccupiedArea.getBBox(), true);
244+
childRenderers.add(flatRenderer);
245+
adjustFieldLayout();
246+
occupiedArea.setBBox(flatRenderer.getOccupiedArea().getBBox().clone());
247+
}
248+
237249
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth(0, parentWidth));
238250
}
239251
if (!childRenderers.isEmpty()) {
@@ -265,5 +277,4 @@ private LayoutResult layout(LayoutContext layoutContext, boolean minMaxWidth) {
265277
return new MinMaxWidthLayoutResult(LayoutResult.FULL, occupiedArea, this, null)
266278
.setMinMaxWidth(new MinMaxWidth(0, parentWidth, occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getWidth()));
267279
}
268-
269280
}

src/test/java/com/itextpdf/html2pdf/css/FloatTest.java

Lines changed: 25 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ This file is part of the iText (R) project.
5252
import com.itextpdf.kernel.pdf.PdfWriter;
5353
import com.itextpdf.kernel.utils.CompareTool;
5454
import com.itextpdf.test.ExtendedITextTest;
55+
import com.itextpdf.test.annotations.LogMessage;
56+
import com.itextpdf.test.annotations.LogMessages;
5557
import com.itextpdf.test.annotations.type.IntegrationTest;
5658

5759
import java.io.File;
@@ -364,6 +366,29 @@ public void float55Test() throws IOException, InterruptedException {
364366
runTest("float55Test", "diff55_");
365367
}
366368

369+
@Test
370+
public void float57Test() throws IOException, InterruptedException {
371+
runTest("float57Test", "diff57_");
372+
}
373+
374+
@Test@Ignore("DEVSIX-1372")
375+
public void float58Test() throws IOException, InterruptedException {
376+
runTest("float58Test", "diff58_");
377+
}
378+
379+
@Test
380+
@LogMessages(messages = {
381+
@LogMessage(messageTemplate = com.itextpdf.io.LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES, count = 1),
382+
})
383+
public void float60Test() throws IOException, InterruptedException {
384+
runTest("float60Test", "diff60_");
385+
}
386+
387+
@Test
388+
public void float61Test() throws IOException, InterruptedException {
389+
runTest("float61Test", "diff61_");
390+
}
391+
367392
@Test
368393
public void floatAndTables01Test() throws IOException, InterruptedException {
369394
runTest("floatAndTables01Test", "diffTables01_");
@@ -414,164 +439,18 @@ public void floatAndTables10Test() throws IOException, InterruptedException {
414439
runTest("floatAndTables10Test", "diffTables10_");
415440
}
416441

417-
@Test
418-
public void floatImage01Test() throws IOException, InterruptedException {
419-
runTest("floatImage01Test", "diffImages01_");
420-
}
421-
422-
@Test
423-
public void floatImage02Test() throws IOException, InterruptedException {
424-
runTest("floatImage02Test", "diffImages02_");
425-
}
426-
427-
@Test
428-
public void floatImage03Test() throws IOException, InterruptedException {
429-
runTest("floatImage03Test", "diffImages03_");
430-
}
431-
432-
@Test
433-
public void floatImage04Test() throws IOException, InterruptedException {
434-
// TODO word splitting logic working not entirely correctly
435-
runTest("floatImage04Test", "diffImages04_");
436-
}
437-
438-
@Test
439-
public void floatImage05Test() throws IOException, InterruptedException {
440-
runTest("floatImage05Test", "diffImages05_");
441-
}
442-
443-
@Test
444-
public void floatImage06Test() throws IOException, InterruptedException {
445-
runTest("floatImage06Test", "diffImages06_");
446-
}
447-
448-
@Test
449-
public void floatImage07Test() throws IOException, InterruptedException {
450-
// TODO word splitting logic working not entirely correctly
451-
runTest("floatImage07Test", "diffImages07_");
452-
}
453-
454-
@Test
455-
public void floatImage08Test() throws IOException, InterruptedException {
456-
runTest("floatImage08Test", "diffImages08_");
457-
}
458-
459-
@Test
460-
public void floatImage09Test() throws IOException, InterruptedException {
461-
runTest("floatImage09Test", "diffImages09_");
462-
}
463-
464-
@Test
465-
public void floatImage10Test() throws IOException, InterruptedException {
466-
// TODO we don't apply leading on floats, this somewhat noticeable when huge line-height in html is used
467-
runTest("floatImage10Test", "diffImages10_");
468-
}
469-
470-
@Test
471-
public void floatImage11Test() throws IOException, InterruptedException {
472-
runTest("floatImage11Test", "diffImages11_");
473-
}
474-
475-
@Test
476-
public void floatImage12Test() throws IOException, InterruptedException {
477-
// TODO we don't apply leading on floats, this somewhat noticeable when huge line-height in html is used
478-
runTest("floatImage12Test", "diffImages12_");
479-
}
480-
481-
@Test
482-
public void floatImage13Test() throws IOException, InterruptedException {
483-
// TODO we don't apply leading on floats, this somewhat noticeable when huge line-height in html is used
484-
runTest("floatImage13Test", "diffImages13_");
485-
}
486-
487442
@Test
488443
@Ignore("DEVSIX-1316")
489444
public void floatImage14Test() throws IOException, InterruptedException {
490445
runTest("floatImage14Test", "diffImages14_");
491446
}
492447

493-
@Test
494-
public void floatInline01Test() throws IOException, InterruptedException {
495-
runTest("floatInline01Test", "diffImages01_");
496-
}
497-
498-
@Test
499-
public void floatInline02Test() throws IOException, InterruptedException {
500-
runTest("floatInline02Test", "diffImages02_");
501-
}
502-
503-
@Test
504-
public void floatInline03Test() throws IOException, InterruptedException {
505-
runTest("floatInline03Test", "diffImages03_");
506-
}
507-
508-
@Test
509-
public void floatInline04Test() throws IOException, InterruptedException {
510-
runTest("floatInline04Test", "diffImages04_");
511-
}
512-
513-
@Test
514-
public void floatInline05Test() throws IOException, InterruptedException {
515-
runTest("floatInline05Test", "diffImages05_");
516-
}
517-
518-
@Test
519-
public void floatInline06Test() throws IOException, InterruptedException {
520-
runTest("floatInline06Test", "diffImages06_");
521-
}
522-
523-
@Test
524-
public void floatInline07Test() throws IOException, InterruptedException {
525-
runTest("floatInline07Test", "diffImages07_");
526-
}
527-
528-
@Test
529-
public void floatInline08Test() throws IOException, InterruptedException {
530-
runTest("floatInline08Test", "diffImages08_");
531-
}
532-
533448
@Test
534449
public void floatInline09Test() throws IOException, InterruptedException {
535450
// TODO DEVSIX-1269
536451
runTest("floatInline09Test", "diffImages09_");
537452
}
538453

539-
@Test
540-
public void floatInline10Test() throws IOException, InterruptedException {
541-
runTest("floatInline10Test", "diffImages10_");
542-
}
543-
544-
@Test
545-
public void floatInline11Test() throws IOException, InterruptedException {
546-
runTest("floatInline11Test", "diffImages11_");
547-
}
548-
549-
@Test
550-
public void floatInline12Test() throws IOException, InterruptedException {
551-
runTest("floatInline12Test", "diffImages12_");
552-
}
553-
554-
@Test
555-
public void floatInline13Test() throws IOException, InterruptedException {
556-
runTest("floatInline13Test", "diffImages13_");
557-
}
558-
559-
@Test
560-
public void floatInline14Test() throws IOException, InterruptedException {
561-
runTest("floatInline14Test", "diffImages14_");
562-
}
563-
564-
@Test
565-
public void floatInline15Test() throws IOException, InterruptedException {
566-
// TODO another difference concerning nested spans processing
567-
runTest("floatInline15Test", "diffImages15_");
568-
}
569-
570-
@Test
571-
public void floatInline16Test() throws IOException, InterruptedException {
572-
runTest("floatInline16Test", "diffImages16_");
573-
}
574-
575454
@Test
576455
public void floatInline17Test() throws IOException, InterruptedException {
577456
runTest("floatInline17Test", "diffImages17_");
@@ -587,9 +466,6 @@ private void runTest(String testName, String diff) throws IOException, Interrupt
587466

588467
@Test
589468
public void responsiveIText() throws IOException, InterruptedException {
590-
// TODO results to be reviewed after floating elements splitting support (DEVSIX-1267)
591-
// Split floating element parent has zero height (and therefore border is not drawn around it),
592-
// even though :after { clear: both} feature is applied in html.
593469
PageSize[] pageSizes = {
594470
null,
595471
new PageSize(PageSize.A3.getHeight(), PageSize.A4.getHeight()),
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)