/src/serenity/Userland/Libraries/LibWeb/DOM/Comment.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/CommentPrototype.h> |
8 | | #include <LibWeb/DOM/Comment.h> |
9 | | #include <LibWeb/HTML/Window.h> |
10 | | #include <LibWeb/Layout/TextNode.h> |
11 | | |
12 | | namespace Web::DOM { |
13 | | |
14 | | JS_DEFINE_ALLOCATOR(Comment); |
15 | | |
16 | | Comment::Comment(Document& document, String const& data) |
17 | 0 | : CharacterData(document, NodeType::COMMENT_NODE, data) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | | // https://dom.spec.whatwg.org/#dom-comment-comment |
22 | | WebIDL::ExceptionOr<JS::NonnullGCPtr<Comment>> Comment::construct_impl(JS::Realm& realm, String const& data) |
23 | 0 | { |
24 | 0 | auto& window = verify_cast<HTML::Window>(realm.global_object()); |
25 | 0 | return realm.heap().allocate<Comment>(realm, window.associated_document(), data); |
26 | 0 | } |
27 | | |
28 | | void Comment::initialize(JS::Realm& realm) |
29 | 0 | { |
30 | 0 | Base::initialize(realm); |
31 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(Comment); |
32 | 0 | } |
33 | | |
34 | | } |