[librsvg: 31/37] NodeChars.to_chunks(): Extract this common function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 31/37] NodeChars.to_chunks(): Extract this common function
- Date: Fri, 28 Dec 2018 03:26:34 +0000 (UTC)
commit a4668426274a50006c17c74e49c5c6ed7ba093bf
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 11 18:27:34 2018 -0600
NodeChars.to_chunks(): Extract this common function
rsvg_internals/src/text.rs | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
---
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 13686199..1322246c 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -303,18 +303,11 @@ fn children_to_chunks(
dy: Option<Length>,
depth: usize,
) {
- let values = cascaded.get();
-
for child in node.children() {
match child.get_type() {
NodeType::Chars => child.with_impl(|chars: &NodeChars| {
- let span = chars.make_span(&child, values, dx, dy, depth);
-
- let num_chunks = chunks.len();
- assert!(num_chunks > 0);
-
- println!("appending span \"{}\"", span.text);
- chunks[num_chunks - 1].spans.push(span);
+ let values = cascaded.get();
+ chars.to_chunks(&child, values, chunks, dx, dy, depth);
}),
NodeType::TSpan => child.with_impl(|tspan: &NodeTSpan| {
@@ -412,6 +405,24 @@ impl NodeChars {
depth,
)
}
+
+ fn to_chunks(
+ &self,
+ node: &RsvgNode,
+ values: &ComputedValues,
+ chunks: &mut Vec<Chunk>,
+ dx: Option<Length>,
+ dy: Option<Length>,
+ depth: usize,
+ ) {
+ let span = self.make_span(&node, values, dx, dy, depth);
+
+ let num_chunks = chunks.len();
+ assert!(num_chunks > 0);
+
+ println!("appending span \"{}\"", span.text);
+ chunks[num_chunks - 1].spans.push(span);
+ }
}
impl NodeTrait for NodeChars {
@@ -579,13 +590,7 @@ fn extract_chars_children_to_chunks_recursively(
for child in node.children() {
match child.get_type() {
NodeType::Chars => child.with_impl(|chars: &NodeChars| {
- let span = chars.make_span(&child, values, None, None, depth);
-
- let num_chunks = chunks.len();
- assert!(num_chunks > 0);
-
- println!("appending span \"{}\"", span.text);
- chunks[num_chunks - 1].spans.push(span);
+ chars.to_chunks(&child, values, chunks, None, None, depth);
}),
_ => extract_chars_children_to_chunks_recursively(chunks, &child, values, depth + 1),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]