aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-03-18 17:22:55 -0400
committerGitHub <noreply@github.com>2019-03-18 17:22:55 -0400
commit34fda66dfa5528f2b10a873e9a67417c6986c712 (patch)
tree8994cc26cc41a45bbc189622871b4a1c0b378f18 /components/script/dom/node.rs
parent0fac8f2f62aff22897a0ca657a840333827cabf0 (diff)
parent4b8282b3b164771e3351c2a85890167ab6d0ab7f (diff)
downloadservo-34fda66dfa5528f2b10a873e9a67417c6986c712.tar.gz
servo-34fda66dfa5528f2b10a873e9a67417c6986c712.zip
Auto merge of #22891 - georgeroman:implement_cdatasection, r=Manishearth
Implement CDATASection interface and createCDATASection method <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #22846 <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22891) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs26
1 files changed, 18 insertions, 8 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 7b5d4157bc0..3331686eef4 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -19,7 +19,7 @@ use crate::dom::bindings::conversions::{self, DerivedFrom};
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
use crate::dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId};
use crate::dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId};
-use crate::dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId};
+use crate::dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId, TextTypeId};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
use crate::dom::bindings::root::{Dom, DomRoot, DomSlice, LayoutDom, MutNullableDom};
use crate::dom::bindings::str::{DOMString, USVString};
@@ -559,7 +559,7 @@ impl Node {
}
match self.type_id() {
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) => self
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::Text)) => self
.parent_node
.get()
.unwrap()
@@ -1577,7 +1577,7 @@ impl Node {
// Step 4-5.
match node.type_id() {
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) => {
if parent.is::<Document>() {
return Err(Error::HierarchyRequest);
}
@@ -2081,7 +2081,12 @@ impl NodeMethods for Node {
// https://dom.spec.whatwg.org/#dom-node-nodetype
fn NodeType(&self) -> u16 {
match self.type_id() {
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) => NodeConstants::TEXT_NODE,
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::Text)) => {
+ NodeConstants::TEXT_NODE
+ },
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::CDATASection)) => {
+ NodeConstants::CDATA_SECTION_NODE
+ },
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
NodeConstants::PROCESSING_INSTRUCTION_NODE
},
@@ -2097,7 +2102,12 @@ impl NodeMethods for Node {
fn NodeName(&self) -> DOMString {
match self.type_id() {
NodeTypeId::Element(..) => self.downcast::<Element>().unwrap().TagName(),
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) => DOMString::from("#text"),
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::Text)) => {
+ DOMString::from("#text")
+ },
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(TextTypeId::CDATASection)) => {
+ DOMString::from("#cdata-section")
+ },
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) => {
self.downcast::<ProcessingInstruction>().unwrap().Target()
},
@@ -2253,7 +2263,7 @@ impl NodeMethods for Node {
// Step 4-5.
match node.type_id() {
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) if self.is::<Document>() => {
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) if self.is::<Document>() => {
return Err(Error::HierarchyRequest);
},
NodeTypeId::DocumentType if !self.is::<Document>() => {
@@ -2476,7 +2486,7 @@ impl NodeMethods for Node {
{
return false;
}
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) |
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) |
NodeTypeId::CharacterData(CharacterDataTypeId::Comment)
if !is_equal_characterdata(this, node) =>
{
@@ -2931,7 +2941,7 @@ impl Into<LayoutNodeType> for NodeTypeId {
fn into(self) -> LayoutNodeType {
match self {
NodeTypeId::Element(e) => LayoutNodeType::Element(e.into()),
- NodeTypeId::CharacterData(CharacterDataTypeId::Text) => LayoutNodeType::Text,
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) => LayoutNodeType::Text,
x => unreachable!("Layout should not traverse nodes of type {:?}", x),
}
}