[librsvg: 15/22] Extract function to expand the marker shorthand
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 15/22] Extract function to expand the marker shorthand
- Date: Wed, 1 Jul 2020 00:04:26 +0000 (UTC)
commit 11324e3159f6b7253e04ea279f04961ca1a47c4f
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Jun 30 15:29:05 2020 -0500
Extract function to expand the marker shorthand
rsvg_internals/src/properties.rs | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 46891a2d..2afdcefc 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -10,6 +10,7 @@ use crate::css::{DeclParser, Declaration, Origin};
use crate::error::*;
use crate::font_props::*;
use crate::parsers::{Parse, ParseValue};
+use crate::properties;
use crate::property_bag::PropertyBag;
use crate::property_defs::*;
use crate::property_macros::Property;
@@ -427,28 +428,35 @@ impl SpecifiedValues {
}
fn set_property_expanding_shorthands(&mut self, prop: &ParsedProperty, replace: bool) {
- use crate::properties as p;
use crate::properties::ParsedProperty::*;
- if let Marker(SpecifiedValue::Specified(p::Marker(ref v))) = *prop {
- // Since "marker" is a shorthand property, we'll just expand it here
- self.set_property(
- &MarkerStart(SpecifiedValue::Specified(p::MarkerStart(v.clone()))),
- replace,
- );
- self.set_property(
- &MarkerMid(SpecifiedValue::Specified(p::MarkerMid(v.clone()))),
- replace,
- );
- self.set_property(
- &MarkerEnd(SpecifiedValue::Specified(p::MarkerEnd(v.clone()))),
- replace,
- );
+ if let Marker(SpecifiedValue::Specified(ref m)) = *prop {
+ self.expand_marker(m, replace);
} else {
self.set_property(prop, replace);
}
}
+ fn expand_marker(&mut self, marker: &properties::Marker, replace: bool) {
+ use crate::properties as p;
+ use crate::properties::ParsedProperty::*;
+
+ let p::Marker(v) = marker;
+
+ self.set_property(
+ &MarkerStart(SpecifiedValue::Specified(p::MarkerStart(v.clone()))),
+ replace,
+ );
+ self.set_property(
+ &MarkerMid(SpecifiedValue::Specified(p::MarkerMid(v.clone()))),
+ replace,
+ );
+ self.set_property(
+ &MarkerEnd(SpecifiedValue::Specified(p::MarkerEnd(v.clone()))),
+ replace,
+ );
+ }
+
pub fn set_parsed_property(&mut self, prop: &ParsedProperty) {
self.set_property_expanding_shorthands(prop, true);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]