Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.8.0_172-ea" Java(TM) SE Runtime Environment (build 1.8.0_172-ea-b03) Java HotSpot(TM) 64-Bit Server VM (build 25.172-b03, mixed mode) ADDITIONAL OS VERSION INFORMATION : macOS 10.12.6 A DESCRIPTION OF THE PROBLEM : When using webPage.executeCommand("removeFormat", null) the formatting of the selected text should be cleared. Instead the style attribute of the body element is removed. REGRESSION. Last worked in version 8u162 ADDITIONAL REGRESSION INFORMATION: java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Create a view with a HTMLEditor and a button to execute the "removeFormat" command and another button "print to console" for debugging. Then view a text that contains a style in the body: public class Controller implements Initializable { public HTMLEditor htmlEditor; @Override public void initialize(URL location, ResourceBundle resources) { htmlEditor.setHtmlText("<html>\n" + "<head>\n" + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" + "</head>\n" + "<body style=\"font-family: san-serif\">\n" + "<p>Test</p>\n" + "</body>\n" + "</html>"); } public void onRemoveFormat(ActionEvent actionEvent) { WebView webView = (WebView) htmlEditor.lookup("WebView"); WebPage webPage = Accessor.getPageFor(webView.getEngine()); webPage.executeCommand("removeFormat", null); } public void onPrintConsole(ActionEvent actionEvent) { System.out.println(htmlEditor.getHtmlText()); } } Now start the program and click the "Print to console" to see this: <html dir="ltr"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body style="font-family: san-serif" contenteditable="true"> <p>Test</p> </body></html> Then select the "Test" text and click on "remove format". Afterward click "Print to console" again. Java version 1.8.0_172 prints this: <html dir="ltr"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body contenteditable="true"> <p>Test</p> </body></html> As you can see the style attribute has been removed from the body tag. However in version 1.8.0_162 it worked correct, the body tag was not modified, the style tag remained there. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - "removeFormat" should only modify the selected text and in this example the text has no formatting so "removeFormat" should do nothing. ACTUAL - The "style" attribute of the body tag is removed, which is incorrect. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class Controller implements Initializable { public HTMLEditor htmlEditor; @Override public void initialize(URL location, ResourceBundle resources) { htmlEditor.setHtmlText("<html>\n" + "<head>\n" + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n" + "</head>\n" + "<body style=\"font-family: san-serif\">\n" + "<p>Test</p>\n" + "</body>\n" + "</html>"); } public void onRemoveFormat(ActionEvent actionEvent) { WebView webView = (WebView) htmlEditor.lookup("WebView"); WebPage webPage = Accessor.getPageFor(webView.getEngine()); webPage.executeCommand("removeFormat", null); } public void onPrintConsole(ActionEvent actionEvent) { System.out.println(htmlEditor.getHtmlText()); } } and <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.control.*?> <?import javafx.scene.web.*?> <?import java.lang.*?> <?import javafx.scene.layout.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.Label?> <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="433.0" prefWidth="671.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.bug2_htmleditor.Controller"> <center> <HTMLEditor fx:id="htmlEditor" /> </center> <bottom> <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <items> <Button mnemonicParsing="false" onAction="#onRemoveFormat" text="Clear Formatting" /> <Button mnemonicParsing="false" onAction="#onPrintConsole" text="Print to console" /> </items> </ToolBar> </bottom> </BorderPane> ---------- END SOURCE ----------
|