diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-18 21:50:52 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-18 21:53:05 +0100 |
commit | 0d8c9024eec12d57270cca1cf6bfc7d03c0ca229 (patch) | |
tree | 9c34cbafd25e03199d0279136f434e263d300a61 /Userland/Libraries/LibWeb/CSS | |
parent | a078733865c645411442bd8c32620176791d12ff (diff) | |
download | serenity-0d8c9024eec12d57270cca1cf6bfc7d03c0ca229.zip |
LibWeb: Add fast_is<T> for CSSRule subclasses
Since we already have a type enum for these, let's use it to make
is<T> bypass dynamic_cast for CSS rules.
These were often near the top of random browser profiles.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSImportRule.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSRule.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/CSSStyleRule.h | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index 2c752daab7..e097f80888 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -60,4 +60,7 @@ private: RefPtr<CSSStyleSheet> m_style_sheet; }; +template<> +inline bool CSSRule::fast_is<CSSImportRule>() const { return type() == CSSRule::Type::Import; } + } diff --git a/Userland/Libraries/LibWeb/CSS/CSSRule.h b/Userland/Libraries/LibWeb/CSS/CSSRule.h index 63fa5c1868..d7f3b51eeb 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRule.h @@ -47,6 +47,9 @@ public: virtual StringView class_name() const = 0; virtual Type type() const = 0; + template<typename T> + bool fast_is() const = delete; + private: }; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index e8db816f6c..abee9ce941 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -59,4 +59,7 @@ private: NonnullRefPtr<CSSStyleDeclaration> m_declaration; }; +template<> +inline bool CSSRule::fast_is<CSSStyleRule>() const { return type() == CSSRule::Type::Style; } + } |