RFR: 8280020: Underline and line-through not straight in WebView [v5]

Kevin Rushforth kcr at openjdk.java.net
Mon Feb 28 15:20:54 UTC 2022


On Sun, 27 Feb 2022 07:10:25 GMT, Jay Bhaskar <duke at openjdk.java.net> wrote:

>> Issue: The end point of  line in drawLinesForText , add thickness to the endPoint.y(). In this case origin which is start point and the end point would not be same, and line would be drawn not straight.
>> Solution: Do not add thickness to the y position of end point of line.
>> Start Point(x,y) ----------End Point(x + width, 0)
>
> Jay Bhaskar has updated the pull request incrementally with one additional commit since the last revision:
> 
>   New chnages for line test

The cleaned up test looks much better. I'll test it on Mac and Windows. I left a few additional comments.

tests/system/src/test/java/test/javafx/scene/web/StraightLineTest.java line 57:

> 55:     private static final CountDownLatch launchLatch = new CountDownLatch(1);
> 56:     private static final int LINE_THICKNESS = 20;
> 57:     private static final int SKIP_TEXT_BOUNDARY = 32;

What does this constant represent?

tests/system/src/test/java/test/javafx/scene/web/StraightLineTest.java line 166:

> 164:             int start_y = (int)webView.getEngine().executeScript("document.getElementsByTagName('div')[0].getBoundingClientRect().y");
> 165:             int height = (int)webView.getEngine().executeScript("document.getElementsByTagName('div')[0].getBoundingClientRect().height");
> 166:             int width = (int)webView.getEngine().executeScript("document.getElementsByTagName('div')[0].getBoundingClientRect().width");

Minor: I recommend switching `width` and `height` to match the order of `x` and `y`.

tests/system/src/test/java/test/javafx/scene/web/StraightLineTest.java line 168:

> 166:             int width = (int)webView.getEngine().executeScript("document.getElementsByTagName('div')[0].getBoundingClientRect().width");
> 167: 
> 168:             int line_start_x = start_x;

You might want to add a small amount (`DELTA`?) to avoid sampling at the edge.

tests/system/src/test/java/test/javafx/scene/web/StraightLineTest.java line 173:

> 171:             String line_color = "rgba(0,0,0,255)"; // color of line
> 172:             System.out.println(line_end_x);
> 173:             System.out.println(line_start_y);

Once you are done debugging the test, you can remove these print statements.

tests/system/src/test/java/test/javafx/scene/web/StraightLineTest.java line 177:

> 175:             for (int x = line_start_x; x < line_end_x; x++) {
> 176:                 String color = colorToString(pr.getColor(x, line_start_y));
> 177:                 assertEquals(color, line_color);

The arguments are backwards (the expected value goes first).

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

PR: https://git.openjdk.java.net/jfx/pull/731


More information about the openjfx-dev mailing list