mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 09:18:55 +00:00
LibWeb/CSS: Take AbstractElement in compute_cascaded_values()
This commit is contained in:
parent
82d194ba99
commit
44e70d9087
Notes:
github-actions[bot]
2025-09-11 16:47:34 +00:00
Author: https://github.com/AtkinsSJ
Commit: 44e70d9087
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6118
2 changed files with 13 additions and 13 deletions
|
@ -1541,7 +1541,7 @@ StyleComputer::MatchingRuleSet StyleComputer::build_matching_rule_set(DOM::Abstr
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-cascade/#cascading
|
// https://www.w3.org/TR/css-cascade/#cascading
|
||||||
// https://drafts.csswg.org/css-cascade-5/#layering
|
// https://drafts.csswg.org/css-cascade-5/#layering
|
||||||
GC::Ref<CascadedProperties> StyleComputer::compute_cascaded_values(DOM::Element& element, Optional<CSS::PseudoElement> pseudo_element, bool did_match_any_pseudo_element_rules, ComputeStyleMode mode, MatchingRuleSet const& matching_rule_set, Optional<LogicalAliasMappingContext> logical_alias_mapping_context, ReadonlySpan<PropertyID> properties_to_cascade) const
|
GC::Ref<CascadedProperties> StyleComputer::compute_cascaded_values(DOM::AbstractElement abstract_element, bool did_match_any_pseudo_element_rules, ComputeStyleMode mode, MatchingRuleSet const& matching_rule_set, Optional<LogicalAliasMappingContext> logical_alias_mapping_context, ReadonlySpan<PropertyID> properties_to_cascade) const
|
||||||
{
|
{
|
||||||
auto cascaded_properties = m_document->heap().allocate<CascadedProperties>();
|
auto cascaded_properties = m_document->heap().allocate<CascadedProperties>();
|
||||||
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded) {
|
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded) {
|
||||||
|
@ -1550,10 +1550,10 @@ GC::Ref<CascadedProperties> StyleComputer::compute_cascaded_values(DOM::Element&
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal user agent declarations
|
// Normal user agent declarations
|
||||||
cascade_declarations(*cascaded_properties, { element, pseudo_element }, matching_rule_set.user_agent_rules, CascadeOrigin::UserAgent, Important::No, {}, logical_alias_mapping_context, properties_to_cascade);
|
cascade_declarations(*cascaded_properties, abstract_element, matching_rule_set.user_agent_rules, CascadeOrigin::UserAgent, Important::No, {}, logical_alias_mapping_context, properties_to_cascade);
|
||||||
|
|
||||||
// Normal user declarations
|
// Normal user declarations
|
||||||
cascade_declarations(*cascaded_properties, { element, pseudo_element }, matching_rule_set.user_rules, CascadeOrigin::User, Important::No, {}, logical_alias_mapping_context, properties_to_cascade);
|
cascade_declarations(*cascaded_properties, abstract_element, matching_rule_set.user_rules, CascadeOrigin::User, Important::No, {}, logical_alias_mapping_context, properties_to_cascade);
|
||||||
|
|
||||||
// Author presentational hints
|
// Author presentational hints
|
||||||
// The spec calls this a special "Author presentational hint origin":
|
// The spec calls this a special "Author presentational hint origin":
|
||||||
|
@ -1561,7 +1561,8 @@ GC::Ref<CascadedProperties> StyleComputer::compute_cascaded_values(DOM::Element&
|
||||||
// however for the purpose of the revert keyword (but not for the revert-layer keyword) it is considered
|
// however for the purpose of the revert keyword (but not for the revert-layer keyword) it is considered
|
||||||
// part of the author origin."
|
// part of the author origin."
|
||||||
// https://drafts.csswg.org/css-cascade-5/#author-presentational-hint-origin
|
// https://drafts.csswg.org/css-cascade-5/#author-presentational-hint-origin
|
||||||
if (!pseudo_element.has_value()) {
|
if (!abstract_element.pseudo_element().has_value()) {
|
||||||
|
auto& element = abstract_element.element();
|
||||||
element.apply_presentational_hints(cascaded_properties);
|
element.apply_presentational_hints(cascaded_properties);
|
||||||
if (element.supports_dimension_attributes()) {
|
if (element.supports_dimension_attributes()) {
|
||||||
apply_dimension_attribute(cascaded_properties, element, HTML::AttributeNames::width, CSS::PropertyID::Width);
|
apply_dimension_attribute(cascaded_properties, element, HTML::AttributeNames::width, CSS::PropertyID::Width);
|
||||||
|
@ -1570,24 +1571,24 @@ GC::Ref<CascadedProperties> StyleComputer::compute_cascaded_values(DOM::Element&
|
||||||
|
|
||||||
// SVG presentation attributes are parsed as CSS values, so we need to handle potential custom properties here.
|
// SVG presentation attributes are parsed as CSS values, so we need to handle potential custom properties here.
|
||||||
if (element.is_svg_element())
|
if (element.is_svg_element())
|
||||||
cascaded_properties->resolve_unresolved_properties({ element, pseudo_element });
|
cascaded_properties->resolve_unresolved_properties(abstract_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal author declarations, ordered by @layer, with un-@layer-ed rules last
|
// Normal author declarations, ordered by @layer, with un-@layer-ed rules last
|
||||||
for (auto const& layer : matching_rule_set.author_rules) {
|
for (auto const& layer : matching_rule_set.author_rules) {
|
||||||
cascade_declarations(cascaded_properties, { element, pseudo_element }, layer.rules, CascadeOrigin::Author, Important::No, layer.qualified_layer_name, logical_alias_mapping_context, properties_to_cascade);
|
cascade_declarations(cascaded_properties, abstract_element, layer.rules, CascadeOrigin::Author, Important::No, layer.qualified_layer_name, logical_alias_mapping_context, properties_to_cascade);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Important author declarations, with un-@layer-ed rules first, followed by each @layer in reverse order.
|
// Important author declarations, with un-@layer-ed rules first, followed by each @layer in reverse order.
|
||||||
for (auto const& layer : matching_rule_set.author_rules.in_reverse()) {
|
for (auto const& layer : matching_rule_set.author_rules.in_reverse()) {
|
||||||
cascade_declarations(cascaded_properties, { element, pseudo_element }, layer.rules, CascadeOrigin::Author, Important::Yes, {}, logical_alias_mapping_context, properties_to_cascade);
|
cascade_declarations(cascaded_properties, abstract_element, layer.rules, CascadeOrigin::Author, Important::Yes, {}, logical_alias_mapping_context, properties_to_cascade);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Important user declarations
|
// Important user declarations
|
||||||
cascade_declarations(cascaded_properties, { element, pseudo_element }, matching_rule_set.user_rules, CascadeOrigin::User, Important::Yes, {}, logical_alias_mapping_context, properties_to_cascade);
|
cascade_declarations(cascaded_properties, abstract_element, matching_rule_set.user_rules, CascadeOrigin::User, Important::Yes, {}, logical_alias_mapping_context, properties_to_cascade);
|
||||||
|
|
||||||
// Important user agent declarations
|
// Important user agent declarations
|
||||||
cascade_declarations(cascaded_properties, { element, pseudo_element }, matching_rule_set.user_agent_rules, CascadeOrigin::UserAgent, Important::Yes, {}, logical_alias_mapping_context, properties_to_cascade);
|
cascade_declarations(cascaded_properties, abstract_element, matching_rule_set.user_agent_rules, CascadeOrigin::UserAgent, Important::Yes, {}, logical_alias_mapping_context, properties_to_cascade);
|
||||||
|
|
||||||
// Transition declarations [css-transitions-1]
|
// Transition declarations [css-transitions-1]
|
||||||
// Note that we have to do these after finishing computing the style,
|
// Note that we have to do these after finishing computing the style,
|
||||||
|
@ -2042,8 +2043,7 @@ LogicalAliasMappingContext StyleComputer::compute_logical_alias_mapping_context(
|
||||||
PropertyID::Direction,
|
PropertyID::Direction,
|
||||||
};
|
};
|
||||||
auto cascaded_properties = compute_cascaded_values(
|
auto cascaded_properties = compute_cascaded_values(
|
||||||
element,
|
{ element, pseudo_element },
|
||||||
pseudo_element,
|
|
||||||
did_match_any_pseudo_element_rules,
|
did_match_any_pseudo_element_rules,
|
||||||
mode, matching_rule_set,
|
mode, matching_rule_set,
|
||||||
{},
|
{},
|
||||||
|
@ -2382,7 +2382,7 @@ GC::Ptr<ComputedProperties> StyleComputer::compute_style_impl(DOM::AbstractEleme
|
||||||
}
|
}
|
||||||
|
|
||||||
auto logical_alias_mapping_context = compute_logical_alias_mapping_context(abstract_element.element(), abstract_element.pseudo_element(), mode, matching_rule_set);
|
auto logical_alias_mapping_context = compute_logical_alias_mapping_context(abstract_element.element(), abstract_element.pseudo_element(), mode, matching_rule_set);
|
||||||
auto cascaded_properties = compute_cascaded_values(abstract_element.element(), abstract_element.pseudo_element(), did_match_any_pseudo_element_rules, mode, matching_rule_set, logical_alias_mapping_context, {});
|
auto cascaded_properties = compute_cascaded_values(abstract_element, did_match_any_pseudo_element_rules, mode, matching_rule_set, logical_alias_mapping_context, {});
|
||||||
abstract_element.set_cascaded_properties(cascaded_properties);
|
abstract_element.set_cascaded_properties(cascaded_properties);
|
||||||
|
|
||||||
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded) {
|
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded) {
|
||||||
|
|
|
@ -231,7 +231,7 @@ private:
|
||||||
|
|
||||||
LogicalAliasMappingContext compute_logical_alias_mapping_context(DOM::Element&, Optional<CSS::PseudoElement>, ComputeStyleMode, MatchingRuleSet const&) const;
|
LogicalAliasMappingContext compute_logical_alias_mapping_context(DOM::Element&, Optional<CSS::PseudoElement>, ComputeStyleMode, MatchingRuleSet const&) const;
|
||||||
[[nodiscard]] GC::Ptr<ComputedProperties> compute_style_impl(DOM::AbstractElement, ComputeStyleMode, Optional<bool&> did_change_custom_properties) const;
|
[[nodiscard]] GC::Ptr<ComputedProperties> compute_style_impl(DOM::AbstractElement, ComputeStyleMode, Optional<bool&> did_change_custom_properties) const;
|
||||||
[[nodiscard]] GC::Ref<CascadedProperties> compute_cascaded_values(DOM::Element&, Optional<CSS::PseudoElement>, bool did_match_any_pseudo_element_rules, ComputeStyleMode, MatchingRuleSet const&, Optional<LogicalAliasMappingContext>, ReadonlySpan<PropertyID> properties_to_cascade) const;
|
[[nodiscard]] GC::Ref<CascadedProperties> compute_cascaded_values(DOM::AbstractElement, bool did_match_any_pseudo_element_rules, ComputeStyleMode, MatchingRuleSet const&, Optional<LogicalAliasMappingContext>, ReadonlySpan<PropertyID> properties_to_cascade) const;
|
||||||
static RefPtr<Gfx::FontCascadeList const> find_matching_font_weight_ascending(Vector<MatchingFontCandidate> const& candidates, int target_weight, float font_size_in_pt, bool inclusive);
|
static RefPtr<Gfx::FontCascadeList const> find_matching_font_weight_ascending(Vector<MatchingFontCandidate> const& candidates, int target_weight, float font_size_in_pt, bool inclusive);
|
||||||
static RefPtr<Gfx::FontCascadeList const> find_matching_font_weight_descending(Vector<MatchingFontCandidate> const& candidates, int target_weight, float font_size_in_pt, bool inclusive);
|
static RefPtr<Gfx::FontCascadeList const> find_matching_font_weight_descending(Vector<MatchingFontCandidate> const& candidates, int target_weight, float font_size_in_pt, bool inclusive);
|
||||||
RefPtr<Gfx::FontCascadeList const> font_matching_algorithm(FlyString const& family_name, int weight, int slope, float font_size_in_pt) const;
|
RefPtr<Gfx::FontCascadeList const> font_matching_algorithm(FlyString const& family_name, int weight, int slope, float font_size_in_pt) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue