HTMLPreElement.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/StyleValues/IdentifierStyleValue.h>
  8. #include <LibWeb/HTML/HTMLPreElement.h>
  9. namespace Web::HTML {
  10. HTMLPreElement::HTMLPreElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : HTMLElement(document, move(qualified_name))
  12. {
  13. }
  14. HTMLPreElement::~HTMLPreElement() = default;
  15. JS::ThrowCompletionOr<void> HTMLPreElement::initialize(JS::Realm& realm)
  16. {
  17. MUST_OR_THROW_OOM(Base::initialize(realm));
  18. set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLPreElementPrototype>(realm, "HTMLPreElement"));
  19. return {};
  20. }
  21. void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) const
  22. {
  23. HTMLElement::apply_presentational_hints(style);
  24. for_each_attribute([&](auto const& name, auto const&) {
  25. if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap))
  26. style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap));
  27. });
  28. }
  29. }