-
Bug
-
Resolution: Unresolved
-
P3
-
jfx25
Regression caused by https://bugs.openjdk.org/browse/JDK-8350149
In Region several height calculations functions were altered to match the behavior and options of their horizontal counterparts to solve discrepancies between the behavior of vertical biased layouts and horizontal biased layouts, which other than their axis, should behave identical.
The height calculations would take a width provided by the caller, but if unavailable (set to -1) and the child was biased, it would just automatically query the child's preferred width and use that as the dependent width.
In contrast, the horizontal functions would only do this if a height was provided by the caller (not -1), and would only override this value if the property fillHeight was false (in which case it would query the child's height directly).
With the change inJDK-8350149, the vertical calculations operate the same as the horizontal ones, as this is generally more flexible. However, the automatic behavior to query the child's size if the dependent size given was set to -1 is no longer there (as this behavior isn't how biased calculations should work).
The TabPaneSkin has chosen to directly call several width/height functions without obeying the content bias contract, which says that in case of bias, the dependent size must be calculated first and then passed to the size calculation one is interested in.
(As an aside, if TabPaneSkin had elected to put all tabs in a single StackPane, then StackPane would have correctly done these calculations, but digging into why it is done this way, with each individual Tab wrapped in its own Node (also a StackPane), is a bit out of scope for this fix).
As it is, TabPaneSkin should check the bias of the tab it is doing calculations for, and if biased, should first query the dependent size before triggering the size calculation it is interested in.
The program below (provided by Dirk Lemmermann, and slightly altered by me) demonstrates the problem. It will resize the only Tab correctly when the window opens on 25-ea+8, but regresses in 25-ea-10.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
/**
* This is a test case to validate whether a TabPane respects the preferred
* height of its content.
* @author Dirk Lemmermann
*/
public class TabPaneBug extends Application {
@Override
public void start(Stage stage) {
Label label = new Label("Lorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna pos-uere!\nCubilia sagittis egestas pharetra sociis montes nullam netus erat.\n\nFusce mauris condimentum neque morbi nunc ligula pretium vehicula nulla, platea dictum mus sapien pulvinar eget porta mi praesent, orci hac dignissim suscipit imperdiet sem per a.\nMauris pellentesque dui vitae velit netus venenatis diam felis urna ultrices, potenti pretium sociosqu eros dictumst dis aenean nibh cursus, leo sagittis integer nullam malesuada aliquet et metus vulputate. Interdum facilisis congue ac proin libero mus ullamcorper mauris leo imperdiet eleifend porta, posuere dignissim erat tincidunt vehicula habitant taciti porttitor scelerisque laoreet neque. Habitant etiam cubilia tempor inceptos ad aptent est et varius, vitae imperdiet phasellus feugiat class purus curabitur ullamcorper maecenas, venenatis mollis fusce cras leo eros metus proin. Fusce aenean sociosqu dis habitant mi sapien inceptos, orci lacinia nisi nascetur convallis at erat sociis, purus integer arcu feugiat sollicitudin libero.\n\nLorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna posuere. Lorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna posuere. Lorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna posuere. Aaill.");
label.setWrapText(true);
label.setMaxWidth(472);
Tab tab1 = new Tab("Tab 1", label);
TabPane tabPane = new TabPane(tab1);
HBox stackPane = new HBox(tabPane);
stackPane.setPadding(new Insets(20));
stage.setScene(new Scene(stackPane));
stage.sizeToScene();
stage.centerOnScreen();
stage.setTitle("Tab Pane Bug");
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
In Region several height calculations functions were altered to match the behavior and options of their horizontal counterparts to solve discrepancies between the behavior of vertical biased layouts and horizontal biased layouts, which other than their axis, should behave identical.
The height calculations would take a width provided by the caller, but if unavailable (set to -1) and the child was biased, it would just automatically query the child's preferred width and use that as the dependent width.
In contrast, the horizontal functions would only do this if a height was provided by the caller (not -1), and would only override this value if the property fillHeight was false (in which case it would query the child's height directly).
With the change in
The TabPaneSkin has chosen to directly call several width/height functions without obeying the content bias contract, which says that in case of bias, the dependent size must be calculated first and then passed to the size calculation one is interested in.
(As an aside, if TabPaneSkin had elected to put all tabs in a single StackPane, then StackPane would have correctly done these calculations, but digging into why it is done this way, with each individual Tab wrapped in its own Node (also a StackPane), is a bit out of scope for this fix).
As it is, TabPaneSkin should check the bias of the tab it is doing calculations for, and if biased, should first query the dependent size before triggering the size calculation it is interested in.
The program below (provided by Dirk Lemmermann, and slightly altered by me) demonstrates the problem. It will resize the only Tab correctly when the window opens on 25-ea+8, but regresses in 25-ea-10.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
/**
* This is a test case to validate whether a TabPane respects the preferred
* height of its content.
* @author Dirk Lemmermann
*/
public class TabPaneBug extends Application {
@Override
public void start(Stage stage) {
Label label = new Label("Lorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna pos-uere!\nCubilia sagittis egestas pharetra sociis montes nullam netus erat.\n\nFusce mauris condimentum neque morbi nunc ligula pretium vehicula nulla, platea dictum mus sapien pulvinar eget porta mi praesent, orci hac dignissim suscipit imperdiet sem per a.\nMauris pellentesque dui vitae velit netus venenatis diam felis urna ultrices, potenti pretium sociosqu eros dictumst dis aenean nibh cursus, leo sagittis integer nullam malesuada aliquet et metus vulputate. Interdum facilisis congue ac proin libero mus ullamcorper mauris leo imperdiet eleifend porta, posuere dignissim erat tincidunt vehicula habitant taciti porttitor scelerisque laoreet neque. Habitant etiam cubilia tempor inceptos ad aptent est et varius, vitae imperdiet phasellus feugiat class purus curabitur ullamcorper maecenas, venenatis mollis fusce cras leo eros metus proin. Fusce aenean sociosqu dis habitant mi sapien inceptos, orci lacinia nisi nascetur convallis at erat sociis, purus integer arcu feugiat sollicitudin libero.\n\nLorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna posuere. Lorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna posuere. Lorem ipsum dolor sit amet consectetur adipiscing elit nunc hendrerit purus, nisi dapibus primis nibh volutpat fringilla ad nisl urna posuere. Aaill.");
label.setWrapText(true);
label.setMaxWidth(472);
Tab tab1 = new Tab("Tab 1", label);
TabPane tabPane = new TabPane(tab1);
HBox stackPane = new HBox(tabPane);
stackPane.setPadding(new Insets(20));
stage.setScene(new Scene(stackPane));
stage.sizeToScene();
stage.centerOnScreen();
stage.setTitle("Tab Pane Bug");
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
- caused by
-
JDK-8350149 VBox ignores bias of child controls when fillWidth is set to false
-
- Resolved
-
- duplicates
-
JDK-8365827 TabPane: prefHeight
-
- Closed
-
- links to
-
Review(master) openjdk/jfx/1900