mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce CharacterData::clone_with_data()
This commit is contained in:
parent
7e1e34e7d5
commit
1dd7c8cf01
3 changed files with 35 additions and 33 deletions
|
@ -33,7 +33,6 @@ use dom::bindings::trace::JSTraceable;
|
|||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::xmlname::namespace_from_domstring;
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::comment::Comment;
|
||||
use dom::document::{Document, DocumentSource, IsHTMLDocument};
|
||||
use dom::documentfragment::DocumentFragment;
|
||||
use dom::documenttype::DocumentType;
|
||||
|
@ -1610,10 +1609,9 @@ impl Node {
|
|||
let doc_fragment = DocumentFragment::new(document.r());
|
||||
Root::upcast::<Node>(doc_fragment)
|
||||
},
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
|
||||
NodeTypeId::CharacterData(_) => {
|
||||
let cdata = node.downcast::<CharacterData>().unwrap();
|
||||
let comment = Comment::new(cdata.Data(), document.r());
|
||||
Root::upcast::<Node>(comment)
|
||||
cdata.clone_with_data(cdata.Data(), &document)
|
||||
},
|
||||
NodeTypeId::Document(_) => {
|
||||
let document = node.downcast::<Document>().unwrap();
|
||||
|
@ -1639,17 +1637,6 @@ impl Node {
|
|||
document.r(), ElementCreator::ScriptCreated);
|
||||
Root::upcast::<Node>(element)
|
||||
},
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
||||
let cdata = node.downcast::<CharacterData>().unwrap();
|
||||
let text = Text::new(cdata.Data(), document.r());
|
||||
Root::upcast::<Node>(text)
|
||||
},
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||
let pi = node.downcast::<ProcessingInstruction>().unwrap();
|
||||
let pi = ProcessingInstruction::new(pi.Target(),
|
||||
pi.upcast::<CharacterData>().Data(), document.r());
|
||||
Root::upcast::<Node>(pi)
|
||||
},
|
||||
};
|
||||
|
||||
// Step 3.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue