Skip to content

Commit 735ac01

Browse files
authored
Merge pull request #55 from noahbald/fix/49+53-default-jobs-and-order
fix: #49, #53 use correct default for enabled jobs and order
2 parents 34de3d1 + 05a6f09 commit 735ac01

File tree

1 file changed

+31
-6
lines changed
  • crates/oxvg_optimiser/src/jobs

1 file changed

+31
-6
lines changed

crates/oxvg_optimiser/src/jobs/mod.rs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait Job {
5656
fn breakdown<N: Node>(&mut self, _document: &N) {}
5757
}
5858

59-
#[derive(Deserialize, Default, Clone)]
59+
#[derive(Deserialize, Clone)]
6060
#[serde(rename_all = "camelCase")]
6161
pub struct Jobs {
6262
add_attributes_to_svg_element: Option<Box<AddAttributesToSVGElement>>,
@@ -131,22 +131,47 @@ impl Jobs {
131131
}
132132
}
133133

134+
impl Default for Jobs {
135+
fn default() -> Self {
136+
Self {
137+
add_attributes_to_svg_element: None,
138+
add_classes_to_svg: None,
139+
apply_transforms: Some(Box::new(ApplyTransforms::default())),
140+
cleanup_attributes: Some(Box::new(CleanupAttributes::default())),
141+
cleanup_enable_background: Some(Box::new(CleanupEnableBackground::default())),
142+
cleanup_ids: Some(Box::new(CleanupIds::default())),
143+
cleanup_list_of_values: None,
144+
cleanup_numeric_values: Some(Box::new(CleanupNumericValues::default())),
145+
collapse_groups: Some(Box::new(CollapseGroups::default())),
146+
convert_colors: Some(Box::new(ConvertColors::default())),
147+
convert_ellipse_to_circle: Some(Box::new(ConvertEllipseToCircle::default())),
148+
convert_path_data: Some(Box::new(ConvertPathData::default())),
149+
convert_shape_to_path: Some(Box::new(ConvertShapeToPath::default())),
150+
convert_transform: Some(Box::new(ConvertTransform::default())),
151+
}
152+
}
153+
}
154+
134155
bitflags! {
135156
#[derive(PartialEq)]
136157
struct JobFlag: usize {
158+
// Non default plugins
137159
const add_attributes_to_svg_element = 0b0000_0001;
138160
const add_classes_to_svg = 0b_0000_0000_0000_0010;
139-
const apply_transforms = 0b00_0000_0000_0000_0100;
161+
const cleanup_list_of_values = 0b0_0000_0100_0000;
162+
163+
// Default plugins
140164
const cleanup_attributes = 0b_0000_0000_0000_1000;
141-
const cleanup_enable_background = 0b000_0001_0000;
142165
const cleanup_ids = 0b00_0000_0000_0000_0010_0000;
143-
const cleanup_list_of_values = 0b0_0000_0100_0000;
144166
const cleanup_numeric_values = 0b0_0000_1000_0000;
145-
const collapse_groups = 0b000_0000_0001_0000_0000;
146167
const convert_colors = 0b0000_0000_0010_0000_0000;
168+
const cleanup_enable_background = 0b000_0001_0000;
169+
const convert_shape_to_path = 0b01_0000_0000_0000;
147170
const convert_ellipse_to_circle = 0b100_0000_0000;
171+
const collapse_groups = 0b000_0000_0001_0000_0000;
172+
// NOTE: This one should be before `convert_path_data` in case the order is ever changed
173+
const apply_transforms = 0b00_0000_0000_0000_0100;
148174
const convert_path_data = 0b0_0000_1000_0000_0000;
149-
const convert_shape_to_path = 0b01_0000_0000_0000;
150175
const convert_transform = 0b0_0010_0000_0000_0000;
151176
}
152177
}

0 commit comments

Comments
 (0)