HTMLPreElement.cpp 1.1 KB

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