Skip to content

Commit a550e5e

Browse files
committed
8350149: VBox ignores bias of child controls when fillWidth is set to false
Reviewed-by: angorya, kcr
1 parent fd099a7 commit a550e5e

File tree

12 files changed

+949
-180
lines changed

12 files changed

+949
-180
lines changed

modules/javafx.graphics/src/main/java/javafx/scene/layout/AnchorPane.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private double computeHeight(final boolean minimum, final double width) {
331331
childWidth = computeChildWidth(child, getSnappedLeftAnchor(child), getSnappedRightAnchor(child), contentWidth, -1);
332332
}
333333
max = Math.max(max, top + (minimum && topAnchor != null && bottomAnchor != null?
334-
child.minHeight(childWidth) : computeChildPrefAreaHeight(child, -1, null, childWidth)) + bottom);
334+
child.minHeight(childWidth) : computeChildPrefAreaHeight(child, -1, null, childWidth, true)) + bottom);
335335
}
336336

337337
return snappedTopInset() + max + snappedBottomInset();
@@ -348,7 +348,7 @@ private double computeChildHeight(Node child, Double topAnchor, Double bottomAnc
348348
if (topAnchor != null && bottomAnchor != null && child.isResizable()) {
349349
return areaHeight - snappedTopInset() - snappedBottomInset() - topAnchor - bottomAnchor;
350350
}
351-
return computeChildPrefAreaHeight(child, -1, Insets.EMPTY, width);
351+
return computeChildPrefAreaHeight(child, -1, Insets.EMPTY, width, true);
352352
}
353353

