Line data Source code
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 : #ifndef mozilla_dom_HTMLPreElement_h
8 : #define mozilla_dom_HTMLPreElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 :
12 : #include "nsIDOMHTMLPreElement.h"
13 : #include "nsGenericHTMLElement.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class HTMLPreElement final : public nsGenericHTMLElement,
19 : public nsIDOMHTMLPreElement
20 : {
21 : public:
22 0 : explicit HTMLPreElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
23 0 : : nsGenericHTMLElement(aNodeInfo)
24 : {
25 0 : }
26 :
27 : // nsISupports
28 : NS_DECL_ISUPPORTS_INHERITED
29 :
30 : // nsIDOMHTMLPreElement
31 : NS_IMETHOD GetWidth(int32_t* aWidth) override;
32 : NS_IMETHOD SetWidth(int32_t aWidth) override;
33 :
34 : virtual bool ParseAttribute(int32_t aNamespaceID,
35 : nsIAtom* aAttribute,
36 : const nsAString& aValue,
37 : nsAttrValue& aResult) override;
38 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
39 : virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
40 :
41 : virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
42 : bool aPreallocateChildren) const override;
43 :
44 : // WebIDL API
45 0 : int32_t Width() const
46 : {
47 0 : return GetIntAttr(nsGkAtoms::width, 0);
48 : }
49 0 : void SetWidth(int32_t aWidth, mozilla::ErrorResult& rv)
50 : {
51 0 : rv = SetIntAttr(nsGkAtoms::width, aWidth);
52 0 : }
53 :
54 : protected:
55 : virtual ~HTMLPreElement();
56 :
57 : virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
58 :
59 : private:
60 : static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
61 : GenericSpecifiedValues* aGenericData);
62 : };
63 :
64 : } // namespace dom
65 : } // namespace mozilla
66 :
67 : #endif // mozilla_dom_HTMLPreElement_h
|