HTMLMarqueeElement.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/ColorStyleValue.h>
  9. #include <LibWeb/HTML/HTMLMarqueeElement.h>
  10. #include <LibWeb/HTML/Parser/HTMLParser.h>
  11. namespace Web::HTML {
  12. JS_DEFINE_ALLOCATOR(HTMLMarqueeElement);
  13. HTMLMarqueeElement::HTMLMarqueeElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  14. : HTMLElement(document, move(qualified_name))
  15. {
  16. }
  17. HTMLMarqueeElement::~HTMLMarqueeElement() = default;
  18. void HTMLMarqueeElement::initialize(JS::Realm& realm)
  19. {
  20. Base::initialize(realm);
  21. WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLMarqueeElement);
  22. }
  23. void HTMLMarqueeElement::apply_presentational_hints(CSS::StyleProperties& style) const
  24. {
  25. HTMLElement::apply_presentational_hints(style);
  26. for_each_attribute([&](auto& name, auto& value) {
  27. if (name == HTML::AttributeNames::bgcolor) {
  28. // https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:rules-for-parsing-a-legacy-colour-value
  29. auto color = parse_legacy_color_value(value);
  30. if (color.has_value())
  31. style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
  32. }
  33. });
  34. }
  35. }