• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 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  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #include "config.h"
23 #include "HTMLOListElement.h"
24 
25 #include "CSSPropertyNames.h"
26 #include "CSSValueKeywords.h"
27 #include "HTMLNames.h"
28 #include "MappedAttribute.h"
29 #include "RenderListItem.h"
30 
31 namespace WebCore {
32 
33 using namespace HTMLNames;
34 
HTMLOListElement(const QualifiedName & tagName,Document * doc)35 HTMLOListElement::HTMLOListElement(const QualifiedName& tagName, Document* doc)
36     : HTMLElement(tagName, doc)
37     , m_start(1)
38 {
39     ASSERT(hasTagName(olTag));
40 }
41 
mapToEntry(const QualifiedName & attrName,MappedAttributeEntry & result) const42 bool HTMLOListElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
43 {
44     if (attrName == typeAttr) {
45         result = eListItem; // Share with <li>
46         return false;
47     }
48 
49     return HTMLElement::mapToEntry(attrName, result);
50 }
51 
parseMappedAttribute(MappedAttribute * attr)52 void HTMLOListElement::parseMappedAttribute(MappedAttribute* attr)
53 {
54     if (attr->name() == typeAttr) {
55         if (attr->value() == "a")
56             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueLowerAlpha);
57         else if (attr->value() == "A")
58             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueUpperAlpha);
59         else if (attr->value() == "i")
60             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueLowerRoman);
61         else if (attr->value() == "I")
62             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueUpperRoman);
63         else if (attr->value() == "1")
64             addCSSProperty(attr, CSSPropertyListStyleType, CSSValueDecimal);
65     } else if (attr->name() == startAttr) {
66         bool canParse;
67         int start = attr->value().toInt(&canParse);
68         if (!canParse)
69             start = 1;
70         if (start == m_start)
71             return;
72         m_start = start;
73         for (RenderObject* child = renderer(); child; child = child->nextInPreOrder(renderer())) {
74             if (child->isListItem())
75                 toRenderListItem(child)->updateValue();
76         }
77     } else
78         HTMLElement::parseMappedAttribute(attr);
79 }
80 
compact() const81 bool HTMLOListElement::compact() const
82 {
83     return !getAttribute(compactAttr).isNull();
84 }
85 
setCompact(bool b)86 void HTMLOListElement::setCompact(bool b)
87 {
88     setAttribute(compactAttr, b ? "" : 0);
89 }
90 
setStart(int start)91 void HTMLOListElement::setStart(int start)
92 {
93     setAttribute(startAttr, String::number(start));
94 }
95 
type() const96 String HTMLOListElement::type() const
97 {
98     return getAttribute(typeAttr);
99 }
100 
setType(const String & value)101 void HTMLOListElement::setType(const String& value)
102 {
103     setAttribute(typeAttr, value);
104 }
105 }
106