6606443: Infinite loop in FlowView.layout when using HTML tables in JEditorPane
Summary: FlowStrategy.damageStart now tracks position changes
Reviewed-by: gsm
--- a/jdk/src/share/classes/javax/swing/text/FlowView.java Wed May 14 07:53:12 2008 -0700
+++ b/jdk/src/share/classes/javax/swing/text/FlowView.java Thu May 22 15:06:22 2008 +0400
@@ -333,17 +333,24 @@
* @since 1.3
*/
public static class FlowStrategy {
- int damageStart = Integer.MAX_VALUE;
+ Position damageStart = null;
Vector<View> viewBuffer;
void addDamage(FlowView fv, int offset) {
if (offset >= fv.getStartOffset() && offset < fv.getEndOffset()) {
- damageStart = Math.min(damageStart, offset);
+ if (damageStart == null || offset < damageStart.getOffset()) {
+ try {
+ damageStart = fv.getDocument().createPosition(offset);
+ } catch (BadLocationException e) {
+ // shouldn't happen since offset is inside view bounds
+ assert(false);
+ }
+ }
}
}
void unsetDamage() {
- damageStart = Integer.MAX_VALUE;
+ damageStart = null;
}
/**
@@ -438,13 +445,14 @@
int p1 = fv.getEndOffset();
if (fv.majorAllocValid) {
- if (damageStart == Integer.MAX_VALUE) {
+ if (damageStart == null) {
return;
}
// In some cases there's no view at position damageStart, so
// step back and search again. See 6452106 for details.
- while ((rowIndex = fv.getViewIndexAtPosition(damageStart)) < 0) {
- damageStart--;
+ int offset = damageStart.getOffset();
+ while ((rowIndex = fv.getViewIndexAtPosition(offset)) < 0) {
+ offset--;
}
if (rowIndex > 0) {
rowIndex--;