KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > BaseRListElement


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

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.CSS2PropertiesImpl;
28 import org.lobobrowser.html.style.HtmlValues;
29 import org.lobobrowser.html.style.ListStyle;
30
31 class BaseRListElement extends RBlock {
32     protected static final String JavaDoc DEFAULT_COUNTER_NAME = "$cobra.counter";
33     protected ListStyle listStyle = null;
34     
35     public BaseRListElement(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer) {
36         super(modelNode, listNesting, pcontext, rcontext, frameContext, parentContainer);
37     }
38     
39     protected void applyStyle() {
40         this.listStyle = null;
41         super.applyStyle();
42         Object JavaDoc rootNode = this.modelNode;
43         if(!(rootNode instanceof HTMLElementImpl)) {
44             return;
45         }
46         HTMLElementImpl rootElement = (HTMLElementImpl) rootNode;
47         CSS2PropertiesImpl props = rootElement.getCurrentStyle();
48         if(props == null) {
49             return;
50         }
51         ListStyle listStyle = null;
52         String JavaDoc listStyleText = props.getListStyle();
53         if(listStyleText != null) {
54             listStyle = HtmlValues.getListStyle(listStyleText);
55         }
56         String JavaDoc listStyleTypeText = props.getListStyleType();
57         if(listStyleTypeText != null) {
58             int listType = HtmlValues.getListStyleType(listStyleTypeText);
59             if(listType != ListStyle.TYPE_UNSET) {
60                 if(listStyle == null) {
61                     listStyle = new ListStyle();
62                 }
63                 listStyle.type = listType;
64             }
65         }
66         if(listStyle == null || listStyle.type == ListStyle.TYPE_UNSET)
67         {
68             String JavaDoc typeAttributeText = rootElement.getAttribute("type");
69             if(typeAttributeText != null) {
70                 int newStyleType = HtmlValues.getListStyleTypeDeprecated(typeAttributeText);
71                 if(newStyleType != ListStyle.TYPE_UNSET) {
72                     if(listStyle == null) {
73                         listStyle = new ListStyle();
74                         this.listStyle = listStyle;
75                     }
76                     listStyle.type = newStyleType;
77                 }
78             }
79         }
80         this.listStyle = listStyle;
81     }
82 }
83
Popular Tags