/src/mozilla-central/dom/html/HTMLLIElement.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "mozilla/dom/HTMLLIElement.h" |
8 | | #include "mozilla/dom/HTMLLIElementBinding.h" |
9 | | |
10 | | #include "mozilla/MappedDeclarations.h" |
11 | | #include "nsAttrValueInlines.h" |
12 | | #include "nsGkAtoms.h" |
13 | | #include "nsStyleConsts.h" |
14 | | #include "nsMappedAttributes.h" |
15 | | |
16 | | NS_IMPL_NS_NEW_HTML_ELEMENT(LI) |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | HTMLLIElement::~HTMLLIElement() |
22 | 0 | { |
23 | 0 | } |
24 | | |
25 | | NS_IMPL_ELEMENT_CLONE(HTMLLIElement) |
26 | | |
27 | | // values that are handled case-insensitively |
28 | | static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = { |
29 | | { "disc", NS_STYLE_LIST_STYLE_DISC }, |
30 | | { "circle", NS_STYLE_LIST_STYLE_CIRCLE }, |
31 | | { "round", NS_STYLE_LIST_STYLE_CIRCLE }, |
32 | | { "square", NS_STYLE_LIST_STYLE_SQUARE }, |
33 | | { nullptr, 0 } |
34 | | }; |
35 | | |
36 | | // values that are handled case-sensitively |
37 | | static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = { |
38 | | { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA }, |
39 | | { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA }, |
40 | | { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN }, |
41 | | { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN }, |
42 | | { "1", NS_STYLE_LIST_STYLE_DECIMAL }, |
43 | | { nullptr, 0 } |
44 | | }; |
45 | | |
46 | | bool |
47 | | HTMLLIElement::ParseAttribute(int32_t aNamespaceID, |
48 | | nsAtom* aAttribute, |
49 | | const nsAString& aValue, |
50 | | nsIPrincipal* aMaybeScriptedPrincipal, |
51 | | nsAttrValue& aResult) |
52 | 0 | { |
53 | 0 | if (aNamespaceID == kNameSpaceID_None) { |
54 | 0 | if (aAttribute == nsGkAtoms::type) { |
55 | 0 | return aResult.ParseEnumValue(aValue, kOrderedListItemTypeTable, |
56 | 0 | true) || |
57 | 0 | aResult.ParseEnumValue(aValue, kUnorderedListItemTypeTable, false); |
58 | 0 | } |
59 | 0 | if (aAttribute == nsGkAtoms::value) { |
60 | 0 | return aResult.ParseIntValue(aValue); |
61 | 0 | } |
62 | 0 | } |
63 | 0 | |
64 | 0 | return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, |
65 | 0 | aMaybeScriptedPrincipal, aResult); |
66 | 0 | } |
67 | | |
68 | | void |
69 | | HTMLLIElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes, |
70 | | MappedDeclarations& aDecls) |
71 | 0 | { |
72 | 0 | if (!aDecls.PropertyIsSet(eCSSProperty_list_style_type)) { |
73 | 0 | // type: enum |
74 | 0 | const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type); |
75 | 0 | if (value && value->Type() == nsAttrValue::eEnum) |
76 | 0 | aDecls.SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue()); |
77 | 0 | } |
78 | 0 |
|
79 | 0 | nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls); |
80 | 0 | } |
81 | | |
82 | | NS_IMETHODIMP_(bool) |
83 | | HTMLLIElement::IsAttributeMapped(const nsAtom* aAttribute) const |
84 | 0 | { |
85 | 0 | static const MappedAttributeEntry attributes[] = { |
86 | 0 | { &nsGkAtoms::type }, |
87 | 0 | { nullptr }, |
88 | 0 | }; |
89 | 0 |
|
90 | 0 | static const MappedAttributeEntry* const map[] = { |
91 | 0 | attributes, |
92 | 0 | sCommonAttributeMap, |
93 | 0 | }; |
94 | 0 |
|
95 | 0 | return FindAttributeDependence(aAttribute, map); |
96 | 0 | } |
97 | | |
98 | | nsMapRuleToAttributesFunc |
99 | | HTMLLIElement::GetAttributeMappingFunction() const |
100 | 0 | { |
101 | 0 | return &MapAttributesIntoRule; |
102 | 0 | } |
103 | | |
104 | | JSObject* |
105 | | HTMLLIElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) |
106 | 0 | { |
107 | 0 | return HTMLLIElement_Binding::Wrap(aCx, this, aGivenProto); |
108 | 0 | } |
109 | | |
110 | | } // namespace dom |
111 | | } // namespace mozilla |