diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-03-31 10:51:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 10:51:18 -0400 |
commit | 3aa15e3fa30194e465c8bbb21c07d5239a6ac9f8 (patch) | |
tree | bd64feee4c1f3d5861f5714b032dd3a52fd2aa70 /components/layout_2020/flow/construct.rs | |
parent | 09271826f6a771cace1755dd18794d7085fccbd3 (diff) | |
parent | fb1ff3f097c0c8a994c9e7c4bb72c3ba5b64492d (diff) | |
download | servo-3aa15e3fa30194e465c8bbb21c07d5239a6ac9f8.tar.gz servo-3aa15e3fa30194e465c8bbb21c07d5239a6ac9f8.zip |
Auto merge of #26070 - servo:layout-2020-more-cleanups, r=SimonSapin
Make LayoutNodeHelpers::text_content return a cow
What does it mean? It means that layout can process `Text` nodes' contents by just borrowing them, potentially saving us from a lot of unnecessary tempoorary allocations, which is nice.
Diffstat (limited to 'components/layout_2020/flow/construct.rs')
-rw-r--r-- | components/layout_2020/flow/construct.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index fe9465f775e..186a4b4d4ff 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -16,6 +16,7 @@ use crate::style_ext::{ComputedValuesExt, DisplayGeneratingBox, DisplayInside, D use rayon::iter::{IntoParallelIterator, ParallelIterator}; use rayon_croissant::ParallelIteratorExt; use servo_arc::Arc; +use std::borrow::Cow; use std::convert::{TryFrom, TryInto}; use style::properties::ComputedValues; use style::selector_parser::PseudoElement; @@ -286,7 +287,12 @@ where } } - fn handle_text(&mut self, node: Node, input: String, parent_style: &Arc<ComputedValues>) { + fn handle_text( + &mut self, + node: Node, + input: Cow<'dom, str>, + parent_style: &Arc<ComputedValues>, + ) { let (leading_whitespace, mut input) = self.handle_leading_whitespace(&input); if leading_whitespace || !input.is_empty() { // This text node should be pushed either to the next ongoing |