mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibWeb: Add support for parsing place-content shorthand CSS property
This commit is contained in:
parent
23be1c5482
commit
dcead6f5eb
12 changed files with 139 additions and 0 deletions
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Hunter Salyer <thefalsehonesty@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "PlaceContentStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ErrorOr<String> PlaceContentStyleValue::to_string() const
|
||||
{
|
||||
return String::formatted("{} {}", TRY(m_properties.align_content->to_string()), TRY(m_properties.justify_content->to_string()));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Hunter Salyer <thefalsehonesty@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class PlaceContentStyleValue final : public StyleValueWithDefaultOperators<PlaceContentStyleValue> {
|
||||
public:
|
||||
static ErrorOr<ValueComparingNonnullRefPtr<PlaceContentStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> align_content, ValueComparingNonnullRefPtr<StyleValue> justify_content)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) PlaceContentStyleValue(move(align_content), move(justify_content)));
|
||||
}
|
||||
virtual ~PlaceContentStyleValue() override = default;
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue> align_content() const { return m_properties.align_content; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> justify_content() const { return m_properties.justify_content; }
|
||||
|
||||
virtual ErrorOr<String> to_string() const override;
|
||||
|
||||
bool properties_equal(PlaceContentStyleValue const& other) const { return m_properties == other.m_properties; };
|
||||
|
||||
private:
|
||||
PlaceContentStyleValue(ValueComparingNonnullRefPtr<StyleValue> align_content, ValueComparingNonnullRefPtr<StyleValue> justify_content)
|
||||
: StyleValueWithDefaultOperators(Type::PlaceContent)
|
||||
, m_properties { .align_content = move(align_content), .justify_content = move(justify_content) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<StyleValue> align_content;
|
||||
ValueComparingNonnullRefPtr<StyleValue> justify_content;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue