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_HTMLLegendElement_h
8 : #define mozilla_dom_HTMLLegendElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsGenericHTMLElement.h"
12 : #include "mozilla/dom/HTMLFormElement.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class HTMLLegendElement final : public nsGenericHTMLElement
18 : {
19 : public:
20 0 : explicit HTMLLegendElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
21 0 : : nsGenericHTMLElement(aNodeInfo)
22 : {
23 0 : }
24 :
25 : NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLLegendElement, legend)
26 :
27 : using nsGenericHTMLElement::Focus;
28 : virtual void Focus(ErrorResult& aError) override;
29 :
30 : virtual bool PerformAccesskey(bool aKeyCausesActivation,
31 : bool aIsTrustedEvent) override;
32 :
33 : // nsIContent
34 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
35 : nsIContent* aBindingParent,
36 : bool aCompileEventHandlers) override;
37 : virtual void UnbindFromTree(bool aDeep = true,
38 : bool aNullParent = true) override;
39 : virtual bool ParseAttribute(int32_t aNamespaceID,
40 : nsIAtom* aAttribute,
41 : const nsAString& aValue,
42 : nsAttrValue& aResult) override;
43 : virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
44 : int32_t aModType) const override;
45 :
46 : virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
47 : bool aPreallocateChildren) const override;
48 :
49 0 : Element* GetFormElement() const
50 : {
51 0 : nsCOMPtr<nsIFormControl> fieldsetControl = do_QueryInterface(GetFieldSet());
52 :
53 0 : return fieldsetControl ? fieldsetControl->GetFormElement() : nullptr;
54 : }
55 :
56 : /**
57 : * WebIDL Interface
58 : */
59 :
60 : already_AddRefed<HTMLFormElement> GetForm();
61 :
62 0 : void GetAlign(DOMString& aAlign)
63 : {
64 0 : GetHTMLAttr(nsGkAtoms::align, aAlign);
65 0 : }
66 :
67 0 : void SetAlign(const nsAString& aAlign, ErrorResult& aError)
68 : {
69 0 : SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
70 0 : }
71 :
72 0 : nsINode* GetScopeChainParent() const override
73 : {
74 0 : Element* form = GetFormElement();
75 0 : return form ? form : nsGenericHTMLElement::GetScopeChainParent();
76 : }
77 :
78 : protected:
79 : virtual ~HTMLLegendElement();
80 :
81 : virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
82 :
83 : /**
84 : * Get the fieldset content element that contains this legend.
85 : * Returns null if there is no fieldset containing this legend.
86 : */
87 : nsIContent* GetFieldSet() const;
88 : };
89 :
90 : } // namespace dom
91 : } // namespace mozilla
92 :
93 : #endif /* mozilla_dom_HTMLLegendElement_h */
|