mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Preload resources hinted by <link rel="preload">
If a page is nice enough to give us some preload hints, we can tell RequestServer to get started on downloading the resources right away, instead of waiting until discovering them later on during parsing.
This commit is contained in:
parent
ed5c807c99
commit
5bb2e6597a
Notes:
sideshowbarker
2024-07-18 03:25:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5bb2e6597a0
2 changed files with 12 additions and 0 deletions
|
@ -36,6 +36,13 @@ void HTMLLinkElement::inserted()
|
|||
if (auto sheet = m_css_loader.style_sheet())
|
||||
document().style_sheets().add_sheet(sheet.release_nonnull());
|
||||
}
|
||||
|
||||
if (m_relationship & Relationship::Preload) {
|
||||
// FIXME: Respect the "as" attribute.
|
||||
LoadRequest request;
|
||||
request.set_url(attribute(HTML::AttributeNames::href));
|
||||
m_preload_resource = ResourceLoader::the().load_resource(Resource::Type::Generic, request);
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLLinkElement::parse_attribute(const FlyString& name, const String& value)
|
||||
|
@ -48,6 +55,8 @@ void HTMLLinkElement::parse_attribute(const FlyString& name, const String& value
|
|||
m_relationship |= Relationship::Stylesheet;
|
||||
else if (part == "alternate")
|
||||
m_relationship |= Relationship::Alternate;
|
||||
else if (part == "preload")
|
||||
m_relationship |= Relationship::Preload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,12 @@ private:
|
|||
enum {
|
||||
Alternate = 1 << 0,
|
||||
Stylesheet = 1 << 1,
|
||||
Preload = 1 << 2,
|
||||
};
|
||||
};
|
||||
|
||||
RefPtr<Resource> m_preload_resource;
|
||||
|
||||
CSSLoader m_css_loader;
|
||||
unsigned m_relationship { 0 };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue