提交 fe3aa074 编写于 作者: P peterz

6606443: Infinite loop in FlowView.layout when using HTML tables in JEditorPane

Summary: FlowStrategy.damageStart now tracks position changes
Reviewed-by: gsm
上级 7be21cbe
...@@ -333,17 +333,24 @@ public abstract class FlowView extends BoxView { ...@@ -333,17 +333,24 @@ public abstract class FlowView extends BoxView {
* @since 1.3 * @since 1.3
*/ */
public static class FlowStrategy { public static class FlowStrategy {
int damageStart = Integer.MAX_VALUE; Position damageStart = null;
Vector<View> viewBuffer; Vector<View> viewBuffer;
void addDamage(FlowView fv, int offset) { void addDamage(FlowView fv, int offset) {
if (offset >= fv.getStartOffset() && offset < fv.getEndOffset()) { 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() { void unsetDamage() {
damageStart = Integer.MAX_VALUE; damageStart = null;
} }
/** /**
...@@ -438,13 +445,14 @@ public abstract class FlowView extends BoxView { ...@@ -438,13 +445,14 @@ public abstract class FlowView extends BoxView {
int p1 = fv.getEndOffset(); int p1 = fv.getEndOffset();
if (fv.majorAllocValid) { if (fv.majorAllocValid) {
if (damageStart == Integer.MAX_VALUE) { if (damageStart == null) {
return; return;
} }
// In some cases there's no view at position damageStart, so // In some cases there's no view at position damageStart, so
// step back and search again. See 6452106 for details. // step back and search again. See 6452106 for details.
while ((rowIndex = fv.getViewIndexAtPosition(damageStart)) < 0) { int offset = damageStart.getOffset();
damageStart--; while ((rowIndex = fv.getViewIndexAtPosition(offset)) < 0) {
offset--;
} }
if (rowIndex > 0) { if (rowIndex > 0) {
rowIndex--; rowIndex--;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册