HTMLFontElement.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  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/StyleValue.h>
  9. #include <LibWeb/HTML/HTMLFontElement.h>
  10. namespace Web::HTML {
  11. HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  12. : HTMLElement(document, move(qualified_name))
  13. {
  14. }
  15. HTMLFontElement::~HTMLFontElement() = default;
  16. void HTMLFontElement::initialize(JS::Realm& realm)
  17. {
  18. Base::initialize(realm);
  19. set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFontElementPrototype>(realm, "HTMLFontElement"));
  20. }
  21. void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const
  22. {
  23. for_each_attribute([&](auto& name, auto& value) {
  24. if (name.equals_ignoring_case("color"sv)) {
  25. auto color = Color::from_string(value);
  26. if (color.has_value())
  27. style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
  28. }
  29. });
  30. }
  31. }