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/HTMLTableElement.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
|
|
|
HTMLTableElement::HTMLTableElement(DOM::Document& document, QualifiedName qualified_name)
|
|
|
|
: HTMLElement(document, move(qualified_name))
|
2020-06-07 23:10:45 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HTMLTableElement::~HTMLTableElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-26 20:01:35 +02:00
|
|
|
void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
2020-06-12 22:52:38 +02:00
|
|
|
{
|
|
|
|
for_each_attribute([&](auto& name, auto& value) {
|
|
|
|
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 12:43:22 +02:00
|
|
|
style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
|
2020-06-13 10:54:20 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-08-26 21:16:29 +02:00
|
|
|
if (name == HTML::AttributeNames::height) {
|
|
|
|
if (auto parsed_value = parse_html_length(document(), value))
|
|
|
|
style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
|
|
|
|
return;
|
|
|
|
}
|
2020-06-13 10:54:20 +02:00
|
|
|
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 10:54:20 +02:00
|
|
|
return;
|
2020-06-12 22:52:38 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-06-07 23:10:45 +02:00
|
|
|
}
|