mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
LibWeb: Move use pseudo element styles from TreeBuilder to StyleComputer
The styling of elements using the `use_pseudo_element()` was only applied on layout. When an element style was recomputed later that styling was not overruled with the pseudo element selector styles. This moves the styling override from `TreeBuilder.cpp` to `StyleComputer.cpp`. Now the styles are always correctly applied. I also removed the method `property_id_by_index()` because it was not needed anymore. Als some calls to `invalidate_layout()` in the Meter, Progress and Select elements where not needed anymore because the style values are update on the changing of the style attribute. This fixes issue #22278.
This commit is contained in:
parent
7578620f25
commit
a05fd28b7b
11 changed files with 44 additions and 49 deletions
|
@ -2136,6 +2136,20 @@ ErrorOr<RefPtr<StyleProperties>> StyleComputer::compute_style_impl(DOM::Element&
|
|||
{
|
||||
build_rule_cache_if_needed();
|
||||
|
||||
// Special path for elements that use pseudo element as style selector
|
||||
if (element.use_pseudo_element().has_value()) {
|
||||
auto& parent_element = verify_cast<HTML::HTMLElement>(*element.root().parent_or_shadow_host());
|
||||
auto style = TRY(compute_style(parent_element, *element.use_pseudo_element()));
|
||||
|
||||
// Merge back inline styles
|
||||
if (element.has_attribute(HTML::AttributeNames::style)) {
|
||||
auto* inline_style = parse_css_style_attribute(CSS::Parser::ParsingContext(document()), *element.get_attribute(HTML::AttributeNames::style), element);
|
||||
for (auto const& property : inline_style->properties())
|
||||
style->set_property(property.property_id, property.value);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
auto style = StyleProperties::create();
|
||||
// 1. Perform the cascade. This produces the "specified style"
|
||||
bool did_match_any_pseudo_element_rules = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue