int availableLineWidth = constraints.getAvailableLineWidth();
ITextRegionList textRegions = currentDocumentRegion.getRegions();
int currentNumberOfRegions = currentDocumentRegion.getNumberOfRegions();
int currentTextRegionIndex = 1;
ITextRegion currentTextRegion = textRegions.get(currentTextRegionIndex);
String currentType = currentTextRegion.getType();
// tag name should always be the first text region
if (DOMRegionContext.XML_TAG_NAME.equals(currentType) && currentTextRegionIndex < currentNumberOfRegions - 1) {
ITextRegion nextTextRegion = textRegions.get(currentTextRegionIndex + 1);
// Bug 221279 - Some non well-formed documents will not contribute a next region
if (nextTextRegion != null && DOMRegionContext.XML_TAG_CLOSE.equals(nextTextRegion.getType())) {
// calculate available line width
int tagNameLineWidth = currentTextRegion.getTextLength() + 3;
availableLineWidth -= tagNameLineWidth;
if (XMLFormattingConstraints.INLINE.equals(indentStrategy)) {