mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-08 04:09:03 +02:00
This changeset gets rid of the `FooView` phantom type in favor of a more brute force approach that just whitelists methods that layout is allowed to call. The set is surprisingly small now that layout isn't going to the DOM for much. If this approach turns out not to scale, we can do something fancier, but I'd rather just have it be safe and secure first and then refactor later for programmer happiness. r? @kmcallister Source-Repo: https://github.com/servo/servo Source-Revision: 824c7ac613ebb80bb432ff6425c5e25c642b6afb
68 lines
1.9 KiB
Rust
68 lines
1.9 KiB
Rust
/* 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, ErrorResult, Fallible};
|
|
use dom::bindings::utils::{Reflectable, Reflector};
|
|
use dom::document::AbstractDocument;
|
|
use dom::node::{Node, NodeTypeId};
|
|
|
|
pub struct CharacterData {
|
|
node: Node,
|
|
data: ~str
|
|
}
|
|
|
|
impl CharacterData {
|
|
pub fn new_inherited(id: NodeTypeId, data: ~str, document: AbstractDocument) -> CharacterData {
|
|
CharacterData {
|
|
node: Node::new_inherited(id, document),
|
|
data: data
|
|
}
|
|
}
|
|
|
|
pub fn Data(&self) -> DOMString {
|
|
self.data.clone()
|
|
}
|
|
|
|
pub fn SetData(&mut self, arg: DOMString) -> ErrorResult {
|
|
self.data = arg;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn Length(&self) -> u32 {
|
|
self.data.len() as u32
|
|
}
|
|
|
|
pub fn SubstringData(&self, offset: u32, count: u32) -> Fallible<DOMString> {
|
|
Ok(self.data.slice(offset as uint, count as uint).to_str())
|
|
}
|
|
|
|
pub fn AppendData(&mut self, arg: DOMString) -> ErrorResult {
|
|
self.data.push_str(arg);
|
|
Ok(())
|
|
}
|
|
|
|
pub fn InsertData(&mut self, _offset: u32, _arg: DOMString) -> ErrorResult {
|
|
fail!("CharacterData::InsertData() is unimplemented")
|
|
}
|
|
|
|
pub fn DeleteData(&mut self, _offset: u32, _count: u32) -> ErrorResult {
|
|
fail!("CharacterData::DeleteData() is unimplemented")
|
|
}
|
|
|
|
pub fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) -> ErrorResult {
|
|
fail!("CharacterData::ReplaceData() is unimplemented")
|
|
}
|
|
}
|
|
|
|
impl Reflectable for CharacterData {
|
|
fn reflector<'a>(&'a self) -> &'a Reflector {
|
|
self.node.reflector()
|
|
}
|
|
|
|
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
|
|
self.node.mut_reflector()
|
|
}
|
|
}
|