1 21 package org.lobobrowser.html.renderer; 22 23 import org.lobobrowser.html.HtmlRendererContext; 24 import org.lobobrowser.html.UserAgentContext; 25 import org.lobobrowser.html.domimpl.HTMLElementImpl; 26 import org.lobobrowser.html.domimpl.NodeImpl; 27 import org.lobobrowser.html.style.ListStyle; 28 import org.lobobrowser.html.style.RenderState; 29 30 class RList extends BaseRListElement { 31 public RList(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer, RCollection parent) { 32 super(modelNode, listNesting, pcontext, rcontext, frameContext, parentContainer); 33 this.defaultMarginInsets = new java.awt.Insets (5, 0, 5, 0); 34 } 35 36 private int counterStart; 37 38 protected void applyStyle() { 39 super.applyStyle(); 40 this.counterStart = 1; 41 Object rootNode = this.modelNode; 42 if(!(rootNode instanceof HTMLElementImpl)) { 43 return; 44 } 45 HTMLElementImpl rootElement = (HTMLElementImpl) rootNode; 46 String startText = rootElement.getAttribute("start"); 47 if(startText != null) { 48 try { 49 this.counterStart = Integer.parseInt(startText); 50 } catch(NumberFormatException nfe) { 51 } 53 } 54 ListStyle listStyle = this.listStyle; 55 if(listStyle == null || listStyle.type == ListStyle.TYPE_UNSET) { 56 if(listStyle == null) { 57 listStyle = new ListStyle(); 58 this.listStyle = listStyle; 59 } 60 if("ul".equalsIgnoreCase(rootElement.getTagName())) { 61 int listNesting = this.listNesting; 62 if(listNesting == 0) { 63 listStyle.type = ListStyle.TYPE_DISC; 64 } 65 else if(listNesting == 1) { 66 listStyle.type = ListStyle.TYPE_CIRCLE; 67 } 68 else { 69 listStyle.type = ListStyle.TYPE_SQUARE; 70 } 71 } 72 else { 73 listStyle.type = ListStyle.TYPE_DECIMAL; 74 } 75 } 76 } 77 78 public void doLayout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, FloatingBounds floatBounds, int tentativeY, int defaultOverflow) { 79 RenderState renderState = this.modelNode.getRenderState(); 80 renderState.resetCount(DEFAULT_COUNTER_NAME, this.listNesting, this.counterStart); 81 super.doLayout(availWidth, availHeight, expandWidth, expandHeight, 82 floatBounds, tentativeY, defaultOverflow); 83 } 84 } | Popular Tags |