mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
LibWeb: Add support for the text-justify property
This commit adds the text-justify property as defined in: https://drafts.csswg.org/css-text/#propdef-text-justify
This commit is contained in:
parent
7fe3f2d970
commit
0679eadd62
7 changed files with 50 additions and 0 deletions
|
@ -21,6 +21,7 @@ public:
|
|||
static CSS::Cursor cursor() { return CSS::Cursor::Auto; }
|
||||
static CSS::WhiteSpace white_space() { return CSS::WhiteSpace::Normal; }
|
||||
static CSS::TextAlign text_align() { return CSS::TextAlign::Left; }
|
||||
static CSS::TextJustify text_justify() { return CSS::TextJustify::Auto; }
|
||||
static CSS::Position position() { return CSS::Position::Static; }
|
||||
static CSS::TextDecorationLine text_decoration_line() { return CSS::TextDecorationLine::None; }
|
||||
static CSS::Length text_decoration_thickness() { return Length::make_px(1); }
|
||||
|
@ -111,6 +112,7 @@ public:
|
|||
CSS::Display display() const { return m_noninherited.display; }
|
||||
Optional<int> const& z_index() const { return m_noninherited.z_index; }
|
||||
CSS::TextAlign text_align() const { return m_inherited.text_align; }
|
||||
CSS::TextJustify text_justify() const { return m_inherited.text_justify; }
|
||||
CSS::TextDecorationLine text_decoration_line() const { return m_noninherited.text_decoration_line; }
|
||||
CSS::LengthPercentage text_decoration_thickness() const { return m_noninherited.text_decoration_thickness; }
|
||||
CSS::TextDecorationStyle text_decoration_style() const { return m_noninherited.text_decoration_style; }
|
||||
|
@ -185,6 +187,7 @@ protected:
|
|||
CSS::ImageRendering image_rendering { InitialValues::image_rendering() };
|
||||
CSS::PointerEvents pointer_events { InitialValues::pointer_events() };
|
||||
CSS::TextAlign text_align { InitialValues::text_align() };
|
||||
CSS::TextJustify text_justify { InitialValues::text_justify() };
|
||||
CSS::TextTransform text_transform { InitialValues::text_transform() };
|
||||
CSS::WhiteSpace white_space { InitialValues::white_space() };
|
||||
CSS::ListStyleType list_style_type { InitialValues::list_style_type() };
|
||||
|
@ -259,6 +262,7 @@ public:
|
|||
void set_clear(CSS::Clear value) { m_noninherited.clear = value; }
|
||||
void set_z_index(Optional<int> value) { m_noninherited.z_index = value; }
|
||||
void set_text_align(CSS::TextAlign text_align) { m_inherited.text_align = text_align; }
|
||||
void set_text_justify(CSS::TextJustify text_justify) { m_inherited.text_justify = text_justify; }
|
||||
void set_text_decoration_line(CSS::TextDecorationLine value) { m_noninherited.text_decoration_line = value; }
|
||||
void set_text_decoration_thickness(CSS::LengthPercentage value) { m_noninherited.text_decoration_thickness = value; }
|
||||
void set_text_decoration_style(CSS::TextDecorationStyle value) { m_noninherited.text_decoration_style = value; }
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
"decimal-leading-zero",
|
||||
"default",
|
||||
"disc",
|
||||
"distribute",
|
||||
"dotted",
|
||||
"double",
|
||||
"e-resize",
|
||||
|
@ -129,6 +130,8 @@
|
|||
"inset",
|
||||
"inside",
|
||||
"interlace",
|
||||
"inter-character",
|
||||
"inter-word",
|
||||
"invert",
|
||||
"italic",
|
||||
"justify",
|
||||
|
|
|
@ -1287,6 +1287,17 @@
|
|||
"unitless-length"
|
||||
]
|
||||
},
|
||||
"text-justify": {
|
||||
"inherited": true,
|
||||
"initial": "auto",
|
||||
"valid-identifiers": [
|
||||
"auto",
|
||||
"none",
|
||||
"inter-word",
|
||||
"inter-character",
|
||||
"distribute"
|
||||
]
|
||||
},
|
||||
"text-transform": {
|
||||
"inherited": true,
|
||||
"initial": "none",
|
||||
|
|
|
@ -438,6 +438,26 @@ Optional<CSS::TextAlign> StyleProperties::text_align() const
|
|||
}
|
||||
}
|
||||
|
||||
Optional<CSS::TextJustify> StyleProperties::text_justify() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::TextJustify);
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
switch (value.value()->to_identifier()) {
|
||||
case CSS::ValueID::Auto:
|
||||
return CSS::TextJustify::Auto;
|
||||
case CSS::ValueID::None:
|
||||
return CSS::TextJustify::None;
|
||||
case CSS::ValueID::InterWord:
|
||||
return CSS::TextJustify::InterWord;
|
||||
case CSS::ValueID::Distribute:
|
||||
case CSS::ValueID::InterCharacter:
|
||||
return CSS::TextJustify::InterCharacter;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Optional<CSS::PointerEvents> StyleProperties::pointer_events() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::PointerEvents);
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
LengthBox length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id, const CSS::Length& default_value) const;
|
||||
Color color_or_fallback(CSS::PropertyID, Layout::NodeWithStyle const&, Color fallback) const;
|
||||
Optional<CSS::TextAlign> text_align() const;
|
||||
Optional<CSS::TextJustify> text_justify() const;
|
||||
CSS::Display display() const;
|
||||
Optional<CSS::Float> float_() const;
|
||||
Optional<CSS::Clear> clear() const;
|
||||
|
|
|
@ -274,6 +274,13 @@ enum class TextDecorationStyle {
|
|||
Wavy,
|
||||
};
|
||||
|
||||
enum class TextJustify {
|
||||
Auto,
|
||||
None,
|
||||
InterWord,
|
||||
InterCharacter,
|
||||
};
|
||||
|
||||
enum class TextTransform {
|
||||
None,
|
||||
Capitalize,
|
||||
|
|
|
@ -365,6 +365,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
|||
if (text_align.has_value())
|
||||
computed_values.set_text_align(text_align.value());
|
||||
|
||||
auto text_justify = specified_style.text_justify();
|
||||
if (text_align.has_value())
|
||||
computed_values.set_text_justify(text_justify.value());
|
||||
|
||||
auto white_space = specified_style.white_space();
|
||||
if (white_space.has_value())
|
||||
computed_values.set_white_space(white_space.value());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue