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

WebView adds padding (or margin) when rendered on the Scene.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 7u60
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      Windows 7 JDK 8 b106 32 bit

    • Subcomponent:
      web

      Description

      When rendering an inline string containing an HTML page having a 'DIV' element styled blue. A blue rectangle appears to have a padding or margin (white space) left and above the 'DIV'.

      I expected the rectangle would be in the upper left (0,0) but with a white scene it seems there is some kind of inset width around the 'DIV'.

      package sample;

      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      /**
       * test for border, margin or padding using WebView
       */
      public class Main4 extends Application {
          Scene createScene() {
              final WebView webView = new WebView();
              final WebEngine webEngine = webView.getEngine();
              webEngine.loadContent(
                      
                              "<html>\n" +
                              "<body>" +
                              "<div style='margin: 0; padding-left: 0px; width: 100; height: 100; background: blue; ' />" +
                              "</body>\n" +
                              "</html>"
              );
              Group grp = new Group(webView);

              Scene scene = new Scene(grp, 150, 150);
              scene.setFill(null);
              return scene;
          }

          @Override public void start(Stage stage) {
              stage.setScene(createScene());
              stage.sizeToScene();
              stage.show();
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              peterz Peter Zhelezniakov (Inactive)
              Reporter:
              cdea Carl Dea
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: