HTMLMarqueeElement.cpp 1.3 KB

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