mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Use DOMRefCell<T> in CharacterData.
This commit is contained in:
parent
fb98384fa5
commit
b42a91d0e9
1 changed files with 4 additions and 6 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
//! DOM bindings for `CharacterData`.
|
//! DOM bindings for `CharacterData`.
|
||||||
|
|
||||||
|
use dom::bindings::cell::{DOMRefCell, Ref};
|
||||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, NodeCast};
|
||||||
use dom::bindings::error::{Fallible, ErrorResult, IndexSize};
|
use dom::bindings::error::{Fallible, ErrorResult, IndexSize};
|
||||||
|
@ -14,15 +15,12 @@ use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingInstructionNodeTypeId, NodeHelpers};
|
use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingInstructionNodeTypeId, NodeHelpers};
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
use std::cell::{Ref, RefCell};
|
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
#[privatize]
|
#[privatize]
|
||||||
pub struct CharacterData {
|
pub struct CharacterData {
|
||||||
node: Node,
|
node: Node,
|
||||||
data: RefCell<DOMString>,
|
data: DOMRefCell<DOMString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterDataDerived for EventTarget {
|
impl CharacterDataDerived for EventTarget {
|
||||||
|
@ -40,7 +38,7 @@ impl CharacterData {
|
||||||
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
|
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
|
||||||
CharacterData {
|
CharacterData {
|
||||||
node: Node::new_inherited(id, document),
|
node: Node::new_inherited(id, document),
|
||||||
data: RefCell::new(data),
|
data: DOMRefCell::new(data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +59,7 @@ impl CharacterData {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn data_for_layout<'a>(&'a self) -> &'a str {
|
pub unsafe fn data_for_layout<'a>(&'a self) -> &'a str {
|
||||||
mem::transmute::<&RefCell<DOMString>, &DOMString>(&self.data).as_slice()
|
self.data.borrow_for_layout().as_slice()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue