JDK-8124789 : Cache invalidation and layout invalidation are not done independently, while the validation is
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-05-23
  • Updated: 2015-06-17
  • Resolved: 2013-07-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Relates :  
Description
The invalidating the layout by using requestLayout() method both the layout and min/pref caches are invalidated. In case the cache is validated before the actual layout pass (e.g. by calling prefWidth(-1)), the cache is not invalidated again and subsequent changes (before the layout pass) are not included in the cached value. Currently, this works only due to bug RT-30363 and 2 layout passes, because it clears the caches on the first pass, fixing the layout on the second pass.

I propose to add method like invalidateSizeHints to Parent that would handle the invalidation of the caches independently.
Comments
Verified on 8.0b106
06-09-2013

@Override public void start(Stage stage) { final Pane pane = new Pane() { @Override protected double computePrefWidth(double d) { System.out.println("call pane"); return super.computePrefWidth(d); } }; final Button b = new Button("Button") { @Override protected double computePrefWidth(double d) { System.out.println("call button"); return super.computePrefWidth(d); } }; b.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { b.requestLayout(); System.out.println("pane.prefWidth(-1) " + pane.prefWidth(-1)); b.setPrefWidth(300); b.requestLayout(); System.out.println("pane.prefWidth(-1) " + pane.prefWidth(-1)); } }); pane.getChildren().add(b); stage.setScene(new Scene(pane, 300, 300)); stage.show(); }
06-09-2013

Simple Test case: create a Pane with a child and place it into a scenegraph and override it's computePreferredWidth(). Call requestLayout() on the child, then call prefWidth(-1) on the pane and then (still on the same pulse) change it's preferred width, call child.requestLayout again. The prefWidth(-1) should then return the new width, but previously, it wouldn't.
06-09-2013

Test case? Steps on reproduction? 2 weeks for it.
05-09-2013

To maintain backward compatibility, requestLayout() is now always called. No new API needed.
17-07-2013