Comment.cpp 724 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/Comment.h>
  7. #include <LibWeb/HTML/Window.h>
  8. #include <LibWeb/Layout/TextNode.h>
  9. namespace Web::DOM {
  10. Comment::Comment(Document& document, DeprecatedString const& data)
  11. : CharacterData(document, NodeType::COMMENT_NODE, data)
  12. {
  13. }
  14. // https://dom.spec.whatwg.org/#dom-comment-comment
  15. WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data)
  16. {
  17. auto& window = verify_cast<HTML::Window>(realm.global_object());
  18. return MUST_OR_THROW_OOM(realm.heap().allocate<Comment>(realm, window.associated_document(), data));
  19. }
  20. }