diff options
author | Roman Kennke <roman@kennke.org> | 2006-12-06 20:21:06 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-12-06 20:21:06 +0000 |
commit | 5e741748dd0b54d0523d6f53602c706fc679f700 (patch) | |
tree | 937fc26596e43e8b84591423efedab05c3d7c9ee | |
parent | 328fe8b0cb8191641275a4a43c426cb6ce88305f (diff) | |
download | classpath-5e741748dd0b54d0523d6f53602c706fc679f700.tar.gz |
2006-12-06 Roman Kennke <kennke@aicas.com>
* javax/swing/JEditorPane.java
(getStream): Buffer the stream for efficiency.
(setPage): Don't scroll the view at this point.
* javax/swing/plaf/basic/BasicTextUI.java
(RootView.paint): Call RootView's setSize to get synchronization.
(RootView.setSize): Synchronize to prevent race in layout code.
* javax/swing/text/AbstractDocument.java
(notifyListeners): New field.
(fireChangedUpdate): Track notifyListener field.
(fireRemoveUpdate): Track notifyListener field.
(fireIndertUpdate): Track notifyListener field.
(writeLock): Check notifyListener and throw IllegalStateException.
* javax/swing/text/View.java
(preferenceChanged): Create local var for better thread safety and
more efficiency.
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | javax/swing/JEditorPane.java | 8 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicTextUI.java | 9 | ||||
-rw-r--r-- | javax/swing/text/AbstractDocument.java | 53 | ||||
-rw-r--r-- | javax/swing/text/View.java | 5 |
5 files changed, 71 insertions, 22 deletions
@@ -1,3 +1,21 @@ +2006-12-06 Roman Kennke <kennke@aicas.com> + + * javax/swing/JEditorPane.java + (getStream): Buffer the stream for efficiency. + (setPage): Don't scroll the view at this point. + * javax/swing/plaf/basic/BasicTextUI.java + (RootView.paint): Call RootView's setSize to get synchronization. + (RootView.setSize): Synchronize to prevent race in layout code. + * javax/swing/text/AbstractDocument.java + (notifyListeners): New field. + (fireChangedUpdate): Track notifyListener field. + (fireRemoveUpdate): Track notifyListener field. + (fireIndertUpdate): Track notifyListener field. + (writeLock): Check notifyListener and throw IllegalStateException. + * javax/swing/text/View.java + (preferenceChanged): Create local var for better thread safety and + more efficiency. + 2006-12-06 Thomas Fitzsimmons <fitzsim@redhat.com> * java/awt/ScrollPane.java (addNotify): Add a parent panel for any diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java index 4f7ad7119..9e13b4418 100644 --- a/javax/swing/JEditorPane.java +++ b/javax/swing/JEditorPane.java @@ -40,7 +40,7 @@ package javax.swing; import java.awt.Container; import java.awt.Dimension; -import java.awt.Rectangle; +import java.io.BufferedInputStream; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; @@ -898,7 +898,7 @@ public class JEditorPane extends JTextComponent if (type != null) setContentType(type); InputStream stream = conn.getInputStream(); - return stream; + return new BufferedInputStream(stream); } public String getText() @@ -1061,10 +1061,6 @@ public class JEditorPane extends JTextComponent throw new IOException("invalid url"); URL old = getPage(); - // Reset scrollbar when URL actually changes. - if (! page.equals(old) && page.getRef() == null) - scrollRectToVisible(new Rectangle(0, 0, 1, 1)); - // Only reload if the URL doesn't point to the same file. // This is not the same as equals because there might be different // URLs on the same file with different anchors. diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java index d4e43c60e..e152a3034 100644 --- a/javax/swing/plaf/basic/BasicTextUI.java +++ b/javax/swing/plaf/basic/BasicTextUI.java @@ -362,7 +362,12 @@ public abstract class BasicTextUI extends TextUI return textComponent; } - public void setSize(float w, float h) + /** + * Sets the size of the renderer. This is synchronized because that + * potentially triggers layout and we don't want more than one thread + * playing with the layout information. + */ + public synchronized void setSize(float w, float h) { if (view != null) view.setSize(w, h); @@ -379,7 +384,7 @@ public abstract class BasicTextUI extends TextUI if (view != null) { Rectangle b = s instanceof Rectangle ? (Rectangle) s : s.getBounds(); - view.setSize(b.width, b.height); + setSize(b.width, b.height); view.paint(g, s); } } diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java index 1e12d5c11..b52c76363 100644 --- a/javax/swing/text/AbstractDocument.java +++ b/javax/swing/text/AbstractDocument.java @@ -176,6 +176,12 @@ public abstract class AbstractDocument implements Document, Serializable private BidiRootElement bidiRoot; /** + * True when we are currently notifying any listeners. This is used + * to detect illegal situations in writeLock(). + */ + private transient boolean notifyListeners; + + /** * Creates a new <code>AbstractDocument</code> with the specified * {@link Content} model. * @@ -325,10 +331,17 @@ public abstract class AbstractDocument implements Document, Serializable */ protected void fireChangedUpdate(DocumentEvent event) { - DocumentListener[] listeners = getDocumentListeners(); - - for (int index = 0; index < listeners.length; ++index) - listeners[index].changedUpdate(event); + notifyListeners = true; + try + { + DocumentListener[] listeners = getDocumentListeners(); + for (int index = 0; index < listeners.length; ++index) + listeners[index].changedUpdate(event); + } + finally + { + notifyListeners = false; + } } /** @@ -339,10 +352,17 @@ public abstract class AbstractDocument implements Document, Serializable */ protected void fireInsertUpdate(DocumentEvent event) { - DocumentListener[] listeners = getDocumentListeners(); - - for (int index = 0; index < listeners.length; ++index) - listeners[index].insertUpdate(event); + notifyListeners = true; + try + { + DocumentListener[] listeners = getDocumentListeners(); + for (int index = 0; index < listeners.length; ++index) + listeners[index].insertUpdate(event); + } + finally + { + notifyListeners = false; + } } /** @@ -353,10 +373,17 @@ public abstract class AbstractDocument implements Document, Serializable */ protected void fireRemoveUpdate(DocumentEvent event) { - DocumentListener[] listeners = getDocumentListeners(); - - for (int index = 0; index < listeners.length; ++index) - listeners[index].removeUpdate(event); + notifyListeners = true; + try + { + DocumentListener[] listeners = getDocumentListeners(); + for (int index = 0; index < listeners.length; ++index) + listeners[index].removeUpdate(event); + } + finally + { + notifyListeners = false; + } } /** @@ -1338,6 +1365,8 @@ public abstract class AbstractDocument implements Document, Serializable { if (Thread.currentThread() == currentWriter) { + if (notifyListeners) + throw new IllegalStateException("Mutation during notify"); numWriters++; return; } diff --git a/javax/swing/text/View.java b/javax/swing/text/View.java index dc611fe49..c63ddbce7 100644 --- a/javax/swing/text/View.java +++ b/javax/swing/text/View.java @@ -335,8 +335,9 @@ public abstract class View implements SwingConstants public void preferenceChanged(View child, boolean width, boolean height) { - if (parent != null) - parent.preferenceChanged(this, width, height); + View p = getParent(); + if (p != null) + p.preferenceChanged(this, width, height); } public int getBreakWeight(int axis, float pos, float len) |