mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 03:11:53 +00:00
LibWeb: Parse the border-image-slice
property
This commit is contained in:
parent
70c2621634
commit
245905b833
Notes:
github-actions[bot]
2025-07-03 09:21:11 +00:00
Author: https://github.com/tcl3
Commit: 245905b833
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5253
Reviewed-by: https://github.com/AtkinsSJ ✅
27 changed files with 1132 additions and 765 deletions
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "BorderImageSliceStyleValue.h"
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String BorderImageSliceStyleValue::to_string(SerializationMode mode) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (first_is_equal_to_all_of(top(), right(), bottom(), left())) {
|
||||
builder.append(top()->to_string(mode));
|
||||
} else if (top() == bottom() && right() == left()) {
|
||||
builder.appendff("{} {}", top()->to_string(mode), right()->to_string(mode));
|
||||
} else if (left() == right()) {
|
||||
builder.appendff("{} {} {}", top()->to_string(mode), right()->to_string(mode), bottom()->to_string(mode));
|
||||
} else {
|
||||
builder.appendff("{} {} {} {}", top()->to_string(mode), right()->to_string(mode), bottom()->to_string(mode), left()->to_string(mode));
|
||||
}
|
||||
|
||||
if (fill())
|
||||
builder.append(" fill"sv);
|
||||
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class BorderImageSliceStyleValue final : public StyleValueWithDefaultOperators<BorderImageSliceStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<BorderImageSliceStyleValue const> create(ValueComparingNonnullRefPtr<CSSStyleValue const> top, ValueComparingNonnullRefPtr<CSSStyleValue const> right, ValueComparingNonnullRefPtr<CSSStyleValue const> bottom, ValueComparingNonnullRefPtr<CSSStyleValue const> left, bool fill)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) BorderImageSliceStyleValue(top, right, bottom, left, fill));
|
||||
}
|
||||
|
||||
virtual ~BorderImageSliceStyleValue() override = default;
|
||||
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> top() const { return m_properties.top; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> left() const { return m_properties.left; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> bottom() const { return m_properties.bottom; }
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> right() const { return m_properties.right; }
|
||||
|
||||
bool fill() const { return m_properties.fill; }
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
bool properties_equal(BorderImageSliceStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
private:
|
||||
BorderImageSliceStyleValue(ValueComparingNonnullRefPtr<CSSStyleValue const> top, ValueComparingNonnullRefPtr<CSSStyleValue const> right, ValueComparingNonnullRefPtr<CSSStyleValue const> bottom, ValueComparingNonnullRefPtr<CSSStyleValue const> left, bool fill)
|
||||
: StyleValueWithDefaultOperators(Type::BorderImageSlice)
|
||||
, m_properties { .top = move(top), .right = move(right), .bottom = move(bottom), .left = move(left), .fill = fill }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> top;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> right;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> bottom;
|
||||
ValueComparingNonnullRefPtr<CSSStyleValue const> left;
|
||||
bool fill;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue