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 #ifndef HTMLMarqueeElement_h___
7 #define HTMLMarqueeElement_h___
9 #include "mozilla/Attributes.h"
10 #include "nsGenericHTMLElement.h"
11 #include "nsContentUtils.h"
13 namespace mozilla::dom
{
14 class HTMLMarqueeElement final
: public nsGenericHTMLElement
{
16 explicit HTMLMarqueeElement(already_AddRefed
<dom::NodeInfo
>&& aNodeInfo
)
17 : nsGenericHTMLElement(std::move(aNodeInfo
)) {}
19 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMarqueeElement
, marquee
);
21 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
22 void UnbindFromTree(UnbindContext
&) override
;
24 static const int kDefaultLoop
= -1;
25 static const int kDefaultScrollAmount
= 6;
26 static const int kDefaultScrollDelayMS
= 85;
28 void GetBehavior(nsAString
& aValue
);
29 void SetBehavior(const nsAString
& aValue
, ErrorResult
& aError
) {
30 SetHTMLAttr(nsGkAtoms::behavior
, aValue
, aError
);
33 void GetDirection(nsAString
& aValue
);
34 void SetDirection(const nsAString
& aValue
, ErrorResult
& aError
) {
35 SetHTMLAttr(nsGkAtoms::direction
, aValue
, aError
);
38 void GetBgColor(DOMString
& aBgColor
) {
39 GetHTMLAttr(nsGkAtoms::bgcolor
, aBgColor
);
41 void SetBgColor(const nsAString
& aBgColor
, ErrorResult
& aError
) {
42 SetHTMLAttr(nsGkAtoms::bgcolor
, aBgColor
, aError
);
44 void GetHeight(DOMString
& aHeight
) {
45 GetHTMLAttr(nsGkAtoms::height
, aHeight
);
47 void SetHeight(const nsAString
& aHeight
, ErrorResult
& aError
) {
48 SetHTMLAttr(nsGkAtoms::height
, aHeight
, aError
);
51 return GetDimensionAttrAsUnsignedInt(nsGkAtoms::hspace
, 0);
53 void SetHspace(uint32_t aValue
, ErrorResult
& aError
) {
54 SetUnsignedIntAttr(nsGkAtoms::hspace
, aValue
, 0, aError
);
57 int loop
= GetIntAttr(nsGkAtoms::loop
, kDefaultLoop
);
64 void SetLoop(int32_t aValue
, ErrorResult
& aError
) {
65 if (aValue
== -1 || aValue
> 0) {
66 SetHTMLIntAttr(nsGkAtoms::loop
, aValue
, aError
);
69 uint32_t ScrollAmount() {
70 return GetUnsignedIntAttr(nsGkAtoms::scrollamount
, kDefaultScrollAmount
);
72 void SetScrollAmount(uint32_t aValue
, ErrorResult
& aError
) {
73 SetUnsignedIntAttr(nsGkAtoms::scrollamount
, aValue
, kDefaultScrollAmount
,
76 uint32_t ScrollDelay() {
77 return GetUnsignedIntAttr(nsGkAtoms::scrolldelay
, kDefaultScrollDelayMS
);
79 void SetScrollDelay(uint32_t aValue
, ErrorResult
& aError
) {
80 SetUnsignedIntAttr(nsGkAtoms::scrolldelay
, aValue
, kDefaultScrollDelayMS
,
83 bool TrueSpeed() const { return GetBoolAttr(nsGkAtoms::truespeed
); }
84 void SetTrueSpeed(bool aValue
, ErrorResult
& aError
) {
85 SetHTMLBoolAttr(nsGkAtoms::truespeed
, aValue
, aError
);
87 void GetWidth(DOMString
& aWidth
) { GetHTMLAttr(nsGkAtoms::width
, aWidth
); }
88 void SetWidth(const nsAString
& aWidth
, ErrorResult
& aError
) {
89 SetHTMLAttr(nsGkAtoms::width
, aWidth
, aError
);
92 return GetDimensionAttrAsUnsignedInt(nsGkAtoms::vspace
, 0);
94 void SetVspace(uint32_t aValue
, ErrorResult
& aError
) {
95 SetUnsignedIntAttr(nsGkAtoms::vspace
, aValue
, 0, aError
);
101 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
102 const nsAString
& aValue
,
103 nsIPrincipal
* aMaybeScriptedPrincipal
,
104 nsAttrValue
& aResult
) override
;
105 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
106 nsMapRuleToAttributesFunc
GetAttributeMappingFunction() const override
;
108 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
111 virtual ~HTMLMarqueeElement();
113 JSObject
* WrapNode(JSContext
* aCx
,
114 JS::Handle
<JSObject
*> aGivenProto
) override
;
117 static void MapAttributesIntoRule(MappedDeclarationsBuilder
&);
119 void DispatchEventToShadowRoot(const nsAString
& aEventTypeArg
);
122 } // namespace mozilla::dom
124 #endif /* HTMLMarqueeElement_h___ */