diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-02-17 13:00:40 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-19 00:51:16 +0100 |
commit | faab2fe101872ce2ab9e8d9a1b37b7818c590225 (patch) | |
tree | fc86c000cb1c60c14916884798b6c055a2136a3e /Userland/Libraries/LibWeb | |
parent | 13d2111b74ada6a173ae6d9bb2d28a803e807b3d (diff) | |
download | serenity-faab2fe101872ce2ab9e8d9a1b37b7818c590225.zip |
LibWeb: Store stylesheet sources as StringViews
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 10 | ||||
-rwxr-xr-x | Userland/Libraries/LibWeb/Scripts/GenerateStyleSheetSource.sh | 7 |
2 files changed, 8 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index e1432e9279..08c89d6873 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -115,9 +115,8 @@ static CSSStyleSheet& default_stylesheet() { static JS::Handle<CSSStyleSheet> sheet; if (!sheet.cell()) { - extern char const default_stylesheet_source[]; - DeprecatedString css = default_stylesheet_source; - sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(), css)); + extern StringView default_stylesheet_source; + sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(), default_stylesheet_source)); } return *sheet; } @@ -126,9 +125,8 @@ static CSSStyleSheet& quirks_mode_stylesheet() { static JS::Handle<CSSStyleSheet> sheet; if (!sheet.cell()) { - extern char const quirks_mode_stylesheet_source[]; - DeprecatedString css = quirks_mode_stylesheet_source; - sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(), css)); + extern StringView quirks_mode_stylesheet_source; + sheet = JS::make_handle(parse_css_stylesheet(CSS::Parser::ParsingContext(), quirks_mode_stylesheet_source)); } return *sheet; } diff --git a/Userland/Libraries/LibWeb/Scripts/GenerateStyleSheetSource.sh b/Userland/Libraries/LibWeb/Scripts/GenerateStyleSheetSource.sh index aef61fcfae..35b8e906f6 100755 --- a/Userland/Libraries/LibWeb/Scripts/GenerateStyleSheetSource.sh +++ b/Userland/Libraries/LibWeb/Scripts/GenerateStyleSheetSource.sh @@ -1,10 +1,11 @@ #!/bin/sh +echo "#include <AK/StringView.h>" echo "namespace Web::CSS {" -echo "extern const char $1[];" -echo "const char $1[] = \"\\" +echo "extern StringView $1;" +echo "StringView $1 = \"\\" grep -v '^ *#' < "$2" | while IFS= read -r line; do echo "$line""\\" done -echo "\";" +echo "\"sv;" echo "}" |