mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Support loading alternative style sheets
Alternative style sheets are now fetched and are applied to the document if they are explicitly enabled by removing the disabled attribute.
This commit is contained in:
parent
25f8c26624
commit
4a3497e9cd
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/tcl3
Commit: 4a3497e9cd
Pull-request: https://github.com/SerenityOS/serenity/pull/23992
7 changed files with 52 additions and 8 deletions
|
@ -50,8 +50,7 @@ void HTMLLinkElement::inserted()
|
|||
{
|
||||
HTMLElement::inserted();
|
||||
|
||||
// FIXME: Handle alternate stylesheets properly
|
||||
if (m_relationship & Relationship::Stylesheet && !(m_relationship & Relationship::Alternate)) {
|
||||
if (m_relationship & Relationship::Stylesheet) {
|
||||
// https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet:fetch-and-process-the-linked-resource
|
||||
// The appropriate times to fetch and process this type of link are:
|
||||
// - When the external resource link is created on a link element that is already browsing-context connected.
|
||||
|
@ -110,8 +109,12 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: Handle alternate stylesheets properly
|
||||
if (m_relationship & Relationship::Stylesheet && !(m_relationship & Relationship::Alternate)) {
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#the-link-element:explicitly-enabled
|
||||
// Whenever the disabled attribute is removed, set the link element's explicitly enabled attribute to true.
|
||||
if (!value.has_value() && name == HTML::AttributeNames::disabled)
|
||||
m_explicitly_enabled = true;
|
||||
|
||||
if (m_relationship & Relationship::Stylesheet) {
|
||||
if (name == HTML::AttributeNames::disabled && m_loaded_style_sheet)
|
||||
document_or_shadow_root_style_sheets().remove_a_css_style_sheet(*m_loaded_style_sheet);
|
||||
|
||||
|
@ -374,7 +377,7 @@ void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastru
|
|||
this,
|
||||
attribute(HTML::AttributeNames::media).value_or({}),
|
||||
in_a_document_tree() ? attribute(HTML::AttributeNames::title).value_or({}) : String {},
|
||||
false,
|
||||
m_relationship & Relationship::Alternate && !m_explicitly_enabled,
|
||||
true,
|
||||
{},
|
||||
nullptr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue