HTMLOListElement.cpp [plain text]
#include "config.h"
#include "HTMLOListElement.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "RenderListItem.h"
#include <wtf/IsoMallocInlines.h>
template<typename T, typename E> inline Optional<T> optionalValue(Expected<T, E>&& expected)
{
return expected ? Optional<T>(WTFMove(expected.value())) : WTF::nullopt;
}
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLOListElement);
using namespace HTMLNames;
inline HTMLOListElement::HTMLOListElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
ASSERT(hasTagName(olTag));
}
Ref<HTMLOListElement> HTMLOListElement::create(Document& document)
{
return adoptRef(*new HTMLOListElement(olTag, document));
}
Ref<HTMLOListElement> HTMLOListElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLOListElement(tagName, document));
}
bool HTMLOListElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == typeAttr)
return true;
return HTMLElement::isPresentationAttribute(name);
}
void HTMLOListElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomString& value, MutableStyleProperties& style)
{
if (name == typeAttr) {
if (value == "a")
addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerAlpha);
else if (value == "A")
addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperAlpha);
else if (value == "i")
addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueLowerRoman);
else if (value == "I")
addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueUpperRoman);
else if (value == "1")
addPropertyToPresentationAttributeStyle(style, CSSPropertyListStyleType, CSSValueDecimal);
} else
HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
void HTMLOListElement::parseAttribute(const QualifiedName& name, const AtomString& value)
{
if (name == startAttr) {
int oldStart = start();
m_start = optionalValue(parseHTMLInteger(value));
if (oldStart == start())
return;
RenderListItem::updateItemValuesForOrderedList(*this);
} else if (name == reversedAttr) {
bool reversed = !value.isNull();
if (reversed == m_isReversed)
return;
m_isReversed = reversed;
RenderListItem::updateItemValuesForOrderedList(*this);
} else
HTMLElement::parseAttribute(name, value);
}
void HTMLOListElement::setStartForBindings(int start)
{
setIntegralAttribute(startAttr, start);
}
unsigned HTMLOListElement::itemCount() const
{
if (!m_itemCount)
m_itemCount = RenderListItem::itemCountForOrderedList(*this);
return m_itemCount.value();
}
}