[librsvg: 10/17] CssRules.add_declaration(): Renamed from define(); take a Declaration
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 10/17] CssRules.add_declaration(): Renamed from define(); take a Declaration
- Date: Fri, 3 May 2019 01:29:29 +0000 (UTC)
commit 7b75510a6fee94293c87619b2f9121ab27c73c68
Author: Federico Mena Quintero <federico gnome org>
Date: Thu May 2 18:57:48 2019 -0500
CssRules.add_declaration(): Renamed from define(); take a Declaration
Instead of building a Declaration inside the function, do it in the caller.
rsvg_internals/src/css.rs | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/rsvg_internals/src/css.rs b/rsvg_internals/src/css.rs
index f488d2e9..20911f65 100644
--- a/rsvg_internals/src/css.rs
+++ b/rsvg_internals/src/css.rs
@@ -109,34 +109,23 @@ impl CssRules {
})
}
- fn define(
- &mut self,
- selector: &str,
- attr: Attribute,
- property: ParsedProperty,
- important: bool,
- ) {
+ fn add_declaration(&mut self, selector: &str, declaration: Declaration) {
let decl_list = self
.selectors_to_declarations
.entry(selector.to_string())
.or_insert_with(|| DeclarationList::new());
- match decl_list.entry(attr) {
+ match decl_list.entry(declaration.attribute) {
Entry::Occupied(mut e) => {
let decl = e.get_mut();
if !decl.important {
- decl.property = property;
- decl.important = important;
+ *decl = declaration;
}
}
Entry::Vacant(v) => {
- v.insert(Declaration {
- attribute: attr,
- property,
- important,
- });
+ v.insert(declaration);
}
}
}
@@ -262,13 +251,19 @@ unsafe extern "C" fn css_property(
let important = from_glib(a_is_important);
- if let Ok(attr) = Attribute::from_str(prop_name) {
- if let Ok(Some(prop)) =
- parse_attribute_value_into_parsed_property(attr, &prop_value, true)
+ if let Ok(attribute) = Attribute::from_str(prop_name) {
+ if let Ok(Some(property)) =
+ parse_attribute_value_into_parsed_property(attribute, &prop_value, true)
{
+ let declaration = Declaration {
+ attribute,
+ property,
+ important,
+ };
+
handler_data
.css_rules
- .define(&selector_name, attr, prop, important);
+ .add_declaration(&selector_name, declaration);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]