diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index 1e5b0048bdd..5f4097b9d69 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -69,6 +69,7 @@ impl CharacterDataMethods for CharacterData { // https://dom.spec.whatwg.org/#dom-characterdata-appenddatadata fn AppendData(&self, data: DOMString) { + // FIXME(ajeffrey): Efficient append on DOMStrings? self.append_data(&*data); } @@ -149,7 +150,8 @@ impl CharacterData { } #[inline] pub fn append_data(&self, data: &str) { - self.data.borrow_mut().0.push_str(data); + // FIXME(ajeffrey): Efficient append on DOMStrings? + self.data.borrow_mut().push_str(data); self.content_changed(); } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 81c2ecb102f..5839de3f4f4 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -182,7 +182,7 @@ fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option) { // Step 6. // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28925 if let Some(suffix) = hyperlink_suffix { - href.0.push_str(&suffix); + href.push_str(&suffix); } // Step 4-5. diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 898a0d69ff8..b77793984cc 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -576,10 +576,11 @@ impl VirtualMethods for HTMLInputElement { mutation.new_value(attr).as_ref().map(|name| name.as_atom())); }, &atom!(placeholder) => { + // FIXME(ajeffrey): Should we do in-place mutation of the placeholder? let mut placeholder = self.placeholder.borrow_mut(); - placeholder.0.clear(); + placeholder.clear(); if let AttributeMutation::Set(_) = mutation { - placeholder.0.extend( + placeholder.extend( attr.value().chars().filter(|&c| c != '\n' && c != '\r')); } }, diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 643b514c21a..aa970e27464 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -186,6 +186,7 @@ impl TextInput { vec!(insert) }; + // FIXME(ajeffrey): effecient append for DOMStrings let mut new_line = prefix.to_owned(); new_line.push_str(&insert_lines[0]); insert_lines[0] = DOMString::from(new_line); @@ -194,7 +195,8 @@ impl TextInput { self.edit_point.index = insert_lines[last_insert_lines_index].len(); self.edit_point.line = begin.line + last_insert_lines_index; - insert_lines[last_insert_lines_index].0.push_str(suffix); + // FIXME(ajeffrey): effecient append for DOMStrings + insert_lines[last_insert_lines_index].push_str(suffix); let mut new_lines = vec!(); new_lines.push_all(lines_prefix); diff --git a/components/util/str.rs b/components/util/str.rs index 180d834a05e..97a3013ecad 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -32,6 +32,13 @@ impl DOMString { pub fn new() -> DOMString { DOMString(String::new()) } + // FIXME(ajeffrey): implement more of the String methods on DOMString? + pub fn push_str(&mut self, string: &str) { + self.0.push_str(string) + } + pub fn clear(&mut self) { + self.0.clear() + } } impl Default for DOMString { @@ -181,6 +188,12 @@ impl FromJSValConvertible for DOMString { } } +impl Extend for DOMString { + fn extend(&mut self, iterable: I) where I: IntoIterator { + self.0.extend(iterable) + } +} + pub type StaticCharVec = &'static [char]; pub type StaticStringVec = &'static [&'static str];