HTMLPreElement.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/CSS/StyleProperties.h>
  8. #include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
  9. #include <LibWeb/HTML/HTMLPreElement.h>
  10. namespace Web::HTML {
  11. JS_DEFINE_ALLOCATOR(HTMLPreElement);
  12. HTMLPreElement::HTMLPreElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  13. : HTMLElement(document, move(qualified_name))
  14. {
  15. }
  16. HTMLPreElement::~HTMLPreElement() = default;
  17. void HTMLPreElement::initialize(JS::Realm& realm)
  18. {
  19. Base::initialize(realm);
  20. set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLPreElementPrototype>(realm, "HTMLPreElement"_fly_string));
  21. }
  22. void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) const
  23. {
  24. HTMLElement::apply_presentational_hints(style);
  25. for_each_attribute([&](auto const& name, auto const&) {
  26. if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap))
  27. style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap));
  28. });
  29. }
  30. }