mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
LibWeb: Don't load stylesheets with rel="alternate"
We're not supposed to load these by default. Alternate stylesheets can be offered in a menu or something, if the user is interested.
This commit is contained in:
parent
2f26d4c6a1
commit
9bb4020195
2 changed files with 25 additions and 1 deletions
|
@ -47,7 +47,7 @@ void HTMLLinkElement::inserted_into(Node& node)
|
||||||
{
|
{
|
||||||
HTMLElement::inserted_into(node);
|
HTMLElement::inserted_into(node);
|
||||||
|
|
||||||
if (rel().split_view(' ').contains_slow("stylesheet"))
|
if (m_relationship & Relationship::Stylesheet && !(m_relationship & Relationship::Alternate))
|
||||||
load_stylesheet(document().complete_url(href()));
|
load_stylesheet(document().complete_url(href()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,4 +87,18 @@ void HTMLLinkElement::load_stylesheet(const URL& url)
|
||||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HTMLLinkElement::parse_attribute(const FlyString& name, const String& value)
|
||||||
|
{
|
||||||
|
if (name == HTML::AttributeNames::rel) {
|
||||||
|
m_relationship = 0;
|
||||||
|
auto parts = value.split_view(' ');
|
||||||
|
for (auto& part : parts) {
|
||||||
|
if (part == "stylesheet")
|
||||||
|
m_relationship |= Relationship::Stylesheet;
|
||||||
|
else if (part == "alternate")
|
||||||
|
m_relationship |= Relationship::Alternate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,18 @@ private:
|
||||||
virtual void resource_did_fail() override;
|
virtual void resource_did_fail() override;
|
||||||
virtual void resource_did_load() override;
|
virtual void resource_did_load() override;
|
||||||
|
|
||||||
|
void parse_attribute(const FlyString&, const String&) override;
|
||||||
|
|
||||||
void load_stylesheet(const URL&);
|
void load_stylesheet(const URL&);
|
||||||
|
|
||||||
|
struct Relationship {
|
||||||
|
enum {
|
||||||
|
Alternate = 1 << 0,
|
||||||
|
Stylesheet = 1 << 1,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned m_relationship { 0 };
|
||||||
RefPtr<StyleSheet> m_style_sheet;
|
RefPtr<StyleSheet> m_style_sheet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue