Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Feb 17, 2024
1 parent 73611a1 commit d1d9aa0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
19 changes: 5 additions & 14 deletions src/render/clip_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub fn render(
// of more complex clipping paths, even if this means that Safari will in some cases not
// display them correctly.

let is_simple_clip_path = is_simple_clip_path(&clip_path.root());
let clip_rules = collect_clip_rules(&clip_path.root());
let is_simple_clip_path = is_simple_clip_path(clip_path.root());
let clip_rules = collect_clip_rules(clip_path.root());

if is_simple_clip_path
&& (clip_rules.iter().all(|f| *f == FillRule::NonZero)
Expand All @@ -49,7 +49,6 @@ pub fn render(
&& clip_rules.len() == 1))
{
create_simple_clip_path(
group,
clip_path,
content,
clip_rules.first().copied().unwrap_or(FillRule::NonZero),
Expand Down Expand Up @@ -94,13 +93,12 @@ fn collect_clip_rules(group: &Group) -> Vec<FillRule> {
}

fn create_simple_clip_path(
parent: &Group,
clip_path: &ClipPath,
content: &mut Content,
clip_rule: FillRule,
) {
if let Some(clip_path) = clip_path.clip_path() {
create_simple_clip_path(parent, clip_path, content, clip_rule);
create_simple_clip_path(clip_path, content, clip_rule);
}

// Just a dummy operation, so that in case the clip path only has hidden children the clip
Expand All @@ -110,7 +108,7 @@ fn create_simple_clip_path(
let base_transform = clip_path.transform();

let mut segments = vec![];
extend_segments_from_group(&clip_path.root(), &base_transform, &mut segments);
extend_segments_from_group(clip_path.root(), &base_transform, &mut segments);
draw_path(segments.into_iter(), content);

if clip_rule == FillRule::NonZero {
Expand Down Expand Up @@ -189,14 +187,7 @@ fn create_complex_clip_path(

let pdf_bbox = bbox_to_non_zero_rect(Some(parent.bounding_box())).to_pdf_rect();

group::render(
&clip_path.root(),
chunk,
&mut content,
ctx,
Transform::default(),
None,
);
group::render(clip_path.root(), chunk, &mut content, ctx, Transform::default(), None);
content.restore_state();

let content_stream = ctx.finish_content(content);
Expand Down
4 changes: 2 additions & 2 deletions src/render/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ fn function(
// We manually pad the stops if necessary so that they are always in the range from 0-1
if let Some(first) = stops.first() {
if first.offset != 0.0 {
let mut new_stop = first.clone();
let mut new_stop = *first;
new_stop.offset = 0.0;
stops.insert(0, new_stop);
}
}

if let Some(last) = stops.last() {
if last.offset != 1.0 {
let mut new_stop = last.clone();
let mut new_stop = *last;
new_stop.offset = 1.0;
stops.push(new_stop);
}
Expand Down
2 changes: 1 addition & 1 deletion src/render/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn create(
// circumvent a bug in Firefox where the bounding box is not applied properly for some transforms.
// If we don't do this, the "half-width-region-with-rotation.svg" test case won't render properly.
clip_to_rect(rect, &mut content);
group::render(&mask.root(), chunk, &mut content, ctx, Transform::default(), None);
group::render(mask.root(), chunk, &mut content, ctx, Transform::default(), None);

content.restore_state();
let content_stream = ctx.finish_content(content);
Expand Down
2 changes: 1 addition & 1 deletion src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn tree_to_stream(
let initial_transform = initial_transform.pre_concat(ctx.get_view_box_transform());
content.transform(initial_transform.to_pdf_transform());

group::render(&tree.root(), chunk, content, ctx, initial_transform, None);
group::render(tree.root(), chunk, content, ctx, initial_transform, None);
content.restore_state();
}

Expand Down
2 changes: 1 addition & 1 deletion src/render/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn create(
}

group::render(
&pattern.root(),
pattern.root(),
chunk,
&mut content,
ctx,
Expand Down

0 comments on commit d1d9aa0

Please sign in to comment.