@@ -572,10 +572,10 @@ static void ensure_pseudo_element_style_for_cssom(DOM::AbstractElement abstract_
572572
573573 bool did_change_custom_properties = false ;
574574 auto style = style_computer.compute_pseudo_element_style_if_needed (abstract_element, did_change_custom_properties);
575- if (style. has_value () )
576- abstract_element.element ().set_computed_style (*pseudo_element, move (style-> properties ), move (style-> values ));
575+ if (style)
576+ abstract_element.element ().set_computed_style (*pseudo_element, move (style));
577577 else
578- abstract_element.element ().set_computed_style (*pseudo_element, nullptr , nullptr );
578+ abstract_element.element ().set_computed_style (*pseudo_element, nullptr );
579579}
580580
581581Optional<StyleProperty> CSSStyleProperties::get_direct_property (PropertyNameAndID const & property_name_and_id) const
@@ -680,31 +680,22 @@ Optional<StyleProperty> CSSStyleProperties::get_direct_property(PropertyNameAndI
680680
681681 if (!layout_node) {
682682 auto computed_values = abstract_element.computed_values ();
683- auto computed_properties = abstract_element.computed_properties ();
684- Optional<StyleComputationResult> transient_style;
683+ RefPtr<ComputedValues const > transient_style;
685684 if (!computed_values) {
686685 // A synthetic pseudo-element without matching rules has no durable style. Seed the ancestor chain
687686 // before this one-off computation so ancestor-dependent selectors still match.
688687 transient_style = abstract_element.document ().style_computer ().compute_style_with_seeded_ancestors (abstract_element);
689- computed_values = transient_style->values ;
690- computed_properties = transient_style->properties ;
688+ computed_values = transient_style;
691689 }
692690
693691 auto computed_value_for_property = [&](PropertyID computed_property_id) -> NonnullRefPtr<StyleValue const > {
694692 if (property_is_logical_alias (computed_property_id))
695693 computed_property_id = map_logical_alias_to_physical_property (computed_property_id, LogicalAliasMappingContext { computed_values->writing_mode (), computed_values->direction () });
696- auto computed_value = computed_values->computed_style_value (computed_property_id).release_nonnull ();
697- if (computed_property_id == PropertyID::Color)
698- return computed_value;
699- if (computed_properties) {
700- auto const & generic_value = computed_properties->property (computed_property_id);
701- // NB: Color keywords need the resolved typed color when there is no layout node.
702- if (property_accepts_type (computed_property_id, ValueType::Color) && generic_value.is_keyword () && first_is_one_of (generic_value.to_keyword (), Keyword::Auto, Keyword::Currentcolor))
703- return computed_value;
704- // NB: Keep the generic value until typed reconstruction is structurally lossless for this property.
705- if (*computed_value != generic_value)
706- return generic_value;
694+ if (computed_property_id == PropertyID::BackgroundColor) {
695+ if (auto style_value = computed_values->background_color_style_value (); style_value && !style_value->depends_on_current_color ())
696+ return style_value.release_nonnull ();
707697 }
698+ auto computed_value = computed_values->computed_style_value (computed_property_id).release_nonnull ();
708699 return computed_value;
709700 };
710701
@@ -816,12 +807,7 @@ RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(L
816807 };
817808
818809 auto get_computed_value = [&element, pseudo_element](PropertyID property_id) -> NonnullRefPtr<StyleValue const > {
819- auto computed_value = element.computed_values (pseudo_element)->computed_style_value (property_id).release_nonnull ();
820- auto const & generic_value = element.computed_properties (pseudo_element)->property (property_id);
821- // NB: Keep the generic value until typed reconstruction is structurally lossless for this property.
822- if (*computed_value != generic_value)
823- return generic_value;
824- return computed_value;
810+ return element.computed_values (pseudo_element)->computed_style_value (property_id).release_nonnull ();
825811 };
826812
827813 if (property_is_logical_alias (property_id)) {
@@ -855,7 +841,10 @@ RefPtr<StyleValue const> CSSStyleProperties::style_value_for_computed_property(L
855841 // -> A resolved value special case property like color defined in another specification
856842 // The resolved value is the used value.
857843 case PropertyID::BackgroundColor:
858- return resolve_color_style_value (*get_computed_value (property_id), layout_node.computed_values ().background_color (), &layout_node);
844+ return resolve_color_style_value (
845+ *layout_node.computed_values ().background_color_style_value (),
846+ layout_node.computed_values ().background_color (),
847+ &layout_node);
859848 case PropertyID::BorderBottomColor:
860849 return resolve_color_style_value (*get_computed_value (property_id), layout_node.computed_values ().border_bottom ().color , &layout_node);
861850 case PropertyID::BorderLeftColor:
0 commit comments