mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb: Use type attribute to determine HTMLLinkElement
mime type
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Previously, the type attribute was ignored on link elements.
This commit is contained in:
parent
cae0ab2139
commit
a4ee3fb1f0
Notes:
github-actions[bot]
2025-02-21 13:13:27 +00:00
Author: https://github.com/tcl3
Commit: a4ee3fb1f0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3653
10 changed files with 62 additions and 2 deletions
|
@ -133,6 +133,17 @@ void HTMLLinkElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
{
|
||||
Base::attribute_changed(name, old_value, value, namespace_);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#processing-the-type-attribute:attr-link-type
|
||||
if (name == HTML::AttributeNames::type) {
|
||||
if (value.has_value())
|
||||
m_mime_type = value->to_ascii_lowercase();
|
||||
else {
|
||||
m_mime_type = {};
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 4.6.7 Link types - https://html.spec.whatwg.org/multipage/links.html#linkTypes
|
||||
auto old_relationship = m_relationship;
|
||||
if (name == HTML::AttributeNames::rel) {
|
||||
|
@ -379,8 +390,14 @@ void HTMLLinkElement::default_fetch_and_process_linked_resource()
|
|||
void HTMLLinkElement::process_stylesheet_resource(bool success, Fetch::Infrastructure::Response const& response, Variant<Empty, Fetch::Infrastructure::FetchAlgorithms::ConsumeBodyFailureTag, ByteBuffer> body_bytes)
|
||||
{
|
||||
// 1. If the resource's Content-Type metadata is not text/css, then set success to false.
|
||||
auto extracted_mime_type = response.header_list()->extract_mime_type();
|
||||
if (!extracted_mime_type.has_value() || extracted_mime_type->essence() != "text/css") {
|
||||
auto mime_type_string = m_mime_type;
|
||||
if (!mime_type_string.has_value()) {
|
||||
auto extracted_mime_type = response.header_list()->extract_mime_type();
|
||||
if (extracted_mime_type.has_value())
|
||||
mime_type_string = extracted_mime_type->essence();
|
||||
}
|
||||
|
||||
if (mime_type_string != "text/css"sv) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue