<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Iosevka Fixed SS16";
        panose-1:2 0 5 9 3 0 0 0 0 4;}
@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Iosevka Fixed SS16";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Thank you John, I think it's the right approach.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">We probably should also look at the other containers to make sure all of them snap properly.  This is a problem especially visible on Windows at fractional scales.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of John Hendrikx <john.hendrikx@gmail.com><br>
<b>Date: </b>Wednesday, February 5, 2025 at 10:20<br>
<b>To: </b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Duplication in HBox/VBox<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Hi list,<br>
<br>
I wish to address the huge amount of duplication in HBox/VBox as it is<br>
error prone when doing modifications there.  I'm in the process of<br>
fixing these classes so that they no longer layout their children<br>
off-by-one-pixel on render scales other than 1 (they will often not<br>
fully fill the box, missing 1 pixel, due to rounding errors or incorrect<br>
snapping of values).<br>
<br>
There's two thing I want to do:<br>
<br>
- Make it clear which values are snapped, raw or near-snapped by using<br>
prefixes "raw", "snapped" and "near" in variables and method names. <br>
Much of the code incorrectly assumes that adding, subtracting or<br>
multiplying two snapped values results in a snapped value.  This is not<br>
true, it is only a nearly snapped value; it must be resnapped if<br>
returned.  By meticulously tracking what is snapped, almost snapped and<br>
raw it is easier to call snap functions only when needed.  This is<br>
mostly renaming of variables.  There are numerous small problems in<br>
these classes (and probably other classes) where values are not<br>
resnapped after floating point calculations.<br>
<br>
- Deduplicate much of the code (I suspect 80-90%) by introducing a<br>
package private class AbstractBox, which holds the duplicated code.<br>
<br>
Since I dislike doing the same work twice, I did some research, and<br>
introducing a package private superclass is a binary compatible change,<br>
even if duplicated public methods are moved to AbstractBox.<br>
<br>
Javadoc will also handle this correctly and will completely hide<br>
AbstractBox; public methods in AbstractBox will show up in HBox/VBox<br>
documentation, and HBox/VBox will be said to extend Pane still.<br>
<br>
An example of this pattern is AbstractStringBuilder, a package private<br>
class from which StringBuilder and StringBuffer inherit. At the time<br>
this was a binary compatible change when StringBuilder was introduced. <br>
By looking at the Javadoc, you can't see it is there<br>
(<a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/StringBuilder.html">https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/StringBuilder.html</a>)<br>
and even its public methods are show as being part of StringBuilder or<br>
StringBuffer directly.<br>
<br>
Let me know what you think.<br>
<br>
--John<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>