eclipse-windowbuilder / windowbuilder

Eclipse Windowbuilder
https://projects.eclipse.org/projects/tools.windowbuilder
Eclipse Public License 1.0
78 stars 30 forks source link

HTML Tooltip not shown on Linux #842

Closed ptziegler closed 1 month ago

ptziegler commented 1 month ago

Hovering over a palette item is supposed to show the tooltip from within a Browser widget. This tooltip doesn't show up on Linux.

image

Cause seems to be that the following listener is never notified: https://github.com/eclipse-windowbuilder/windowbuilder/blob/de5b02465e1b7b00b67da3e54e5ed9b0e687ba93/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/HtmlTooltipHelper.java#L158-L165

ptziegler commented 1 month ago

This SWT snippet uses a similar mechanism which does receive the events, making this very likely a WindowBuilder issue.

ptziegler commented 1 month ago

As one should, we simply suppress any and all exceptions that are thrown by the Java runtime. This NPE is thrown when calculating the bounds of the HTML document...

java.lang.NullPointerException: Cannot invoke "java.lang.Number.intValue()" because "o" is null
    at org.eclipse.wb.internal.core.model.property.table.HtmlTooltipHelper.evaluateScriptInt(HtmlTooltipHelper.java:256)
    at org.eclipse.wb.internal.core.model.property.table.HtmlTooltipHelper.getContentOffsetHeight(HtmlTooltipHelper.java:239)
    at org.eclipse.wb.internal.core.model.property.table.HtmlTooltipHelper.expandShellToShowFullPage_Height(HtmlTooltipHelper.java:199)
    at org.eclipse.wb.internal.core.model.property.table.HtmlTooltipHelper.tweakBrowserSize(HtmlTooltipHelper.java:189)
    at org.eclipse.wb.internal.core.model.property.table.HtmlTooltipHelper$2.changed(HtmlTooltipHelper.java:161)
ptziegler commented 1 month ago

The problem is caused by this listener here, especially line 131. For whatever reason, a "location" event is fired while the browser is constructed. Because this listener disposes the whole shell, the browser is closed before it's done, leading to this weird behavior.

https://github.com/eclipse-windowbuilder/windowbuilder/blob/ce36bdb3e59723053fde24ca3166fc65353a3b85/org.eclipse.wb.core/src/org/eclipse/wb/internal/core/model/property/table/HtmlTooltipHelper.java#L127-L142

After the listener has been commented out, the tooltip is shown correctly again:

image