On Tue, 14 Feb 2023 23:02:16 GMT, Damon Nguyen <dngu...@openjdk.org> wrote:
>> Previous fix to HTML in AquaButtonUI fixed spacing issue for HTML images in >> a JButton in Aqua L&F. The new issue comes from having text inside the HTML >> as the button's text. If an icon is used, this icon exceeds the bounds of >> the button and overlaps the border. >> >> Added additional logic to check if HTML contains an img. If so, apply the >> previous fix. Otherwise, the original implementation for Aqua's JButton HTML >> layout works correctly, so use this behavior. >> >> Added a test based on the provided test in the bug report. Automated the >> test using a BufferedImage and changed the icon color to RED. Tested with >> multiple runs on Aqua L&F, and the test passes with the update where it >> fails without the update. > > Damon Nguyen has updated the pull request incrementally with one additional > commit since the last revision: > > Add instanceof check Changes requested by swi...@github.com (no known OpenJDK username). src/java.desktop/macosx/classes/com/apple/laf/AquaButtonUI.java line 344: > 342: final View v = (View)c.getClientProperty(BasicHTML.propertyKey); > 343: if (v != null && c instanceof AbstractButton > 344: && ((AbstractButton) c).getIcon() == null) { We already know for certain that `c` is an AbstractButton. The first thing in the paint call, the component is casted. Why cast again when we can reuse the variable: Suggestion: if (v != null && b.getIcon() == null) { (also on ln 309 we could do the same thing) ------------- PR: https://git.openjdk.org/jdk/pull/12520