354354
@Override protected void layoutChildren() {

modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderPane.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ private double getAreaWidth(Node child, double height, boolean minimum) {
626626
private double getAreaHeight(Node child, double width, boolean minimum) {
627627
if (child != null && child.isManaged()) {
628628
Insets margin = getNodeMargin(child);
629-
return minimum ? computeChildMinAreaHeight(child, -1, margin, width):
630-
computeChildPrefAreaHeight(child, -1, margin, width);
629+
return minimum ? computeChildMinAreaHeight(child, -1, margin, width, false):
630+
computeChildPrefAreaHeight(child, -1, margin, width, false);
631631
}
632632
return 0;
633633
}

modules/javafx.graphics/src/main/java/javafx/scene/layout/GridPane.java

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,13 @@ private CompositeSize computePrefHeights(double[] widths) {
14471447
Node child = managed.get(i);
14481448
int start = getNodeRowIndex(child);
14491449
int end = getNodeRowEndConvertRemaining(child);
1450-
double childPrefAreaHeight = computeChildPrefAreaHeight(child, isNodePositionedByBaseline(child) ? rowPrefBaselineComplement[start] : -1, getMargin(child),
1451-
widths == null ? -1 : getTotalWidthOfNodeColumns(child, widths));
1450+
double childPrefAreaHeight = computeChildPrefAreaHeight(
1451+
child,
1452+
isNodePositionedByBaseline(child) ? rowPrefBaselineComplement[start] : -1,
1453+
getMargin(child),
1454+
widths == null ? -1 : getTotalWidthOfNodeColumns(child, widths),
1455+
false
1456+
);
14521457
if (start == end && !result.isPreset(start)) {
14531458
double min = getRowMinHeight(start);
14541459
double max = getRowMaxHeight(start);
@@ -1490,8 +1495,13 @@ private CompositeSize computeMinHeights(double[] widths) {
14901495
Node child = managed.get(i);
14911496
int start = getNodeRowIndex(child);
14921497
int end = getNodeRowEndConvertRemaining(child);
1493-
double childMinAreaHeight = computeChildMinAreaHeight(child, isNodePositionedByBaseline(child) ? rowMinBaselineComplement[start] : -1, getMargin(child),
1494-
widths == null ? -1 : getTotalWidthOfNodeColumns(child, widths));
1498+
double childMinAreaHeight = computeChildMinAreaHeight(
1499+
child,
1500+
isNodePositionedByBaseline(child) ? rowMinBaselineComplement[start] : -1,
1501+
getMargin(child),
1502+
widths == null ? -1 : getTotalWidthOfNodeColumns(child, widths),
1503+
false
1504+
);
14951505
if (start == end && !result.isPreset(start)) {
14961506
result.setMaxSize(start, childMinAreaHeight);
14971507
} else if (start != end){
@@ -1581,17 +1591,20 @@ private CompositeSize computePrefWidths(double[] heights) {
15811591
Node child = managed.get(i);
15821592
int start = getNodeColumnIndex(child);
15831593
int end = getNodeColumnEndConvertRemaining(child);
1594+
double childPrefAreaWidth = computeChildPrefAreaWidth(
1595+
child,
1596+
getBaselineComplementForChild(child),
1597+
getMargin(child),
1598+
heights == null ? -1 : getTotalHeightOfNodeRows(child, heights),
1599+
false
1600+
);
15841601
if (start == end && !result.isPreset(start)) {
15851602
double min = getColumnMinWidth(start);
15861603
double max = getColumnMaxWidth(start);
1587-
result.setMaxSize(start, boundedSize(min < 0 ? 0 : min, computeChildPrefAreaWidth(child,
1588-
getBaselineComplementForChild(child), getMargin(child),
1589-
heights == null ? -1 : getTotalHeightOfNodeRows(child, heights), false),
1604+
result.setMaxSize(start, boundedSize(min < 0 ? 0 : min, childPrefAreaWidth,
15901605
max < 0 ? Double.MAX_VALUE : max));
15911606
} else if (start != end) {
1592-
result.setMaxMultiSize(start, end + 1, computeChildPrefAreaWidth(child, getBaselineComplementForChild(child),
1593-
getMargin(child),
1594-
heights == null ? -1 : getTotalHeightOfNodeRows(child, heights), false));
1607+
result.setMaxMultiSize(start, end + 1, childPrefAreaWidth);
15951608
}
15961609
}
15971610
return result;
@@ -1627,14 +1640,17 @@ private CompositeSize computeMinWidths(double[] heights) {
16271640
Node child = managed.get(i);
16281641
int start = getNodeColumnIndex(child);
16291642
int end = getNodeColumnEndConvertRemaining(child);
1643+
double childMinAreaWidth = computeChildMinAreaWidth(
1644+
child,
1645+
getBaselineComplementForChild(child),
1646+
getMargin(child),
1647+
heights == null ? -1 : getTotalHeightOfNodeRows(child, heights),
1648+
false
1649+
);
16301650
if (start == end && !result.isPreset(start)) {
1631-
result.setMaxSize(start, computeChildMinAreaWidth(child, getBaselineComplementForChild(child),
1632-
getMargin(child),
1633-
heights == null ? -1 : getTotalHeightOfNodeRows(child, heights),false));
1651+
result.setMaxSize(start, childMinAreaWidth);
16341652
} else if (start != end){
1635-
result.setMaxMultiSize(start, end + 1, computeChildMinAreaWidth(child, getBaselineComplementForChild(child),
1636-
getMargin(child),
1637-
heights == null ? -1 : getTotalHeightOfNodeRows(child, heights), false));
1653+
result.setMaxMultiSize(start, end + 1, childMinAreaWidth);
16381654
}
16391655
}
16401656
return result;

modules/javafx.graphics/src/main/java/javafx/scene/layout/HBox.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ private boolean shouldFillHeight() {
417417
if (width != -1 && getContentBias() != null) {
418418
double prefWidths[][] = getAreaWidths(managed, -1, false);
419419
adjustAreaWidths(managed, prefWidths, width, -1);
420-
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, prefWidths[0], getAlignmentInternal().getVpos());
420+
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, prefWidths[0], false, getAlignmentInternal().getVpos());
421421
} else {
422422
contentHeight = computeMaxMinAreaHeight(managed, marginAccessor, getAlignmentInternal().getVpos());
423423
}
@@ -440,7 +440,7 @@ private boolean shouldFillHeight() {
440440
if (width != -1 && getContentBias() != null) {
441441
double prefWidths[][] = getAreaWidths(managed, -1, false);
442442
adjustAreaWidths(managed, prefWidths, width, -1);
443-
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, prefWidths[0], getAlignmentInternal().getVpos());
443+
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, prefWidths[0], false, getAlignmentInternal().getVpos());
444444
} else {
445445
contentHeight = computeMaxPrefAreaHeight(managed, marginAccessor, getAlignmentInternal().getVpos());
446446
}

0 commit comments

Comments
 (0)