diff options
author | Sam Atkins <atkinssj@gmail.com> | 2021-07-01 14:13:48 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-11 23:19:56 +0200 |
commit | 89bfde29dc2d9fd27fceb5b1de9cdd7bb5389f3a (patch) | |
tree | 5caa21ac8f1fcc32827c919ec9f9ae306107982e /Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h | |
parent | a558916e1f77ed21c49e2e59cd83f09ce2dfa5ac (diff) | |
download | serenity-89bfde29dc2d9fd27fceb5b1de9cdd7bb5389f3a.zip |
LibWeb: Convert some CSS parser *Rule classes to using pointers
Previously these were all passed around by value, but some of them
(StyleComponentValueRule and StyleBlockRule) want to include each
other as fields, so this had to change.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h b/Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h index f03265dbef..1510bbcdb3 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleComponentValueRule.h @@ -7,12 +7,15 @@ #pragma once -#include <LibWeb/CSS/Parser/StyleBlockRule.h> -#include <LibWeb/CSS/Parser/StyleFunctionRule.h> +#include <AK/NonnullRefPtr.h> +#include <AK/RefPtr.h> #include <LibWeb/CSS/Parser/Token.h> namespace Web::CSS { +class StyleBlockRule; +class StyleFunctionRule; + class StyleComponentValueRule { friend class Parser; @@ -27,10 +30,18 @@ public: ~StyleComponentValueRule(); bool is_block() const { return m_type == ComponentType::Block; } - StyleBlockRule const& block() const { return m_block; } + StyleBlockRule const& block() const + { + VERIFY(is_block()); + return *m_block; + } bool is_function() const { return m_type == ComponentType::Function; } - StyleFunctionRule const& function() const { return m_function; } + StyleFunctionRule const& function() const + { + VERIFY(is_function()); + return *m_function; + } bool is(Token::TokenType type) const { @@ -44,7 +55,7 @@ public: private: ComponentType m_type; Token m_token; - StyleFunctionRule m_function; - StyleBlockRule m_block; + RefPtr<StyleFunctionRule> m_function; + RefPtr<StyleBlockRule> m_block; }; } |