On Thu, 26 Jun 2025 11:33:15 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request with a new target base due 
>> to a merge or a rebase. The incremental webrev excludes the unrelated 
>> changes brought in by the merge/rebase. The pull request contains 33 
>> additional commits since the last revision:
>> 
>>  - Merge branch 'master' of https://git.openjdk.java.net/jdk into JDK-8348760
>>  - Windows 10 offset correction without icon
>>  - Fix issue for presence of gap between buller and text only if atleast 1 
>> menuitem has imageicon
>>  - Text alignment fix
>>  - Merge branch 'master' of https://git.openjdk.java.net/jdk into JDK-8348760
>>  - Review comments fix
>>  - Expand wildcard imports
>>  - Remove unneeded methods
>>  - Merge branch 'master' of https://git.openjdk.java.net/jdk into JDK-8348760
>>  - Code duplication removed
>>  - ... and 23 more: https://git.openjdk.org/jdk/compare/30e97b8d...ea1016fc
>
> src/java.desktop/share/classes/com/sun/java/swing/SwingUtilities3.java line 
> 163:
> 
>> 161:             rect.y += insets.top;
>> 162:             rect.width -= (insets.right + rect.x);
>> 163:             rect.height -= (insets.bottom + rect.y);
> 
> Suggestion:
> 
>             rect.width -= (insets.right + insets.left);
>             rect.height -= (insets.bottom + insets.top);
> 
> The formula doesn't look right. Why do you subtract `rect.x` and `rect.y` 
> instead of `insets.left` and `insets.top`?
> 
> This would work correctly if both `rect.x` and `rect.y` are zero, but it 
> would give wrong results in other cases.

It was the same calculation used in `BasicMenuItemUI `which is now moved to 
`SwingUtilities3 `so that it can be called from Basic and `WindowsMenuItemUI 
`to avoid code duplication....you can compare the contents before the 
fix.....in this specific case, `rect.x` is inclusive of `insets.left`..

Similarly other SwingUtilities3 changes are also as it was in BasicMenuItemUI, 
it was just moved verbatim from BasicMenuItemUI to it so that it can be called 
from both Basic and WindowsMenuItemUI class with no changes..nothing more and 
nothing less...probably it can be optimized but I wanted to keep the call and 
the content in each method in SwingUtilities3 same as it was in BasicMenuItemUI

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23324#discussion_r2174091099

Reply via email to