Fix style in CharacterData.

This commit is contained in:
Patrick Walton 2013-05-03 15:36:58 -07:00
parent c0e79daff9
commit a178a7a5d1

View file

@ -1,3 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! DOM bindings for `CharacterData`.
use dom::bindings::utils::{DOMString, null_string, str}; use dom::bindings::utils::{DOMString, null_string, str};
use dom::node::{Node, NodeTypeId}; use dom::node::{Node, NodeTypeId};
@ -8,50 +14,51 @@ pub struct CharacterData {
data: DOMString data: DOMString
} }
pub impl CharacterData { impl CharacterData {
fn new(id: NodeTypeId, data: ~str) -> CharacterData { pub fn new(id: NodeTypeId, data: ~str) -> CharacterData {
CharacterData { CharacterData {
parent: Node::new(id), parent: Node::new(id),
data: str(data) data: str(data)
} }
} }
fn GetData(&self) -> DOMString { pub fn GetData(&self) -> DOMString {
copy self.data copy self.data
} }
fn SetData(&mut self, arg: DOMString) { pub fn SetData(&mut self, arg: DOMString) {
self.data = arg; self.data = arg;
} }
fn Length(&self) -> u32 { pub fn Length(&self) -> u32 {
match self.data { match self.data {
str(ref s) => s.len() as u32, str(ref s) => s.len() as u32,
null_string => 0 null_string => 0
} }
} }
fn SubstringData(&self, offset: u32, count: u32) -> DOMString { pub fn SubstringData(&self, offset: u32, count: u32) -> DOMString {
match self.data { match self.data {
str(ref s) => str(s.slice(offset as uint, count as uint).to_str()), str(ref s) => str(s.slice(offset as uint, count as uint).to_str()),
null_string => null_string null_string => null_string
} }
} }
fn AppendData(&mut self, arg: DOMString) { pub fn AppendData(&mut self, arg: DOMString) {
let s = self.data.to_str(); let s = self.data.to_str();
self.data = str(str::append(s, arg.to_str())); self.data = str(str::append(s, arg.to_str()));
} }
fn InsertData(&mut self, _offset: u32, _arg: DOMString) { pub fn InsertData(&mut self, _offset: u32, _arg: DOMString) {
fail!(~"nyi") fail!("CharacterData::InsertData() is unimplemented")
} }
fn DeleteData(&mut self, _offset: u32, _count: u32) { pub fn DeleteData(&mut self, _offset: u32, _count: u32) {
fail!(~"nyi") fail!("CharacterData::DeleteData() is unimplemented")
} }
fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) { pub fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) {
fail!(~"nyi") fail!("CharacterData::ReplaceData() is unimplemented")
} }
} }