LibWeb: Support bgcolor attribute on tr elements

This commit is contained in:
Nicolas Ramz 2023-07-04 17:18:59 +02:00 committed by Sam Atkins
parent bd93b4984b
commit 876ad69ea3
Notes: sideshowbarker 2024-07-18 02:13:10 +09:00
2 changed files with 18 additions and 0 deletions

View file

@ -5,12 +5,15 @@
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/HTML/HTMLTableCellElement.h>
#include <LibWeb/HTML/HTMLTableElement.h>
#include <LibWeb/HTML/HTMLTableRowElement.h>
#include <LibWeb/HTML/HTMLTableSectionElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Namespace.h>
namespace Web::HTML {
@ -30,6 +33,20 @@ JS::ThrowCompletionOr<void> HTMLTableRowElement::initialize(JS::Realm& realm)
return {};
}
void HTMLTableRowElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
Base::apply_presentational_hints(style);
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::bgcolor) {
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value);
if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors());
return;
}
});
}
void HTMLTableRowElement::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);

View file

@ -32,6 +32,7 @@ private:
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
JS::GCPtr<DOM::HTMLCollection> mutable m_cells;
};