Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8182152

CSS resolution errors in modena.bss

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin Forge.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      macOS 10.12.5

      A DESCRIPTION OF THE PROBLEM :
      I have a minimal working example (see steps to reproduce). It seems like a combination of removing and adding a node back to a scene, combined with a CSS rule which relies on the relative position of nodes in the hierarchy.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The complete code snippet is below. If you follow these steps to reproduce, you will see stderr report the problem. In my larger example, sometimes but not always, this causes JavaFX controls to be styled incorrectly due to the errors which occurred during CSS resolution.

      Steps to produce bug:
        Click "Add tab back" button once
        Click the cross in the tab header of the second window which appears (note: the tab header! Do not just close the window directly). Second window should hide.
        Click "Add tab back" button again
        See stderr output.

      Only occurs on the 2nd click of the button, not on the 1st, or the 3rd, 4th, etc. For me, it always occurs on the 2nd click, without fail, if you follow those exact instructions.




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I shouldn't see any errors on stderr.
      ACTUAL -
      I get this output on stderr:

      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-background-color' while resolving lookups for '-fx-text-fill' from rule '*.label' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-background-color' while resolving lookups for '-fx-text-fill' from rule '*.label' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-control-inner-background' while resolving lookups for '-fx-highlight-fill' from rule '*.text-input' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-inner-color' while resolving lookups for '-fx-text-fill' from rule '*.text-input' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-inner-color' while resolving lookups for '-fx-highlight-text-fill' from rule '*.text-input' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-box-border' while resolving lookups for '-fx-background-color' from rule '*.text-input' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Jun 13, 2017 10:57:54 AM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-control-inner-background' while resolving lookups for '-fx-prompt-text-fill' from rule '*.text-input' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      See actual result field.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.collections.ListChangeListener;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.StackPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;

      import java.io.File;
      import java.nio.file.Files;
      import java.util.Collections;

      public class TabPaneCSSBug extends Application
      {
          @Override
          public void start(Stage primaryStage) throws Exception
          {
              // There is a second window, with a tab pane, which hides itself when
              // the tabs are empty.
              TabPane tabPane = new TabPane();
              Stage otherWindow = new Stage();
              Scene otherScene = new Scene(tabPane);
              // Make this a self contained example, write CSS file ourselves:
              File cssFile = File.createTempFile("tabs", "css");
              cssFile.deleteOnExit();
              Files.write(cssFile.toPath(), Collections.singletonList(".myvbox .mylabel { -fx-content-display: graphic-only; }"));
              otherScene.getStylesheets().add(cssFile.toURI().toURL().toString());
              otherWindow.setScene(otherScene);
              tabPane.getTabs().addListener((ListChangeListener<? super Tab>) c -> {
                  if (tabPane.getTabs().isEmpty())
                      otherWindow.close();
              });

              // Add some content to the tab we will show in second window:
              Label label = new Label("Body", new StackPane(new Rectangle()));
              label.getStyleClass().add("mylabel");
              VBox vBox = new VBox(label, new Label("Body #2", new StackPane(new Rectangle())), new TextField("text field"));
              vBox.getStyleClass().add("myvbox");
              Tab tab = new Tab("Title", vBox);

              // Add a button to main window which puts the tab back in the other window's tab pane and shows it:
              Button button = new Button("Add tab back");
              button.setOnAction(e -> {
                  tabPane.getTabs().add(tab);
                  otherWindow.show();
              });
              primaryStage.setScene(new Scene(button));
              primaryStage.show();

              // Steps to produce bug:
              // Click "Add tab back" button once
              // Click the cross in the tab header of the second window which appears. Second window should hide.
              // Click "Add tab back" button again
              // See stderr output.
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I can remove the CSS rule and implement the styling in code, which avoids the issue.

        Attachments

          Activity

            People

            • Assignee:
              scfitch Stephen Fitch
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: