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

HTML content rendering issues #561

Closed
mgarin opened this issue Oct 14, 2019 · 2 comments
Closed

HTML content rendering issues #561

mgarin opened this issue Oct 14, 2019 · 2 comments
Assignees

Comments

@mgarin
Copy link
Owner

mgarin commented Oct 14, 2019

@Sciss Found an interesting issue with <hr> and <i> rendering in HTML content, quote:

I'm seeing an exception when using horizontal-rule <hr> in label that uses HTML:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.text.html.HRuleView.paint(HRuleView.java:148)
    at javax.swing.text.BoxView.paintChild(BoxView.java:161)
    at javax.swing.text.BoxView.paint(BoxView.java:433)
    at javax.swing.text.BoxView.paintChild(BoxView.java:161)
    at javax.swing.text.BoxView.paint(BoxView.java:433)
    at javax.swing.text.ParagraphView.paint(ParagraphView.java:580)
    at javax.swing.text.html.ParagraphView.paint(ParagraphView.java:233)
    at javax.swing.text.BoxView.paintChild(BoxView.java:161)
    at javax.swing.text.BoxView.paint(BoxView.java:433)
    at javax.swing.text.html.BlockView.paint(BlockView.java:282)
    at javax.swing.text.BoxView.paintChild(BoxView.java:161)
    at javax.swing.text.BoxView.paint(BoxView.java:433)
    at javax.swing.text.html.BlockView.paint(BlockView.java:282)
    at javax.swing.text.BoxView.paintChild(BoxView.java:161)
    at javax.swing.text.BoxView.paint(BoxView.java:433)
    at javax.swing.text.html.BlockView.paint(BlockView.java:282)
    at com.alee.utils.swing.BasicHTML$Renderer.paint(BasicHTML.java:544)
    at com.alee.painter.decoration.content.AbstractTextContent.paintHtml(AbstractTextContent.java:501)
    at com.alee.painter.decoration.content.AbstractTextContent.paintContent(AbstractTextContent.java:468)
    at com.alee.painter.decoration.content.AbstractContent.paint(AbstractContent.java:342)
    at com.alee.painter.decoration.layout.AbstractContentLayout.paintContent(AbstractContentLayout.java:265)
    at com.alee.painter.decoration.content.AbstractContent.paint(AbstractContent.java:342)
    at com.alee.painter.decoration.ContentDecoration.paintContent(ContentDecoration.java:157)
    at com.alee.painter.decoration.WebDecoration.paint(WebDecoration.java:417)
    at com.alee.painter.decoration.AbstractDecorationPainter.paint(AbstractDecorationPainter.java:1367)
    at com.alee.laf.label.WebLabelUI.paint(WebLabelUI.java:172)
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
    at javax.swing.JComponent.paintComponent(JComponent.java:780)

If I remove the <hr> in the label text, the error disappears, so I suspect that it's the cause of the problem somehow. Doesn't happen with Metal LaF.

      val html =
        s"""<html><center>
           |<font size=+1><b>About BLA</b></font><p>
           |<p>&nbsp;<p><hr>
           |<i>Foo<i>
           |""".stripMargin
      val lb = new javax.swing.JLabel(html)

Also element doesn't have effect (no italics rendering)

@mgarin mgarin added this to the v1.2.11 milestone Oct 14, 2019
@mgarin mgarin self-assigned this Oct 14, 2019
@mgarin
Copy link
Owner Author

mgarin commented Oct 14, 2019

I've managed to confirm <hr> issue, but <i> works correctly for me.
I'll push fix for <hr> soon along with other fixes and improvements.

mgarin added a commit that referenced this issue Oct 14, 2019
- BasicHTML.java - Fixed NPEs and rendering issues for `<hr>` and possibly some other HTML elements
@mgarin
Copy link
Owner Author

mgarin commented Oct 14, 2019

Problem was in BasicHTML class replacement within WebLaF.

BasicHTML replacement was originally added to fix HTML content foreground issues ( #420 ) and host property of the Renderer view subclass was omitted. Hard to say whether it was intentional or not. Either way it doesn't cause issues described in #420 and fixes current issues so it was either an error or an optimization that didn't work out well.

There is also a possibility that foreground issue described in #420 was related to non-UIResource colors that were provided from the style back then or some missing L&F defaults.

@mgarin mgarin closed this as completed Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant