8231084: Large performance regression in SwingMark TextArea in 14-b13
8231336: Corrupted option dialog in JTHarness with JDK14b13
Reviewed-by: serb, prr
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java Wed Nov 06 10:48:10 2019 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java Wed Nov 06 11:05:28 2019 +0530
@@ -702,7 +702,6 @@
Document doc = editor.getDocument();
Element elem = doc.getDefaultRootElement();
setView(f.create(elem));
- rootViewNeedsLayout = false;
}
/**
@@ -948,10 +947,9 @@
if ((d.width > (i.left + i.right + caretMargin)) && (d.height > (i.top + i.bottom))) {
rootView.setSize(d.width - i.left - i.right -
caretMargin, d.height - i.top - i.bottom);
- } if (!rootViewNeedsLayout) {
+ } else if (d.width == 0 && d.height == 0) {
// Probably haven't been layed out yet, force some sort of
// initial sizing.
- rootViewNeedsLayout = true;
rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
d.width = (int) Math.min((long) rootView.getPreferredSpan(View.X_AXIS) +
@@ -1403,7 +1401,6 @@
private static final Position.Bias[] discardBias = new Position.Bias[1];
private DefaultCaret dropCaret;
private int caretMargin;
- private boolean rootViewNeedsLayout;
/**
* Root view that acts as a gateway between the component
@@ -1966,7 +1963,6 @@
// normal insert update
Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
rootView.insertUpdate(e, alloc, rootView.getViewFactory());
- rootViewNeedsLayout = false;
}
/**
@@ -1982,7 +1978,6 @@
public final void removeUpdate(DocumentEvent e) {
Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
rootView.removeUpdate(e, alloc, rootView.getViewFactory());
- rootViewNeedsLayout = false;
}
/**
@@ -1998,7 +1993,6 @@
public final void changedUpdate(DocumentEvent e) {
Rectangle alloc = (painted) ? getVisibleEditorRect() : null;
rootView.changedUpdate(e, alloc, rootView.getViewFactory());
- rootViewNeedsLayout = false;
}
// --- LayoutManager2 methods --------------------------------
--- a/test/jdk/ProblemList.txt Wed Nov 06 10:48:10 2019 +0530
+++ b/test/jdk/ProblemList.txt Wed Nov 06 11:05:28 2019 +0530
@@ -733,6 +733,7 @@
# jdk_swing
com/sun/java/swing/plaf/windows/Test8173145.java 8198334 windows-all
+javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all
javax/swing/border/TestTitledBorderLeak.java 8213531 linux-all
javax/swing/JComponent/7154030/bug7154030.java 7190978 generic-all
--- a/test/jdk/javax/swing/JEditorPane/8226513/JEditorPaneLayoutTest.java Wed Nov 06 10:48:10 2019 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @key headful
- * @bug 8226513
- * @summary JEditorPane is shown with incorrect size
- * @run main/othervm -Dsun.java2d.uiScale=1.0 JEditorPaneLayoutTest
- */
-
-import javax.swing.JFrame;
-import javax.swing.JEditorPane;
-import javax.swing.SwingUtilities;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.html.HTMLEditorKit;
-import java.awt.Dimension;
-import java.awt.Robot;
-
-public class JEditorPaneLayoutTest {
-
- public static final String TEXT =
- "some text some text some text <br> some text";
- static JFrame frame;
- static JEditorPane editorPane;
- static Dimension size1;
- static Dimension size2;
- static Dimension size3;
- static Dimension size4;
-
- public static void main(String[] args) throws Exception {
- Robot robot = new Robot();
-
- SwingUtilities.invokeAndWait(() -> {
- frame = new JFrame();
- editorPane = new JEditorPane("text/html", TEXT);
- size1 = editorPane.getPreferredSize();
- editorPane.setText(TEXT);
- frame.add(editorPane);
- frame.pack();
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- });
-
- robot.waitForIdle();
- robot.delay(300);
-
- SwingUtilities.invokeAndWait(() -> {
- size2 = editorPane.getSize();
- frame.dispose();
-
- frame = new JFrame();
- editorPane = new JEditorPane("text/html", TEXT);
- editorPane.getPreferredSize();
- editorPane.setText(TEXT);
- frame.add(editorPane);
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- });
-
- robot.waitForIdle();
- robot.delay(300);
-
- if (!size1.equals(size2)) {
- SwingUtilities.invokeLater(frame::dispose);
- throw new RuntimeException("Wrong size " + size2 +
- " expected " + size1);
- }
-
- SwingUtilities.invokeAndWait(() -> {
- editorPane.setText(TEXT);
- frame.pack();
- size3 = editorPane.getSize();
- frame.dispose();
-
- frame = new JFrame();
- editorPane = new JEditorPane("text/html", TEXT);
- editorPane.getPreferredSize();
- editorPane.setSize(1, 1);
- Document doc = new HTMLEditorKit().createDefaultDocument();
- try {
- doc.insertString(0, TEXT, null);
- } catch (BadLocationException e) {
- e.printStackTrace();
- }
- editorPane.setDocument(doc);
- editorPane.setText(TEXT);
- frame.add(editorPane);
- frame.pack();
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- });
-
- robot.waitForIdle();
- robot.delay(300);
-
- if (!size1.equals(size3)) {
- SwingUtilities.invokeLater(frame::dispose);
- throw new RuntimeException("Wrong size " + size3 +
- " expected " + size1);
- }
-
- SwingUtilities.invokeAndWait(() -> {
- size4 = editorPane.getSize();
- frame.dispose();
- });
-
- robot.waitForIdle();
- robot.delay(300);
-
- if (!size1.equals(size4)) {
- SwingUtilities.invokeLater(frame::dispose);
- throw new RuntimeException("Wrong size " + size4 +
- " expected " + size1);
- }
- }
-}
--- a/test/jdk/javax/swing/JTextArea/ScrollbarFlicker/ScrollFlickerTest.java Wed Nov 06 10:48:10 2019 +0530
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @key headful
- * @bug 8160246
- * @summary Regression: 4410243 reproducible with GTK LaF
- * @run main ScrollFlickerTest
- */
-
-import javax.swing.*;
-import java.awt.*;
-
-public class ScrollFlickerTest {
-
- private static JFrame frame;
- private static JScrollPane scroll;
- private static int cnt = 0;
-
- public static void main(String[] args) throws Exception {
- SwingUtilities.invokeAndWait(() -> {
- frame = new JFrame();
- frame.setSize(300, 200);
- frame.getContentPane().setLayout(null);
- JTextArea text = new JTextArea("Test test test test");
- text.setLineWrap(true);
- scroll = new JScrollPane(text);
- frame.getContentPane().add(scroll);
- scroll.setBounds(1, 1, 100, 50);
- frame.setVisible(true);
- });
-
- Robot robot = new Robot();
- robot.waitForIdle();
- robot.delay(200);
-
- SwingUtilities.invokeAndWait(() -> {
- Insets insets = scroll.getInsets();
- scroll.setSize(insets.left + insets.right +
- scroll.getVerticalScrollBar().getPreferredSize().width, 50);
- scroll.revalidate();
- });
- robot.delay(200);
- SwingUtilities.invokeAndWait(() ->
- scroll.getViewport().addChangeListener((e) -> cnt++));
- robot.delay(1000);
-
- SwingUtilities.invokeLater(frame::dispose);
-
- if (cnt > 0) {
- throw new RuntimeException("Scroll bar flickers");
- }
- }
-}