mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibWeb: Pick up the CSS "visibility" property an honor it when painting
This commit is contained in:
parent
01662b2320
commit
df8ef03957
5 changed files with 33 additions and 1 deletions
|
@ -31,6 +31,7 @@ public:
|
|||
static Color color() { return Color::Black; }
|
||||
static Color background_color() { return Color::Transparent; }
|
||||
static CSS::ListStyleType list_style_type() { return CSS::ListStyleType::Disc; }
|
||||
static CSS::Visibility visibility() { return CSS::Visibility::Visible; }
|
||||
static CSS::FlexDirection flex_direction() { return CSS::FlexDirection::Row; }
|
||||
static CSS::FlexWrap flex_wrap() { return CSS::FlexWrap::Nowrap; }
|
||||
static CSS::ImageRendering image_rendering() { return CSS::ImageRendering::Auto; }
|
||||
|
@ -127,6 +128,7 @@ public:
|
|||
float flex_shrink() const { return m_noninherited.flex_shrink; }
|
||||
CSS::AlignItems align_items() const { return m_noninherited.align_items; }
|
||||
float opacity() const { return m_noninherited.opacity; }
|
||||
CSS::Visibility visibility() const { return m_inherited.visibility; }
|
||||
CSS::ImageRendering image_rendering() const { return m_inherited.image_rendering; }
|
||||
CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; }
|
||||
Vector<BoxShadowData> const& box_shadow() const { return m_noninherited.box_shadow; }
|
||||
|
@ -191,6 +193,7 @@ protected:
|
|||
CSS::TextTransform text_transform { InitialValues::text_transform() };
|
||||
CSS::WhiteSpace white_space { InitialValues::white_space() };
|
||||
CSS::ListStyleType list_style_type { InitialValues::list_style_type() };
|
||||
CSS::Visibility visibility { InitialValues::visibility() };
|
||||
|
||||
Optional<Color> fill;
|
||||
Optional<Color> stroke;
|
||||
|
@ -303,6 +306,7 @@ public:
|
|||
void set_transformations(Vector<CSS::Transformation> value) { m_noninherited.transformations = move(value); }
|
||||
void set_box_sizing(CSS::BoxSizing value) { m_noninherited.box_sizing = value; }
|
||||
void set_vertical_align(Variant<CSS::VerticalAlign, CSS::LengthPercentage> value) { m_noninherited.vertical_align = value; }
|
||||
void set_visibility(CSS::Visibility value) { m_inherited.visibility = value; }
|
||||
|
||||
void set_fill(Color value) { m_inherited.fill = value; }
|
||||
void set_stroke(Color value) { m_inherited.stroke = value; }
|
||||
|
|
|
@ -698,6 +698,23 @@ Optional<CSS::Cursor> StyleProperties::cursor() const
|
|||
}
|
||||
}
|
||||
|
||||
Optional<CSS::Visibility> StyleProperties::visibility() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::Visibility);
|
||||
if (!value.has_value() || !value.value()->is_identifier())
|
||||
return {};
|
||||
switch (value.value()->to_identifier()) {
|
||||
case CSS::ValueID::Visible:
|
||||
return CSS::Visibility::Visible;
|
||||
case CSS::ValueID::Hidden:
|
||||
return CSS::Visibility::Hidden;
|
||||
case CSS::ValueID::Collapse:
|
||||
return CSS::Visibility::Collapse;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
CSS::Display StyleProperties::display() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::Display);
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
float flex_shrink() const;
|
||||
Optional<CSS::AlignItems> align_items() const;
|
||||
float opacity() const;
|
||||
Optional<CSS::Visibility> visibility() const;
|
||||
Optional<CSS::ImageRendering> image_rendering() const;
|
||||
Optional<CSS::JustifyContent> justify_content() const;
|
||||
Optional<CSS::Overflow> overflow_x() const;
|
||||
|
|
|
@ -315,6 +315,12 @@ enum class VerticalAlign {
|
|||
Top,
|
||||
};
|
||||
|
||||
enum class Visibility {
|
||||
Visible,
|
||||
Hidden,
|
||||
Collapse,
|
||||
};
|
||||
|
||||
enum class WhiteSpace {
|
||||
Normal,
|
||||
Pre,
|
||||
|
|
|
@ -465,7 +465,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
|||
|
||||
computed_values.set_z_index(specified_style.z_index());
|
||||
computed_values.set_opacity(specified_style.opacity());
|
||||
if (computed_values.opacity() == 0)
|
||||
|
||||
if (auto maybe_visibility = specified_style.visibility(); maybe_visibility.has_value())
|
||||
computed_values.set_visibility(maybe_visibility.release_value());
|
||||
|
||||
if (computed_values.opacity() == 0 || computed_values.visibility() != CSS::Visibility::Visible)
|
||||
m_visible = false;
|
||||
|
||||
if (auto maybe_length_percentage = specified_style.length_percentage(CSS::PropertyID::Width); maybe_length_percentage.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue