8150225: api/javax_swing/text/AbstractWriter/index_indent failed
Reviewed-by: serb, aniyogi
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractWriter.java Mon Mar 28 08:56:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractWriter.java Tue Mar 29 14:43:05 2016 +0530
@@ -441,7 +441,7 @@
--offsetIndent;
}
else {
- indentLevel = indentLevel > 0 ? indentLevel-- : 0;
+ indentLevel--;
}
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLWriter.java Mon Mar 28 08:56:34 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLWriter.java Tue Mar 29 14:43:05 2016 +0530
@@ -178,7 +178,8 @@
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 @@
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 @@
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
--- a/jdk/test/javax/swing/text/html/HTMLEditorKit/7104635/HTMLEditorKitWriterBug.java Mon Mar 28 08:56:34 2016 -0700
+++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/7104635/HTMLEditorKitWriterBug.java Tue Mar 29 14:43:05 2016 +0530
@@ -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
*/