Przeglądaj źródła

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.
Andreas Kling 4 lat temu
rodzic
commit
0d8c9024ee

+ 3 - 0
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; }
+
 }

+ 3 - 0
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:
 };
 

+ 3 - 0
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; }
+
 }