summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/FontFace.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/FontFace.h12
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp8
-rw-r--r--Userland/Libraries/LibWeb/Dump.cpp2
5 files changed, 18 insertions, 16 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/FontFace.cpp b/Userland/Libraries/LibWeb/CSS/FontFace.cpp
index b4b585258c..8babc28f5b 100644
--- a/Userland/Libraries/LibWeb/CSS/FontFace.cpp
+++ b/Userland/Libraries/LibWeb/CSS/FontFace.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -8,7 +8,7 @@
namespace Web::CSS {
-FontFace::FontFace(DeprecatedFlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges)
+FontFace::FontFace(FlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges)
: m_font_family(move(font_family))
, m_sources(move(sources))
, m_unicode_ranges(move(unicode_ranges))
diff --git a/Userland/Libraries/LibWeb/CSS/FontFace.h b/Userland/Libraries/LibWeb/CSS/FontFace.h
index 77cd7f9e8f..9ae577511f 100644
--- a/Userland/Libraries/LibWeb/CSS/FontFace.h
+++ b/Userland/Libraries/LibWeb/CSS/FontFace.h
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
-#include <AK/DeprecatedFlyString.h>
+#include <AK/FlyString.h>
#include <AK/URL.h>
#include <LibWeb/CSS/UnicodeRange.h>
@@ -17,19 +17,19 @@ public:
struct Source {
AK::URL url;
// FIXME: Do we need to keep this around, or is it only needed to discard unwanted formats during parsing?
- Optional<DeprecatedFlyString> format;
+ Optional<FlyString> format;
};
- FontFace(DeprecatedFlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges);
+ FontFace(FlyString font_family, Vector<Source> sources, Vector<UnicodeRange> unicode_ranges);
~FontFace() = default;
- DeprecatedFlyString font_family() const { return m_font_family; }
+ FlyString font_family() const { return m_font_family; }
Vector<Source> const& sources() const { return m_sources; }
Vector<UnicodeRange> const& unicode_ranges() const { return m_unicode_ranges; }
// FIXME: font-style, font-weight, font-stretch, font-feature-settings
private:
- DeprecatedFlyString m_font_family;
+ FlyString m_font_family;
Vector<Source> m_sources;
Vector<UnicodeRange> m_unicode_ranges;
};
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 84ca9c5c7e..cffd2e6b97 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -5300,7 +5300,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
{
auto declarations_and_at_rules = parse_a_list_of_declarations(tokens);
- Optional<DeprecatedFlyString> font_family;
+ Optional<FlyString> font_family;
Vector<FontFace::Source> src;
Vector<UnicodeRange> unicode_range;
@@ -5352,7 +5352,7 @@ CSSRule* Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens)
if (had_syntax_error || font_family_parts.is_empty())
continue;
- font_family = DeprecatedString::join(' ', font_family_parts);
+ font_family = String::join(' ', font_family_parts).release_value_but_fixme_should_propagate_errors();
continue;
}
if (declaration.name().equals_ignoring_case("src"sv)) {
@@ -5423,7 +5423,7 @@ Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>
// FIXME: Implement optional tech() function from CSS-Fonts-4.
if (auto maybe_url = parse_url_function(first, AllowedDataUrlType::Font); maybe_url.has_value()) {
auto url = maybe_url.release_value();
- Optional<DeprecatedFlyString> format;
+ Optional<FlyString> format;
source_tokens.skip_whitespace();
if (!source_tokens.has_next_token()) {
@@ -5457,7 +5457,7 @@ Vector<FontFace::Source> Parser::parse_font_face_src(TokenStream<ComponentValue>
continue;
}
- format = format_name;
+ format = FlyString::from_utf8(format_name).release_value_but_fixme_should_propagate_errors();
} else {
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: @font-face src invalid (unrecognized function token `{}`); discarding.", function.name());
return {};
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index 4dbb41256a..6f6ca0f32b 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -1532,9 +1532,11 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet)
if (!is<CSSFontFaceRule>(rule))
continue;
auto const& font_face = static_cast<CSSFontFaceRule const&>(rule).font_face();
+ // FIXME: Use font_face.font_family() directly when we port to new Strings here.
+ auto font_family = font_face.font_family().to_string().to_deprecated_string();
if (font_face.sources().is_empty())
continue;
- if (m_loaded_fonts.contains(font_face.font_family()))
+ if (m_loaded_fonts.contains(font_family))
continue;
// NOTE: This is rather ad-hoc, we just look for the first valid
@@ -1562,8 +1564,8 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet)
LoadRequest request;
auto url = m_document.parse_url(candidate_url.value().to_deprecated_string());
- auto loader = make<FontLoader>(const_cast<StyleComputer&>(*this), font_face.font_family(), move(url));
- const_cast<StyleComputer&>(*this).m_loaded_fonts.set(font_face.font_family(), move(loader));
+ auto loader = make<FontLoader>(const_cast<StyleComputer&>(*this), font_family, move(url));
+ const_cast<StyleComputer&>(*this).m_loaded_fonts.set(font_family, move(loader));
}
}
diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp
index 518178c7c6..22ac299f9f 100644
--- a/Userland/Libraries/LibWeb/Dump.cpp
+++ b/Userland/Libraries/LibWeb/Dump.cpp
@@ -599,7 +599,7 @@ void dump_font_face_rule(StringBuilder& builder, CSS::CSSFontFaceRule const& rul
builder.append("sources:\n"sv);
for (auto const& source : font_face.sources()) {
indent(builder, indent_levels + 2);
- builder.appendff("url={}, format={}\n", source.url, source.format.value_or("???"));
+ builder.appendff("url={}, format={}\n", source.url, source.format.value_or(String::from_utf8_short_string("???"sv)));
}
indent(builder, indent_levels + 1);