Skip to content

Commit bf76ed2

Browse files
committed
8370652: Control and ScrollPaneSkin should snap computed width/height values to prevent scrollbars appearing due to rounding errors
Reviewed-by: angorya, kcr
1 parent 200b01f commit bf76ed2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

modules/javafx.controls/src/main/java/javafx/scene/control/Control.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ protected Control() {
607607
if (skinBase != null) {
608608
final double x = snappedLeftInset();
609609
final double y = snappedTopInset();
610-
final double w = snapSizeX(getWidth()) - x - snappedRightInset();
611-
final double h = snapSizeY(getHeight()) - y - snappedBottomInset();
610+
final double w = snapSpaceX(snapSizeX(getWidth()) - x - snappedRightInset());
611+
final double h = snapSpaceY(snapSizeY(getHeight()) - y - snappedBottomInset());
612612
skinBase.layoutChildren(x, y, w, h);
613613
} else {
614614
Node n = getSkinNode();

modules/javafx.controls/src/main/java/javafx/scene/control/skin/ScrollPaneSkin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,10 @@ public final ScrollBar getVerticalScrollBar() {
423423
double minWidth = vsbWidth + snappedLeftInset() + snappedRightInset();
424424

425425
if (sp.getPrefViewportWidth() > 0) {
426-
return (sp.getPrefViewportWidth() + minWidth);
426+
return snapSpaceX(sp.getPrefViewportWidth() + minWidth);
427427
}
428428
else if (sp.getContent() != null) {
429-
return (sp.getContent().prefWidth(height) + minWidth);
429+
return snapSpaceX(sp.getContent().prefWidth(height) + minWidth);
430430
}
431431
else {
432432
return Math.max(minWidth, DEFAULT_PREF_SIZE);
@@ -441,10 +441,10 @@ else if (sp.getContent() != null) {
441441
double minHeight = hsbHeight + snappedTopInset() + snappedBottomInset();
442442

443443
if (sp.getPrefViewportHeight() > 0) {
444-
return (sp.getPrefViewportHeight() + minHeight);
444+
return snapSpaceY(sp.getPrefViewportHeight() + minHeight);
445445
}
446446
else if (sp.getContent() != null) {
447-
return (sp.getContent().prefHeight(width) + minHeight);
447+
return snapSpaceY(sp.getContent().prefHeight(width) + minHeight);
448448
}
449449
else {
450450
return Math.max(minHeight, DEFAULT_PREF_SIZE);
@@ -459,7 +459,7 @@ else if (sp.getContent() != null) {
459459
double minWidth = vsbWidth + snappedLeftInset() + snappedRightInset();
460460

461461
if (sp.getMinViewportWidth() > 0) {
462-
return (sp.getMinViewportWidth() + minWidth);
462+
return snapSpaceX(sp.getMinViewportWidth() + minWidth);
463463
} else {
464464
double w = corner.minWidth(-1);
465465
return (w > 0) ? (3 * w) : (DEFAULT_MIN_SIZE);
@@ -475,7 +475,7 @@ else if (sp.getContent() != null) {
475475
double minHeight = hsbHeight + snappedTopInset() + snappedBottomInset();
476476

477477
if (sp.getMinViewportHeight() > 0) {
478-
return (sp.getMinViewportHeight() + minHeight);
478+
return snapSpaceY(sp.getMinViewportHeight() + minHeight);
479479
} else {
480480
double h = corner.minHeight(-1);
481481
return (h > 0) ? (3 * h) : (DEFAULT_MIN_SIZE);

0 commit comments

Comments
 (0)