<Swing Dev> RFR: 8257664: HTMLEditorKit: Wrong CSS relative font sizes

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Fri Jan 15 09:42:07 UTC 2021


On Sun, 13 Dec 2020 14:51:47 GMT, Stanimir Stamenkov <github.com+1247730+stanio at openjdk.org> wrote:

> Fix for [JDK-8257664][] – HTMLEditorKit: Wrong CSS relative font sizes.
> 
> _Disclaimer:_ I'm the reporter of the issue and I've been advised the best chance to get it addressed is to submit a pull request against this repository.  I haven't built the JDK myself, I'll need guidance if required.  I have a proof-of-concept example – demonstrating the bug and a workaround available as a [public gist](https://gist.github.com/stanio/b79ce9348946aa6b3395328ec4c59d14).  I have included a sample test though I don't know if it is annotated properly.
> 
> **Current behavior**
> 
> <style>
>   h2, .h2 { font-size: 150% }
> </style>
> 
> <body>
> 
>   <h2>Foo</h2>            
> 
>   <div class=h2>Bar</div> 
> 
>   <ol class=h2>           
>     <li>Baz</li>          
>   </ol>
> 
>   <table class=h2>
>     <tr>
>       <td>Qux</td>        
>     </tr>
>   </table>
> 
> </body>
> 
> **Expected behavior**
> 
> All text should be displayed with a font size of the computed `<body>` font-size × 1.5.
> 
> [JDK-8257664]: https://bugs.openjdk.java.net/browse/JDK-8257664

test/jdk/javax/swing/text/html/StyleSheet/bug8257665.java line 4:

> 2:  * <Copyright>
> 3:  */
> 4: 

You can copy the copyright from any of the test present in this directory, just change the year to 2021

test/jdk/javax/swing/text/html/StyleSheet/bug8257665.java line 14:

> 12: /*
> 13:  * @test
> 14:  * @key headless

No need to specify headless tag. If it's not @key headful, then it is implicitly headless

test/jdk/javax/swing/text/html/StyleSheet/bug8257665.java line 17:

> 15:  * @bug 8257665
> 16:  * @summary  Tests inherited font-size with parent percentage specification.
> 17:  * @run main bug8257665

We normally dont use bugid as name for the test. You probably can name it TestWrongCSSFontSize.java

src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java line 3423:

> 3421:      */
> 3422:     static final Object FONT_SIZE_INHERIT =
> 3423:             new CSS().new FontSize().parseCssValue("100%");

Do we need to instantiate new CSS object here? Can't we reuse "css" variable which is already initialized?

-------------

PR: https://git.openjdk.java.net/jdk/pull/1759


More information about the swing-dev mailing list