aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorAnthony Ramine <nox@nox.paris>2020-03-31 14:58:56 +0200
committerAnthony Ramine <nox@nox.paris>2020-03-31 15:02:13 +0200
commit6fe294fa5bab1b0ccd80d6dfb53be85adfaec4ad (patch)
tree6a177fee39ac5ba1c3c2de58e3d11657b2044d2e /components/script/dom/node.rs
parent409bd3d989c1877f8e0a5da92bd758dd20ac724b (diff)
downloadservo-6fe294fa5bab1b0ccd80d6dfb53be85adfaec4ad.tar.gz
servo-6fe294fa5bab1b0ccd80d6dfb53be85adfaec4ad.zip
Make LayoutNodeHelpers::text_content return a cow
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 07b7d60cbe6..251f6fcab18 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -87,7 +87,7 @@ use servo_arc::Arc;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use smallvec::SmallVec;
-use std::borrow::ToOwned;
+use std::borrow::Cow;
use std::cell::{Cell, UnsafeCell};
use std::cmp;
use std::default::Default;
@@ -1326,7 +1326,7 @@ pub trait LayoutNodeHelpers<'dom> {
unsafe fn init_style_and_layout_data(self, _: OpaqueStyleAndLayoutData);
unsafe fn take_style_and_layout_data(self) -> OpaqueStyleAndLayoutData;
- fn text_content(self) -> String;
+ fn text_content(self) -> Cow<'dom, str>;
fn selection(self) -> Option<Range<usize>>;
fn image_url(self) -> Option<ServoUrl>;
fn image_density(self) -> Option<f64>;
@@ -1456,17 +1456,17 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
val
}
- fn text_content(self) -> String {
+ fn text_content(self) -> Cow<'dom, str> {
if let Some(text) = self.downcast::<Text>() {
- return text.upcast().data_for_layout().to_owned();
+ return text.upcast().data_for_layout().into();
}
if let Some(input) = self.downcast::<HTMLInputElement>() {
- return input.value_for_layout().into_owned();
+ return input.value_for_layout();
}
if let Some(area) = self.downcast::<HTMLTextAreaElement>() {
- return area.value_for_layout();
+ return area.value_for_layout().into();
}
panic!("not text!")