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

WebView creates a plethora of invisible ScrollBarWidget instances when resized

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 7u25
    • Fix Version/s: tbd
    • Component/s: javafx
    • Environment:

      JDK 7 u25 64bit, JavaFX 2.2.25, Windows 7 64, NetBeans 7.3

    • Subcomponent:
      web

      Description

      While exploring the WebView control with ScenicView, I could not help but notice that, when resized, the control has a tendency to create a plethora of new ScrollBarWidget intances. It appears that the control creates new scrollbar whenever he thinks those are needed and that the old scrollbars always remain in the control's children list and never get removed or reused, they just sit there invisible on screen.

      package test;

      import com.javafx.experiments.scenicview.ScenicView;
      import java.util.Set;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ToolBar;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      /**
       * Test for the {@code HTMLLabel} class.
       * @author Fabrice Bouyé (fabriceb@spc.int)
       */
      public class Main extends Application {

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              Application.launch(args);
          }

          /**
           * {@inheritDoc}
           */
          @Override
          public void start(Stage primaryStage) {
              String text = "<html><body>"
                      + "Hello <b>World</b>!"
                      + "<p>lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet</p>"
                      + "<p>duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi lorem ipsum dolor sit amet consectetuer adipiscing elit sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat</p>"
                      + "<p>ut wisi enim ad minim veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi</p>"
                      + "<p>nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum lorem ipsum dolor sit amet consectetuer adipiscing elit sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat ut wisi enim ad minim veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat</p>"
                      + "<p>duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat vel illum dolore eu feugiat nulla facilisis</p>"
                      + "<p>at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr at accusam aliquyam diam diam dolore dolores duo eirmod eos erat et nonumy sed tempor et et invidunt justo labore stet clita ea et gubergren kasd magna no rebum sanctus sea sed takimata ut vero voluptua est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat</p>"
                      + "<p>consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat sed diam voluptua at vero eos et accusam et justo duo dolores et ea rebum stet clita kasd gubergren no sea takimata sanctus est lorem ipsum dolor sit amet</p>"
                      + "</body></html>";
              final WebView webView = new WebView();
              webView.getEngine().loadContent(text);
              Button button = new Button("Report");
              button.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent t) {
                      Set<Node> scrolls = webView.lookupAll(".scroll-bar");
                      System.out.println(scrolls.size());
                  }
              });
              ToolBar toolBar = new ToolBar();
              BorderPane root = new BorderPane();
              root.setCenter(webView);
              root.setTop(button);
              Scene scene = new Scene(root);
              primaryStage.setTitle("Test_HTMLLabel");
              primaryStage.setWidth(500);
              primaryStage.setHeight(500);
              primaryStage.setScene(scene);
              primaryStage.show();
              ScenicView.show(scene);
          }
      }


      Using the following simple example, if the scrollbar remains untouched (AKA scroll value stays 0) you will notice that, sometimes (not always) when the stage is expanded and shrinked vertically and then shrinked horizontally, a new ScrollBarWidget child will be added to the WebView (it's clearly visible in SceneView).

      This is also noticeable when hitting the "Report" button: for each ScrollBarWidget instance in the scene, two instances of nodes "scroll-bar" are reported (the ScrollBarWidget has this style and so does ScrollBarSkin, which makes 2 occurences for a single scroll bar). The more invisible scrollbars in the WebView control, the higher the number printed on the output.

      A screenshot of the issue has been hosted on: https://lh3.googleusercontent.com/-xI-4XBXuN2k/UgHHLqtQuXI/AAAAAAAABuM/3wQsg5VIYrQ/w1047-h884-no/WebViewScrollBug.png

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fbouyajfx Fabrice Bouyé (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported: