mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
LibWeb: Fix resolving relative URLs in style sheets
Relative URLs in style sheets should be resolved relative to the style sheet they're in instead of the document.
This commit is contained in:
parent
a37bee919a
commit
1ed5e79478
4 changed files with 14 additions and 3 deletions
|
@ -34,13 +34,21 @@ static void log_parse_error(const SourceLocation& location = SourceLocation::cur
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
ParsingContext::ParsingContext(DOM::Document const& document, Optional<AK::URL> const url)
|
||||
: m_document(&document)
|
||||
, m_url(move(url))
|
||||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(DOM::Document const& document)
|
||||
: m_document(&document)
|
||||
, m_url(document.url())
|
||||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(DOM::ParentNode& parent_node)
|
||||
: m_document(&parent_node.document())
|
||||
, m_url(parent_node.document().url())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -49,9 +57,10 @@ bool ParsingContext::in_quirks_mode() const
|
|||
return m_document ? m_document->in_quirks_mode() : false;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-values-4/#relative-urls
|
||||
AK::URL ParsingContext::complete_url(String const& addr) const
|
||||
{
|
||||
return m_document ? m_document->url().complete_url(addr) : AK::URL::create_with_url_or_path(addr);
|
||||
return m_url.has_value() ? m_url->complete_url(addr) : AK::URL::create_with_url_or_path(addr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue