mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Privatize DocumentType
This commit is contained in:
parent
e15f8cb37f
commit
ba073d7e99
3 changed files with 28 additions and 12 deletions
|
@ -15,11 +15,12 @@ use servo_util::str::DOMString;
|
||||||
/// The `DOCTYPE` tag.
|
/// The `DOCTYPE` tag.
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DocumentType {
|
pub struct DocumentType {
|
||||||
pub node: Node,
|
node: Node,
|
||||||
pub name: DOMString,
|
name: DOMString,
|
||||||
pub public_id: DOMString,
|
public_id: DOMString,
|
||||||
pub system_id: DOMString,
|
system_id: DOMString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentTypeDerived for EventTarget {
|
impl DocumentTypeDerived for EventTarget {
|
||||||
|
@ -53,6 +54,21 @@ impl DocumentType {
|
||||||
document);
|
document);
|
||||||
Node::reflect_node(box documenttype, document, DocumentTypeBinding::Wrap)
|
Node::reflect_node(box documenttype, document, DocumentTypeBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn name<'a>(&'a self) -> &'a DOMString {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn public_id<'a>(&'a self) -> &'a DOMString {
|
||||||
|
&self.public_id
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn system_id<'a>(&'a self) -> &'a DOMString {
|
||||||
|
&self.system_id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
|
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInst
|
||||||
|
|
||||||
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
||||||
html.push_str("<!DOCTYPE");
|
html.push_str("<!DOCTYPE");
|
||||||
html.push_str(doctype.name.as_slice());
|
html.push_str(doctype.name().as_slice());
|
||||||
html.push_char('>');
|
html.push_char('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1458,9 +1458,9 @@ impl Node {
|
||||||
let copy: Root<Node> = match node.type_id() {
|
let copy: Root<Node> = match node.type_id() {
|
||||||
DoctypeNodeTypeId => {
|
DoctypeNodeTypeId => {
|
||||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
||||||
let doctype = DocumentType::new(doctype.name.clone(),
|
let doctype = DocumentType::new(doctype.name().clone(),
|
||||||
Some(doctype.public_id.clone()),
|
Some(doctype.public_id().clone()),
|
||||||
Some(doctype.system_id.clone()), *document);
|
Some(doctype.system_id().clone()), *document);
|
||||||
NodeCast::from_temporary(doctype)
|
NodeCast::from_temporary(doctype)
|
||||||
},
|
},
|
||||||
DocumentFragmentNodeTypeId => {
|
DocumentFragmentNodeTypeId => {
|
||||||
|
@ -1612,7 +1612,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
CommentNodeTypeId => "#comment".to_string(),
|
CommentNodeTypeId => "#comment".to_string(),
|
||||||
DoctypeNodeTypeId => {
|
DoctypeNodeTypeId => {
|
||||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(self).unwrap();
|
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(self).unwrap();
|
||||||
doctype.name.clone()
|
doctype.name().clone()
|
||||||
},
|
},
|
||||||
DocumentFragmentNodeTypeId => "#document-fragment".to_string(),
|
DocumentFragmentNodeTypeId => "#document-fragment".to_string(),
|
||||||
DocumentNodeTypeId => "#document".to_string()
|
DocumentNodeTypeId => "#document".to_string()
|
||||||
|
@ -1959,9 +1959,9 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
fn is_equal_doctype(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
fn is_equal_doctype(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
||||||
let other_doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(other).unwrap();
|
let other_doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(other).unwrap();
|
||||||
(doctype.name == other_doctype.name) &&
|
(*doctype.name() == *other_doctype.name()) &&
|
||||||
(doctype.public_id == other_doctype.public_id) &&
|
(*doctype.public_id() == *other_doctype.public_id()) &&
|
||||||
(doctype.system_id == other_doctype.system_id)
|
(*doctype.system_id() == *other_doctype.system_id())
|
||||||
}
|
}
|
||||||
fn is_equal_element(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
fn is_equal_element(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||||
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue