HTMLBRElement.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/HTMLBRElementPrototype.h>
  7. #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
  8. #include <LibWeb/DOM/Document.h>
  9. #include <LibWeb/HTML/HTMLBRElement.h>
  10. #include <LibWeb/Layout/BreakNode.h>
  11. namespace Web::HTML {
  12. JS_DEFINE_ALLOCATOR(HTMLBRElement);
  13. HTMLBRElement::HTMLBRElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  14. : HTMLElement(document, move(qualified_name))
  15. {
  16. }
  17. HTMLBRElement::~HTMLBRElement() = default;
  18. void HTMLBRElement::initialize(JS::Realm& realm)
  19. {
  20. Base::initialize(realm);
  21. WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLBRElement);
  22. }
  23. JS::GCPtr<Layout::Node> HTMLBRElement::create_layout_node(CSS::StyleProperties style)
  24. {
  25. return heap().allocate<Layout::BreakNode>(document(), *this, move(style));
  26. }
  27. void HTMLBRElement::adjust_computed_style(CSS::StyleProperties& style)
  28. {
  29. // https://drafts.csswg.org/css-display-3/#unbox
  30. if (style.display().is_contents())
  31. style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None)));
  32. }
  33. }