diff --git a/CHANGELOG.md b/CHANGELOG.md index db0ed487..c242393c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ FlatLaf Change Log ================== +## 3.5.3-SNAPSHOT + +#### Fixed bugs + +- HTML: Fixed wrong rendering if HTML text contains `" + bodyInBody + "", bodyPlain ); + testHtmlBaseSize( "${BASE_SIZE}

header1

" + body + "", "header1\n" + bodyPlain ); + + testHtmlBaseSize( "${BASE_SIZE}" + bodyInBody + "", bodyPlain ); + testHtmlBaseSize( "${BASE_SIZE}

header1

" + body + "", "header1\n" + bodyPlain ); + } + + private void testHtmlBaseSize( String html, String expectedPlain ) { + testHtmlBaseSizeImpl( html, expectedPlain ); + testHtmlBaseSizeImpl( html.toUpperCase( Locale.ENGLISH ), expectedPlain.toUpperCase( Locale.ENGLISH ) ); + } + + private void testHtmlBaseSizeImpl( String html, String expectedPlain ) { + String baseSize = ""; + String baseSizeInHead = "" + baseSize + ""; + + String expectedHtml = html.replace( "${BASE_SIZE}", baseSize ).replace( "${BASE_SIZE_IN_HEAD}", baseSizeInHead ); + html = html.replace( "${BASE_SIZE}", "" ).replace( "${BASE_SIZE_IN_HEAD}", "" ); + + testHtml( html, expectedHtml, expectedPlain ); + } + + private void testHtml( String html, String expectedHtml, String expectedPlain ) { + FlatHTML.testUpdateRenderer = (c, newHtml) -> { + assertEquals( expectedHtml, newHtml ); + assertEquals( expectedPlain, getPlainText( c ) ); + }; + new JLabel( html ); + FlatHTML.testUpdateRenderer = null; + } + + private String getPlainText( JComponent c ) { + View view = (View) c.getClientProperty( BasicHTML.propertyKey ); + if( view == null ) + return null; + + Document doc = view.getDocument(); + try { + return doc.getText( 0, doc.getLength() ).trim(); + } catch( BadLocationException ex ) { + ex.printStackTrace(); + return null; + } + } +} diff --git a/gradle.properties b/gradle.properties index 45d95dee..3dbb0b31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ # flatlaf.releaseVersion = 3.5.2 -flatlaf.developmentVersion = 3.6-SNAPSHOT +flatlaf.developmentVersion = 3.5.3-SNAPSHOT org.gradle.parallel = true # org.gradle.warning.mode = all