ladybird/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.h
Sam Atkins d16600a48b LibWeb: Propagate errors from StyleValue construction
Turns out we create a lot of these, mostly from places that don't return
ErrorOr. The yak stack grows.
2023-05-06 08:07:28 +02:00

44 lines
1.3 KiB
C++

/*
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/PercentageOr.h>
#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
public:
static ErrorOr<ValueComparingNonnullRefPtr<EdgeStyleValue>> create(PositionEdge edge, LengthPercentage const& offset)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) EdgeStyleValue(edge, offset));
}
virtual ~EdgeStyleValue() override = default;
PositionEdge edge() const { return m_properties.edge; }
LengthPercentage const& offset() const { return m_properties.offset; }
virtual ErrorOr<String> to_string() const override;
bool properties_equal(EdgeStyleValue const& other) const { return m_properties == other.m_properties; }
private:
EdgeStyleValue(PositionEdge edge, LengthPercentage const& offset)
: StyleValueWithDefaultOperators(Type::Edge)
, m_properties { .edge = edge, .offset = offset }
{
}
struct Properties {
PositionEdge edge;
LengthPercentage offset;
bool operator==(Properties const&) const = default;
} m_properties;
};
}