2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2010 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
24 #include "core/html/HTMLOListElement.h"
26 #include "CSSPropertyNames.h"
27 #include "CSSValueKeywords.h"
28 #include "HTMLNames.h"
29 #include "core/rendering/RenderListItem.h"
33 using namespace HTMLNames;
35 HTMLOListElement::HTMLOListElement(Document& document)
36 : HTMLElement(olTag, document)
39 , m_hasExplicitStart(false)
41 , m_shouldRecalculateItemCount(false)
43 ScriptWrappable::init(this);
46 PassRefPtrWillBeRawPtr<HTMLOListElement> HTMLOListElement::create(Document& document)
48 return adoptRefWillBeRefCountedGarbageCollected(new HTMLOListElement(document));
51 bool HTMLOListElement::isPresentationAttribute(const QualifiedName& name) const
55 return HTMLElement::isPresentationAttribute(name);
58 void HTMLOListElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
60 if (name == typeAttr) {
62 addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerAlpha);
63 else if (value == "A")
64 addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperAlpha);
65 else if (value == "i")
66 addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerRoman);
67 else if (value == "I")
68 addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperRoman);
69 else if (value == "1")
70 addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueDecimal);
72 HTMLElement::collectStyleForPresentationAttribute(name, value, style);
75 void HTMLOListElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
77 if (name == startAttr) {
78 int oldStart = start();
80 int parsedStart = value.toInt(&canParse);
81 m_hasExplicitStart = canParse;
82 m_start = canParse ? parsedStart : 0xBADBEEF;
83 if (oldStart == start())
86 } else if (name == reversedAttr) {
87 bool reversed = !value.isNull();
88 if (reversed == m_isReversed)
90 m_isReversed = reversed;
93 HTMLElement::parseAttribute(name, value);
96 void HTMLOListElement::setStart(int start)
98 setIntegralAttribute(startAttr, start);
101 void HTMLOListElement::updateItemValues()
105 document().updateDistributionForNodeIfNeeded(this);
106 RenderListItem::updateItemValuesForOrderedList(this);
109 void HTMLOListElement::recalculateItemCount()
111 m_itemCount = RenderListItem::itemCountForOrderedList(this);
112 m_shouldRecalculateItemCount = false;