LibWeb: Allow url("foo") and url('foo') in CSS background-image values

This is very hackish and will be fixed by writing a proper CSS parser.
This commit is contained in:
Andreas Kling 2020-06-13 00:11:38 +02:00
parent 0306ada1ff
commit 365703e3f3
Notes: sideshowbarker 2024-07-19 05:41:25 +09:00

View file

@ -354,6 +354,11 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
if (!string.ends_with(')'))
continue;
auto url = string.substring_view(4, string.length() - 5);
if (url.length() >= 2 && url.starts_with('"') && url.ends_with('"'))
url = url.substring_view(1, url.length() - 2);
else if (url.length() >= 2 && url.starts_with('\'') && url.ends_with('\''))
url = url.substring_view(1, url.length() - 2);
auto background_image_value = ImageStyleValue::create(document.complete_url(url), document);
style.set_property(CSS::PropertyID::BackgroundImage, move(background_image_value));
}