/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, the SerenityOS developers. |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/HTMLDivElementPrototype.h> |
8 | | #include <LibWeb/Bindings/Intrinsics.h> |
9 | | #include <LibWeb/CSS/StyleProperties.h> |
10 | | #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h> |
11 | | #include <LibWeb/HTML/HTMLDivElement.h> |
12 | | |
13 | | namespace Web::HTML { |
14 | | |
15 | | JS_DEFINE_ALLOCATOR(HTMLDivElement); |
16 | | |
17 | | HTMLDivElement::HTMLDivElement(DOM::Document& document, DOM::QualifiedName qualified_name) |
18 | 0 | : HTMLElement(document, move(qualified_name)) |
19 | 0 | { |
20 | 0 | } |
21 | | |
22 | 0 | HTMLDivElement::~HTMLDivElement() = default; |
23 | | |
24 | | // https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 |
25 | | void HTMLDivElement::apply_presentational_hints(CSS::StyleProperties& style) const |
26 | 0 | { |
27 | 0 | for_each_attribute([&](auto& name, auto& value) { |
28 | 0 | if (name.equals_ignoring_ascii_case("align"sv)) { |
29 | 0 | if (value.equals_ignoring_ascii_case("left"sv)) |
30 | 0 | style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::LibwebLeft)); |
31 | 0 | else if (value.equals_ignoring_ascii_case("right"sv)) |
32 | 0 | style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::LibwebRight)); |
33 | 0 | else if (value.equals_ignoring_ascii_case("center"sv)) |
34 | 0 | style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::LibwebCenter)); |
35 | 0 | else if (value.equals_ignoring_ascii_case("justify"sv)) |
36 | 0 | style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Justify)); |
37 | 0 | } |
38 | 0 | }); |
39 | 0 | } |
40 | | |
41 | | void HTMLDivElement::initialize(JS::Realm& realm) |
42 | 0 | { |
43 | 0 | Base::initialize(realm); |
44 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLDivElement); |
45 | 0 | } |
46 | | |
47 | | } |