mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Implement Range::createContextualFragment
This commit is contained in:
parent
2ef1437457
commit
5ab7f54762
12 changed files with 52 additions and 38 deletions
|
@ -130,7 +130,6 @@ impl Element {
|
||||||
create_element(name, prefix, document, creator)
|
create_element(name, prefix, document, creator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn new_inherited(local_name: Atom,
|
pub fn new_inherited(local_name: Atom,
|
||||||
namespace: Namespace, prefix: Option<DOMString>,
|
namespace: Namespace, prefix: Option<DOMString>,
|
||||||
document: &Document) -> Element {
|
document: &Document) -> Element {
|
||||||
|
|
|
@ -22,6 +22,9 @@ use dom::bindings::weakref::{WeakRef, WeakRefVec};
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::documentfragment::DocumentFragment;
|
use dom::documentfragment::DocumentFragment;
|
||||||
|
use dom::element::Element;
|
||||||
|
use dom::htmlbodyelement::HTMLBodyElement;
|
||||||
|
use dom::htmlscriptelement::HTMLScriptElement;
|
||||||
use dom::node::{Node, UnbindContext};
|
use dom::node::{Node, UnbindContext};
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use heapsize::HeapSizeOf;
|
use heapsize::HeapSizeOf;
|
||||||
|
@ -893,6 +896,44 @@ impl RangeMethods for Range {
|
||||||
// Step 6.
|
// Step 6.
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface
|
||||||
|
fn CreateContextualFragment(&self, fragment: DOMString) -> Fallible<Root<DocumentFragment>> {
|
||||||
|
// Step 1.
|
||||||
|
let node = self.StartContainer();
|
||||||
|
let element = match node.type_id() {
|
||||||
|
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment => None,
|
||||||
|
NodeTypeId::Element(_) => Some(node),
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::Comment) |
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => node.GetParentNode(),
|
||||||
|
NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) |
|
||||||
|
NodeTypeId::DocumentType => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Step 2.
|
||||||
|
let should_create_body = element.as_ref().map_or(true, |elem| {
|
||||||
|
let elem = elem.downcast::<Element>().unwrap();
|
||||||
|
elem.local_name() == &atom!("html") && elem.html_element_in_html_document()
|
||||||
|
});
|
||||||
|
let element: Root<Node> = if should_create_body {
|
||||||
|
Root::upcast(HTMLBodyElement::new(atom!("body"), None, &self.StartContainer().owner_doc()))
|
||||||
|
} else {
|
||||||
|
Root::upcast(element.unwrap())
|
||||||
|
};
|
||||||
|
|
||||||
|
// Step 3.
|
||||||
|
let fragment_node = try!(element.parse_fragment(fragment));
|
||||||
|
|
||||||
|
// Step 4.
|
||||||
|
for node in fragment_node.upcast::<Node>().traverse_preorder() {
|
||||||
|
if let Some(script) = node.downcast::<HTMLScriptElement>() {
|
||||||
|
script.set_already_started(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 5.
|
||||||
|
Ok(fragment_node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
|
|
|
@ -76,9 +76,9 @@ interface Range {
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface
|
||||||
partial interface Range {
|
partial interface Range {
|
||||||
// [NewObject, Throws]
|
[NewObject, Throws]
|
||||||
// DocumentFragment createContextualFragment(DOMString fragment);
|
DocumentFragment createContextualFragment(DOMString fragment);
|
||||||
};//
|
};
|
||||||
|
|
||||||
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface
|
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface
|
||||||
partial interface Range {
|
partial interface Range {
|
||||||
|
|
|
@ -1,35 +1,11 @@
|
||||||
[createContextualFragment.html]
|
[createContextualFragment.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
[Must not throw INVALID_STATE_ERR for a detached node.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Simple test with paragraphs]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Don't auto-create <body> when applied to <html>]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[<script>s should be run when appended to the document (but not before)]
|
[<script>s should be run when appended to the document (but not before)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[<html> and <body> must work the same, 1]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[<html> and <body> must work the same, 2]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Implicit <body> creation]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Namespace generally shouldn't matter]
|
[Namespace generally shouldn't matter]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[<html> in a different namespace shouldn't be special]
|
[<html> in a different namespace shouldn't be special]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[null should be stringified]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[undefined should be stringified]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[load-events-networkState.html]
|
[load-events-networkState.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
|
||||||
[NETWORK_NO_SOURCE]
|
[NETWORK_NO_SOURCE]
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
type: testharness
|
type: testharness
|
||||||
[error]
|
[error]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[119.html]
|
|
||||||
type: testharness
|
|
||||||
[scheduler: external defer script created with createContextualFragment]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
[quickCheckAPI-G_I.html]
|
[quickCheckAPI-G_I.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
disabled: https://github.com/servo/servo/issues/10656
|
disabled: https://github.com/servo/servo/issues/10656
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
[copy-tex-image-2d-formats.html]
|
[copy-tex-image-2d-formats.html]
|
||||||
[WebGL test #3: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
[WebGL test #3: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #6: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
[WebGL test #6: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #9: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
[WebGL test #9: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #15: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
[WebGL test #15: getError expected: NO_ERROR. Was INVALID_ENUM : should be no errors]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #16: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
[WebGL test #16: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,3 @@
|
||||||
expected:
|
expected:
|
||||||
if os == "linux": CRASH
|
if os == "linux": CRASH
|
||||||
if os == "mac": TIMEOUT
|
if os == "mac": TIMEOUT
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[texture-npot.html]
|
[texture-npot.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
|
|
||||||
[WebGL test #4: at (0, 0) expected: 0,0,0,255 was 192,0,128,64]
|
[WebGL test #4: at (0, 0) expected: 0,0,0,255 was 192,0,128,64]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -117,3 +116,4 @@
|
||||||
|
|
||||||
[WebGL test #83: getError expected: NO_ERROR. Was INVALID_ENUM : gl.generateMipmap with POT texture should return succeed]
|
[WebGL test #83: getError expected: NO_ERROR. Was INVALID_ENUM : gl.generateMipmap with POT texture should return succeed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,3 @@
|
||||||
expected:
|
expected:
|
||||||
if os == "linux": CRASH
|
if os == "linux": CRASH
|
||||||
if os == "mac": TIMEOUT
|
if os == "mac": TIMEOUT
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue