# HG changeset patch # User rchamyal # Date 1459242785 -19800 # Node ID cf668c19e0debead64b990aa44ad6e253f42cc44 # Parent 1a3a230a7d64b5e59be4b05d475782729bbafbc7 8150225: api/javax_swing/text/AbstractWriter/index_indent failed Reviewed-by: serb, aniyogi diff -r 1a3a230a7d64 -r cf668c19e0de jdk/src/java.desktop/share/classes/javax/swing/text/AbstractWriter.java --- 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--; } } diff -r 1a3a230a7d64 -r cf668c19e0de jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLWriter.java --- 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 diff -r 1a3a230a7d64 -r cf668c19e0de jdk/test/javax/swing/text/html/HTMLEditorKit/7104635/HTMLEditorKitWriterBug.java --- 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 */