/src/mozilla-central/dom/html/HTMLDivElement.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 "HTMLDivElement.h" |
8 | | #include "nsGenericHTMLElement.h" |
9 | | #include "nsStyleConsts.h" |
10 | | #include "nsMappedAttributes.h" |
11 | | #include "mozilla/dom/HTMLDivElementBinding.h" |
12 | | |
13 | | NS_IMPL_NS_NEW_HTML_ELEMENT(Div) |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | HTMLDivElement::~HTMLDivElement() |
19 | 0 | { |
20 | 0 | } |
21 | | |
22 | | NS_IMPL_ELEMENT_CLONE(HTMLDivElement) |
23 | | |
24 | | JSObject* |
25 | | HTMLDivElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) |
26 | 0 | { |
27 | 0 | return dom::HTMLDivElement_Binding::Wrap(aCx, this, aGivenProto); |
28 | 0 | } |
29 | | |
30 | | bool |
31 | | HTMLDivElement::ParseAttribute(int32_t aNamespaceID, |
32 | | nsAtom* aAttribute, |
33 | | const nsAString& aValue, |
34 | | nsIPrincipal* aMaybeScriptedPrincipal, |
35 | | nsAttrValue& aResult) |
36 | 0 | { |
37 | 0 | if (aNamespaceID == kNameSpaceID_None) { |
38 | 0 | if (mNodeInfo->Equals(nsGkAtoms::marquee)) { |
39 | 0 | if ((aAttribute == nsGkAtoms::width) || |
40 | 0 | (aAttribute == nsGkAtoms::height)) { |
41 | 0 | return aResult.ParseSpecialIntValue(aValue); |
42 | 0 | } |
43 | 0 | if (aAttribute == nsGkAtoms::bgcolor) { |
44 | 0 | return aResult.ParseColor(aValue); |
45 | 0 | } |
46 | 0 | if ((aAttribute == nsGkAtoms::hspace) || |
47 | 0 | (aAttribute == nsGkAtoms::vspace)) { |
48 | 0 | return aResult.ParseIntWithBounds(aValue, 0); |
49 | 0 | } |
50 | 0 | } |
51 | 0 | |
52 | 0 | if (mNodeInfo->Equals(nsGkAtoms::div) && |
53 | 0 | aAttribute == nsGkAtoms::align) { |
54 | 0 | return ParseDivAlignValue(aValue, aResult); |
55 | 0 | } |
56 | 0 | } |
57 | 0 | |
58 | 0 | return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, |
59 | 0 | aMaybeScriptedPrincipal, aResult); |
60 | 0 | } |
61 | | |
62 | | void |
63 | | HTMLDivElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes, |
64 | | MappedDeclarations& aDecls) |
65 | 0 | { |
66 | 0 | nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aDecls); |
67 | 0 | nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls); |
68 | 0 | } |
69 | | |
70 | | static void |
71 | | MapMarqueeAttributesIntoRule(const nsMappedAttributes* aAttributes, MappedDeclarations& aDecls) |
72 | 0 | { |
73 | 0 | nsGenericHTMLElement::MapImageMarginAttributeInto(aAttributes, aDecls); |
74 | 0 | nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aDecls); |
75 | 0 | nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls); |
76 | 0 | nsGenericHTMLElement::MapBGColorInto(aAttributes, aDecls); |
77 | 0 | } |
78 | | |
79 | | NS_IMETHODIMP_(bool) |
80 | | HTMLDivElement::IsAttributeMapped(const nsAtom* aAttribute) const |
81 | 0 | { |
82 | 0 | if (mNodeInfo->Equals(nsGkAtoms::div)) { |
83 | 0 | static const MappedAttributeEntry* const map[] = { |
84 | 0 | sDivAlignAttributeMap, |
85 | 0 | sCommonAttributeMap |
86 | 0 | }; |
87 | 0 | return FindAttributeDependence(aAttribute, map); |
88 | 0 | } |
89 | 0 | if (mNodeInfo->Equals(nsGkAtoms::marquee)) { |
90 | 0 | static const MappedAttributeEntry* const map[] = { |
91 | 0 | sImageMarginSizeAttributeMap, |
92 | 0 | sBackgroundColorAttributeMap, |
93 | 0 | sCommonAttributeMap |
94 | 0 | }; |
95 | 0 | return FindAttributeDependence(aAttribute, map); |
96 | 0 | } |
97 | 0 | |
98 | 0 | return nsGenericHTMLElement::IsAttributeMapped(aAttribute); |
99 | 0 | } |
100 | | |
101 | | nsMapRuleToAttributesFunc |
102 | | HTMLDivElement::GetAttributeMappingFunction() const |
103 | 0 | { |
104 | 0 | if (mNodeInfo->Equals(nsGkAtoms::div)) { |
105 | 0 | return &MapAttributesIntoRule; |
106 | 0 | } |
107 | 0 | if (mNodeInfo->Equals(nsGkAtoms::marquee)) { |
108 | 0 | return &MapMarqueeAttributesIntoRule; |
109 | 0 | } |
110 | 0 | return nsGenericHTMLElement::GetAttributeMappingFunction(); |
111 | 0 | } |
112 | | |
113 | | } // namespace dom |
114 | | } // namespace mozilla |