Serenity Operating System
at master 40 lines 1.2 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibWeb/Bindings/Intrinsics.h> 8#include <LibWeb/CSS/StyleProperties.h> 9#include <LibWeb/CSS/StyleValue.h> 10#include <LibWeb/HTML/HTMLFontElement.h> 11 12namespace Web::HTML { 13 14HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qualified_name) 15 : HTMLElement(document, move(qualified_name)) 16{ 17} 18 19HTMLFontElement::~HTMLFontElement() = default; 20 21JS::ThrowCompletionOr<void> HTMLFontElement::initialize(JS::Realm& realm) 22{ 23 MUST_OR_THROW_OOM(Base::initialize(realm)); 24 set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFontElementPrototype>(realm, "HTMLFontElement")); 25 26 return {}; 27} 28 29void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const 30{ 31 for_each_attribute([&](auto& name, auto& value) { 32 if (name.equals_ignoring_ascii_case("color"sv)) { 33 auto color = Color::from_string(value); 34 if (color.has_value()) 35 style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value())); 36 } 37 }); 38} 39 40}