2020-06-07 23:10:45 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-07 23:10:45 +02:00
|
|
|
*/
|
|
|
|
|
2021-03-09 17:22:35 +01:00
|
|
|
#include <LibWeb/CSS/Parser/DeprecatedCSSParser.h>
|
2020-07-26 15:08:16 +02:00
|
|
|
#include <LibWeb/HTML/HTMLTableCellElement.h>
|
2020-06-07 23:10:45 +02:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-06-07 23:10:45 +02:00
|
|
|
|
2021-02-07 11:20:15 +01:00
|
|
|
HTMLTableCellElement::HTMLTableCellElement(DOM::Document& document, QualifiedName qualified_name)
|
|
|
|
: HTMLElement(document, move(qualified_name))
|
2020-06-07 23:10:45 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HTMLTableCellElement::~HTMLTableCellElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-26 20:01:35 +02:00
|
|
|
void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
2020-06-12 22:47:51 +02:00
|
|
|
{
|
|
|
|
for_each_attribute([&](auto& name, auto& value) {
|
|
|
|
if (name == HTML::AttributeNames::bgcolor) {
|
|
|
|
auto color = Color::from_string(value);
|
|
|
|
if (color.has_value())
|
2020-07-26 20:01:35 +02:00
|
|
|
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
|
2020-06-13 15:16:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (name == HTML::AttributeNames::align) {
|
|
|
|
if (value.equals_ignoring_case("center") || value.equals_ignoring_case("middle"))
|
|
|
|
style.set_property(CSS::PropertyID::TextAlign, StringView("-libweb-center"));
|
|
|
|
else
|
|
|
|
style.set_property(CSS::PropertyID::TextAlign, value.view());
|
|
|
|
return;
|
2020-06-12 22:47:51 +02:00
|
|
|
}
|
2020-06-28 14:30:03 +02:00
|
|
|
if (name == HTML::AttributeNames::width) {
|
2020-07-22 01:13:18 +02:00
|
|
|
if (auto parsed_value = parse_html_length(document(), value))
|
2020-06-28 14:30:03 +02:00
|
|
|
style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
|
|
|
|
return;
|
|
|
|
}
|
2020-06-12 22:47:51 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-06-07 23:10:45 +02:00
|
|
|
}
|