HTMLLegendElement.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_HTMLLegendElement_h
  6. #define mozilla_dom_HTMLLegendElement_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsGenericHTMLElement.h"
  9. #include "mozilla/dom/HTMLFormElement.h"
  10. namespace mozilla {
  11. namespace dom {
  12. class HTMLLegendElement final : public nsGenericHTMLElement
  13. {
  14. public:
  15. explicit HTMLLegendElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  16. : nsGenericHTMLElement(aNodeInfo)
  17. {
  18. }
  19. NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLLegendElement, legend)
  20. using nsGenericHTMLElement::Focus;
  21. virtual void Focus(ErrorResult& aError) override;
  22. virtual bool PerformAccesskey(bool aKeyCausesActivation,
  23. bool aIsTrustedEvent) override;
  24. // nsIContent
  25. virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
  26. nsIContent* aBindingParent,
  27. bool aCompileEventHandlers) override;
  28. virtual void UnbindFromTree(bool aDeep = true,
  29. bool aNullParent = true) override;
  30. virtual bool ParseAttribute(int32_t aNamespaceID,
  31. nsIAtom* aAttribute,
  32. const nsAString& aValue,
  33. nsAttrValue& aResult) override;
  34. virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
  35. int32_t aModType) const override;
  36. virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
  37. Element* GetFormElement() const
  38. {
  39. nsCOMPtr<nsIFormControl> fieldsetControl = do_QueryInterface(GetFieldSet());
  40. return fieldsetControl ? fieldsetControl->GetFormElement() : nullptr;
  41. }
  42. /**
  43. * WebIDL Interface
  44. */
  45. already_AddRefed<HTMLFormElement> GetForm();
  46. void GetAlign(DOMString& aAlign)
  47. {
  48. GetHTMLAttr(nsGkAtoms::align, aAlign);
  49. }
  50. void SetAlign(const nsAString& aAlign, ErrorResult& aError)
  51. {
  52. SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
  53. }
  54. nsINode* GetScopeChainParent() const override
  55. {
  56. Element* form = GetFormElement();
  57. return form ? form : nsGenericHTMLElement::GetScopeChainParent();
  58. }
  59. protected:
  60. virtual ~HTMLLegendElement();
  61. virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  62. /**
  63. * Get the fieldset content element that contains this legend.
  64. * Returns null if there is no fieldset containing this legend.
  65. */
  66. nsIContent* GetFieldSet() const;
  67. };
  68. } // namespace dom
  69. } // namespace mozilla
  70. #endif /* mozilla_dom_HTMLLegendElement_h */