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