Text.cpp 709 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/Text.h>
  7. #include <LibWeb/DOM/Window.h>
  8. #include <LibWeb/Layout/TextNode.h>
  9. namespace Web::DOM {
  10. Text::Text(Document& document, const String& data)
  11. : CharacterData(document, NodeType::TEXT_NODE, data)
  12. {
  13. }
  14. Text::~Text()
  15. {
  16. }
  17. RefPtr<Layout::Node> Text::create_layout_node()
  18. {
  19. return adopt_ref(*new Layout::TextNode(document(), *this));
  20. }
  21. // https://dom.spec.whatwg.org/#dom-text-text
  22. NonnullRefPtr<Text> Text::create_with_global_object(Bindings::WindowObject& window, String const& data)
  23. {
  24. return make_ref_counted<Text>(window.impl().document(), data);
  25. }
  26. }