mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibWeb/CSS: Parse and use tech() in @font-face { src }
This commit is contained in:
parent
5b42f8d707
commit
d611806f18
Notes:
github-actions[bot]
2025-06-05 11:39:21 +00:00
Author: https://github.com/AtkinsSJ
Commit: d611806f18
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4983
Reviewed-by: https://github.com/shannonbooth
10 changed files with 131 additions and 35 deletions
|
@ -9,10 +9,11 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
FontSourceStyleValue::FontSourceStyleValue(Source source, Optional<FlyString> format)
|
||||
FontSourceStyleValue::FontSourceStyleValue(Source source, Optional<FlyString> format, Vector<FontTech> tech)
|
||||
: StyleValueWithDefaultOperators(Type::FontSource)
|
||||
, m_source(move(source))
|
||||
, m_format(move(format))
|
||||
, m_tech(move(tech))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,6 @@ String FontSourceStyleValue::to_string(SerializationMode) const
|
|||
},
|
||||
[this](URL const& url) {
|
||||
// <url> [ format(<font-format>)]? [ tech( <font-tech>#)]?
|
||||
// FIXME: tech()
|
||||
StringBuilder builder;
|
||||
builder.append(url.to_string());
|
||||
|
||||
|
@ -46,6 +46,14 @@ String FontSourceStyleValue::to_string(SerializationMode) const
|
|||
builder.append(")"sv);
|
||||
}
|
||||
|
||||
if (!m_tech.is_empty()) {
|
||||
builder.append(" tech("sv);
|
||||
serialize_a_comma_separated_list(builder, m_tech, [](auto& builder, FontTech const tech) {
|
||||
return builder.append(CSS::to_string(tech));
|
||||
});
|
||||
builder.append(")"sv);
|
||||
}
|
||||
|
||||
return builder.to_string_without_validation();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/URL.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -19,24 +20,26 @@ public:
|
|||
};
|
||||
using Source = Variant<Local, URL>;
|
||||
|
||||
static ValueComparingNonnullRefPtr<FontSourceStyleValue const> create(Source source, Optional<FlyString> format)
|
||||
static ValueComparingNonnullRefPtr<FontSourceStyleValue const> create(Source source, Optional<FlyString> format, Vector<FontTech> tech)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) FontSourceStyleValue(move(source), move(format)));
|
||||
return adopt_ref(*new (nothrow) FontSourceStyleValue(move(source), move(format), move(tech)));
|
||||
}
|
||||
virtual ~FontSourceStyleValue() override;
|
||||
|
||||
Source const& source() const { return m_source; }
|
||||
Optional<FlyString> const& format() const { return m_format; }
|
||||
Vector<FontTech> const& tech() const { return m_tech; }
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
bool properties_equal(FontSourceStyleValue const&) const;
|
||||
|
||||
private:
|
||||
FontSourceStyleValue(Source source, Optional<FlyString> format);
|
||||
FontSourceStyleValue(Source source, Optional<FlyString> format, Vector<FontTech> tech);
|
||||
|
||||
Source m_source;
|
||||
Optional<FlyString> m_format;
|
||||
Vector<FontTech> m_tech;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue