mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb: Make sure we run selectors for mixed-case tag names
Before this change, we would never apply CSS rules where the selector had a mixed-case tag name. This happened because our rule caches would key them on the lowercased tag name, but we didn't lowercase the tag name when fetching things from the cache. This uncovered the fact that the SVG2 spec has a bunch of style applied to non-rendered elements in a way that doesn't match other browsers. Instead of blindly following the spec, we now match other browsers.
This commit is contained in:
parent
61df035612
commit
b3fd939628
Notes:
github-actions[bot]
2025-07-09 12:37:53 +00:00
Author: https://github.com/awesomekling
Commit: b3fd939628
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5369
Reviewed-by: https://github.com/gmta ✅
5 changed files with 11 additions and 10 deletions
|
@ -3280,7 +3280,7 @@ void RuleCache::for_each_matching_rules(DOM::Element const& element, Optional<Ps
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auto it = rules_by_tag_name.find(element.local_name()); it != rules_by_tag_name.end()) {
|
if (auto it = rules_by_tag_name.find(element.lowercased_local_name()); it != rules_by_tag_name.end()) {
|
||||||
if (callback(it->value) == IterationDecision::Break)
|
if (callback(it->value) == IterationDecision::Break)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,8 @@ public:
|
||||||
virtual FlyString node_name() const final { return html_uppercased_qualified_name(); }
|
virtual FlyString node_name() const final { return html_uppercased_qualified_name(); }
|
||||||
FlyString const& local_name() const { return m_qualified_name.local_name(); }
|
FlyString const& local_name() const { return m_qualified_name.local_name(); }
|
||||||
|
|
||||||
|
FlyString const& lowercased_local_name() const { return m_qualified_name.lowercased_local_name(); }
|
||||||
|
|
||||||
// NOTE: This is for the JS bindings
|
// NOTE: This is for the JS bindings
|
||||||
FlyString const& tag_name() const { return html_uppercased_qualified_name(); }
|
FlyString const& tag_name() const { return html_uppercased_qualified_name(); }
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ QualifiedName::QualifiedName(FlyString const& local_name, Optional<FlyString> co
|
||||||
|
|
||||||
QualifiedName::Impl::Impl(FlyString const& a_local_name, Optional<FlyString> const& a_prefix, Optional<FlyString> const& a_namespace)
|
QualifiedName::Impl::Impl(FlyString const& a_local_name, Optional<FlyString> const& a_prefix, Optional<FlyString> const& a_namespace)
|
||||||
: local_name(a_local_name)
|
: local_name(a_local_name)
|
||||||
|
, lowercased_local_name(local_name.to_ascii_lowercase())
|
||||||
, prefix(a_prefix)
|
, prefix(a_prefix)
|
||||||
, namespace_(a_namespace)
|
, namespace_(a_namespace)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
Optional<FlyString> const& prefix() const { return m_impl->prefix; }
|
Optional<FlyString> const& prefix() const { return m_impl->prefix; }
|
||||||
Optional<FlyString> const& namespace_() const { return m_impl->namespace_; }
|
Optional<FlyString> const& namespace_() const { return m_impl->namespace_; }
|
||||||
|
|
||||||
|
FlyString const& lowercased_local_name() const { return m_impl->lowercased_local_name; }
|
||||||
|
|
||||||
FlyString const& as_string() const { return m_impl->as_string; }
|
FlyString const& as_string() const { return m_impl->as_string; }
|
||||||
|
|
||||||
struct Impl : public RefCounted<Impl> {
|
struct Impl : public RefCounted<Impl> {
|
||||||
|
@ -29,6 +31,7 @@ public:
|
||||||
|
|
||||||
void make_internal_string();
|
void make_internal_string();
|
||||||
FlyString local_name;
|
FlyString local_name;
|
||||||
|
FlyString lowercased_local_name;
|
||||||
Optional<FlyString> prefix;
|
Optional<FlyString> prefix;
|
||||||
Optional<FlyString> namespace_;
|
Optional<FlyString> namespace_;
|
||||||
FlyString as_string;
|
FlyString as_string;
|
||||||
|
|
|
@ -14,14 +14,8 @@ svg:not(:root), image, marker, pattern, symbol { overflow: hidden; }
|
||||||
white-space-collapse: preserve-spaces;
|
white-space-collapse: preserve-spaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Allow setting the rest of these to `display: none`.
|
/* NOTE: These rules are in the SVG spec, but don't match how other engines behave.
|
||||||
Currently that breaks <use> and <mask> and probably others. */
|
So we simply comment them out for now.
|
||||||
desc, title, metadata,
|
|
||||||
pattern, linearGradient, radialGradient,
|
|
||||||
script, style {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
defs,
|
defs,
|
||||||
clipPath, mask, marker,
|
clipPath, mask, marker,
|
||||||
desc, title, metadata,
|
desc, title, metadata,
|
||||||
|
@ -30,10 +24,11 @@ script, style,
|
||||||
symbol {
|
symbol {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
:host(use) > symbol {
|
:host(use) > symbol {
|
||||||
display: inline !important;
|
display: inline !important;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
:link, :visited {
|
:link, :visited {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue