mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 12:08:14 +00:00
LibWeb: Rename StyleRule -> Rule
This name is what's used in the spec, and is a little less confusing.
This commit is contained in:
parent
cf24dc2e0c
commit
431a9938a8
8 changed files with 43 additions and 43 deletions
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
DeclarationOrAtRule::DeclarationOrAtRule(RefPtr<StyleRule> at)
|
||||
DeclarationOrAtRule::DeclarationOrAtRule(RefPtr<Rule> at)
|
||||
: m_type(DeclarationType::At)
|
||||
, m_at(move(at))
|
||||
{
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/Parser/Declaration.h>
|
||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||
#include <LibWeb/CSS/Parser/Rule.h>
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
class DeclarationOrAtRule {
|
||||
public:
|
||||
explicit DeclarationOrAtRule(RefPtr<StyleRule> at);
|
||||
explicit DeclarationOrAtRule(RefPtr<Rule> at);
|
||||
explicit DeclarationOrAtRule(Declaration declaration);
|
||||
~DeclarationOrAtRule();
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
bool is_at_rule() const { return m_type == DeclarationType::At; }
|
||||
bool is_declaration() const { return m_type == DeclarationType::Declaration; }
|
||||
|
||||
StyleRule const& at_rule() const
|
||||
Rule const& at_rule() const
|
||||
{
|
||||
VERIFY(is_at_rule());
|
||||
return *m_at;
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
private:
|
||||
DeclarationType m_type;
|
||||
RefPtr<StyleRule> m_at;
|
||||
RefPtr<Rule> m_at;
|
||||
Optional<Declaration> m_declaration;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||
#include <LibWeb/CSS/Parser/Function.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||
#include <LibWeb/CSS/Parser/Rule.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
@ -1520,12 +1520,12 @@ Optional<GeneralEnclosed> Parser::parse_general_enclosed(TokenStream<ComponentVa
|
|||
// 5.4.1. Consume a list of rules
|
||||
// https://www.w3.org/TR/css-syntax-3/#consume-list-of-rules
|
||||
template<typename T>
|
||||
NonnullRefPtrVector<StyleRule> Parser::consume_a_list_of_rules(TokenStream<T>& tokens, TopLevel top_level)
|
||||
NonnullRefPtrVector<Rule> Parser::consume_a_list_of_rules(TokenStream<T>& tokens, TopLevel top_level)
|
||||
{
|
||||
// To consume a list of rules, given a top-level flag:
|
||||
|
||||
// Create an initially empty list of rules.
|
||||
NonnullRefPtrVector<StyleRule> rules;
|
||||
NonnullRefPtrVector<Rule> rules;
|
||||
|
||||
// Repeatedly consume the next input token:
|
||||
for (;;) {
|
||||
|
@ -1588,7 +1588,7 @@ NonnullRefPtrVector<StyleRule> Parser::consume_a_list_of_rules(TokenStream<T>& t
|
|||
// 5.4.2. Consume an at-rule
|
||||
// https://www.w3.org/TR/css-syntax-3/#consume-at-rule
|
||||
template<typename T>
|
||||
NonnullRefPtr<StyleRule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
||||
NonnullRefPtr<Rule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
||||
{
|
||||
// To consume an at-rule:
|
||||
|
||||
|
@ -1597,7 +1597,7 @@ NonnullRefPtr<StyleRule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
|||
VERIFY(name_ident.is(Token::Type::AtKeyword));
|
||||
|
||||
// Create a new at-rule with its name set to the value of the current input token, its prelude initially set to an empty list, and its value initially set to nothing.
|
||||
// NOTE: We create the StyleRule fully initialized when we return it instead.
|
||||
// NOTE: We create the Rule fully initialized when we return it instead.
|
||||
FlyString at_rule_name = ((Token)name_ident).at_keyword();
|
||||
Vector<ComponentValue> prelude;
|
||||
RefPtr<Block> block;
|
||||
|
@ -1609,21 +1609,21 @@ NonnullRefPtr<StyleRule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
|||
// <semicolon-token>
|
||||
if (token.is(Token::Type::Semicolon)) {
|
||||
// Return the at-rule.
|
||||
return StyleRule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
return Rule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
}
|
||||
|
||||
// <EOF-token>
|
||||
if (token.is(Token::Type::EndOfFile)) {
|
||||
// This is a parse error. Return the at-rule.
|
||||
log_parse_error();
|
||||
return StyleRule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
return Rule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
}
|
||||
|
||||
// <{-token>
|
||||
if (token.is(Token::Type::OpenCurly)) {
|
||||
// Consume a simple block and assign it to the at-rule’s block. Return the at-rule.
|
||||
block = consume_a_simple_block(tokens);
|
||||
return StyleRule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
return Rule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
}
|
||||
|
||||
// simple block with an associated token of <{-token>
|
||||
|
@ -1632,7 +1632,7 @@ NonnullRefPtr<StyleRule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
|||
if (component_value.is_block() && component_value.block().is_curly()) {
|
||||
// Assign the block to the at-rule’s block. Return the at-rule.
|
||||
block = component_value.block();
|
||||
return StyleRule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
return Rule::make_at_rule(move(at_rule_name), move(prelude), move(block));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1649,12 +1649,12 @@ NonnullRefPtr<StyleRule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
|||
// 5.4.3. Consume a qualified rule
|
||||
// https://www.w3.org/TR/css-syntax-3/#consume-qualified-rule
|
||||
template<typename T>
|
||||
RefPtr<StyleRule> Parser::consume_a_qualified_rule(TokenStream<T>& tokens)
|
||||
RefPtr<Rule> Parser::consume_a_qualified_rule(TokenStream<T>& tokens)
|
||||
{
|
||||
// To consume a qualified rule:
|
||||
|
||||
// Create a new qualified rule with its prelude initially set to an empty list, and its value initially set to nothing.
|
||||
// NOTE: We create the StyleRule fully initialized when we return it instead.
|
||||
// NOTE: We create the Rule fully initialized when we return it instead.
|
||||
Vector<ComponentValue> prelude;
|
||||
RefPtr<Block> block;
|
||||
|
||||
|
@ -1673,7 +1673,7 @@ RefPtr<StyleRule> Parser::consume_a_qualified_rule(TokenStream<T>& tokens)
|
|||
if (token.is(Token::Type::OpenCurly)) {
|
||||
// Consume a simple block and assign it to the qualified rule’s block. Return the qualified rule.
|
||||
block = consume_a_simple_block(tokens);
|
||||
return StyleRule::make_qualified_rule(move(prelude), move(block));
|
||||
return Rule::make_qualified_rule(move(prelude), move(block));
|
||||
}
|
||||
|
||||
// simple block with an associated token of <{-token>
|
||||
|
@ -1682,7 +1682,7 @@ RefPtr<StyleRule> Parser::consume_a_qualified_rule(TokenStream<T>& tokens)
|
|||
if (component_value.is_block() && component_value.block().is_curly()) {
|
||||
// Assign the block to the qualified rule’s block. Return the qualified rule.
|
||||
block = component_value.block();
|
||||
return StyleRule::make_qualified_rule(move(prelude), move(block));
|
||||
return Rule::make_qualified_rule(move(prelude), move(block));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2112,10 +2112,10 @@ RefPtr<CSSRule> Parser::parse_as_css_rule()
|
|||
// 5.3.5. Parse a rule
|
||||
// https://www.w3.org/TR/css-syntax-3/#parse-rule
|
||||
template<typename T>
|
||||
RefPtr<StyleRule> Parser::parse_a_rule(TokenStream<T>& tokens)
|
||||
RefPtr<Rule> Parser::parse_a_rule(TokenStream<T>& tokens)
|
||||
{
|
||||
// To parse a rule from input:
|
||||
RefPtr<StyleRule> rule;
|
||||
RefPtr<Rule> rule;
|
||||
|
||||
// 1. Normalize input, and set input to the result.
|
||||
// Note: This is done when initializing the Parser.
|
||||
|
@ -2153,7 +2153,7 @@ RefPtr<StyleRule> Parser::parse_a_rule(TokenStream<T>& tokens)
|
|||
// 5.3.4. Parse a list of rules
|
||||
// https://www.w3.org/TR/css-syntax-3/#parse-list-of-rules
|
||||
template<typename T>
|
||||
NonnullRefPtrVector<StyleRule> Parser::parse_a_list_of_rules(TokenStream<T>& tokens)
|
||||
NonnullRefPtrVector<Rule> Parser::parse_a_list_of_rules(TokenStream<T>& tokens)
|
||||
{
|
||||
// To parse a list of rules from input:
|
||||
|
||||
|
@ -2373,7 +2373,7 @@ Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_val
|
|||
return {};
|
||||
}
|
||||
|
||||
RefPtr<CSSRule> Parser::convert_to_rule(NonnullRefPtr<StyleRule> rule)
|
||||
RefPtr<CSSRule> Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
|
||||
{
|
||||
if (rule->is_at_rule()) {
|
||||
if (has_ignored_vendor_prefix(rule->at_rule_name())) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <LibWeb/CSS/Parser/Declaration.h>
|
||||
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||
#include <LibWeb/CSS/Parser/Function.h>
|
||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||
#include <LibWeb/CSS/Parser/Rule.h>
|
||||
#include <LibWeb/CSS/Parser/Tokenizer.h>
|
||||
#include <LibWeb/CSS/Ratio.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
|
@ -121,18 +121,18 @@ private:
|
|||
// "Parse a stylesheet" is intended to be the normal parser entry point, for parsing stylesheets.
|
||||
struct ParsedStyleSheet {
|
||||
Optional<AK::URL> location;
|
||||
NonnullRefPtrVector<StyleRule> rules;
|
||||
NonnullRefPtrVector<Rule> rules;
|
||||
};
|
||||
template<typename T>
|
||||
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<AK::URL> location);
|
||||
|
||||
// "Parse a list of rules" is intended for the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of <CDO-token> and <CDC-token>.
|
||||
template<typename T>
|
||||
NonnullRefPtrVector<StyleRule> parse_a_list_of_rules(TokenStream<T>&);
|
||||
NonnullRefPtrVector<Rule> parse_a_list_of_rules(TokenStream<T>&);
|
||||
|
||||
// "Parse a rule" is intended for use by the CSSStyleSheet#insertRule method, and similar functions which might exist, which parse text into a single rule.
|
||||
template<typename T>
|
||||
RefPtr<StyleRule> parse_a_rule(TokenStream<T>&);
|
||||
RefPtr<Rule> parse_a_rule(TokenStream<T>&);
|
||||
|
||||
// "Parse a declaration" is used in @supports conditions. [CSS3-CONDITIONAL]
|
||||
template<typename T>
|
||||
|
@ -179,11 +179,11 @@ private:
|
|||
Yes
|
||||
};
|
||||
template<typename T>
|
||||
[[nodiscard]] NonnullRefPtrVector<StyleRule> consume_a_list_of_rules(TokenStream<T>&, TopLevel);
|
||||
[[nodiscard]] NonnullRefPtrVector<Rule> consume_a_list_of_rules(TokenStream<T>&, TopLevel);
|
||||
template<typename T>
|
||||
[[nodiscard]] NonnullRefPtr<StyleRule> consume_an_at_rule(TokenStream<T>&);
|
||||
[[nodiscard]] NonnullRefPtr<Rule> consume_an_at_rule(TokenStream<T>&);
|
||||
template<typename T>
|
||||
RefPtr<StyleRule> consume_a_qualified_rule(TokenStream<T>&);
|
||||
RefPtr<Rule> consume_a_qualified_rule(TokenStream<T>&);
|
||||
template<typename T>
|
||||
[[nodiscard]] Vector<DeclarationOrAtRule> consume_a_style_blocks_contents(TokenStream<T>&);
|
||||
template<typename T>
|
||||
|
@ -202,7 +202,7 @@ private:
|
|||
RefPtr<CSSRule> parse_font_face_rule(TokenStream<ComponentValue>&);
|
||||
Vector<FontFace::Source> parse_font_face_src(TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<CSSRule> convert_to_rule(NonnullRefPtr<StyleRule>);
|
||||
RefPtr<CSSRule> convert_to_rule(NonnullRefPtr<Rule>);
|
||||
RefPtr<PropertyOwningCSSStyleDeclaration> convert_to_style_declaration(Vector<DeclarationOrAtRule> declarations);
|
||||
Optional<StyleProperty> convert_to_style_property(Declaration const&);
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/Parser/StyleRule.h>
|
||||
#include <LibWeb/CSS/Parser/Rule.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
StyleRule::StyleRule(StyleRule::Type type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
Rule::Rule(Rule::Type type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
: m_type(type)
|
||||
, m_at_rule_name(move(name))
|
||||
, m_prelude(move(prelude))
|
||||
|
@ -18,9 +18,9 @@ StyleRule::StyleRule(StyleRule::Type type, FlyString name, Vector<ComponentValue
|
|||
{
|
||||
}
|
||||
|
||||
StyleRule::~StyleRule() = default;
|
||||
Rule::~Rule() = default;
|
||||
|
||||
String StyleRule::to_string() const
|
||||
String Rule::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
@ -15,24 +15,24 @@
|
|||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
class StyleRule : public RefCounted<StyleRule> {
|
||||
class Rule : public RefCounted<Rule> {
|
||||
public:
|
||||
enum class Type {
|
||||
At,
|
||||
Qualified,
|
||||
};
|
||||
|
||||
static NonnullRefPtr<StyleRule> make_at_rule(FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
static NonnullRefPtr<Rule> make_at_rule(FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
{
|
||||
return adopt_ref(*new StyleRule(Type::At, move(name), move(prelude), move(block)));
|
||||
return adopt_ref(*new Rule(Type::At, move(name), move(prelude), move(block)));
|
||||
}
|
||||
|
||||
static NonnullRefPtr<StyleRule> make_qualified_rule(Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
static NonnullRefPtr<Rule> make_qualified_rule(Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
{
|
||||
return adopt_ref(*new StyleRule(Type::Qualified, {}, move(prelude), move(block)));
|
||||
return adopt_ref(*new Rule(Type::Qualified, {}, move(prelude), move(block)));
|
||||
}
|
||||
|
||||
~StyleRule();
|
||||
~Rule();
|
||||
|
||||
bool is_qualified_rule() const { return m_type == Type::Qualified; }
|
||||
bool is_at_rule() const { return m_type == Type::At; }
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
String to_string() const;
|
||||
|
||||
private:
|
||||
StyleRule(Type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);
|
||||
Rule(Type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);
|
||||
|
||||
Type const m_type;
|
||||
FlyString m_at_rule_name;
|
Loading…
Add table
Add a link
Reference in a new issue