mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibWeb: Expose Declaration's internals with getters
This is more in line with our style of not accessing `m_foo` fields directly.
This commit is contained in:
parent
611a209756
commit
802ccc210f
2 changed files with 14 additions and 10 deletions
|
@ -20,6 +20,10 @@ public:
|
||||||
Declaration();
|
Declaration();
|
||||||
~Declaration();
|
~Declaration();
|
||||||
|
|
||||||
|
String const& name() const { return m_name; }
|
||||||
|
Vector<ComponentValue> const& values() const { return m_values; }
|
||||||
|
Important importance() const { return m_important; }
|
||||||
|
|
||||||
String to_string() const;
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2515,7 +2515,7 @@ RefPtr<PropertyOwningCSSStyleDeclaration> Parser::convert_to_style_declaration(V
|
||||||
|
|
||||||
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
||||||
{
|
{
|
||||||
auto& property_name = declaration.m_name;
|
auto& property_name = declaration.name();
|
||||||
auto property_id = property_id_from_string(property_name);
|
auto property_id = property_id_from_string(property_name);
|
||||||
|
|
||||||
if (property_id == PropertyID::Invalid) {
|
if (property_id == PropertyID::Invalid) {
|
||||||
|
@ -2529,7 +2529,7 @@ Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& dec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto value_token_stream = TokenStream(declaration.m_values);
|
auto value_token_stream = TokenStream(declaration.values());
|
||||||
auto value = parse_css_value(property_id, value_token_stream);
|
auto value = parse_css_value(property_id, value_token_stream);
|
||||||
if (value.is_error()) {
|
if (value.is_error()) {
|
||||||
if (value.error() != ParsingResult::IncludesIgnoredVendorPrefix) {
|
if (value.error() != ParsingResult::IncludesIgnoredVendorPrefix) {
|
||||||
|
@ -2542,9 +2542,9 @@ Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& dec
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_id == PropertyID::Custom) {
|
if (property_id == PropertyID::Custom) {
|
||||||
return StyleProperty { declaration.m_important, property_id, value.release_value(), declaration.m_name };
|
return StyleProperty { declaration.importance(), property_id, value.release_value(), declaration.name() };
|
||||||
} else {
|
} else {
|
||||||
return StyleProperty { declaration.m_important, property_id, value.release_value(), {} };
|
return StyleProperty { declaration.importance(), property_id, value.release_value(), {} };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4131,13 +4131,13 @@ RefPtr<CSSRule> Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& declaration = declaration_or_at_rule.declaration();
|
auto& declaration = declaration_or_at_rule.declaration();
|
||||||
if (declaration.m_name.equals_ignoring_case("font-family"sv)) {
|
if (declaration.name().equals_ignoring_case("font-family"sv)) {
|
||||||
// FIXME: This is very similar to, but different from, the logic in parse_font_family_value().
|
// FIXME: This is very similar to, but different from, the logic in parse_font_family_value().
|
||||||
// Ideally they could share code.
|
// Ideally they could share code.
|
||||||
Vector<String> font_family_parts;
|
Vector<String> font_family_parts;
|
||||||
bool had_syntax_error = false;
|
bool had_syntax_error = false;
|
||||||
for (size_t i = 0; i < declaration.m_values.size(); ++i) {
|
for (size_t i = 0; i < declaration.values().size(); ++i) {
|
||||||
auto& part = declaration.m_values[i];
|
auto& part = declaration.values()[i];
|
||||||
if (part.is(Token::Type::Whitespace))
|
if (part.is(Token::Type::Whitespace))
|
||||||
continue;
|
continue;
|
||||||
if (part.is(Token::Type::String)) {
|
if (part.is(Token::Type::String)) {
|
||||||
|
@ -4170,11 +4170,11 @@ RefPtr<CSSRule> Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens
|
||||||
font_family = String::join(' ', font_family_parts);
|
font_family = String::join(' ', font_family_parts);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (declaration.m_name.equals_ignoring_case("src"sv)) {
|
if (declaration.name().equals_ignoring_case("src"sv)) {
|
||||||
Vector<FontFace::Source> supported_sources;
|
Vector<FontFace::Source> supported_sources;
|
||||||
// FIXME: Implement `local()`.
|
// FIXME: Implement `local()`.
|
||||||
// FIXME: Implement `format()`.
|
// FIXME: Implement `format()`.
|
||||||
TokenStream token_stream { declaration.m_values };
|
TokenStream token_stream { declaration.values() };
|
||||||
auto list_of_source_token_lists = parse_a_comma_separated_list_of_component_values(token_stream);
|
auto list_of_source_token_lists = parse_a_comma_separated_list_of_component_values(token_stream);
|
||||||
for (auto const& source_token_list : list_of_source_token_lists) {
|
for (auto const& source_token_list : list_of_source_token_lists) {
|
||||||
Optional<AK::URL> url;
|
Optional<AK::URL> url;
|
||||||
|
@ -4201,7 +4201,7 @@ RefPtr<CSSRule> Parser::parse_font_face_rule(TokenStream<ComponentValue>& tokens
|
||||||
src = move(supported_sources);
|
src = move(supported_sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Unrecognized descriptor '{}' in @font-family; discarding.", declaration.m_name);
|
dbgln_if(CSS_PARSER_DEBUG, "CSSParser: Unrecognized descriptor '{}' in @font-family; discarding.", declaration.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!font_family.has_value()) {
|
if (!font_family.has_value()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue