mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb/CSS: Remove URL parameter to the CSS Parser
We no longer complete any URLs during parsing.
This commit is contained in:
parent
9e2e796f2d
commit
bc1d323ba0
Notes:
github-actions[bot]
2025-05-03 11:02:42 +00:00
Author: https://github.com/AtkinsSJ
Commit: bc1d323ba0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4536
5 changed files with 3 additions and 35 deletions
|
@ -156,7 +156,7 @@ void CSSImportRule::fetch()
|
|||
}
|
||||
auto decoded = decoded_or_error.release_value();
|
||||
|
||||
auto imported_style_sheet = parse_css_stylesheet(Parser::ParsingParams(*strong_this->m_document, parsed_url), decoded, parsed_url, strong_this->m_media_query_list);
|
||||
auto imported_style_sheet = parse_css_stylesheet(Parser::ParsingParams(*strong_this->m_document), decoded, parsed_url, strong_this->m_media_query_list);
|
||||
|
||||
// 5. Set importedStylesheet’s origin-clean flag to parentStylesheet’s origin-clean flag.
|
||||
imported_style_sheet->set_origin_clean(parent_style_sheet->is_origin_clean());
|
||||
|
|
|
@ -63,7 +63,6 @@ GC_DEFINE_ALLOCATOR(FontFace);
|
|||
GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, FontFaceDescriptors const& descriptors)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
auto base_url = HTML::relevant_settings_object(realm.global_object()).api_base_url();
|
||||
|
||||
// 1. Let font face be a fresh FontFace object. Set font face’s status attribute to "unloaded",
|
||||
// Set its internal [[FontStatusPromise]] slot to a fresh pending Promise object.
|
||||
|
@ -76,7 +75,7 @@ GC::Ref<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, Font
|
|||
// set font face’s corresponding attributes to the empty string, and set font face’s status attribute to "error".
|
||||
// Otherwise, set font face’s corresponding attributes to the serialization of the parsed values.
|
||||
|
||||
Parser::ParsingParams parsing_params { realm, base_url };
|
||||
Parser::ParsingParams parsing_params { realm };
|
||||
auto try_parse_descriptor = [&parsing_params, &font_face, &realm](DescriptorID descriptor_id, String const& string) -> String {
|
||||
auto result = parse_css_descriptor(parsing_params, AtRuleID::FontFace, descriptor_id, string);
|
||||
if (!result) {
|
||||
|
|
|
@ -45,25 +45,9 @@ ParsingParams::ParsingParams(JS::Realm& realm, ParsingMode mode)
|
|||
{
|
||||
}
|
||||
|
||||
ParsingParams::ParsingParams(JS::Realm& realm, ::URL::URL url, ParsingMode mode)
|
||||
: realm(realm)
|
||||
, url(move(url))
|
||||
, mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
ParsingParams::ParsingParams(DOM::Document const& document, ::URL::URL url, ParsingMode mode)
|
||||
: realm(const_cast<JS::Realm&>(document.realm()))
|
||||
, document(&document)
|
||||
, url(move(url))
|
||||
, mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
ParsingParams::ParsingParams(DOM::Document const& document, ParsingMode mode)
|
||||
: realm(const_cast<JS::Realm&>(document.realm()))
|
||||
, document(&document)
|
||||
, url(document.url())
|
||||
, mode(mode)
|
||||
{
|
||||
}
|
||||
|
@ -77,7 +61,6 @@ Parser Parser::create(ParsingParams const& context, StringView input, StringView
|
|||
Parser::Parser(ParsingParams const& context, Vector<Token> tokens)
|
||||
: m_document(context.document)
|
||||
, m_realm(context.realm)
|
||||
, m_url(context.url)
|
||||
, m_parsing_mode(context.mode)
|
||||
, m_tokens(move(tokens))
|
||||
, m_token_stream(m_tokens)
|
||||
|
@ -1864,13 +1847,4 @@ bool Parser::is_parsing_svg_presentation_attribute() const
|
|||
return m_parsing_mode == ParsingMode::SVGPresentationAttribute;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#relative-urls
|
||||
// FIXME: URLs shouldn't be completed during parsing, but when used.
|
||||
Optional<::URL::URL> Parser::complete_url(StringView relative_url) const
|
||||
{
|
||||
if (!m_url.has_value())
|
||||
return ::URL::Parser::basic_parse(relative_url);
|
||||
return m_url->complete_url(relative_url);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,13 +71,10 @@ enum class ParsingMode {
|
|||
struct ParsingParams {
|
||||
explicit ParsingParams(ParsingMode = ParsingMode::Normal);
|
||||
explicit ParsingParams(JS::Realm&, ParsingMode = ParsingMode::Normal);
|
||||
explicit ParsingParams(JS::Realm&, ::URL::URL, ParsingMode = ParsingMode::Normal);
|
||||
explicit ParsingParams(DOM::Document const&, ::URL::URL, ParsingMode = ParsingMode::Normal);
|
||||
explicit ParsingParams(DOM::Document const&, ParsingMode = ParsingMode::Normal);
|
||||
|
||||
GC::Ptr<JS::Realm> realm;
|
||||
GC::Ptr<DOM::Document const> document;
|
||||
::URL::URL url;
|
||||
ParsingMode mode { ParsingMode::Normal };
|
||||
|
||||
Vector<RuleContext> rule_context;
|
||||
|
@ -480,11 +477,9 @@ private:
|
|||
JS::Realm& realm() const;
|
||||
bool in_quirks_mode() const;
|
||||
bool is_parsing_svg_presentation_attribute() const;
|
||||
Optional<::URL::URL> complete_url(StringView) const;
|
||||
|
||||
GC::Ptr<DOM::Document const> m_document;
|
||||
GC::Ptr<JS::Realm> m_realm;
|
||||
Optional<::URL::URL> m_url;
|
||||
ParsingMode m_parsing_mode { ParsingMode::Normal };
|
||||
|
||||
Vector<Token> m_tokens;
|
||||
|
|
|
@ -68,7 +68,7 @@ GC::Ref<CSSStyleSheet> StyleSheetList::create_a_css_style_sheet(String const& cs
|
|||
// AD-HOC: The spec never tells us when to parse this style sheet, but the most logical place is here.
|
||||
// AD-HOC: Are we supposed to use the document's URL for the stylesheet's location during parsing? Not doing it breaks things.
|
||||
auto location_url = location.value_or(document().url());
|
||||
auto sheet = parse_css_stylesheet(Parser::ParsingParams { document(), location_url }, css_text, location_url);
|
||||
auto sheet = parse_css_stylesheet(Parser::ParsingParams { document() }, css_text, location_url);
|
||||
|
||||
sheet->set_parent_css_style_sheet(parent_style_sheet);
|
||||
sheet->set_owner_css_rule(owner_rule);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue