mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 14:47:35 +00:00
LibWeb: Add "object-position" CSS property into ComputedValues
This commit is contained in:
parent
677a00ed92
commit
a0dc9584de
5 changed files with 46 additions and 29 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <LibWeb/CSS/Ratio.h>
|
||||
#include <LibWeb/CSS/Size.h>
|
||||
#include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
|
||||
#include <LibWeb/CSS/Transformation.h>
|
||||
|
||||
|
@ -76,6 +77,13 @@ struct ResolvedBackdropFilter {
|
|||
Vector<FilterFunction> filters;
|
||||
};
|
||||
|
||||
struct ObjectPosition {
|
||||
PositionEdge edge_x { PositionEdge::Left };
|
||||
CSS::LengthPercentage offset_x { Percentage(50) };
|
||||
PositionEdge edge_y { PositionEdge::Top };
|
||||
CSS::LengthPercentage offset_y { Percentage(50) };
|
||||
};
|
||||
|
||||
class InitialValues {
|
||||
public:
|
||||
static AspectRatio aspect_ratio() { return AspectRatio { true, {} }; }
|
||||
|
@ -154,6 +162,7 @@ public:
|
|||
static Vector<Vector<String>> grid_template_areas() { return {}; }
|
||||
static CSS::Time transition_delay() { return CSS::Time::make_seconds(0); }
|
||||
static CSS::ObjectFit object_fit() { return CSS::ObjectFit::Fill; }
|
||||
static CSS::ObjectPosition object_position() { return {}; }
|
||||
static Color outline_color() { return Color::Black; }
|
||||
static CSS::Length outline_offset() { return CSS::Length::make_px(0); }
|
||||
static CSS::OutlineStyle outline_style() { return CSS::OutlineStyle::None; }
|
||||
|
@ -359,6 +368,7 @@ public:
|
|||
CSS::BorderCollapse border_collapse() const { return m_inherited.border_collapse; }
|
||||
Vector<Vector<String>> const& grid_template_areas() const { return m_noninherited.grid_template_areas; }
|
||||
CSS::ObjectFit object_fit() const { return m_noninherited.object_fit; }
|
||||
CSS::ObjectPosition object_position() const { return m_noninherited.object_position; }
|
||||
|
||||
CSS::LengthBox const& inset() const { return m_noninherited.inset; }
|
||||
const CSS::LengthBox& margin() const { return m_noninherited.margin; }
|
||||
|
@ -548,6 +558,7 @@ protected:
|
|||
CSS::Length outline_width { InitialValues::outline_width() };
|
||||
CSS::TableLayout table_layout { InitialValues::table_layout() };
|
||||
CSS::ObjectFit object_fit { InitialValues::object_fit() };
|
||||
CSS::ObjectPosition object_position { InitialValues::object_position() };
|
||||
|
||||
Optional<MaskReference> mask;
|
||||
CSS::MaskType mask_type { InitialValues::mask_type() };
|
||||
|
@ -660,6 +671,7 @@ public:
|
|||
void set_table_layout(CSS::TableLayout value) { m_noninherited.table_layout = value; }
|
||||
void set_quotes(CSS::QuotesData value) { m_inherited.quotes = value; }
|
||||
void set_object_fit(CSS::ObjectFit value) { m_noninherited.object_fit = value; }
|
||||
void set_object_position(CSS::ObjectPosition value) { m_noninherited.object_position = value; }
|
||||
|
||||
void set_fill(SVGPaint value) { m_inherited.fill = value; }
|
||||
void set_stroke(SVGPaint value) { m_inherited.stroke = value; }
|
||||
|
|
|
@ -1026,10 +1026,24 @@ Optional<CSS::ObjectFit> StyleProperties::object_fit() const
|
|||
return value_id_to_object_fit(value->to_identifier());
|
||||
}
|
||||
|
||||
CSS::PositionStyleValue const& StyleProperties::object_position() const
|
||||
CSS::ObjectPosition StyleProperties::object_position() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::ObjectPosition);
|
||||
return value->as_position();
|
||||
auto const& position = value->as_position();
|
||||
CSS::ObjectPosition object_position;
|
||||
auto const& edge_x = position.edge_x();
|
||||
auto const& edge_y = position.edge_y();
|
||||
if (edge_x->is_edge()) {
|
||||
auto const& edge = edge_x->as_edge();
|
||||
object_position.edge_x = edge.edge();
|
||||
object_position.offset_x = edge.offset();
|
||||
}
|
||||
if (edge_y->is_edge()) {
|
||||
auto const& edge = edge_y->as_edge();
|
||||
object_position.edge_y = edge.edge();
|
||||
object_position.offset_y = edge.offset();
|
||||
}
|
||||
return object_position;
|
||||
}
|
||||
|
||||
Optional<CSS::TableLayout> StyleProperties::table_layout() const
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
Vector<Vector<String>> grid_template_areas() const;
|
||||
String grid_area() const;
|
||||
Optional<CSS::ObjectFit> object_fit() const;
|
||||
CSS::PositionStyleValue const& object_position() const;
|
||||
CSS::ObjectPosition object_position() const;
|
||||
Optional<CSS::TableLayout> table_layout() const;
|
||||
|
||||
static Vector<CSS::Transformation> transformations_for_style_value(StyleValue const& value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue