LibWeb: Add writing-mode CSS property, and its values

Introduce the `writing-mode` property, as specified in
https://drafts.csswg.org/css-writing-modes/#block-flow

(cherry picked from commit c3f3e93b7e46e2f366fbc904852763af546d3913;
amended to fix conflict on `height:` in expectation)
This commit is contained in:
BenJilks 2024-10-27 22:12:54 +00:00 committed by Nico Weber
parent ded4fc8b2f
commit de4fe9fcfe
8 changed files with 40 additions and 1 deletions

View file

@ -49,6 +49,7 @@ white-space: normal
word-break: normal
word-spacing: normal
word-wrap: normal
writing-mode: horizontal-tb
align-content: normal
align-items: normal
align-self: auto
@ -123,7 +124,7 @@ grid-row-start: auto
grid-template-areas: none
grid-template-columns: auto
grid-template-rows: auto
height: 2125px
height: 2142px
inline-size: auto
inset-block-end: auto
inset-block-start: auto

View file

@ -191,6 +191,7 @@ public:
static CSS::TransformBox transform_box() { return CSS::TransformBox::ViewBox; }
static CSS::Direction direction() { return CSS::Direction::Ltr; }
static CSS::UnicodeBidi unicode_bidi() { return CSS::UnicodeBidi::Normal; }
static CSS::WritingMode writing_mode() { return CSS::WritingMode::HorizontalTb; }
// https://www.w3.org/TR/SVG/geometry.html
static LengthPercentage cx() { return CSS::Length::make_px(0); }
@ -443,6 +444,7 @@ public:
CSS::ObjectPosition object_position() const { return m_noninherited.object_position; }
CSS::Direction direction() const { return m_inherited.direction; }
CSS::UnicodeBidi unicode_bidi() const { return m_noninherited.unicode_bidi; }
CSS::WritingMode writing_mode() const { return m_inherited.writing_mode; }
CSS::LengthBox const& inset() const { return m_noninherited.inset; }
const CSS::LengthBox& margin() const { return m_noninherited.margin; }
@ -567,6 +569,7 @@ protected:
CSS::Visibility visibility { InitialValues::visibility() };
CSS::QuotesData quotes { InitialValues::quotes() };
CSS::Direction direction { InitialValues::direction() };
CSS::WritingMode writing_mode { InitialValues::writing_mode() };
Optional<SVGPaint> fill;
CSS::FillRule fill_rule { InitialValues::fill_rule() };
@ -813,6 +816,7 @@ public:
void set_object_position(CSS::ObjectPosition value) { m_noninherited.object_position = value; }
void set_direction(CSS::Direction value) { m_inherited.direction = value; }
void set_unicode_bidi(CSS::UnicodeBidi value) { m_noninherited.unicode_bidi = value; }
void set_writing_mode(CSS::WritingMode value) { m_inherited.writing_mode = value; }
void set_fill(SVGPaint value) { m_inherited.fill = value; }
void set_stroke(SVGPaint value) { m_inherited.stroke = value; }

View file

@ -508,5 +508,12 @@
"keep-all",
"break-all",
"break-word"
],
"writing-mode": [
"horizontal-tb",
"vertical-rl",
"vertical-lr",
"sideways-rl",
"sideways-lr"
]
}

View file

@ -185,6 +185,7 @@
"high-quality",
"highlight",
"highlighttext",
"horizontal-tb",
"hover",
"inactiveborder",
"inactivecaption",
@ -339,6 +340,8 @@
"semi-expanded",
"separate",
"serif",
"sideways-lr",
"sideways-rl",
"slider-horizontal",
"slow",
"small",
@ -403,6 +406,8 @@
"upper-latin",
"upper-roman",
"uppercase",
"vertical-lr",
"vertical-rl",
"vertical-text",
"view-box",
"visible",

View file

@ -2795,6 +2795,18 @@
"normal"
]
},
"writing-mode": {
"animation-type": "none",
"inherited": true,
"initial": "horizontal-tb",
"valid-identifiers": [
"horizontal-tb",
"vertical-rl",
"vertical-lr",
"sideways-rl",
"sideways-lr"
]
},
"x": {
"__comment": "This is an SVG 2 geometry property, see: https://www.w3.org/TR/SVG/geometry.html#X.",
"animation-type": "by-computed-value",

View file

@ -1310,6 +1310,12 @@ Optional<CSS::UnicodeBidi> StyleProperties::unicode_bidi() const
return keyword_to_unicode_bidi(value->to_keyword());
}
Optional<CSS::WritingMode> StyleProperties::writing_mode() const
{
auto value = property(CSS::PropertyID::WritingMode);
return keyword_to_writing_mode(value->to_keyword());
}
Optional<CSS::MaskType> StyleProperties::mask_type() const
{
auto value = property(CSS::PropertyID::MaskType);

View file

@ -171,6 +171,7 @@ public:
Optional<CSS::TableLayout> table_layout() const;
Optional<CSS::Direction> direction() const;
Optional<CSS::UnicodeBidi> unicode_bidi() const;
Optional<CSS::WritingMode> writing_mode() const;
static Vector<CSS::Transformation> transformations_for_style_value(CSSStyleValue const& value);
Vector<CSS::Transformation> transformations() const;

View file

@ -925,6 +925,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
if (auto scrollbar_width = computed_style.scrollbar_width(); scrollbar_width.has_value())
computed_values.set_scrollbar_width(scrollbar_width.value());
if (auto writing_mode = computed_style.writing_mode(); writing_mode.has_value())
computed_values.set_writing_mode(writing_mode.value());
propagate_style_to_anonymous_wrappers();
}