HTMLMarqueeElement.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/HTML/HTMLMarqueeElement.h>
  8. namespace Web::HTML {
  9. HTMLMarqueeElement::HTMLMarqueeElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  10. : HTMLElement(document, move(qualified_name))
  11. {
  12. }
  13. HTMLMarqueeElement::~HTMLMarqueeElement() = default;
  14. JS::ThrowCompletionOr<void> HTMLMarqueeElement::initialize(JS::Realm& realm)
  15. {
  16. MUST_OR_THROW_OOM(Base::initialize(realm));
  17. set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMarqueeElementPrototype>(realm, "HTMLMarqueeElement"));
  18. return {};
  19. }
  20. void HTMLMarqueeElement::apply_presentational_hints(CSS::StyleProperties& style) const
  21. {
  22. HTMLElement::apply_presentational_hints(style);
  23. for_each_attribute([&](auto& name, auto& value) {
  24. if (name == HTML::AttributeNames::bgcolor) {
  25. auto color = Color::from_string(value);
  26. if (color.has_value())
  27. style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
  28. }
  29. });
  30. }
  31. }