| 1 package org.lobobrowser.html.domimpl; 2 3 import org.lobobrowser.html.style.*; 4 import org.w3c.dom.html2.HTMLParagraphElement; 5 6 public class HTMLPElementImpl extends HTMLAbstractUIElement implements 7 HTMLParagraphElement { 8 public HTMLPElementImpl(String name) { 9 super(name); 10 } 11 12 public String getAlign() { 13 return this.getAttribute("align"); 14 } 15 16 public void setAlign(String align) { 17 this.setAttribute("align", align); 18 } 19 20 protected void appendInnerTextImpl(StringBuffer buffer) { 21 int length = buffer.length(); 22 int lineBreaks; 23 if(length == 0) { 24 lineBreaks = 2; 25 } 26 else { 27 int start = length - 4; 28 if (start < 0) { 29 start = 0; 30 } 31 lineBreaks = 0; 32 for(int i = start; i < length; i++) { 33 char ch = buffer.charAt(i); 34 if(ch == '\n') { 35 lineBreaks++; 36 } 37 } 38 } 39 for(int i = 0; i < 2 - lineBreaks; i++) { 40 buffer.append("\r\n"); 41 } 42 super.appendInnerTextImpl(buffer); 43 buffer.append("\r\n\r\n"); 44 } 45 46 protected RenderState createRenderState(RenderState prevRenderState) { 47 return new BlockRenderState(prevRenderState, this); 48 } 49 } 50 | Popular Tags |