mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Merge pull request #3063 from Ms2ger/Range
Implement some missing Range pieces; r=Manishearth
This commit is contained in:
commit
007e320ec9
5 changed files with 68 additions and 8 deletions
|
@ -38,15 +38,16 @@ use dom::htmlelement::HTMLElement;
|
||||||
use dom::htmlheadelement::HTMLHeadElement;
|
use dom::htmlheadelement::HTMLHeadElement;
|
||||||
use dom::htmlhtmlelement::HTMLHtmlElement;
|
use dom::htmlhtmlelement::HTMLHtmlElement;
|
||||||
use dom::htmltitleelement::HTMLTitleElement;
|
use dom::htmltitleelement::HTMLTitleElement;
|
||||||
|
use dom::location::Location;
|
||||||
use dom::mouseevent::MouseEvent;
|
use dom::mouseevent::MouseEvent;
|
||||||
use dom::node::{Node, ElementNodeTypeId, DocumentNodeTypeId, NodeHelpers};
|
use dom::node::{Node, ElementNodeTypeId, DocumentNodeTypeId, NodeHelpers};
|
||||||
use dom::node::{CloneChildren, DoNotCloneChildren};
|
use dom::node::{CloneChildren, DoNotCloneChildren};
|
||||||
use dom::nodelist::NodeList;
|
use dom::nodelist::NodeList;
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use dom::processinginstruction::ProcessingInstruction;
|
use dom::processinginstruction::ProcessingInstruction;
|
||||||
|
use dom::range::Range;
|
||||||
use dom::uievent::UIEvent;
|
use dom::uievent::UIEvent;
|
||||||
use dom::window::{Window, WindowHelpers};
|
use dom::window::{Window, WindowHelpers};
|
||||||
use dom::location::Location;
|
|
||||||
use html::hubbub_html_parser::build_element_from_tag;
|
use html::hubbub_html_parser::build_element_from_tag;
|
||||||
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
|
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
|
||||||
use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage};
|
use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage};
|
||||||
|
@ -504,6 +505,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http://dom.spec.whatwg.org/#dom-document-createrange
|
||||||
|
fn CreateRange(&self) -> Temporary<Range> {
|
||||||
|
Range::new(self)
|
||||||
|
}
|
||||||
|
|
||||||
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
|
// http://www.whatwg.org/specs/web-apps/current-work/#document.title
|
||||||
fn Title(&self) -> DOMString {
|
fn Title(&self) -> DOMString {
|
||||||
let mut title = String::new();
|
let mut title = String::new();
|
||||||
|
|
|
@ -4,14 +4,16 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::RangeBinding;
|
use dom::bindings::codegen::Bindings::RangeBinding;
|
||||||
use dom::bindings::codegen::Bindings::RangeBinding::RangeMethods;
|
use dom::bindings::codegen::Bindings::RangeBinding::RangeMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::{GlobalRef, Window};
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
|
use dom::document::Document;
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct Range {
|
pub struct Range {
|
||||||
pub reflector_: Reflector
|
reflector_: Reflector
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Range {
|
impl Range {
|
||||||
|
@ -21,16 +23,24 @@ impl Range {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalRef) -> Temporary<Range> {
|
pub fn new(document: &JSRef<Document>) -> Temporary<Range> {
|
||||||
reflect_dom_object(box Range::new_inherited(), global, RangeBinding::Wrap)
|
let window = document.window.root();
|
||||||
|
reflect_dom_object(box Range::new_inherited(),
|
||||||
|
&Window(*window),
|
||||||
|
RangeBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Range>> {
|
pub fn Constructor(global: &GlobalRef) -> Fallible<Temporary<Range>> {
|
||||||
Ok(Range::new(global))
|
let document = global.as_window().Document().root();
|
||||||
|
Ok(Range::new(&*document))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RangeMethods for JSRef<'a, Range> {
|
impl<'a> RangeMethods for JSRef<'a, Range> {
|
||||||
|
/// http://dom.spec.whatwg.org/#dom-range-detach
|
||||||
|
fn Detach(&self) {
|
||||||
|
// This method intentionally left blank.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for Range {
|
impl Reflectable for Range {
|
||||||
|
|
|
@ -43,6 +43,8 @@ interface Document : Node {
|
||||||
|
|
||||||
[Throws]
|
[Throws]
|
||||||
Event createEvent(DOMString interface_);
|
Event createEvent(DOMString interface_);
|
||||||
|
|
||||||
|
Range createRange();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* http://www.whatwg.org/specs/web-apps/current-work/#the-document-object */
|
/* http://www.whatwg.org/specs/web-apps/current-work/#the-document-object */
|
||||||
|
|
|
@ -59,7 +59,7 @@ interface Range {
|
||||||
// void surroundContents(Node newParent);
|
// void surroundContents(Node newParent);
|
||||||
|
|
||||||
// Range cloneRange();
|
// Range cloneRange();
|
||||||
// void detach();
|
void detach();
|
||||||
|
|
||||||
// [Throws]
|
// [Throws]
|
||||||
// boolean isPointInRange(Node node, unsigned long offset);
|
// boolean isPointInRange(Node node, unsigned long offset);
|
||||||
|
|
|
@ -1,3 +1,45 @@
|
||||||
[interfaces.html]
|
[interfaces.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: ERROR
|
expected: TIMEOUT
|
||||||
|
[DOMException exception: existence and properties of exception interface prototype object]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMException exception: existence and properties of exception interface prototype object\'s "name" property]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMError interface: existence and properties of interface object]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMError interface object length]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMError interface: existence and properties of interface prototype object]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMError interface: existence and properties of interface prototype object\'s "constructor" property]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMError interface: attribute name]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[DOMError interface: attribute message]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Event interface object length]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Event interface: document.createEvent("Event") must have own property "isTrusted"]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Event interface: new Event("foo") must have own property "isTrusted"]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[CustomEvent interface object length]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[Event interface: new CustomEvent("foo") must have own property "isTrusted"]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[EventTarget interface: existence and properties of interface object]
|
||||||
|
expected: TIMEOUT
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue