mirror of
https://github.com/servo/servo.git
synced 2025-07-29 18:20:24 +01:00
commit
ec417a84b1
2 changed files with 21 additions and 1 deletions
|
@ -934,6 +934,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-element-localname
|
||||||
fn LocalName(self) -> DOMString {
|
fn LocalName(self) -> DOMString {
|
||||||
self.local_name.as_slice().to_owned()
|
self.local_name.as_slice().to_owned()
|
||||||
}
|
}
|
||||||
|
@ -1079,17 +1080,20 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
self.GetAttributeNS(namespace, local_name).is_some()
|
self.GetAttributeNS(namespace, local_name).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
||||||
fn GetElementsByTagName(self, localname: DOMString) -> Temporary<HTMLCollection> {
|
fn GetElementsByTagName(self, localname: DOMString) -> Temporary<HTMLCollection> {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), localname)
|
HTMLCollection::by_tag_name(window.r(), NodeCast::from_ref(self), localname)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens
|
||||||
fn GetElementsByTagNameNS(self, maybe_ns: Option<DOMString>,
|
fn GetElementsByTagNameNS(self, maybe_ns: Option<DOMString>,
|
||||||
localname: DOMString) -> Temporary<HTMLCollection> {
|
localname: DOMString) -> Temporary<HTMLCollection> {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), localname, maybe_ns)
|
HTMLCollection::by_tag_name_ns(window.r(), NodeCast::from_ref(self), localname, maybe_ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
|
||||||
fn GetElementsByClassName(self, classes: DOMString) -> Temporary<HTMLCollection> {
|
fn GetElementsByClassName(self, classes: DOMString) -> Temporary<HTMLCollection> {
|
||||||
let window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
HTMLCollection::by_class_name(window.r(), NodeCast::from_ref(self), classes)
|
||||||
|
@ -1126,12 +1130,13 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
rect.origin.x + rect.size.width)
|
rect.origin.x + rect.size.width)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-element-interface
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
||||||
fn GetInnerHTML(self) -> Fallible<DOMString> {
|
fn GetInnerHTML(self) -> Fallible<DOMString> {
|
||||||
//XXX TODO: XML case
|
//XXX TODO: XML case
|
||||||
self.serialize(ChildrenOnly)
|
self.serialize(ChildrenOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-innerHTML
|
||||||
fn SetInnerHTML(self, value: DOMString) -> Fallible<()> {
|
fn SetInnerHTML(self, value: DOMString) -> Fallible<()> {
|
||||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
@ -1141,10 +1146,12 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||||
fn GetOuterHTML(self) -> Fallible<DOMString> {
|
fn GetOuterHTML(self) -> Fallible<DOMString> {
|
||||||
self.serialize(IncludeNode)
|
self.serialize(IncludeNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML
|
||||||
fn SetOuterHTML(self, value: DOMString) -> Fallible<()> {
|
fn SetOuterHTML(self, value: DOMString) -> Fallible<()> {
|
||||||
let context_document = document_from_node(self).root();
|
let context_document = document_from_node(self).root();
|
||||||
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
let context_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
|
|
@ -174,55 +174,67 @@ impl Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EventMethods for JSRef<'a, Event> {
|
impl<'a> EventMethods for JSRef<'a, Event> {
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-eventphase
|
||||||
fn EventPhase(self) -> u16 {
|
fn EventPhase(self) -> u16 {
|
||||||
self.phase.get() as u16
|
self.phase.get() as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(self) -> DOMString {
|
||||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||||
let type_ = self.type_.borrow();
|
let type_ = self.type_.borrow();
|
||||||
type_.clone()
|
type_.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-target
|
||||||
fn GetTarget(self) -> Option<Temporary<EventTarget>> {
|
fn GetTarget(self) -> Option<Temporary<EventTarget>> {
|
||||||
self.target.get()
|
self.target.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||||
fn GetCurrentTarget(self) -> Option<Temporary<EventTarget>> {
|
fn GetCurrentTarget(self) -> Option<Temporary<EventTarget>> {
|
||||||
self.current_target.get()
|
self.current_target.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
||||||
fn DefaultPrevented(self) -> bool {
|
fn DefaultPrevented(self) -> bool {
|
||||||
self.canceled.get()
|
self.canceled.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-preventdefault
|
||||||
fn PreventDefault(self) {
|
fn PreventDefault(self) {
|
||||||
if self.cancelable.get() {
|
if self.cancelable.get() {
|
||||||
self.canceled.set(true)
|
self.canceled.set(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
||||||
fn StopPropagation(self) {
|
fn StopPropagation(self) {
|
||||||
self.stop_propagation.set(true);
|
self.stop_propagation.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
||||||
fn StopImmediatePropagation(self) {
|
fn StopImmediatePropagation(self) {
|
||||||
self.stop_immediate.set(true);
|
self.stop_immediate.set(true);
|
||||||
self.stop_propagation.set(true);
|
self.stop_propagation.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-bubbles
|
||||||
fn Bubbles(self) -> bool {
|
fn Bubbles(self) -> bool {
|
||||||
self.bubbles.get()
|
self.bubbles.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-cancelable
|
||||||
fn Cancelable(self) -> bool {
|
fn Cancelable(self) -> bool {
|
||||||
self.cancelable.get()
|
self.cancelable.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-timestamp
|
||||||
fn TimeStamp(self) -> u64 {
|
fn TimeStamp(self) -> u64 {
|
||||||
self.timestamp
|
self.timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-initevent
|
||||||
fn InitEvent(self,
|
fn InitEvent(self,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
bubbles: bool,
|
bubbles: bool,
|
||||||
|
@ -242,6 +254,7 @@ impl<'a> EventMethods for JSRef<'a, Event> {
|
||||||
self.cancelable.set(cancelable);
|
self.cancelable.set(cancelable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
||||||
fn IsTrusted(self) -> bool {
|
fn IsTrusted(self) -> bool {
|
||||||
self.trusted.get()
|
self.trusted.get()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue