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 file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_HTMLOptGroupElement_h
8 : #define mozilla_dom_HTMLOptGroupElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsIDOMHTMLOptGroupElement.h"
12 : #include "nsGenericHTMLElement.h"
13 :
14 : namespace mozilla {
15 : class EventChainPreVisitor;
16 : namespace dom {
17 :
18 : class HTMLOptGroupElement final : public nsGenericHTMLElement,
19 : public nsIDOMHTMLOptGroupElement
20 : {
21 : public:
22 : explicit HTMLOptGroupElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
23 :
24 0 : NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLOptGroupElement, optgroup)
25 :
26 : // nsISupports
27 : NS_DECL_ISUPPORTS_INHERITED
28 :
29 : // nsIDOMHTMLOptGroupElement
30 : NS_DECL_NSIDOMHTMLOPTGROUPELEMENT
31 :
32 : // nsINode
33 : virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
34 : bool aNotify) override;
35 : virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
36 :
37 : // nsIContent
38 : virtual nsresult GetEventTargetParent(
39 : EventChainPreVisitor& aVisitor) override;
40 :
41 : virtual EventStates IntrinsicState() const override;
42 :
43 : virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
44 : bool aPreallocateChildren) const override;
45 :
46 : virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
47 : const nsAttrValue* aValue,
48 : const nsAttrValue* aOldValue,
49 : bool aNotify) override;
50 :
51 0 : virtual nsIDOMNode* AsDOMNode() override { return this; }
52 :
53 0 : virtual bool IsDisabled() const override {
54 0 : return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
55 : }
56 :
57 0 : bool Disabled() const
58 : {
59 0 : return GetBoolAttr(nsGkAtoms::disabled);
60 : }
61 0 : void SetDisabled(bool aValue, ErrorResult& aError)
62 : {
63 0 : SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aError);
64 0 : }
65 :
66 : // The XPCOM GetLabel is OK for us
67 0 : void SetLabel(const nsAString& aLabel, ErrorResult& aError)
68 : {
69 0 : SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
70 0 : }
71 :
72 : protected:
73 : virtual ~HTMLOptGroupElement();
74 :
75 : virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
76 :
77 : protected:
78 :
79 : /**
80 : * Get the select content element that contains this option
81 : * @param aSelectElement the select element [OUT]
82 : */
83 : Element* GetSelect();
84 : };
85 :
86 : } // namespace dom
87 : } // namespace mozilla
88 :
89 : #endif /* mozilla_dom_HTMLOptGroupElement_h */
|