8150225: api/javax_swing/text/AbstractWriter/index_indent failed

Reviewed-by: serb, aniyogi
This commit is contained in:
Rajeev Chamyal 2016-03-29 14:43:05 +05:30
parent 03bb7d11b7
commit dc8fa87bb6
3 changed files with 15 additions and 5 deletions

View File

@ -441,7 +441,7 @@ public abstract class AbstractWriter {
--offsetIndent;
}
else {
indentLevel = indentLevel > 0 ? indentLevel-- : 0;
indentLevel--;
}
}

View File

@ -178,7 +178,8 @@ public class HTMLWriter extends AbstractWriter {
if (!synthesizedElement(top)) {
AttributeSet attrs = top.getAttributes();
if (!matchNameAttribute(attrs, HTML.Tag.PRE) &&
!isFormElementWithContent(attrs)) {
!isFormElementWithContent(attrs) &&
!isPreTagWithParagraphTag(attrs)) {
decrIndent();
}
endTag(top);
@ -223,7 +224,8 @@ public class HTMLWriter extends AbstractWriter {
if (!synthesizedElement(current)) {
AttributeSet attrs = current.getAttributes();
if (!matchNameAttribute(attrs, HTML.Tag.PRE) &&
!isFormElementWithContent(attrs)) {
!isFormElementWithContent(attrs) &&
!isPreTagWithParagraphTag(attrs)) {
decrIndent();
}
endTag(current);
@ -830,6 +832,14 @@ public class HTMLWriter extends AbstractWriter {
matchNameAttribute(attr, HTML.Tag.SELECT);
}
/**
* Determines if the element associated with the attributeset
* is a P tag and it is within Pre tag. If true, returns true else
* false
*/
private boolean isPreTagWithParagraphTag(AttributeSet attr) {
return inPre && matchNameAttribute(attr, HTML.Tag.P);
}
/**
* Determines whether a the indentation needs to be

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -23,7 +23,7 @@
/*
* @test
* @bug 7104635
* @bug 7104635 8150225
* @summary HTMLEditorKit fails to write down some html files
* @run main HTMLEditorKitWriterBug
*/