mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Make NodeTypeId include CharacterData variant
NodeTypeId is supposed to reflect the WebIDL inheritance hierarchy. All of Text/ProcessingInstruction/Comment inherit from CharacterData, which inherits from Node. There should be a CharacterDataTypeId value that differentiates between those, instead.
This commit is contained in:
parent
1e150140bd
commit
f404853c99
9 changed files with 67 additions and 78 deletions
|
@ -47,6 +47,7 @@ use text::TextRunScanner;
|
|||
use wrapper::{PostorderNodeMutTraversal, PseudoElementType, TLayoutNode, ThreadSafeLayoutNode};
|
||||
|
||||
use gfx::display_list::OpaqueNode;
|
||||
use script::dom::characterdata::CharacterDataTypeId;
|
||||
use script::dom::element::ElementTypeId;
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
use script::dom::htmlobjectelement::is_image_data;
|
||||
|
@ -789,7 +790,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
// fragment that needs to be generated for this inline node.
|
||||
let mut fragments = LinkedList::new();
|
||||
match (node.get_pseudo_element_type(), node.type_id()) {
|
||||
(_, Some(NodeTypeId::Text)) => {
|
||||
(_, Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text))) => {
|
||||
self.create_fragments_for_node_text_content(&mut fragments, node, &style)
|
||||
}
|
||||
(PseudoElementType::Normal, _) => {
|
||||
|
@ -1239,12 +1240,12 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
};
|
||||
(munged_display, style.get_box().float, style.get_box().position)
|
||||
}
|
||||
Some(NodeTypeId::Text) => (display::T::inline, float::T::none, position::T::static_),
|
||||
Some(NodeTypeId::Comment) |
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text)) => (display::T::inline, float::T::none, position::T::static_),
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::Comment)) |
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction)) |
|
||||
Some(NodeTypeId::DocumentType) |
|
||||
Some(NodeTypeId::DocumentFragment) |
|
||||
Some(NodeTypeId::Document) |
|
||||
Some(NodeTypeId::ProcessingInstruction) => {
|
||||
Some(NodeTypeId::Document) => {
|
||||
(display::T::none, float::T::none, position::T::static_)
|
||||
}
|
||||
};
|
||||
|
@ -1382,9 +1383,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
|||
fn is_replaced_content(&self) -> bool {
|
||||
match self.type_id() {
|
||||
None |
|
||||
Some(NodeTypeId::Text) |
|
||||
Some(NodeTypeId::ProcessingInstruction) |
|
||||
Some(NodeTypeId::Comment) |
|
||||
Some(NodeTypeId::CharacterData(_)) |
|
||||
Some(NodeTypeId::DocumentType) |
|
||||
Some(NodeTypeId::DocumentFragment) |
|
||||
Some(NodeTypeId::Document) |
|
||||
|
|
|
@ -14,6 +14,7 @@ use incremental::{self, RestyleDamage};
|
|||
use opaque_node::OpaqueNodeMethods;
|
||||
use wrapper::{LayoutElement, LayoutNode, TLayoutNode};
|
||||
|
||||
use script::dom::characterdata::CharacterDataTypeId;
|
||||
use script::dom::node::NodeTypeId;
|
||||
use script::layout_interface::Animation;
|
||||
use selectors::bloom::BloomFilter;
|
||||
|
@ -676,7 +677,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
&mut None => panic!("no layout data"),
|
||||
&mut Some(ref mut layout_data) => {
|
||||
match self.type_id() {
|
||||
Some(NodeTypeId::Text) => {
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text)) => {
|
||||
// Text nodes get a copy of the parent style. This ensures
|
||||
// that during fragment construction any non-inherited
|
||||
// CSS properties (such as vertical-align) are correctly
|
||||
|
|
|
@ -45,7 +45,7 @@ use script::dom::bindings::codegen::InheritTypes::{HTMLIFrameElementCast, HTMLCa
|
|||
use script::dom::bindings::codegen::InheritTypes::{HTMLImageElementCast, HTMLInputElementCast};
|
||||
use script::dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementCast, NodeCast, TextCast};
|
||||
use script::dom::bindings::js::LayoutJS;
|
||||
use script::dom::characterdata::LayoutCharacterDataHelpers;
|
||||
use script::dom::characterdata::{CharacterDataTypeId, LayoutCharacterDataHelpers};
|
||||
use script::dom::element::{Element, ElementTypeId};
|
||||
use script::dom::element::{LayoutElementHelpers, RawLayoutElementHelpers};
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
|
@ -1048,7 +1048,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
/// `empty_cells` per CSS 2.1 § 17.6.1.1.
|
||||
pub fn is_content(&self) -> bool {
|
||||
match self.type_id() {
|
||||
Some(NodeTypeId::Element(..)) | Some(NodeTypeId::Text(..)) => true,
|
||||
Some(NodeTypeId::Element(..)) | Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text(..))) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,18 +33,16 @@ pub struct CharacterData {
|
|||
impl CharacterDataDerived for EventTarget {
|
||||
fn is_characterdata(&self) -> bool {
|
||||
match *self.type_id() {
|
||||
EventTargetTypeId::Node(NodeTypeId::Text) |
|
||||
EventTargetTypeId::Node(NodeTypeId::Comment) |
|
||||
EventTargetTypeId::Node(NodeTypeId::ProcessingInstruction) => true,
|
||||
EventTargetTypeId::Node(NodeTypeId::CharacterData(_)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CharacterData {
|
||||
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
|
||||
pub fn new_inherited(id: CharacterDataTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
|
||||
CharacterData {
|
||||
node: Node::new_inherited(id, document),
|
||||
node: Node::new_inherited(NodeTypeId::CharacterData(id), document),
|
||||
data: DOMRefCell::new(data),
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +151,15 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
|||
}
|
||||
}
|
||||
|
||||
/// The different types of CharacterData.
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
#[jstraceable]
|
||||
pub enum CharacterDataTypeId {
|
||||
Comment,
|
||||
Text,
|
||||
ProcessingInstruction,
|
||||
}
|
||||
|
||||
pub trait CharacterDataHelpers<'a> {
|
||||
fn data(self) -> Ref<'a, DOMString>;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::InheritTypes::CommentDerived;
|
|||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JSRef, Rootable, Temporary};
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::characterdata::{CharacterData, CharacterDataTypeId};
|
||||
use dom::document::Document;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
|
@ -22,14 +22,14 @@ pub struct Comment {
|
|||
|
||||
impl CommentDerived for EventTarget {
|
||||
fn is_comment(&self) -> bool {
|
||||
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::Comment)
|
||||
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::CharacterData(CharacterDataTypeId::Comment))
|
||||
}
|
||||
}
|
||||
|
||||
impl Comment {
|
||||
fn new_inherited(text: DOMString, document: JSRef<Document>) -> Comment {
|
||||
Comment {
|
||||
characterdata: CharacterData::new_inherited(NodeTypeId::Comment, text, document)
|
||||
characterdata: CharacterData::new_inherited(CharacterDataTypeId::Comment, text, document)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ use dom::bindings::js::Unrooted;
|
|||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::bindings::utils::{Reflectable, reflect_dom_object};
|
||||
use dom::characterdata::{CharacterData, CharacterDataHelpers};
|
||||
use dom::characterdata::{CharacterData, CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::comment::Comment;
|
||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument, DocumentSource};
|
||||
use dom::documentfragment::DocumentFragment;
|
||||
|
@ -269,13 +269,11 @@ impl LayoutDataRef {
|
|||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
#[jstraceable]
|
||||
pub enum NodeTypeId {
|
||||
CharacterData(CharacterDataTypeId),
|
||||
DocumentType,
|
||||
DocumentFragment,
|
||||
Comment,
|
||||
Document,
|
||||
Element(ElementTypeId),
|
||||
Text,
|
||||
ProcessingInstruction,
|
||||
}
|
||||
|
||||
trait PrivateNodeHelpers {
|
||||
|
@ -616,7 +614,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
|
||||
#[inline]
|
||||
fn is_text(self) -> bool {
|
||||
self.type_id == NodeTypeId::Text
|
||||
self.type_id == NodeTypeId::CharacterData(CharacterDataTypeId::Text)
|
||||
}
|
||||
|
||||
fn get_flag(self, flag: NodeFlags) -> bool {
|
||||
|
@ -1420,7 +1418,7 @@ impl Node {
|
|||
|
||||
// Step 4-5.
|
||||
match node.type_id() {
|
||||
NodeTypeId::Text => {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
||||
if parent.is_document() {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
|
@ -1432,8 +1430,8 @@ impl Node {
|
|||
},
|
||||
NodeTypeId::DocumentFragment |
|
||||
NodeTypeId::Element(_) |
|
||||
NodeTypeId::ProcessingInstruction |
|
||||
NodeTypeId::Comment => (),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) |
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => (),
|
||||
NodeTypeId::Document => return Err(HierarchyRequest)
|
||||
}
|
||||
|
||||
|
@ -1507,9 +1505,7 @@ impl Node {
|
|||
},
|
||||
}
|
||||
},
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction |
|
||||
NodeTypeId::Comment => (),
|
||||
NodeTypeId::CharacterData(_) => (),
|
||||
NodeTypeId::Document => unreachable!(),
|
||||
}
|
||||
},
|
||||
|
@ -1711,7 +1707,7 @@ impl Node {
|
|||
let doc_fragment = DocumentFragment::new(document.r());
|
||||
NodeCast::from_temporary(doc_fragment)
|
||||
},
|
||||
NodeTypeId::Comment => {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => {
|
||||
let cdata = CharacterDataCast::to_ref(node).unwrap();
|
||||
let comment = Comment::new(cdata.Data(), document.r());
|
||||
NodeCast::from_temporary(comment)
|
||||
|
@ -1739,12 +1735,12 @@ impl Node {
|
|||
document.r(), ElementCreator::ScriptCreated);
|
||||
NodeCast::from_temporary(element)
|
||||
},
|
||||
NodeTypeId::Text => {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
||||
let cdata = CharacterDataCast::to_ref(node).unwrap();
|
||||
let text = Text::new(cdata.Data(), document.r());
|
||||
NodeCast::from_temporary(text)
|
||||
},
|
||||
NodeTypeId::ProcessingInstruction => {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||
let pi = ProcessingInstruction::new(pi.Target(),
|
||||
CharacterDataCast::from_ref(pi).Data(), document.r());
|
||||
|
@ -1819,13 +1815,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
// https://dom.spec.whatwg.org/#dom-node-nodetype
|
||||
fn NodeType(self) -> u16 {
|
||||
match self.type_id {
|
||||
NodeTypeId::Element(_) => NodeConstants::ELEMENT_NODE,
|
||||
NodeTypeId::Text => NodeConstants::TEXT_NODE,
|
||||
NodeTypeId::ProcessingInstruction => NodeConstants::PROCESSING_INSTRUCTION_NODE,
|
||||
NodeTypeId::Comment => NodeConstants::COMMENT_NODE,
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => NodeConstants::TEXT_NODE,
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => NodeConstants::PROCESSING_INSTRUCTION_NODE,
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => NodeConstants::COMMENT_NODE,
|
||||
NodeTypeId::Document => NodeConstants::DOCUMENT_NODE,
|
||||
NodeTypeId::DocumentType => NodeConstants::DOCUMENT_TYPE_NODE,
|
||||
NodeTypeId::DocumentFragment => NodeConstants::DOCUMENT_FRAGMENT_NODE,
|
||||
NodeTypeId::Element(_) => NodeConstants::ELEMENT_NODE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1836,13 +1832,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
let elem: JSRef<Element> = ElementCast::to_ref(self).unwrap();
|
||||
elem.TagName()
|
||||
}
|
||||
NodeTypeId::Text => "#text".to_owned(),
|
||||
NodeTypeId::ProcessingInstruction => {
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => "#text".to_owned(),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
|
||||
let processing_instruction: JSRef<ProcessingInstruction> =
|
||||
ProcessingInstructionCast::to_ref(self).unwrap();
|
||||
processing_instruction.Target()
|
||||
}
|
||||
NodeTypeId::Comment => "#comment".to_owned(),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) => "#comment".to_owned(),
|
||||
NodeTypeId::DocumentType => {
|
||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(self).unwrap();
|
||||
doctype.name().clone()
|
||||
|
@ -1861,10 +1857,8 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
||||
fn GetOwnerDocument(self) -> Option<Temporary<Document>> {
|
||||
match self.type_id {
|
||||
NodeTypeId::CharacterData(..) |
|
||||
NodeTypeId::Element(..) |
|
||||
NodeTypeId::Comment |
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction |
|
||||
NodeTypeId::DocumentType |
|
||||
NodeTypeId::DocumentFragment => Some(self.owner_doc()),
|
||||
NodeTypeId::Document => None
|
||||
|
@ -1924,9 +1918,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||
fn GetNodeValue(self) -> Option<DOMString> {
|
||||
match self.type_id {
|
||||
NodeTypeId::Comment |
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction => {
|
||||
NodeTypeId::CharacterData(..) => {
|
||||
let chardata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
|
||||
Some(chardata.Data())
|
||||
}
|
||||
|
@ -1939,9 +1931,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||
fn SetNodeValue(self, val: Option<DOMString>) {
|
||||
match self.type_id {
|
||||
NodeTypeId::Comment |
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction => {
|
||||
NodeTypeId::CharacterData(..) => {
|
||||
self.SetTextContent(val)
|
||||
}
|
||||
_ => {}
|
||||
|
@ -1956,9 +1946,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
let content = Node::collect_text_contents(self.traverse_preorder());
|
||||
Some(content)
|
||||
}
|
||||
NodeTypeId::Comment |
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction => {
|
||||
NodeTypeId::CharacterData(..) => {
|
||||
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
|
||||
Some(characterdata.Data())
|
||||
}
|
||||
|
@ -1986,9 +1974,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
// Step 3.
|
||||
Node::replace_all(node.r(), self);
|
||||
}
|
||||
NodeTypeId::Comment |
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction => {
|
||||
NodeTypeId::CharacterData(..) => {
|
||||
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
|
||||
characterdata.SetData(value);
|
||||
|
||||
|
@ -2034,14 +2020,12 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
|
||||
// Step 4-5.
|
||||
match node.type_id() {
|
||||
NodeTypeId::Text if self.is_document() => return Err(HierarchyRequest),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) if self.is_document() => return Err(HierarchyRequest),
|
||||
NodeTypeId::DocumentType if !self.is_document() => return Err(HierarchyRequest),
|
||||
NodeTypeId::DocumentFragment |
|
||||
NodeTypeId::DocumentType |
|
||||
NodeTypeId::Element(..) |
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction |
|
||||
NodeTypeId::Comment => (),
|
||||
NodeTypeId::CharacterData(..) => (),
|
||||
NodeTypeId::Document => return Err(HierarchyRequest)
|
||||
}
|
||||
|
||||
|
@ -2107,9 +2091,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
return Err(HierarchyRequest);
|
||||
}
|
||||
},
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::ProcessingInstruction |
|
||||
NodeTypeId::Comment => (),
|
||||
NodeTypeId::CharacterData(..) => (),
|
||||
NodeTypeId::Document => unreachable!()
|
||||
}
|
||||
},
|
||||
|
@ -2269,9 +2251,9 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
// Step 3.
|
||||
NodeTypeId::DocumentType if !is_equal_doctype(this, node) => return false,
|
||||
NodeTypeId::Element(..) if !is_equal_element(this, node) => return false,
|
||||
NodeTypeId::ProcessingInstruction if !is_equal_processinginstruction(this, node) => return false,
|
||||
NodeTypeId::Text |
|
||||
NodeTypeId::Comment if !is_equal_characterdata(this, node) => return false,
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) if !is_equal_processinginstruction(this, node) => return false,
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) |
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) if !is_equal_characterdata(this, node) => return false,
|
||||
// Step 4.
|
||||
NodeTypeId::Element(..) if !is_equal_element_attrs(this, node) => return false,
|
||||
_ => ()
|
||||
|
|
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::ProcessingInstructionBinding;
|
|||
use dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods;
|
||||
use dom::bindings::codegen::InheritTypes::ProcessingInstructionDerived;
|
||||
use dom::bindings::js::{JSRef, Temporary};
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::characterdata::{CharacterData, CharacterDataTypeId};
|
||||
use dom::document::Document;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
|
@ -21,14 +21,14 @@ pub struct ProcessingInstruction {
|
|||
|
||||
impl ProcessingInstructionDerived for EventTarget {
|
||||
fn is_processinginstruction(&self) -> bool {
|
||||
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::ProcessingInstruction)
|
||||
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction))
|
||||
}
|
||||
}
|
||||
|
||||
impl ProcessingInstruction {
|
||||
fn new_inherited(target: DOMString, data: DOMString, document: JSRef<Document>) -> ProcessingInstruction {
|
||||
ProcessingInstruction {
|
||||
characterdata: CharacterData::new_inherited(NodeTypeId::ProcessingInstruction, data, document),
|
||||
characterdata: CharacterData::new_inherited(CharacterDataTypeId::ProcessingInstruction, data, document),
|
||||
target: target
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use dom::bindings::error::{Error, Fallible};
|
|||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JSRef, OptionalRootable, Rootable, RootedReference};
|
||||
use dom::bindings::js::Temporary;
|
||||
use dom::characterdata::{CharacterData, CharacterDataHelpers};
|
||||
use dom::characterdata::{CharacterData, CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::document::Document;
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
|
@ -27,14 +27,14 @@ pub struct Text {
|
|||
|
||||
impl TextDerived for EventTarget {
|
||||
fn is_text(&self) -> bool {
|
||||
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::Text)
|
||||
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::CharacterData(CharacterDataTypeId::Text))
|
||||
}
|
||||
}
|
||||
|
||||
impl Text {
|
||||
fn new_inherited(text: DOMString, document: JSRef<Document>) -> Text {
|
||||
Text {
|
||||
characterdata: CharacterData::new_inherited(NodeTypeId::Text, text, document)
|
||||
characterdata: CharacterData::new_inherited(CharacterDataTypeId::Text, text, document)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use dom::bindings::codegen::InheritTypes::ProcessingInstructionCast;
|
|||
use dom::bindings::js::{JS, JSRef, OptionalRootable, Root, Rootable};
|
||||
use dom::bindings::js::{RootedReference, Temporary};
|
||||
use dom::bindings::trace::RootedVec;
|
||||
use dom::characterdata::CharacterDataHelpers;
|
||||
use dom::characterdata::{CharacterDataHelpers, CharacterDataTypeId};
|
||||
use dom::comment::Comment;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::document::{DocumentSource, IsHTMLDocument};
|
||||
|
@ -247,17 +247,17 @@ impl<'a> Serializable for JSRef<'a, Node> {
|
|||
serializer.write_doctype(&doctype.name())
|
||||
},
|
||||
|
||||
(IncludeNode, NodeTypeId::Text) => {
|
||||
(IncludeNode, NodeTypeId::CharacterData(CharacterDataTypeId::Text)) => {
|
||||
let cdata = CharacterDataCast::to_ref(node).unwrap();
|
||||
serializer.write_text(&cdata.data())
|
||||
},
|
||||
|
||||
(IncludeNode, NodeTypeId::Comment) => {
|
||||
(IncludeNode, NodeTypeId::CharacterData(CharacterDataTypeId::Comment)) => {
|
||||
let cdata = CharacterDataCast::to_ref(node).unwrap();
|
||||
serializer.write_comment(&cdata.data())
|
||||
},
|
||||
|
||||
(IncludeNode, NodeTypeId::ProcessingInstruction) => {
|
||||
(IncludeNode, NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction)) => {
|
||||
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||
let data = CharacterDataCast::from_ref(pi).data();
|
||||
serializer.write_processing_instruction(&pi.target(), &data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue