HTMLElement.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include "nsGenericHTMLElement.h"
  6. #include "mozilla/dom/HTMLElementBinding.h"
  7. #include "nsContentUtils.h"
  8. namespace mozilla {
  9. namespace dom {
  10. class HTMLElement final : public nsGenericHTMLElement
  11. {
  12. public:
  13. explicit HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  14. virtual ~HTMLElement();
  15. virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo,
  16. nsINode** aResult) const override;
  17. protected:
  18. virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
  19. };
  20. HTMLElement::HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  21. : nsGenericHTMLElement(aNodeInfo)
  22. {
  23. }
  24. HTMLElement::~HTMLElement()
  25. {
  26. }
  27. NS_IMPL_ELEMENT_CLONE(HTMLElement)
  28. JSObject*
  29. HTMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
  30. {
  31. return dom::HTMLElementBinding::Wrap(aCx, this, aGivenProto);
  32. }
  33. } // namespace dom
  34. } // namespace mozilla
  35. // Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand.
  36. // (Calling the macro directly (with no args) produces compiler warnings.)
  37. nsGenericHTMLElement*
  38. NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
  39. mozilla::dom::FromParser aFromParser)
  40. {
  41. return new mozilla::dom::HTMLElement(aNodeInfo);
  42. }
  43. // Distinct from the above in order to have function pointer that compared unequal
  44. // to a function pointer to the above.
  45. nsGenericHTMLElement*
  46. NS_NewCustomElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
  47. mozilla::dom::FromParser aFromParser)
  48. {
  49. return new mozilla::dom::HTMLElement(aNodeInfo);
  50. }