@@ -1760,24 +1760,6 @@ void StyleComputer::compute_defaulted_values(ComputedProperties& style, DOM::Ele
1760
1760
auto const & inherited_value = get_inherit_value (CSS::PropertyID::Color, element, pseudo_element);
1761
1761
style.set_property (CSS::PropertyID::Color, inherited_value);
1762
1762
}
1763
-
1764
- // AD-HOC: The -libweb-inherit-or-center style defaults to centering, unless a style value usually would have been
1765
- // inherited. This is used to support the ad-hoc default <th> text-align behavior.
1766
- if (element && element->local_name () == HTML::TagNames::th
1767
- && style.property (PropertyID::TextAlign).to_keyword () == Keyword::LibwebInheritOrCenter) {
1768
- auto const * parent_element = element;
1769
- while ((parent_element = parent_element->element_to_inherit_style_from ({}))) {
1770
- auto parent_computed = parent_element->computed_properties ();
1771
- auto parent_cascaded = parent_element->cascaded_properties ({});
1772
- if (!parent_computed || !parent_cascaded)
1773
- break ;
1774
- if (parent_cascaded->property (PropertyID::TextAlign)) {
1775
- auto const & style_value = parent_computed->property (PropertyID::TextAlign);
1776
- style.set_property (PropertyID::TextAlign, style_value, ComputedProperties::Inherited::Yes);
1777
- break ;
1778
- }
1779
- }
1780
- }
1781
1763
}
1782
1764
1783
1765
Length::FontMetrics StyleComputer::calculate_root_element_font_metrics (ComputedProperties const & style) const
@@ -2307,11 +2289,13 @@ void StyleComputer::resolve_effective_overflow_values(ComputedProperties& style)
2307
2289
2308
2290
static void compute_text_align (ComputedProperties& style, DOM::Element const & element, Optional<PseudoElement> pseudo_element)
2309
2291
{
2292
+ auto text_align_keyword = style.property (PropertyID::TextAlign).to_keyword ();
2293
+
2310
2294
// https://drafts.csswg.org/css-text-4/#valdef-text-align-match-parent
2311
2295
// This value behaves the same as inherit (computes to its parent’s computed value) except that an inherited
2312
2296
// value of start or end is interpreted against the parent’s direction value and results in a computed value of
2313
2297
// either left or right. Computes to start when specified on the root element.
2314
- if (style. property (PropertyID::TextAlign). to_keyword () == Keyword::MatchParent) {
2298
+ if (text_align_keyword == Keyword::MatchParent) {
2315
2299
auto const parent = element.element_to_inherit_style_from (pseudo_element);
2316
2300
if (parent) {
2317
2301
auto const & parent_text_align = parent->computed_properties ()->property (PropertyID::TextAlign);
@@ -2340,6 +2324,23 @@ static void compute_text_align(ComputedProperties& style, DOM::Element const& el
2340
2324
style.set_property (PropertyID::TextAlign, KeywordStyleValue::create (Keyword::Start));
2341
2325
}
2342
2326
}
2327
+
2328
+ // AD-HOC: The -libweb-inherit-or-center style defaults to centering, unless a style value usually would have been
2329
+ // inherited. This is used to support the ad-hoc default <th> text-align behavior.
2330
+ if (text_align_keyword == Keyword::LibwebInheritOrCenter && element.local_name () == HTML::TagNames::th) {
2331
+ auto const * parent_element = &element;
2332
+ while ((parent_element = parent_element->element_to_inherit_style_from ({}))) {
2333
+ auto parent_computed = parent_element->computed_properties ();
2334
+ auto parent_cascaded = parent_element->cascaded_properties ({});
2335
+ if (!parent_computed || !parent_cascaded)
2336
+ break ;
2337
+ if (parent_cascaded->property (PropertyID::TextAlign)) {
2338
+ auto const & style_value = parent_computed->property (PropertyID::TextAlign);
2339
+ style.set_property (PropertyID::TextAlign, style_value, ComputedProperties::Inherited::Yes);
2340
+ break ;
2341
+ }
2342
+ }
2343
+ }
2343
2344
}
2344
2345
2345
2346
enum class BoxTypeTransformation {
0 commit comments