mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Implement Range#cloneContents
This commit is contained in:
parent
acf47a02cf
commit
207648f14d
5 changed files with 174 additions and 549 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeConstants;
|
||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
|
||||
|
@ -9,7 +10,7 @@ use dom::bindings::codegen::Bindings::RangeBinding::{self, RangeConstants};
|
|||
use dom::bindings::codegen::Bindings::RangeBinding::RangeMethods;
|
||||
use dom::bindings::codegen::Bindings::TextBinding::TextMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, TextCast};
|
||||
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, NodeCast, TextCast};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::HierarchyRequest;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
|
@ -17,7 +18,9 @@ use dom::bindings::js::{JS, Root, RootedReference};
|
|||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
use dom::characterdata::CharacterDataTypeId;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::documentfragment::DocumentFragment;
|
||||
use dom::node::{Node, NodeHelpers, NodeTypeId};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
|
||||
use std::rc::Rc;
|
||||
|
@ -60,6 +63,25 @@ impl Range {
|
|||
let document = global.as_window().Document();
|
||||
Ok(Range::new_with_doc(document.r()))
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#contained
|
||||
fn contains(&self, node: &Node) -> bool {
|
||||
let inner = self.inner.borrow();
|
||||
let start = &inner.start;
|
||||
let end = &inner.end;
|
||||
match (bp_position(node, 0, start.node().r(), start.offset()),
|
||||
bp_position(node, node.len(), end.node().r(), end.offset())) {
|
||||
(Some(Ordering::Greater), Some(Ordering::Less)) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#partially-contained
|
||||
fn partially_contains(&self, node: &Node) -> bool {
|
||||
let inner = self.inner.borrow();
|
||||
inner.start.node().inclusive_ancestors().any(|n| n.r() == node) !=
|
||||
inner.end.node().inclusive_ancestors().any(|n| n.r() == node)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RangeHelpers<'a> {
|
||||
|
@ -250,7 +272,7 @@ impl<'a> RangeMethods for &'a Range {
|
|||
})
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-range-intersectsnodenode
|
||||
// https://dom.spec.whatwg.org/#dom-range-intersectsnode
|
||||
fn IntersectsNode(self, node: &Node) -> bool {
|
||||
let inner = self.inner().borrow();
|
||||
let start = &inner.start;
|
||||
|
@ -287,6 +309,145 @@ impl<'a> RangeMethods for &'a Range {
|
|||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-range-clonecontents
|
||||
// https://dom.spec.whatwg.org/#concept-range-clone
|
||||
fn CloneContents(self) -> Fallible<Root<DocumentFragment>> {
|
||||
let inner = self.inner.borrow();
|
||||
let start = &inner.start;
|
||||
let end = &inner.end;
|
||||
|
||||
// Step 3.
|
||||
let start_node = start.node();
|
||||
let start_offset = start.offset();
|
||||
let end_node = end.node();
|
||||
let end_offset = end.offset();
|
||||
|
||||
// Step 1.
|
||||
let fragment = DocumentFragment::new(start_node.owner_doc().r());
|
||||
|
||||
// Step 2.
|
||||
if start == end {
|
||||
return Ok(fragment);
|
||||
}
|
||||
|
||||
if end_node == start_node {
|
||||
if let Some(text) = CharacterDataCast::to_ref(start_node.r()) {
|
||||
// Step 4.1.
|
||||
let clone = start_node.CloneNode(true);
|
||||
// Step 4.2.
|
||||
let text = text.SubstringData(start_offset, end_offset - start_offset);
|
||||
CharacterDataCast::to_ref(clone.r()).unwrap().SetData(text.unwrap());
|
||||
// Step 4.3.
|
||||
try!(NodeCast::from_ref(fragment.r()).AppendChild(clone.r()));
|
||||
// Step 4.4
|
||||
return Ok(fragment);
|
||||
}
|
||||
}
|
||||
|
||||
// Steps 5-6.
|
||||
let common_ancestor = self.CommonAncestorContainer();
|
||||
|
||||
let first_contained_child =
|
||||
if start_node.is_inclusive_ancestor_of(end_node.r()) {
|
||||
// Step 7.
|
||||
None
|
||||
} else {
|
||||
// Step 8.
|
||||
common_ancestor.children()
|
||||
.find(|node| Range::partially_contains(self, node))
|
||||
};
|
||||
|
||||
let last_contained_child =
|
||||
if end_node.is_inclusive_ancestor_of(start_node.r()) {
|
||||
// Step 9.
|
||||
None
|
||||
} else {
|
||||
// Step 10.
|
||||
common_ancestor.rev_children()
|
||||
.find(|node| Range::partially_contains(self, node))
|
||||
};
|
||||
|
||||
// Step 11.
|
||||
let contained_children =
|
||||
common_ancestor.children().filter(|n| Range::contains(self, n));
|
||||
|
||||
// Step 12.
|
||||
if common_ancestor.children()
|
||||
.filter(|n| Range::contains(self, n))
|
||||
.any(|n| n.is_doctype()) {
|
||||
return Err(HierarchyRequest);
|
||||
}
|
||||
|
||||
if let Some(child) = first_contained_child {
|
||||
// Step 13.
|
||||
if let Some(text) = CharacterDataCast::to_ref(child.r()) {
|
||||
assert!(child == start_node);
|
||||
// Step 13.1.
|
||||
let clone = start_node.CloneNode(true); // CharacterData has no children.
|
||||
// Step 13.2
|
||||
let text = text.SubstringData(start_offset, start_node.len() - start_offset);
|
||||
CharacterDataCast::to_ref(clone.r()).unwrap().SetData(text.unwrap());
|
||||
// Step 13.3.
|
||||
try!(NodeCast::from_ref(fragment.r()).AppendChild(clone.r()));
|
||||
} else {
|
||||
// Step 14.1.
|
||||
let clone = child.CloneNode(false);
|
||||
// Step 14.2.
|
||||
try!(NodeCast::from_ref(fragment.r()).AppendChild(clone.r()));
|
||||
// Step 14.3.
|
||||
let subrange = Range::new(clone.owner_doc().r(),
|
||||
start_node.r(),
|
||||
start_offset,
|
||||
child.r(),
|
||||
child.len());
|
||||
// Step 14.4.
|
||||
let subfragment = try!(subrange.CloneContents());
|
||||
// Step 14.5.
|
||||
try!(clone.AppendChild(NodeCast::from_ref(subfragment.r())));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 15.
|
||||
for child in contained_children {
|
||||
// Step 15.1.
|
||||
let clone = child.CloneNode(true);
|
||||
// Step 15.2.
|
||||
try!(NodeCast::from_ref(fragment.r()).AppendChild(clone.r()));
|
||||
}
|
||||
|
||||
if let Some(child) = last_contained_child {
|
||||
// Step 16.
|
||||
if let Some(text) = CharacterDataCast::to_ref(child.r()) {
|
||||
assert!(child == end_node);
|
||||
// Step 16.1.
|
||||
let clone = end_node.CloneNode(true); // CharacterData has no children.
|
||||
// Step 16.2.
|
||||
let text = text.SubstringData(0, end_offset);
|
||||
CharacterDataCast::to_ref(clone.r()).unwrap().SetData(text.unwrap());
|
||||
// Step 16.3.
|
||||
try!(NodeCast::from_ref(fragment.r()).AppendChild(clone.r()));
|
||||
} else {
|
||||
// Step 17.1.
|
||||
let clone = child.CloneNode(false);
|
||||
// Step 17.2.
|
||||
try!(NodeCast::from_ref(fragment.r()).AppendChild(clone.r()));
|
||||
// Step 17.3.
|
||||
let subrange = Range::new(clone.owner_doc().r(),
|
||||
child.r(),
|
||||
0,
|
||||
end_node.r(),
|
||||
end_offset);
|
||||
// Step 17.4.
|
||||
let subfragment = try!(subrange.CloneContents());
|
||||
// Step 17.5.
|
||||
try!(clone.AppendChild(NodeCast::from_ref(subfragment.r())));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 18.
|
||||
Ok(fragment)
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-range-detach
|
||||
fn Detach(self) {
|
||||
// This method intentionally left blank.
|
||||
|
|
|
@ -46,8 +46,8 @@ interface Range {
|
|||
// void deleteContents();
|
||||
// [NewObject, Throws]
|
||||
// DocumentFragment extractContents();
|
||||
// [NewObject, Throws]
|
||||
// DocumentFragment cloneContents();
|
||||
[NewObject, Throws]
|
||||
DocumentFragment cloneContents();
|
||||
[Throws]
|
||||
void insertNode(Node node);
|
||||
// [Throws]
|
||||
|
|
|
@ -249,9 +249,6 @@
|
|||
[Range interface: operation extractContents()]
|
||||
expected: FAIL
|
||||
|
||||
[Range interface: operation cloneContents()]
|
||||
expected: FAIL
|
||||
|
||||
[Range interface: operation surroundContents(Node)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -264,9 +261,6 @@
|
|||
[Range interface: document.createRange() must inherit property "extractContents" with the proper type (21)]
|
||||
expected: FAIL
|
||||
|
||||
[Range interface: document.createRange() must inherit property "cloneContents" with the proper type (22)]
|
||||
expected: FAIL
|
||||
|
||||
[Range interface: document.createRange() must inherit property "surroundContents" with the proper type (24)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -279,9 +273,6 @@
|
|||
[Range interface: detachedRange must inherit property "extractContents" with the proper type (21)]
|
||||
expected: FAIL
|
||||
|
||||
[Range interface: detachedRange must inherit property "cloneContents" with the proper type (22)]
|
||||
expected: FAIL
|
||||
|
||||
[Range interface: detachedRange must inherit property "surroundContents" with the proper type (24)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,530 +0,0 @@
|
|||
[Range-cloneContents.html]
|
||||
type: testharness
|
||||
[Range.detach()]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 0 [paras[0\].firstChild, 0, paras[0\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 0 [paras[0\].firstChild, 0, paras[0\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 0 [paras[0\].firstChild, 0, paras[0\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 1 [paras[0\].firstChild, 0, paras[0\].firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 1 [paras[0\].firstChild, 0, paras[0\].firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 1 [paras[0\].firstChild, 0, paras[0\].firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 2 [paras[0\].firstChild, 2, paras[0\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 2 [paras[0\].firstChild, 2, paras[0\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 2 [paras[0\].firstChild, 2, paras[0\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 3 [paras[0\].firstChild, 2, paras[0\].firstChild, 9\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 3 [paras[0\].firstChild, 2, paras[0\].firstChild, 9\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 3 [paras[0\].firstChild, 2, paras[0\].firstChild, 9\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 4 [paras[1\].firstChild, 0, paras[1\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 4 [paras[1\].firstChild, 0, paras[1\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 4 [paras[1\].firstChild, 0, paras[1\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 5 [paras[1\].firstChild, 2, paras[1\].firstChild, 9\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 5 [paras[1\].firstChild, 2, paras[1\].firstChild, 9\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 5 [paras[1\].firstChild, 2, paras[1\].firstChild, 9\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 6 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 6 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 6 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 7 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 7 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 7 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 8 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 8 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 8 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 9 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 9 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 9 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 10 [document.documentElement, 0, document.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 10 [document.documentElement, 0, document.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 10 [document.documentElement, 0, document.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 11 [document.documentElement, 0, document.documentElement, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 11 [document.documentElement, 0, document.documentElement, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 11 [document.documentElement, 0, document.documentElement, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 12 [document.documentElement, 1, document.documentElement, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 12 [document.documentElement, 1, document.documentElement, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 12 [document.documentElement, 1, document.documentElement, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 13 [document.head, 1, document.head, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 13 [document.head, 1, document.head, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 13 [document.head, 1, document.head, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 14 [document.body, 4, document.body, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 14 [document.body, 4, document.body, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 14 [document.body, 4, document.body, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 15 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 15 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 15 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 16 [paras[0\], 0, paras[0\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 16 [paras[0\], 0, paras[0\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 16 [paras[0\], 0, paras[0\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 17 [detachedPara1, 0, detachedPara1, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 17 [detachedPara1, 0, detachedPara1, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 17 [detachedPara1, 0, detachedPara1, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 18 [paras[0\].firstChild, 0, paras[1\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 18 [paras[0\].firstChild, 0, paras[1\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 18 [paras[0\].firstChild, 0, paras[1\].firstChild, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 19 [paras[0\].firstChild, 0, paras[1\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 19 [paras[0\].firstChild, 0, paras[1\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 19 [paras[0\].firstChild, 0, paras[1\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 20 [paras[0\].firstChild, 3, paras[3\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 20 [paras[0\].firstChild, 3, paras[3\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 20 [paras[0\].firstChild, 3, paras[3\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 21 [paras[0\], 0, paras[0\].firstChild, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 21 [paras[0\], 0, paras[0\].firstChild, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 21 [paras[0\], 0, paras[0\].firstChild, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 22 [testDiv, 2, paras[4\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 22 [testDiv, 2, paras[4\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 22 [testDiv, 2, paras[4\], 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 23 [document, 0, document, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 23 [document, 0, document, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 24 [document, 0, document, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 24 [document, 0, document, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 25 [comment, 2, comment, 3\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 25 [comment, 2, comment, 3\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 25 [comment, 2, comment, 3\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 26 [testDiv, 0, comment, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 26 [testDiv, 0, comment, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 26 [testDiv, 0, comment, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 27 [foreignDoc, 1, foreignComment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 27 [foreignDoc, 1, foreignComment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 27 [foreignDoc, 1, foreignComment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 28 [foreignDoc.body, 0, foreignTextNode, 36\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 28 [foreignDoc.body, 0, foreignTextNode, 36\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 28 [foreignDoc.body, 0, foreignTextNode, 36\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 29 [xmlDoc, 1, xmlComment, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 29 [xmlDoc, 1, xmlComment, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 29 [xmlDoc, 1, xmlComment, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 30 [detachedTextNode, 0, detachedTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 30 [detachedTextNode, 0, detachedTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 30 [detachedTextNode, 0, detachedTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 31 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 31 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 31 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 32 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 32 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 32 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 33 [detachedComment, 3, detachedComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 33 [detachedComment, 3, detachedComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 33 [detachedComment, 3, detachedComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 34 [detachedForeignComment, 0, detachedForeignComment, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 34 [detachedForeignComment, 0, detachedForeignComment, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 34 [detachedForeignComment, 0, detachedForeignComment, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 35 [detachedXmlComment, 2, detachedXmlComment, 6\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 35 [detachedXmlComment, 2, detachedXmlComment, 6\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 35 [detachedXmlComment, 2, detachedXmlComment, 6\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 36 [docfrag, 0, docfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 36 [docfrag, 0, docfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 36 [docfrag, 0, docfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 37 [paras[1\].firstChild, 0, paras[1\].firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 37 [paras[1\].firstChild, 0, paras[1\].firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 37 [paras[1\].firstChild, 0, paras[1\].firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 38 [paras[1\].firstChild, 2, paras[1\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 38 [paras[1\].firstChild, 2, paras[1\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 38 [paras[1\].firstChild, 2, paras[1\].firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 39 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 39 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 39 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 40 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 40 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 40 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 41 [foreignDoc.head, 1, foreignDoc.head, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 41 [foreignDoc.head, 1, foreignDoc.head, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 41 [foreignDoc.head, 1, foreignDoc.head, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 42 [foreignDoc.body, 0, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 42 [foreignDoc.body, 0, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 42 [foreignDoc.body, 0, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 43 [paras[0\], 0, paras[0\], 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 43 [paras[0\], 0, paras[0\], 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 43 [paras[0\], 0, paras[0\], 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 44 [detachedPara1, 0, detachedPara1, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 44 [detachedPara1, 0, detachedPara1, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 44 [detachedPara1, 0, detachedPara1, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 45 [testDiv, 1, paras[2\].firstChild, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 45 [testDiv, 1, paras[2\].firstChild, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 45 [testDiv, 1, paras[2\].firstChild, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 46 [document.documentElement, 1, document.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 46 [document.documentElement, 1, document.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 46 [document.documentElement, 1, document.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 47 [foreignDoc.documentElement, 1, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 47 [foreignDoc.documentElement, 1, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 47 [foreignDoc.documentElement, 1, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 48 [document, 1, document, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 48 [document, 1, document, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 48 [document, 1, document, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 49 [paras[2\].firstChild, 4, comment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 49 [paras[2\].firstChild, 4, comment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 49 [paras[2\].firstChild, 4, comment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 50 [paras[3\], 1, comment, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 50 [paras[3\], 1, comment, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 50 [paras[3\], 1, comment, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 51 [foreignDoc, 0, foreignDoc, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 51 [foreignDoc, 0, foreignDoc, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 51 [foreignDoc, 0, foreignDoc, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 52 [xmlDoc, 0, xmlDoc, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 52 [xmlDoc, 0, xmlDoc, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 52 [xmlDoc, 0, xmlDoc, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 53 [detachedForeignTextNode, 7, detachedForeignTextNode, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 53 [detachedForeignTextNode, 7, detachedForeignTextNode, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 53 [detachedForeignTextNode, 7, detachedForeignTextNode, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 54 [detachedXmlTextNode, 7, detachedXmlTextNode, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 54 [detachedXmlTextNode, 7, detachedXmlTextNode, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 54 [detachedXmlTextNode, 7, detachedXmlTextNode, 7\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 55 [detachedComment, 5, detachedComment, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 55 [detachedComment, 5, detachedComment, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 55 [detachedComment, 5, detachedComment, 5\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 56 [detachedForeignComment, 4, detachedForeignComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 56 [detachedForeignComment, 4, detachedForeignComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 56 [detachedForeignComment, 4, detachedForeignComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 57 [foreignDocfrag, 0, foreignDocfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 57 [foreignDocfrag, 0, foreignDocfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 57 [foreignDocfrag, 0, foreignDocfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting DOM for range 58 [xmlDocfrag, 0, xmlDocfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Resulting cursor position for range 58 [xmlDocfrag, 0, xmlDocfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Returned fragment for range 58 [xmlDocfrag, 0, xmlDocfrag, 0\]]
|
||||
expected: FAIL
|
||||
|
|
@ -46,10 +46,11 @@ function myCloneContents(range) {
|
|||
var originalEndOffset = range.endOffset;
|
||||
|
||||
// "If original start node and original end node are the same, and they are
|
||||
// a Text or Comment node:"
|
||||
// a Text, ProcessingInstruction, or Comment node:"
|
||||
if (range.startContainer == range.endContainer
|
||||
&& (range.startContainer.nodeType == Node.TEXT_NODE
|
||||
|| range.startContainer.nodeType == Node.COMMENT_NODE)) {
|
||||
|| range.startContainer.nodeType == Node.COMMENT_NODE
|
||||
|| range.startContainer.nodeType == Node.PROCESSING_INSTRUCTION_NODE)) {
|
||||
// "Let clone be the result of calling cloneNode(false) on original
|
||||
// start node."
|
||||
var clone = originalStartNode.cloneNode(false);
|
||||
|
@ -130,10 +131,11 @@ function myCloneContents(range) {
|
|||
}
|
||||
}
|
||||
|
||||
// "If first partially contained child is a Text or Comment node:"
|
||||
// "If first partially contained child is a Text, ProcessingInstruction, or Comment node:"
|
||||
if (firstPartiallyContainedChild
|
||||
&& (firstPartiallyContainedChild.nodeType == Node.TEXT_NODE
|
||||
|| firstPartiallyContainedChild.nodeType == Node.COMMENT_NODE)) {
|
||||
|| firstPartiallyContainedChild.nodeType == Node.COMMENT_NODE
|
||||
|| firstPartiallyContainedChild.nodeType == Node.PROCESSING_INSTRUCTION_NODE)) {
|
||||
// "Let clone be the result of calling cloneNode(false) on original
|
||||
// start node."
|
||||
var clone = originalStartNode.cloneNode(false);
|
||||
|
@ -185,10 +187,11 @@ function myCloneContents(range) {
|
|||
frag.appendChild(clone);
|
||||
}
|
||||
|
||||
// "If last partially contained child is a Text or Comment node:"
|
||||
// "If last partially contained child is a Text, ProcessingInstruction, or Comment node:"
|
||||
if (lastPartiallyContainedChild
|
||||
&& (lastPartiallyContainedChild.nodeType == Node.TEXT_NODE
|
||||
|| lastPartiallyContainedChild.nodeType == Node.COMMENT_NODE)) {
|
||||
|| lastPartiallyContainedChild.nodeType == Node.COMMENT_NODE
|
||||
|| lastPartiallyContainedChild.nodeType == Node.PROCESSING_INSTRUCTION_NODE)) {
|
||||
// "Let clone be the result of calling cloneNode(false) on original
|
||||
// end node."
|
||||
var clone = originalEndNode.cloneNode(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue