diff --git a/README.md b/README.md index b4b74053d..02b99c2fc 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ from ````/openhtmltopdf-examples/src/main/java/com/openhtmltopdf/testcases/Testc ## CHANGELOG ### head - 1.0.1-SNAPSHOT ++ [#396](https://github.com/danfickle/openhtmltopdf/issues/396) Much faster rendering of boxes using border-radius properties. Thanks @mndzielski. + [#400](https://github.com/danfickle/openhtmltopdf/pull/400) Support for `lang` and `title` attrbiutes and `abbr` tag for accessible PDFs. Thanks @Ignaciort91. ### 1.0.0 (2019-July-23) diff --git a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/AbstractOutputDevice.java b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/AbstractOutputDevice.java index 835114548..d15fe8e65 100644 --- a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/AbstractOutputDevice.java +++ b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/AbstractOutputDevice.java @@ -247,7 +247,12 @@ private void paintBackground0( return; } - Area borderBounds = new Area(BorderPainter.generateBorderBounds(backgroundBounds, border, true)); + Shape borderBoundsShape = BorderPainter.generateBorderBounds(backgroundBounds, border, true); + + // FIXME for issue 396 - generating an Area for a shape with curves is very very slow and + // memory intensive. However, not generating an area for simple squares breaks many tests. + // Therefore, for now, we just don't use an area if there are border radii present. + Area borderBounds = border.hasBorderRadius() && c.isFastRenderer() ? null : new Area(borderBoundsShape); Shape oldclip = null; @@ -259,12 +264,12 @@ private void paintBackground0( } setClip(borderBounds); } else if (backgroundImage != null) { - pushClip(borderBounds); + pushClip(borderBounds != null ? borderBounds : borderBoundsShape); } if (backgroundColor != null && backgroundColor != FSRGBColor.TRANSPARENT) { setColor(backgroundColor); - fill(borderBounds); + fill(borderBounds != null ? borderBounds : borderBoundsShape); } if (backgroundImage != null) { diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/expected/border-radius.pdf b/openhtmltopdf-examples/src/main/resources/visualtest/expected/border-radius.pdf new file mode 100644 index 000000000..063529239 Binary files /dev/null and b/openhtmltopdf-examples/src/main/resources/visualtest/expected/border-radius.pdf differ diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/html/border-radius.html b/openhtmltopdf-examples/src/main/resources/visualtest/html/border-radius.html new file mode 100644 index 000000000..d70be1283 --- /dev/null +++ b/openhtmltopdf-examples/src/main/resources/visualtest/html/border-radius.html @@ -0,0 +1,44 @@ + +
+ + + + + + + + + diff --git a/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java b/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java index c8f80f0d6..20b45b5e9 100644 --- a/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java +++ b/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java @@ -883,6 +883,14 @@ public void testFloatClearBoth() throws IOException { assertTrue(vt.runTest("float-clear-both")); } + /** + * Tests that border radii work. Issue 396. + */ + @Test + public void testBorderRadius() throws IOException { + assertTrue(vt.runTest("border-radius")); + } + // TODO: // + Elements that appear just on generated overflow pages. // + content property (page counters, etc)